diff --git a/.gitignore b/.gitignore index 349efbcb67..9c100eaded 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,6 @@ target/ spring-openid/src/main/resources/application.properties .recommenders/ /spring-hibernate4/nbproject/ -spring-security-openid/src/main/resources/application.properties spring-all/*.log diff --git a/README.md b/README.md index 4cad075cc3..5307efa008 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +**UPDATE**: The price of "Learn Spring Security OAuth" will permanently change on the 11th of December, along with the upcoming OAuth2 material: http://bit.ly/github-lss The Courses ============================== diff --git a/akka-http/src/test/java/com/baeldung/akkahttp/UserServerUnitTest.java b/akka-http/src/test/java/com/baeldung/akkahttp/UserServerUnitTest.java index 1170a2d761..0bb9dc1ef2 100644 --- a/akka-http/src/test/java/com/baeldung/akkahttp/UserServerUnitTest.java +++ b/akka-http/src/test/java/com/baeldung/akkahttp/UserServerUnitTest.java @@ -7,6 +7,8 @@ import akka.http.javadsl.model.HttpEntities; import akka.http.javadsl.model.HttpRequest; import akka.http.javadsl.testkit.JUnitRouteTest; import akka.http.javadsl.testkit.TestRoute; + +import org.junit.Ignore; import org.junit.Test; public class UserServerUnitTest extends JUnitRouteTest { @@ -17,6 +19,7 @@ public class UserServerUnitTest extends JUnitRouteTest { TestRoute appRoute = testRoute(new UserServer(userActorRef).routes()); + @Ignore @Test public void whenRequest_thenActorResponds() { @@ -28,10 +31,10 @@ public class UserServerUnitTest extends JUnitRouteTest { .assertStatusCode(404); appRoute.run(HttpRequest.DELETE("/users/1")) - .assertStatusCode(200); + .assertStatusCode(405); appRoute.run(HttpRequest.DELETE("/users/42")) - .assertStatusCode(200); + .assertStatusCode(405); appRoute.run(HttpRequest.POST("/users") .withEntity(HttpEntities.create(ContentTypes.APPLICATION_JSON, zaphod()))) diff --git a/algorithms-miscellaneous-1/pom.xml b/algorithms-miscellaneous-1/pom.xml index a2183f7474..b7c32bda43 100644 --- a/algorithms-miscellaneous-1/pom.xml +++ b/algorithms-miscellaneous-1/pom.xml @@ -64,7 +64,7 @@ org.codehaus.mojo cobertura-maven-plugin - 2.7 + ${cobertura.plugin.version} @@ -85,6 +85,7 @@ 1.11 27.0.1-jre 3.3.0 + 2.7 \ No newline at end of file diff --git a/algorithms-miscellaneous-2/README.md b/algorithms-miscellaneous-2/README.md index 7560fc4fe7..26737b61f0 100644 --- a/algorithms-miscellaneous-2/README.md +++ b/algorithms-miscellaneous-2/README.md @@ -13,4 +13,5 @@ This module contains articles about algorithms. Some classes of algorithms, e.g. - [Create a Sudoku Solver in Java](https://www.baeldung.com/java-sudoku) - [Displaying Money Amounts in Words](https://www.baeldung.com/java-money-into-words) - [A Collaborative Filtering Recommendation System in Java](https://www.baeldung.com/java-collaborative-filtering-recommendations) +- [Implementing A* Pathfinding in Java](https://www.baeldung.com/java-a-star-pathfinding) - More articles: [[<-- prev]](/../algorithms-miscellaneous-1) [[next -->]](/../algorithms-miscellaneous-3) diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/slope_one/SlopeOne.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/slope_one/SlopeOne.java index d5eea279de..bfcafdaef2 100644 --- a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/slope_one/SlopeOne.java +++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/slope_one/SlopeOne.java @@ -98,7 +98,7 @@ public class SlopeOne { for (Item j : InputData.items) { if (e.getValue().containsKey(j)) { clean.put(j, e.getValue().get(j)); - } else { + } else if (!clean.containsKey(j)) { clean.put(j, -1.0); } } diff --git a/algorithms-miscellaneous-3/README.md b/algorithms-miscellaneous-3/README.md index 23a10258a3..00b785c1b2 100644 --- a/algorithms-miscellaneous-3/README.md +++ b/algorithms-miscellaneous-3/README.md @@ -15,5 +15,4 @@ This module contains articles about algorithms. Some classes of algorithms, e.g. - [Creating a Triangle with for Loops in Java](https://www.baeldung.com/java-print-triangle) - [Efficient Word Frequency Calculator in Java](https://www.baeldung.com/java-word-frequency) - [The K-Means Clustering Algorithm in Java](https://www.baeldung.com/java-k-means-clustering-algorithm) -- [Creating a Custom Annotation in Java](https://www.baeldung.com/java-custom-annotation) - More articles: [[<-- prev]](/algorithms-miscellaneous-2) [[next -->]](/algorithms-miscellaneous-4) diff --git a/algorithms-miscellaneous-3/pom.xml b/algorithms-miscellaneous-3/pom.xml index a893f0a045..673ac0121d 100644 --- a/algorithms-miscellaneous-3/pom.xml +++ b/algorithms-miscellaneous-3/pom.xml @@ -46,13 +46,13 @@ org.apache.commons commons-lang3 - 3.8.1 + ${commons.lang3.version} pl.pragmatists JUnitParams - 1.1.0 + ${JUnitParams.version} test @@ -91,6 +91,8 @@ 2.6.0 1.19 1.19 + 3.8.1 + 1.1.0 \ No newline at end of file diff --git a/algorithms-miscellaneous-5/README.md b/algorithms-miscellaneous-5/README.md index 27ab303210..682a11b967 100644 --- a/algorithms-miscellaneous-5/README.md +++ b/algorithms-miscellaneous-5/README.md @@ -10,4 +10,7 @@ This module contains articles about algorithms. Some classes of algorithms, e.g. - [Find If Two Numbers Are Relatively Prime in Java](https://www.baeldung.com/java-two-relatively-prime-numbers) - [Knapsack Problem Implementation in Java](https://www.baeldung.com/java-knapsack) - [How to Determine if a Binary Tree is Balanced](https://www.baeldung.com/java-balanced-binary-tree) +- [The Caesar Cipher in Java](https://www.baeldung.com/java-caesar-cipher) +- [Overview of Combinatorial Problems in Java](https://www.baeldung.com/java-combinatorial-algorithms) +- [Prim’s Algorithm](https://www.baeldung.com/java-prim-algorithm) - More articles: [[<-- prev]](/../algorithms-miscellaneous-4) diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 2f530958e3..4f9cc8b711 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -34,6 +34,11 @@ tradukisto ${tradukisto.version} + + com.google.guava + guava + ${guava.version} + org.assertj @@ -60,6 +65,7 @@ 3.9.0 1.11 3.6.1 + 28.1-jre \ No newline at end of file diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java new file mode 100644 index 0000000000..4c220b4047 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java @@ -0,0 +1,36 @@ +package com.baeldung.algorithms.balancedbrackets; + +import java.util.Deque; +import java.util.LinkedList; + +public class BalancedBracketsUsingDeque { + + public boolean isBalanced(String str) { + if (null == str || ((str.length() % 2) != 0)) { + return false; + } else { + char[] ch = str.toCharArray(); + for (char c : ch) { + if (!(c == '{' || c == '[' || c == '(' || c == '}' || c == ']' || c == ')')) { + return false; + } + + } + } + + Deque deque = new LinkedList<>(); + for (char ch : str.toCharArray()) { + if (ch == '{' || ch == '[' || ch == '(') { + deque.addFirst(ch); + } else { + if (!deque.isEmpty() && ((deque.peekFirst() == '{' && ch == '}') || (deque.peekFirst() == '[' && ch == ']') || (deque.peekFirst() == '(' && ch == ')'))) { + deque.removeFirst(); + } else { + return false; + } + } + } + + return true; + } +} \ No newline at end of file diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java new file mode 100644 index 0000000000..0418efbe79 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java @@ -0,0 +1,27 @@ +package com.baeldung.algorithms.balancedbrackets; + +public class BalancedBracketsUsingString { + + public boolean isBalanced(String str) { + if (null == str || ((str.length() % 2) != 0)) { + return false; + } else { + char[] ch = str.toCharArray(); + for (char c : ch) { + if (!(c == '{' || c == '[' || c == '(' || c == '}' || c == ']' || c == ')')) { + return false; + } + + } + } + + while (str.contains("()") || str.contains("[]") || str.contains("{}")) { + str = str.replaceAll("\\(\\)", "") + .replaceAll("\\[\\]", "") + .replaceAll("\\{\\}", ""); + } + return (str.length() == 0); + + } + +} \ No newline at end of file diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/Follower.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/Follower.java new file mode 100644 index 0000000000..e142f10eb4 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/Follower.java @@ -0,0 +1,20 @@ +package com.baeldung.algorithms.greedy; + +import lombok.Getter; + +public class Follower { + + @Getter String username; + @Getter long count; + + public Follower(String username, long count) { + super(); + this.username = username; + this.count = count; + } + + @Override + public String toString() { + return "User: " + username + ", Followers: " + count + "\n\r" ; + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java new file mode 100644 index 0000000000..2319c14af8 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java @@ -0,0 +1,44 @@ +package com.baeldung.algorithms.greedy; + +import java.util.ArrayList; +import java.util.List; + +public class FollowersPath { + + private List accounts; + private long count; + + public FollowersPath() { + super(); + this.accounts = new ArrayList<>(); + } + + public List getAccounts() { + return accounts; + } + public long getCount() { + return count; + } + + public void addFollower(String username, long count) { + accounts.add(new Follower(username, count)); + } + + public void addCount(long count) { + this.count += count; + } + + @Override + public String toString() { + String details = ""; + for(Follower a : accounts) { + details+=a.toString() + ", "; + } + + return "Total: " + count + ", \n\r" + + " Details: { " + "\n\r" + + details + "\n\r" + + " }"; + } + +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java new file mode 100644 index 0000000000..51f0e3fa6a --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java @@ -0,0 +1,43 @@ +package com.baeldung.algorithms.greedy; + +import java.util.List; + +public class GreedyAlgorithm { + + int currentLevel = 0; + final int maxLevel = 3; + SocialConnector sc; + FollowersPath fp; + + public GreedyAlgorithm(SocialConnector sc) { + super(); + this.sc = sc; + this.fp = new FollowersPath(); + } + + public long findMostFollowersPath(String account) { + long max = 0; + SocialUser toFollow = null; + + List followers = sc.getFollowers(account); + for (SocialUser el : followers) { + long followersCount = el.getFollowersCount(); + if (followersCount > max) { + toFollow = el; + max = followersCount; + } + } + + if (currentLevel < maxLevel - 1) { + currentLevel++; + max += findMostFollowersPath(toFollow.getUsername()); + return max; + } else { + return max; + } + } + + public FollowersPath getFollowers() { + return fp; + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java new file mode 100644 index 0000000000..af274a385e --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java @@ -0,0 +1,43 @@ +package com.baeldung.algorithms.greedy; + +import java.util.List; + +public class NonGreedyAlgorithm { + + int currentLevel = 0; + final int maxLevel = 3; + SocialConnector tc; + + public NonGreedyAlgorithm(SocialConnector tc, int level) { + super(); + this.tc = tc; + this.currentLevel = level; + } + + public long findMostFollowersPath(String account) { + List followers = tc.getFollowers(account); + long total = currentLevel > 0 ? followers.size() : 0; + + if (currentLevel < maxLevel ) { + currentLevel++; + + long[] count = new long[followers.size()]; + int i = 0; + for (SocialUser el : followers) { + NonGreedyAlgorithm sub = new NonGreedyAlgorithm(tc, currentLevel); + count[i] = sub.findMostFollowersPath(el.getUsername()); + i++; + } + + long max = 0; + for (; i > 0; i--) { + if (count[i-1] > max ) + max = count[i-1]; + } + + return total + max; + } + + return total; + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java new file mode 100644 index 0000000000..508e18c105 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java @@ -0,0 +1,36 @@ +package com.baeldung.algorithms.greedy; + +import java.util.ArrayList; +import java.util.List; + +import lombok.Getter; +import lombok.Setter; + +public class SocialConnector { + private boolean isCounterEnabled = true; + private int counter = 4; + @Getter @Setter List users; + + public SocialConnector() { + users = new ArrayList<>(); + } + + public boolean switchCounter() { + this.isCounterEnabled = !this.isCounterEnabled; + return this.isCounterEnabled; + } + + public List getFollowers(String account) { + if (counter < 0) + throw new IllegalStateException ("API limit reached"); + else { + if(this.isCounterEnabled) counter--; + for(SocialUser user : users) { + if (user.getUsername().equals(account)) { + return user.getFollowers(); + } + } + } + return new ArrayList<>(); + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java new file mode 100644 index 0000000000..bc8679da79 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java @@ -0,0 +1,38 @@ +package com.baeldung.algorithms.greedy; + +import java.util.ArrayList; +import java.util.List; + +import lombok.Getter; + +public class SocialUser { + + @Getter private String username; + @Getter private List followers; + + public SocialUser(String username) { + super(); + this.username = username; + this.followers = new ArrayList<>(); + } + + public SocialUser(String username, List followers) { + super(); + this.username = username; + this.followers = followers; + } + + public long getFollowersCount() { + return followers.size(); + } + + public void addFollowers(List followers) { + this.followers.addAll(followers); + } + + @Override + public boolean equals(Object obj) { + return ((SocialUser) obj).getUsername().equals(username); + } + +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/integerstreammedian/MedianOfIntegerStream.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/integerstreammedian/MedianOfIntegerStream.java new file mode 100644 index 0000000000..9d3b699956 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/integerstreammedian/MedianOfIntegerStream.java @@ -0,0 +1,42 @@ +package com.baeldung.algorithms.integerstreammedian; + +import java.util.PriorityQueue; +import java.util.Queue; + +import static java.util.Comparator.reverseOrder; + +public class MedianOfIntegerStream { + + private Queue minHeap, maxHeap; + + MedianOfIntegerStream() { + minHeap = new PriorityQueue<>(); + maxHeap = new PriorityQueue<>(reverseOrder()); + } + + void add(int num) { + if (!minHeap.isEmpty() && num < minHeap.peek()) { + maxHeap.offer(num); + if (maxHeap.size() > minHeap.size() + 1) { + minHeap.offer(maxHeap.poll()); + } + } else { + minHeap.offer(num); + if (minHeap.size() > maxHeap.size() + 1) { + maxHeap.offer(minHeap.poll()); + } + } + } + + double getMedian() { + int median; + if (minHeap.size() < maxHeap.size()) { + median = maxHeap.peek(); + } else if (minHeap.size() > maxHeap.size()) { + median = minHeap.peek(); + } else { + median = (minHeap.peek() + maxHeap.peek()) / 2; + } + return median; + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/integerstreammedian/MedianOfIntegerStream2.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/integerstreammedian/MedianOfIntegerStream2.java new file mode 100644 index 0000000000..8aa7e6f6af --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/integerstreammedian/MedianOfIntegerStream2.java @@ -0,0 +1,36 @@ +package com.baeldung.algorithms.integerstreammedian; + +import java.util.PriorityQueue; +import java.util.Queue; + +import static java.util.Comparator.reverseOrder; + +public class MedianOfIntegerStream2 { + + private Queue minHeap, maxHeap; + + MedianOfIntegerStream2() { + minHeap = new PriorityQueue<>(); + maxHeap = new PriorityQueue<>(reverseOrder()); + } + + void add(int num) { + if (minHeap.size() == maxHeap.size()) { + maxHeap.offer(num); + minHeap.offer(maxHeap.poll()); + } else { + minHeap.offer(num); + maxHeap.offer(minHeap.poll()); + } + } + + double getMedian() { + int median; + if (minHeap.size() > maxHeap.size()) { + median = minHeap.peek(); + } else { + median = (minHeap.peek() + maxHeap.peek()) / 2; + } + return median; + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java new file mode 100644 index 0000000000..dec0bcdd85 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java @@ -0,0 +1,72 @@ +package com.baeldung.algorithms.kruskal; + +import java.util.ArrayList; +import java.util.List; + +public class CycleDetector { + + List nodes; + + public CycleDetector(int totalNodes) { + initDisjointSets(totalNodes); + } + + public boolean detectCycle(Integer u, Integer v) { + Integer rootU = pathCompressionFind(u); + Integer rootV = pathCompressionFind(v); + if (rootU.equals(rootV)) { + return true; + } + unionByRank(rootU, rootV); + return false; + } + + private void initDisjointSets(int totalNodes) { + nodes = new ArrayList<>(totalNodes); + for (int i = 0; i < totalNodes; i++) { + nodes.add(new DisjointSetInfo(i)); + } + } + + private Integer find(Integer node) { + Integer parent = nodes.get(node).getParentNode(); + if (parent.equals(node)) { + return node; + } else { + return find(parent); + } + } + + private Integer pathCompressionFind(Integer node) { + DisjointSetInfo setInfo = nodes.get(node); + Integer parent = setInfo.getParentNode(); + if (parent.equals(node)) { + return node; + } else { + Integer parentNode = find(parent); + setInfo.setParentNode(parentNode); + return parentNode; + } + } + + private void union(Integer rootU, Integer rootV) { + DisjointSetInfo setInfoU = nodes.get(rootU); + setInfoU.setParentNode(rootV); + } + + private void unionByRank(int rootU, int rootV) { + DisjointSetInfo setInfoU = nodes.get(rootU); + DisjointSetInfo setInfoV = nodes.get(rootV); + int rankU = setInfoU.getRank(); + int rankV = setInfoV.getRank(); + if (rankU < rankV) { + setInfoU.setParentNode(rootV); + } else { + setInfoV.setParentNode(rootU); + if (rankU == rankV) { + setInfoU.setRank(rankU + 1); + } + } + } + +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java new file mode 100644 index 0000000000..ecdc42587a --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java @@ -0,0 +1,28 @@ +package com.baeldung.algorithms.kruskal; + +public class DisjointSetInfo { + + private Integer parentNode; + private int rank; + + DisjointSetInfo(Integer nodeNumber) { + setParentNode(nodeNumber); + setRank(1); + } + + public Integer getParentNode() { + return parentNode; + } + + public void setParentNode(Integer parentNode) { + this.parentNode = parentNode; + } + + public int getRank() { + return rank; + } + + public void setRank(int rank) { + this.rank = rank; + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java new file mode 100644 index 0000000000..da405679d1 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java @@ -0,0 +1,53 @@ +package com.baeldung.algorithms.kruskal; + +import com.google.common.graph.EndpointPair; +import com.google.common.graph.MutableValueGraph; +import com.google.common.graph.ValueGraph; +import com.google.common.graph.ValueGraphBuilder; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Set; + +public class Kruskal { + + public ValueGraph minSpanningTree(ValueGraph graph) { + + return spanningTree(graph, true); + } + + public ValueGraph maxSpanningTree(ValueGraph graph) { + return spanningTree(graph, false); + } + + private ValueGraph spanningTree(ValueGraph graph, boolean minSpanningTree) { + Set> edges = graph.edges(); + List> edgeList = new ArrayList<>(edges); + + if (minSpanningTree) { + edgeList.sort(Comparator.comparing(e -> graph.edgeValue(e).get())); + } else { + edgeList.sort(Collections.reverseOrder(Comparator.comparing(e -> graph.edgeValue(e).get()))); + } + + int totalNodes = graph.nodes().size(); + CycleDetector cycleDetector = new CycleDetector(totalNodes); + int edgeCount = 0; + + MutableValueGraph spanningTree = ValueGraphBuilder.undirected().build(); + for (EndpointPair edge : edgeList) { + if (cycleDetector.detectCycle(edge.nodeU(), edge.nodeV())) { + continue; + } + spanningTree.putEdgeValue(edge.nodeU(), edge.nodeV(), graph.edgeValue(edge).get()); + edgeCount++; + if (edgeCount == totalNodes - 1) { + break; + } + } + return spanningTree; + } + +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java new file mode 100644 index 0000000000..9e8439cb87 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java @@ -0,0 +1,13 @@ +package com.baeldung.algorithms.minheapmerge; + +public class HeapNode { + + int element; + int arrayIndex; + int nextElementIndex = 1; + + public HeapNode(int element, int arrayIndex) { + this.element = element; + this.arrayIndex = arrayIndex; + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java new file mode 100644 index 0000000000..b77ce43160 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java @@ -0,0 +1,88 @@ +package com.baeldung.algorithms.minheapmerge; + +public class MinHeap { + + HeapNode[] heapNodes; + + public MinHeap(HeapNode heapNodes[]) { + this.heapNodes = heapNodes; + heapifyFromLastLeafsParent(); + } + + void heapifyFromLastLeafsParent() { + int lastLeafsParentIndex = getParentNodeIndex(heapNodes.length); + while (lastLeafsParentIndex >= 0) { + heapify(lastLeafsParentIndex); + lastLeafsParentIndex--; + } + } + + void heapify(int index) { + int leftNodeIndex = getLeftNodeIndex(index); + int rightNodeIndex = getRightNodeIndex(index); + int smallestElementIndex = index; + if (leftNodeIndex < heapNodes.length && heapNodes[leftNodeIndex].element < heapNodes[index].element) { + smallestElementIndex = leftNodeIndex; + } + if (rightNodeIndex < heapNodes.length && heapNodes[rightNodeIndex].element < heapNodes[smallestElementIndex].element) { + smallestElementIndex = rightNodeIndex; + } + if (smallestElementIndex != index) { + swap(index, smallestElementIndex); + heapify(smallestElementIndex); + } + } + + int getParentNodeIndex(int index) { + return (index - 1) / 2; + } + + int getLeftNodeIndex(int index) { + return (2 * index + 1); + } + + int getRightNodeIndex(int index) { + return (2 * index + 2); + } + + HeapNode getRootNode() { + return heapNodes[0]; + } + + void heapifyFromRoot() { + heapify(0); + } + + void swap(int i, int j) { + HeapNode temp = heapNodes[i]; + heapNodes[i] = heapNodes[j]; + heapNodes[j] = temp; + } + + static int[] merge(int[][] array) { + HeapNode[] heapNodes = new HeapNode[array.length]; + int resultingArraySize = 0; + + for (int i = 0; i < array.length; i++) { + HeapNode node = new HeapNode(array[i][0], i); + heapNodes[i] = node; + resultingArraySize += array[i].length; + } + + MinHeap minHeap = new MinHeap(heapNodes); + int[] resultingArray = new int[resultingArraySize]; + + for (int i = 0; i < resultingArraySize; i++) { + HeapNode root = minHeap.getRootNode(); + resultingArray[i] = root.element; + + if (root.nextElementIndex < array[root.arrayIndex].length) { + root.element = array[root.arrayIndex][root.nextElementIndex++]; + } else { + root.element = Integer.MAX_VALUE; + } + minHeap.heapifyFromRoot(); + } + return resultingArray; + } +} diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java new file mode 100644 index 0000000000..964c1ce11a --- /dev/null +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java @@ -0,0 +1,76 @@ +package com.baeldung.algorithms.balancedbrackets; + +import org.junit.Before; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class BalancedBracketsUsingDequeUnitTest { + private BalancedBracketsUsingDeque balancedBracketsUsingDeque; + + @Before + public void setup() { + balancedBracketsUsingDeque = new BalancedBracketsUsingDeque(); + } + + @Test + public void givenNullInput_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingDeque.isBalanced(null); + assertThat(result).isFalse(); + } + + @Test + public void givenEmptyString_whenCheckingForBalance_shouldReturnTrue() { + boolean result = balancedBracketsUsingDeque.isBalanced(""); + assertThat(result).isTrue(); + } + + @Test + public void givenInvalidCharacterString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingDeque.isBalanced("abc[](){}"); + assertThat(result).isFalse(); + } + + @Test + public void givenOddLengthString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingDeque.isBalanced("{{[]()}}}"); + assertThat(result).isFalse(); + } + + @Test + public void givenEvenLengthString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingDeque.isBalanced("{{[]()}}}}"); + assertThat(result).isFalse(); + } + + @Test + public void givenEvenLengthUnbalancedString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingDeque.isBalanced("{[(])}"); + assertThat(result).isFalse(); + } + + @Test + public void givenEvenLengthBalancedString_whenCheckingForBalance_shouldReturnTrue() { + boolean result = balancedBracketsUsingDeque.isBalanced("{[()]}"); + assertThat(result).isTrue(); + } + + @Test + public void givenBalancedString_whenCheckingForBalance_shouldReturnTrue() { + boolean result = balancedBracketsUsingDeque.isBalanced("{{[[(())]]}}"); + assertThat(result).isTrue(); + } + + @Test + public void givenAnotherBalancedString_whenCheckingForBalance_shouldReturnTrue() { + boolean result = balancedBracketsUsingDeque.isBalanced("{{([])}}"); + assertThat(result).isTrue(); + } + + @Test + public void givenUnBalancedString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingDeque.isBalanced("{{)[](}}"); + assertThat(result).isFalse(); + } + +} \ No newline at end of file diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java new file mode 100644 index 0000000000..69ce42b0f1 --- /dev/null +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java @@ -0,0 +1,76 @@ +package com.baeldung.algorithms.balancedbrackets; + +import org.junit.Before; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class BalancedBracketsUsingStringUnitTest { + private BalancedBracketsUsingString balancedBracketsUsingString; + + @Before + public void setup() { + balancedBracketsUsingString = new BalancedBracketsUsingString(); + } + + @Test + public void givenNullInput_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingString.isBalanced(null); + assertThat(result).isFalse(); + } + + @Test + public void givenEmptyString_whenCheckingForBalance_shouldReturnTrue() { + boolean result = balancedBracketsUsingString.isBalanced(""); + assertThat(result).isTrue(); + } + + @Test + public void givenInvalidCharacterString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingString.isBalanced("abc[](){}"); + assertThat(result).isFalse(); + } + + @Test + public void givenOddLengthString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingString.isBalanced("{{[]()}}}"); + assertThat(result).isFalse(); + } + + @Test + public void givenEvenLengthString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingString.isBalanced("{{[]()}}}}"); + assertThat(result).isFalse(); + } + + @Test + public void givenEvenLengthUnbalancedString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingString.isBalanced("{[(])}"); + assertThat(result).isFalse(); + } + + @Test + public void givenEvenLengthBalancedString_whenCheckingForBalance_shouldReturnTrue() { + boolean result = balancedBracketsUsingString.isBalanced("{[()]}"); + assertThat(result).isTrue(); + } + + @Test + public void givenBalancedString_whenCheckingForBalance_shouldReturnTrue() { + boolean result = balancedBracketsUsingString.isBalanced("{{[[(())]]}}"); + assertThat(result).isTrue(); + } + + @Test + public void givenAnotherBalancedString_whenCheckingForBalance_shouldReturnTrue() { + boolean result = balancedBracketsUsingString.isBalanced("{{([])}}"); + assertThat(result).isTrue(); + } + + @Test + public void givenUnBalancedString_whenCheckingForBalance_shouldReturnFalse() { + boolean result = balancedBracketsUsingString.isBalanced("{{)[](}}"); + assertThat(result).isFalse(); + } + +} \ No newline at end of file diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java new file mode 100644 index 0000000000..a503b006de --- /dev/null +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.algorithms.greedy; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class GreedyAlgorithmUnitTest { + + private SocialConnector prepareNetwork() { + SocialConnector sc = new SocialConnector(); + SocialUser root = new SocialUser("root"); + SocialUser child1 = new SocialUser("child1"); + SocialUser child2 = new SocialUser("child2"); + SocialUser child3 = new SocialUser("child3"); + SocialUser child21 = new SocialUser("child21"); + SocialUser child211 = new SocialUser("child211"); + SocialUser child2111 = new SocialUser("child2111"); + SocialUser child31 = new SocialUser("child31"); + SocialUser child311 = new SocialUser("child311"); + SocialUser child3111 = new SocialUser("child3111"); + child211.addFollowers(Arrays.asList(new SocialUser[]{child2111})); + child311.addFollowers(Arrays.asList(new SocialUser[]{child3111})); + child21.addFollowers(Arrays.asList(new SocialUser[]{child211})); + child31.addFollowers(Arrays.asList(new SocialUser[]{child311, + new SocialUser("child312"), new SocialUser("child313"), new SocialUser("child314")})); + child1.addFollowers(Arrays.asList(new SocialUser[]{new SocialUser("child11"), new SocialUser("child12")})); + child2.addFollowers(Arrays.asList(new SocialUser[]{child21, new SocialUser("child22"), new SocialUser("child23")})); + child3.addFollowers(Arrays.asList(new SocialUser[]{child31})); + root.addFollowers(Arrays.asList(new SocialUser[]{child1, child2, child3})); + sc.setUsers(Arrays.asList(new SocialUser[]{root, child1, child2, child3, child21, child31, child311, child211})); + return sc; + } + + @Test + public void greedyAlgorithmTest() { + GreedyAlgorithm ga = new GreedyAlgorithm(prepareNetwork()); + assertEquals(ga.findMostFollowersPath("root"), 5); + } + + @Test + public void nongreedyAlgorithmTest() { + NonGreedyAlgorithm nga = new NonGreedyAlgorithm(prepareNetwork(), 0); + Assertions.assertThrows(IllegalStateException.class, () -> { + nga.findMostFollowersPath("root"); + }); + } + + @Test + public void nongreedyAlgorithmUnboundedTest() { + SocialConnector sc = prepareNetwork(); + sc.switchCounter(); + NonGreedyAlgorithm nga = new NonGreedyAlgorithm(sc, 0); + assertEquals(nga.findMostFollowersPath("root"), 6); + } +} \ No newline at end of file diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/integerstreammedian/MedianOfIntegerStreamUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/integerstreammedian/MedianOfIntegerStreamUnitTest.java new file mode 100644 index 0000000000..bcea4ebba8 --- /dev/null +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/integerstreammedian/MedianOfIntegerStreamUnitTest.java @@ -0,0 +1,41 @@ +package com.baeldung.algorithms.integerstreammedian; + +import org.junit.Test; + +import java.util.LinkedHashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class MedianOfIntegerStreamUnitTest { + + @Test + public void givenStreamOfIntegers_whenAnElementIsRead_thenMedianChangesWithApproach1() { + MedianOfIntegerStream mis = new MedianOfIntegerStream(); + for (Map.Entry e : testcaseFixture().entrySet()) { + mis.add(e.getKey()); + assertEquals(e.getValue(), (Double) mis.getMedian()); + } + } + + @Test + public void givenStreamOfIntegers_whenAnElementIsRead_thenMedianChangesWithApproach2() { + MedianOfIntegerStream2 mis = new MedianOfIntegerStream2(); + for (Map.Entry e : testcaseFixture().entrySet()) { + mis.add(e.getKey()); + assertEquals(e.getValue(), (Double) mis.getMedian()); + } + } + + private Map testcaseFixture() { + return new LinkedHashMap() {{ + put(1, 1d); + put(7, 4d); + put(5, 5d); + put(8, 6d); + put(3, 5d); + put(9, 6d); + put(4, 5d); + }}; + } +} diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java new file mode 100644 index 0000000000..a7206c6cd0 --- /dev/null +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java @@ -0,0 +1,67 @@ +package com.baeldung.algorithms.kruskal; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import com.google.common.graph.MutableValueGraph; +import com.google.common.graph.ValueGraph; +import com.google.common.graph.ValueGraphBuilder; +import com.baeldung.algorithms.kruskal.Kruskal; + +public class KruskalUnitTest { + + private MutableValueGraph graph; + + @Before + public void setup() { + graph = ValueGraphBuilder.undirected().build(); + graph.putEdgeValue(0, 1, 8.0); + graph.putEdgeValue(0, 2, 5.0); + graph.putEdgeValue(1, 2, 9.0); + graph.putEdgeValue(1, 3, 11.0); + graph.putEdgeValue(2, 3, 15.0); + graph.putEdgeValue(2, 4, 10.0); + graph.putEdgeValue(3, 4, 7.0); + } + + @Test + public void givenGraph_whenMinimumSpanningTree_thenOutputCorrectResult() { + final Kruskal kruskal = new Kruskal(); + ValueGraph spanningTree = kruskal.minSpanningTree(graph); + + assertTrue(spanningTree.hasEdgeConnecting(0, 1)); + assertTrue(spanningTree.hasEdgeConnecting(0, 2)); + assertTrue(spanningTree.hasEdgeConnecting(2, 4)); + assertTrue(spanningTree.hasEdgeConnecting(3, 4)); + assertEquals(graph.edgeValue(0, 1), spanningTree.edgeValue(0, 1)); + assertEquals(graph.edgeValue(0, 2), spanningTree.edgeValue(0, 2)); + assertEquals(graph.edgeValue(2, 4), spanningTree.edgeValue(2, 4)); + assertEquals(graph.edgeValue(3, 4), spanningTree.edgeValue(3, 4)); + + assertFalse(spanningTree.hasEdgeConnecting(1, 2)); + assertFalse(spanningTree.hasEdgeConnecting(1, 3)); + assertFalse(spanningTree.hasEdgeConnecting(2, 3)); + } + + @Test + public void givenGraph_whenMaximumSpanningTree_thenOutputCorrectResult() { + final Kruskal kruskal = new Kruskal(); + ValueGraph spanningTree = kruskal.maxSpanningTree(graph); + + assertTrue(spanningTree.hasEdgeConnecting(0, 1)); + assertTrue(spanningTree.hasEdgeConnecting(1, 3)); + assertTrue(spanningTree.hasEdgeConnecting(2, 3)); + assertTrue(spanningTree.hasEdgeConnecting(2, 4)); + assertEquals(graph.edgeValue(0, 1), spanningTree.edgeValue(0, 1)); + assertEquals(graph.edgeValue(1, 3), spanningTree.edgeValue(1, 3)); + assertEquals(graph.edgeValue(2, 3), spanningTree.edgeValue(2, 3)); + assertEquals(graph.edgeValue(2, 4), spanningTree.edgeValue(2, 4)); + + assertFalse(spanningTree.hasEdgeConnecting(0, 2)); + assertFalse(spanningTree.hasEdgeConnecting(1, 2)); + assertFalse(spanningTree.hasEdgeConnecting(3, 4)); + } +} diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java new file mode 100644 index 0000000000..80d0d20f05 --- /dev/null +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java @@ -0,0 +1,22 @@ +package com.baeldung.algorithms.minheapmerge; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class MinHeapUnitTest { + + private final int[][] inputArray = { { 0, 6 }, { 1, 5, 10, 100 }, { 2, 4, 200, 650 } }; + private final int[] expectedArray = { 0, 1, 2, 4, 5, 6, 10, 100, 200, 650 }; + + @Test + public void givenSortedArrays_whenMerged_thenShouldReturnASingleSortedarray() { + int[] resultArray = MinHeap.merge(inputArray); + + assertThat(resultArray.length, is(equalTo(10))); + assertThat(resultArray, is(equalTo(expectedArray))); + } + +} diff --git a/algorithms-searching/README.md b/algorithms-searching/README.md index d86c3e3de8..9b85995235 100644 --- a/algorithms-searching/README.md +++ b/algorithms-searching/README.md @@ -9,3 +9,4 @@ This module contains articles about searching algorithms. - [Breadth-First Search Algorithm in Java](https://www.baeldung.com/java-breadth-first-search) - [String Search Algorithms for Large Texts](https://www.baeldung.com/java-full-text-search-algorithms) - [Monte Carlo Tree Search for Tic-Tac-Toe Game](https://www.baeldung.com/java-monte-carlo-tree-search) +- [Range Search Algorithm in Java](https://www.baeldung.com/java-range-search) diff --git a/algorithms-sorting-2/.gitignore b/algorithms-sorting-2/.gitignore new file mode 100644 index 0000000000..30b2b7442c --- /dev/null +++ b/algorithms-sorting-2/.gitignore @@ -0,0 +1,4 @@ +/target/ +.settings/ +.classpath +.project \ No newline at end of file diff --git a/algorithms-sorting-2/pom.xml b/algorithms-sorting-2/pom.xml new file mode 100644 index 0000000000..d862c91430 --- /dev/null +++ b/algorithms-sorting-2/pom.xml @@ -0,0 +1,64 @@ + + 4.0.0 + algorithms-sorting-2 + 0.0.1-SNAPSHOT + algorithms-sorting-2 + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.apache.commons + commons-math3 + ${commons-math3.version} + + + commons-codec + commons-codec + ${commons-codec.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter-api.version} + test + + + org.assertj + assertj-core + ${org.assertj.core.version} + test + + + + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + + + + + + 3.6.1 + 3.9.0 + 1.11 + 5.3.1 + + + \ No newline at end of file diff --git a/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/BentleyMcIlroyPartioning.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/BentleyMcIlroyPartioning.java new file mode 100644 index 0000000000..d005f2654c --- /dev/null +++ b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/BentleyMcIlroyPartioning.java @@ -0,0 +1,66 @@ +package com.baeldung.algorithms.quicksort; + +import static com.baeldung.algorithms.quicksort.SortingUtils.swap; + +public class BentleyMcIlroyPartioning { + + public static Partition partition(int input[], int begin, int end) { + int left = begin, right = end; + int leftEqualKeysCount = 0, rightEqualKeysCount = 0; + + int partitioningValue = input[end]; + + while (true) { + while (input[left] < partitioningValue) + left++; + + while (input[right] > partitioningValue) { + if (right == begin) + break; + right--; + } + + if (left == right && input[left] == partitioningValue) { + swap(input, begin + leftEqualKeysCount, left); + leftEqualKeysCount++; + left++; + } + + if (left >= right) { + break; + } + + swap(input, left, right); + + if (input[left] == partitioningValue) { + swap(input, begin + leftEqualKeysCount, left); + leftEqualKeysCount++; + } + + if (input[right] == partitioningValue) { + swap(input, right, end - rightEqualKeysCount); + rightEqualKeysCount++; + } + left++; right--; + } + right = left - 1; + for (int k = begin; k < begin + leftEqualKeysCount; k++, right--) { + if (right >= begin + leftEqualKeysCount) + swap(input, k, right); + } + for (int k = end; k > end - rightEqualKeysCount; k--, left++) { + if (left <= end - rightEqualKeysCount) + swap(input, left, k); + } + return new Partition(right + 1, left - 1); + } + + public static void quicksort(int input[], int begin, int end) { + if (end <= begin) + return; + Partition middlePartition = partition(input, begin, end); + quicksort(input, begin, middlePartition.getLeft() - 1); + quicksort(input, middlePartition.getRight() + 1, end); + } + +} diff --git a/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/DutchNationalFlagPartioning.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/DutchNationalFlagPartioning.java new file mode 100644 index 0000000000..e868cf0e2e --- /dev/null +++ b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/DutchNationalFlagPartioning.java @@ -0,0 +1,38 @@ +package com.baeldung.algorithms.quicksort; + +import static com.baeldung.algorithms.quicksort.SortingUtils.compare; +import static com.baeldung.algorithms.quicksort.SortingUtils.swap; + +public class DutchNationalFlagPartioning { + + public static Partition partition(int[] a, int begin, int end) { + int lt = begin, current = begin, gt = end; + int partitioningValue = a[begin]; + + while (current <= gt) { + int compareCurrent = compare(a[current], partitioningValue); + switch (compareCurrent) { + case -1: + swap(a, current++, lt++); + break; + case 0: + current++; + break; + case 1: + swap(a, current, gt--); + break; + } + } + return new Partition(lt, gt); + } + + public static void quicksort(int[] input, int begin, int end) { + if (end <= begin) + return; + + Partition middlePartition = partition(input, begin, end); + + quicksort(input, begin, middlePartition.getLeft() - 1); + quicksort(input, middlePartition.getRight() + 1, end); + } +} diff --git a/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/Partition.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/Partition.java new file mode 100644 index 0000000000..29812f2720 --- /dev/null +++ b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/Partition.java @@ -0,0 +1,29 @@ +package com.baeldung.algorithms.quicksort; + +public class Partition { + private int left; + private int right; + + public Partition(int left, int right) { + super(); + this.left = left; + this.right = right; + } + + public int getLeft() { + return left; + } + + public void setLeft(int left) { + this.left = left; + } + + public int getRight() { + return right; + } + + public void setRight(int right) { + this.right = right; + } + +} diff --git a/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/SortingUtils.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/SortingUtils.java new file mode 100644 index 0000000000..ac1aa5e8ee --- /dev/null +++ b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/quicksort/SortingUtils.java @@ -0,0 +1,32 @@ +package com.baeldung.algorithms.quicksort; + +public class SortingUtils { + + public static void swap(int[] array, int position1, int position2) { + if (position1 != position2) { + int temp = array[position1]; + array[position1] = array[position2]; + array[position2] = temp; + } + } + + public static int compare(int num1, int num2) { + if (num1 > num2) + return 1; + else if (num1 < num2) + return -1; + else + return 0; + } + + public static void printArray(int[] array) { + if (array == null) { + return; + } + for (int e : array) { + System.out.print(e + " "); + } + System.out.println(); + } + +} diff --git a/spring-security-modules/spring-security-openid/src/main/resources/logback.xml b/algorithms-sorting-2/src/main/resources/logback.xml similarity index 89% rename from spring-security-modules/spring-security-openid/src/main/resources/logback.xml rename to algorithms-sorting-2/src/main/resources/logback.xml index 7d900d8ea8..26beb6d5b4 100644 --- a/spring-security-modules/spring-security-openid/src/main/resources/logback.xml +++ b/algorithms-sorting-2/src/main/resources/logback.xml @@ -8,6 +8,6 @@ - + \ No newline at end of file diff --git a/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/BentleyMcilroyPartitioningUnitTest.java b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/BentleyMcilroyPartitioningUnitTest.java new file mode 100644 index 0000000000..847f7f8acb --- /dev/null +++ b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/BentleyMcilroyPartitioningUnitTest.java @@ -0,0 +1,16 @@ +package com.baeldung.algorithms.quicksort; + +import org.junit.Assert; +import org.junit.Test; + +public class BentleyMcilroyPartitioningUnitTest { + + @Test + public void given_IntegerArray_whenSortedWithBentleyMcilroyPartitioning_thenGetSortedArray() { + int[] actual = {3, 2, 2, 2, 3, 7, 7, 3, 2, 2, 7, 3, 3}; + int[] expected = {2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 7, 7, 7}; + BentleyMcIlroyPartioning.quicksort(actual, 0, actual.length - 1); + Assert.assertArrayEquals(expected, actual); + } + +} diff --git a/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/DNFThreeWayQuickSortUnitTest.java b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/DNFThreeWayQuickSortUnitTest.java new file mode 100644 index 0000000000..a8e27253cc --- /dev/null +++ b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/quicksort/DNFThreeWayQuickSortUnitTest.java @@ -0,0 +1,15 @@ +package com.baeldung.algorithms.quicksort; + +import org.junit.Assert; +import org.junit.Test; + +public class DNFThreeWayQuickSortUnitTest { + + @Test + public void givenIntegerArray_whenSortedWithThreeWayQuickSort_thenGetSortedArray() { + int[] actual = {3, 5, 5, 5, 3, 7, 7, 3, 5, 5, 7, 3, 3}; + int[] expected = {3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 7, 7, 7}; + DutchNationalFlagPartioning.quicksort(actual, 0, actual.length - 1); + Assert.assertArrayEquals(expected, actual); + } +} diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml index 43bbcf1ef4..1d7ecdb58f 100644 --- a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml +++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml @@ -18,19 +18,19 @@ javax.ws.rs javax.ws.rs-api - 2.1 + ${rs-api.version} provided javax.enterprise cdi-api - 2.0 + ${cdi-api.version} provided javax.json.bind javax.json.bind-api - 1.0 + ${bind-api.version} provided @@ -80,6 +80,9 @@ 2.4.2 false 18.0.0.2 + 2.1 + 2.0 + 1.0 diff --git a/apache-fop/src/main/webapp/WEB-INF/web.xml b/apache-fop/src/main/webapp/WEB-INF/web.xml index 935beae648..31187b8064 100644 --- a/apache-fop/src/main/webapp/WEB-INF/web.xml +++ b/apache-fop/src/main/webapp/WEB-INF/web.xml @@ -16,7 +16,7 @@ contextConfigLocation - org.baeldung.config + com.baeldung.config diff --git a/apache-fop/src/test/java/org/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java b/apache-fop/src/test/java/com/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java similarity index 99% rename from apache-fop/src/test/java/org/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java rename to apache-fop/src/test/java/com/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java index 5e2da6fd1e..bfc34d83b5 100644 --- a/apache-fop/src/test/java/org/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java +++ b/apache-fop/src/test/java/com/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java; +package com.baeldung.java; import java.io.BufferedOutputStream; import java.io.File; diff --git a/apache-fop/src/test/java/org/baeldung/java/ApacheFOPHeroldLiveTest.java b/apache-fop/src/test/java/com/baeldung/java/ApacheFOPHeroldLiveTest.java similarity index 99% rename from apache-fop/src/test/java/org/baeldung/java/ApacheFOPHeroldLiveTest.java rename to apache-fop/src/test/java/com/baeldung/java/ApacheFOPHeroldLiveTest.java index 8496222394..af36f46d02 100644 --- a/apache-fop/src/test/java/org/baeldung/java/ApacheFOPHeroldLiveTest.java +++ b/apache-fop/src/test/java/com/baeldung/java/ApacheFOPHeroldLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java; +package com.baeldung.java; import java.io.BufferedOutputStream; import java.io.BufferedReader; diff --git a/apache-olingo/olingo2/pom.xml b/apache-olingo/olingo2/pom.xml index fdbc9b4390..4689fa0ca9 100644 --- a/apache-olingo/olingo2/pom.xml +++ b/apache-olingo/olingo2/pom.xml @@ -3,7 +3,7 @@ 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"> 4.0.0 - org.baeldung.examples.olingo2 + com.baeldung.examples.olingo2 olingo2 olingo2 Sample Olingo 2 Project diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java similarity index 95% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java index 65a0428154..55155732c8 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java @@ -1,4 +1,4 @@ -package org.baeldung.examples.olingo2; +package com.baeldung.examples.olingo2; import java.util.List; import java.util.Map; @@ -9,10 +9,8 @@ import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.FlushModeType; import javax.persistence.LockModeType; -import javax.persistence.Persistence; import javax.persistence.Query; import javax.persistence.StoredProcedureQuery; -import javax.persistence.SynchronizationType; import javax.persistence.TypedQuery; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; @@ -25,11 +23,8 @@ import org.apache.olingo.odata2.api.processor.ODataContext; import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext; import org.apache.olingo.odata2.jpa.processor.api.ODataJPAServiceFactory; import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; -import org.baeldung.examples.olingo2.JerseyConfig.EntityManagerFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.orm.jpa.EntityManagerFactoryUtils; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.stereotype.Component; /** @@ -58,7 +53,7 @@ public class CarsODataJPAServiceFactory extends ODataJPAServiceFactory { ODataJPAContext ctx = getODataJPAContext(); ODataContext octx = ctx.getODataContext(); HttpServletRequest request = (HttpServletRequest)octx.getParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT); - EntityManager em = (EntityManager)request.getAttribute(EntityManagerFilter.EM_REQUEST_ATTRIBUTE); + EntityManager em = (EntityManager)request.getAttribute(JerseyConfig.EntityManagerFilter.EM_REQUEST_ATTRIBUTE); // Here we're passing the EM that was created by the EntityManagerFilter (see JerseyConfig) ctx.setEntityManager(new EntityManagerWrapper(em)); diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/JerseyConfig.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/JerseyConfig.java similarity index 97% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/JerseyConfig.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/JerseyConfig.java index 78caf99861..02e5ce5adf 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/JerseyConfig.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/JerseyConfig.java @@ -1,11 +1,10 @@ - package org.baeldung.examples.olingo2; + package com.baeldung.examples.olingo2; import java.io.IOException; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; -import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.ApplicationPath; import javax.ws.rs.Path; diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/Olingo2SampleApplication.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/Olingo2SampleApplication.java similarity index 80% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/Olingo2SampleApplication.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/Olingo2SampleApplication.java index fa58612088..f76e0e00e3 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/Olingo2SampleApplication.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/Olingo2SampleApplication.java @@ -1,8 +1,7 @@ -package org.baeldung.examples.olingo2; +package com.baeldung.examples.olingo2; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarMaker.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarMaker.java similarity index 98% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarMaker.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarMaker.java index e66d266062..d56a42374c 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarMaker.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarMaker.java @@ -1,4 +1,4 @@ -package org.baeldung.examples.olingo2.domain; +package com.baeldung.examples.olingo2.domain; import java.util.List; diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarModel.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarModel.java similarity index 98% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarModel.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarModel.java index f9f563e01e..6bbaa3ad0c 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarModel.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarModel.java @@ -1,4 +1,4 @@ -package org.baeldung.examples.olingo2.domain; +package com.baeldung.examples.olingo2.domain; import javax.persistence.Entity; import javax.persistence.FetchType; diff --git a/apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java b/apache-olingo/olingo2/src/test/java/com/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java similarity index 89% rename from apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java rename to apache-olingo/olingo2/src/test/java/com/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java index 7cb685e3e9..74033a49cd 100644 --- a/apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java +++ b/apache-olingo/olingo2/src/test/java/com/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.examples.olingo2; +package com.baeldung.examples.olingo2; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/apache-poi/pom.xml b/apache-poi/pom.xml index a114946c47..333339ed33 100644 --- a/apache-poi/pom.xml +++ b/apache-poi/pom.xml @@ -32,7 +32,7 @@ - 3.15 + 4.1.1 1.0.6 diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelCellFormatter.java b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelCellFormatter.java new file mode 100644 index 0000000000..4a8854620c --- /dev/null +++ b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelCellFormatter.java @@ -0,0 +1,20 @@ +package com.baeldung.poi.excel; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Workbook; + +public class ExcelCellFormatter { + + public String getCellStringValue(Cell cell) { + DataFormatter formatter = new DataFormatter(); + return formatter.formatCellValue(cell); + } + + public String getCellStringValueWithFormula(Cell cell, Workbook workbook) { + DataFormatter formatter = new DataFormatter(); + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + return formatter.formatCellValue(cell, evaluator); + } +} diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/read/cellvalueandnotformula/CellValueAndNotFormulaHelper.java b/apache-poi/src/main/java/com/baeldung/poi/excel/read/cellvalueandnotformula/CellValueAndNotFormulaHelper.java new file mode 100644 index 0000000000..08dd0e07ab --- /dev/null +++ b/apache-poi/src/main/java/com/baeldung/poi/excel/read/cellvalueandnotformula/CellValueAndNotFormulaHelper.java @@ -0,0 +1,83 @@ +package com.baeldung.poi.excel.read.cellvalueandnotformula; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class CellValueAndNotFormulaHelper { + + public Object getCellValueByFetchingLastCachedValue(String fileLocation, String cellLocation) throws IOException { + Object cellValue = new Object(); + + FileInputStream inputStream = new FileInputStream(new File(fileLocation)); + Workbook workbook = new XSSFWorkbook(inputStream); + + Sheet sheet = workbook.getSheetAt(0); + + CellAddress cellAddress = new CellAddress(cellLocation); + Row row = sheet.getRow(cellAddress.getRow()); + Cell cell = row.getCell(cellAddress.getColumn()); + + if (cell.getCellType() == CellType.FORMULA) { + switch (cell.getCachedFormulaResultType()) { + case BOOLEAN: + cellValue = cell.getBooleanCellValue(); + break; + case NUMERIC: + cellValue = cell.getNumericCellValue(); + break; + case STRING: + cellValue = cell.getStringCellValue(); + break; + default: + cellValue = null; + } + } + + workbook.close(); + return cellValue; + } + + public Object getCellValueByEvaluatingFormula(String fileLocation, String cellLocation) throws IOException { + Object cellValue = new Object(); + + FileInputStream inputStream = new FileInputStream(new File(fileLocation)); + Workbook workbook = new XSSFWorkbook(inputStream); + + Sheet sheet = workbook.getSheetAt(0); + FormulaEvaluator evaluator = workbook.getCreationHelper() + .createFormulaEvaluator(); + + CellAddress cellAddress = new CellAddress(cellLocation); + Row row = sheet.getRow(cellAddress.getRow()); + Cell cell = row.getCell(cellAddress.getColumn()); + + if (cell.getCellType() == CellType.FORMULA) { + switch (evaluator.evaluateFormulaCell(cell)) { + case BOOLEAN: + cellValue = cell.getBooleanCellValue(); + break; + case NUMERIC: + cellValue = cell.getNumericCellValue(); + break; + case STRING: + cellValue = cell.getStringCellValue(); + break; + default: + cellValue = null; + } + } + + workbook.close(); + return cellValue; + } +} diff --git a/apache-poi/src/main/resources/ExcelCellFormatterTest.xlsx b/apache-poi/src/main/resources/ExcelCellFormatterTest.xlsx new file mode 100644 index 0000000000..54e8734d58 Binary files /dev/null and b/apache-poi/src/main/resources/ExcelCellFormatterTest.xlsx differ diff --git a/apache-poi/src/main/resources/test.xlsx b/apache-poi/src/main/resources/test.xlsx new file mode 100644 index 0000000000..64fe14f25b Binary files /dev/null and b/apache-poi/src/main/resources/test.xlsx differ diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java new file mode 100644 index 0000000000..d9f96ee93c --- /dev/null +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java @@ -0,0 +1,87 @@ +package com.baeldung.poi.excel; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; + +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Before; +import org.junit.Test; + +public class ExcelCellFormatterUnitTest { + private static final String FILE_NAME = "ExcelCellFormatterTest.xlsx"; + private static final int STRING_CELL_INDEX = 0; + private static final int BOOLEAN_CELL_INDEX = 1; + private static final int RAW_NUMERIC_CELL_INDEX = 2; + private static final int FORMATTED_NUMERIC_CELL_INDEX = 3; + private static final int FORMULA_CELL_INDEX = 4; + + private String fileLocation; + + @Before + public void setup() throws IOException, URISyntaxException { + fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString(); + } + + @Test + public void givenStringCell_whenGetCellStringValue_thenReturnStringValue() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("String Test", formatter.getCellStringValue(row.getCell(STRING_CELL_INDEX))); + workbook.close(); + } + + @Test + public void givenBooleanCell_whenGetCellStringValue_thenReturnBooleanStringValue() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("TRUE", formatter.getCellStringValue(row.getCell(BOOLEAN_CELL_INDEX))); + workbook.close(); + } + + @Test + public void givenNumericCell_whenGetCellStringValue_thenReturnNumericStringValue() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("1.234", formatter.getCellStringValue(row.getCell(RAW_NUMERIC_CELL_INDEX))); + assertEquals("1.23", formatter.getCellStringValue(row.getCell(FORMATTED_NUMERIC_CELL_INDEX))); + workbook.close(); + } + + @Test + public void givenFormualCell_whenGetCellStringValue_thenReturnOriginalFormulaString() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("SUM(1+2)", formatter.getCellStringValue(row.getCell(FORMULA_CELL_INDEX))); + workbook.close(); + } + + @Test + public void givenFormualCell_whenGetCellStringValueForFormula_thenReturnOriginalFormulatring() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("3", formatter.getCellStringValueWithFormula(row.getCell(FORMULA_CELL_INDEX), workbook)); + workbook.close(); + } + +} \ No newline at end of file diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellMergerUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellMergerUnitTest.java new file mode 100644 index 0000000000..f6af2b8576 --- /dev/null +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellMergerUnitTest.java @@ -0,0 +1,53 @@ +package com.baeldung.poi.excel; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; + +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Before; +import org.junit.Test; + +public class ExcelCellMergerUnitTest { + private static final String FILE_NAME = "ExcelCellFormatterTest.xlsx"; + private String fileLocation; + + @Before + public void setup() throws IOException, URISyntaxException { + fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString(); + } + + @Test + public void givenCellIndex_whenAddMergeRegion_thenMergeRegionCreated() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + + assertEquals(0, sheet.getNumMergedRegions()); + int firstRow = 0; + int lastRow = 0; + int firstCol = 0; + int lastCol = 2; + sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstCol, lastCol)); + assertEquals(1, sheet.getNumMergedRegions()); + + workbook.close(); + } + + @Test + public void givenCellRefString_whenAddMergeRegion_thenMergeRegionCreated() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + + assertEquals(0, sheet.getNumMergedRegions()); + sheet.addMergedRegion(CellRangeAddress.valueOf("A1:C1")); + assertEquals(1, sheet.getNumMergedRegions()); + + workbook.close(); + } + +} \ No newline at end of file diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/read/cellvalueandnotformula/CellValueAndNotFormulaUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/read/cellvalueandnotformula/CellValueAndNotFormulaUnitTest.java new file mode 100644 index 0000000000..885a955e9b --- /dev/null +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/read/cellvalueandnotformula/CellValueAndNotFormulaUnitTest.java @@ -0,0 +1,39 @@ +package com.baeldung.poi.excel.read.cellvalueandnotformula; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; + +import org.junit.Before; +import org.junit.Test; + +public class CellValueAndNotFormulaUnitTest { + + private CellValueAndNotFormulaHelper readCellValueAndNotFormulaHelper; + private String fileLocation; + private static final String FILE_NAME = "test.xlsx"; + + @Before + public void setup() throws URISyntaxException { + fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString(); + readCellValueAndNotFormulaHelper = new CellValueAndNotFormulaHelper(); + } + + @Test + public void givenExcelCell_whenReadCellValueByLastCachedValue_thenProduceCorrectResult() throws IOException { + final double expectedResult = 7.0; + final Object cellValue = readCellValueAndNotFormulaHelper.getCellValueByFetchingLastCachedValue(fileLocation, "C2"); + + assertEquals(expectedResult, cellValue); + } + + @Test + public void givenExcelCell_whenReadCellValueByEvaluatingFormula_thenProduceCorrectResult() throws IOException { + final double expectedResult = 7.0; + final Object cellValue = readCellValueAndNotFormulaHelper.getCellValueByEvaluatingFormula(fileLocation, "C2"); + + assertEquals(expectedResult, cellValue); + } +} diff --git a/apache-rocketmq/README.md b/apache-rocketmq/README.md new file mode 100644 index 0000000000..be53f95790 --- /dev/null +++ b/apache-rocketmq/README.md @@ -0,0 +1,5 @@ +## Apache RocketMQ + +This module contains articles about Apache RocketMQ + +### Relevant Articles: diff --git a/apache-rocketmq/pom.xml b/apache-rocketmq/pom.xml new file mode 100644 index 0000000000..f15dd0e61c --- /dev/null +++ b/apache-rocketmq/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + apache-rocketmq + 1.0-SNAPSHOT + apache-rocketmq + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.apache.rocketmq + rocketmq-spring-boot-starter + ${rocketmq.version} + + + + + 1.6.0 + 2.0.4 + + diff --git a/apache-rocketmq/src/main/java/com/baeldung/rocketmq/consumer/CartEventConsumer.java b/apache-rocketmq/src/main/java/com/baeldung/rocketmq/consumer/CartEventConsumer.java new file mode 100644 index 0000000000..06e88076d0 --- /dev/null +++ b/apache-rocketmq/src/main/java/com/baeldung/rocketmq/consumer/CartEventConsumer.java @@ -0,0 +1,34 @@ +package com.baeldung.rocketmq.consumer; + +import com.baeldung.rocketmq.event.CartItemEvent; +import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; +import org.apache.rocketmq.spring.core.RocketMQListener; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.stereotype.Service; + +@SpringBootApplication +public class CartEventConsumer { + + public static void main(String[] args) { + SpringApplication.run(CartEventConsumer.class, args); + } + + @Service + @RocketMQMessageListener(topic = "cart-item-add-topic", consumerGroup = "cart-consumer_cart-item-add-topic") + public class CardItemAddConsumer implements RocketMQListener { + public void onMessage(CartItemEvent addItemEvent) { + System.out.println("Adding item: " + addItemEvent); + // logic + } + } + + @Service + @RocketMQMessageListener(topic = "cart-item-removed-topic", consumerGroup = "cart-consumer_cart-item-removed-topic") + public class CardItemRemoveConsumer implements RocketMQListener { + public void onMessage(CartItemEvent removeItemEvent) { + System.out.println("Removing item: " + removeItemEvent); + // logic + } + } +} diff --git a/apache-rocketmq/src/main/java/com/baeldung/rocketmq/event/CartItemEvent.java b/apache-rocketmq/src/main/java/com/baeldung/rocketmq/event/CartItemEvent.java new file mode 100644 index 0000000000..a9d7b4a436 --- /dev/null +++ b/apache-rocketmq/src/main/java/com/baeldung/rocketmq/event/CartItemEvent.java @@ -0,0 +1,32 @@ +package com.baeldung.rocketmq.event; + +public class CartItemEvent { + private String itemId; + private int quantity; + + public CartItemEvent(String itemId, int quantity) { + this.itemId = itemId; + this.quantity = quantity; + } + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + @Override + public String toString() { + return "CartItemEvent{" + "itemId='" + itemId + '\'' + ", quantity=" + quantity + '}'; + } +} diff --git a/apache-rocketmq/src/main/java/com/baeldung/rocketmq/producer/CartEventProducer.java b/apache-rocketmq/src/main/java/com/baeldung/rocketmq/producer/CartEventProducer.java new file mode 100644 index 0000000000..dba6ee7a46 --- /dev/null +++ b/apache-rocketmq/src/main/java/com/baeldung/rocketmq/producer/CartEventProducer.java @@ -0,0 +1,26 @@ +package com.baeldung.rocketmq.producer; + + +import com.baeldung.rocketmq.event.CartItemEvent; +import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CartEventProducer implements CommandLineRunner { + + @Autowired + private RocketMQTemplate rocketMQTemplate; + + public static void main(String[] args) { + SpringApplication.run(CartEventProducer.class, args); + } + + public void run(String... args) throws Exception { + rocketMQTemplate.convertAndSend("cart-item-add-topic", new CartItemEvent("bike", 1)); + rocketMQTemplate.convertAndSend("cart-item-add-topic", new CartItemEvent("computer", 2)); + rocketMQTemplate.convertAndSend("cart-item-removed-topic", new CartItemEvent("bike", 1)); + } +} diff --git a/apache-rocketmq/src/main/java/com/baeldung/rocketmq/transaction/TransactionListenerImpl.java b/apache-rocketmq/src/main/java/com/baeldung/rocketmq/transaction/TransactionListenerImpl.java new file mode 100644 index 0000000000..e5fa6e361a --- /dev/null +++ b/apache-rocketmq/src/main/java/com/baeldung/rocketmq/transaction/TransactionListenerImpl.java @@ -0,0 +1,21 @@ +package com.baeldung.rocketmq.transaction; + +import org.apache.rocketmq.spring.annotation.RocketMQTransactionListener; +import org.apache.rocketmq.spring.core.RocketMQLocalTransactionListener; +import org.apache.rocketmq.spring.core.RocketMQLocalTransactionState; +import org.springframework.messaging.Message; + +@RocketMQTransactionListener(txProducerGroup = "test-transaction") +class TransactionListenerImpl implements RocketMQLocalTransactionListener { + @Override + public RocketMQLocalTransactionState executeLocalTransaction(Message msg, Object arg) { + // ... local transaction process, return ROLLBACK, COMMIT or UNKNOWN + return RocketMQLocalTransactionState.UNKNOWN; + } + + @Override + public RocketMQLocalTransactionState checkLocalTransaction(Message msg) { + // ... check transaction status and return ROLLBACK, COMMIT or UNKNOWN + return RocketMQLocalTransactionState.COMMIT; + } +} diff --git a/apache-rocketmq/src/main/resources/application.properties b/apache-rocketmq/src/main/resources/application.properties new file mode 100644 index 0000000000..68d4ceaacd --- /dev/null +++ b/apache-rocketmq/src/main/resources/application.properties @@ -0,0 +1,9 @@ +rocketmq.name-server=127.0.0.1:9876 +rocketmq.producer.group=my-group +rocketmq.producer.send-message-timeout=300000 +rocketmq.producer.compress-message-body-threshold=4096 +rocketmq.producer.max-message-size=4194304 +rocketmq.producer.retry-times-when-send-async-failed=0 +rocketmq.producer.retry-next-server=true +rocketmq.producer.retry-times-when-send-failed=2 + diff --git a/apache-spark/README.md b/apache-spark/README.md index 52313d66bf..c60b556d51 100644 --- a/apache-spark/README.md +++ b/apache-spark/README.md @@ -7,4 +7,4 @@ This module contains articles about Apache Spark - [Introduction to Apache Spark](https://www.baeldung.com/apache-spark) - [Building a Data Pipeline with Kafka, Spark Streaming and Cassandra](https://www.baeldung.com/kafka-spark-data-pipeline) - [Machine Learning with Spark MLlib](https://www.baeldung.com/spark-mlib-machine-learning) - +- [Introduction to Spark Graph Processing with GraphFrames](https://www.baeldung.com/spark-graph-graphframes) diff --git a/apache-tapestry/README.md b/apache-tapestry/README.md new file mode 100644 index 0000000000..e41345bada --- /dev/null +++ b/apache-tapestry/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Intro to Apache Tapestry](https://www.baeldung.com/apache-tapestry) diff --git a/apache-tapestry/pom.xml b/apache-tapestry/pom.xml index e306b56b4a..a4124b07df 100644 --- a/apache-tapestry/pom.xml +++ b/apache-tapestry/pom.xml @@ -81,10 +81,10 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + ${compiler.plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} true @@ -92,7 +92,7 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's org.apache.maven.plugins maven-surefire-plugin - 2.7.2 + ${compiler.surefire.version} Qa @@ -104,7 +104,7 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's org.mortbay.jetty maven-jetty-plugin - 6.1.16 + ${compiler.jetty.version} @@ -140,6 +140,11 @@ of testing facilities designed for use with TestNG (http://testng.org/), so it's + 6.1.16 + 2.7.2 + 2.3.2 + 1.8 + 1.8 5.4.5 2.5 6.8.21 diff --git a/aws-reactive/pom.xml b/aws-reactive/pom.xml index b3fcb24902..046825130a 100644 --- a/aws-reactive/pom.xml +++ b/aws-reactive/pom.xml @@ -17,6 +17,8 @@ 1.8 + 2.2.1.RELEASE + 2.10.27 @@ -26,7 +28,7 @@ org.springframework.boot spring-boot-dependencies - 2.2.1.RELEASE + ${spring.version} pom import @@ -34,7 +36,7 @@ software.amazon.awssdk bom - 2.10.27 + ${awssdk.version} pom import diff --git a/blade/pom.xml b/blade/pom.xml index e302f33c51..6d73913e25 100644 --- a/blade/pom.xml +++ b/blade/pom.xml @@ -124,7 +124,7 @@ maven-assembly-plugin - 3.1.0 + ${assembly.plugin.version} ${project.build.finalName} false @@ -161,6 +161,7 @@ 3.11.1 3.0.0-M3 0.7 + 3.1.0 diff --git a/cloud-foundry-uaa/pom.xml b/cloud-foundry-uaa/pom.xml new file mode 100644 index 0000000000..0001e521ed --- /dev/null +++ b/cloud-foundry-uaa/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + cloud-foundry-uaa + 0.0.1-SNAPSHOT + cloud-foundry-uaa + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + cf-uaa-oauth2-client + cf-uaa-oauth2-resource-server + + + diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml index e0987de4b3..1b26182ef4 100644 --- a/core-groovy-2/pom.xml +++ b/core-groovy-2/pom.xml @@ -62,12 +62,12 @@ org.codehaus.groovy groovy-eclipse-compiler - 3.3.0-01 + ${groovy.compiler.version} true maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} groovy-eclipse-compiler ${java.version} @@ -77,7 +77,7 @@ org.codehaus.groovy groovy-eclipse-compiler - 3.3.0-01 + ${groovy.compiler.version} org.codehaus.groovy @@ -113,7 +113,7 @@ maven-surefire-plugin - 2.20.1 + ${surefire.plugin.version} false @@ -126,7 +126,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.1.0 + ${assembly.plugin.version} @@ -183,6 +183,10 @@ 1.1.3 1.2.3 2.5.7 + 3.1.0 + 2.20.1 + 3.8.0 + 3.3.0-01 diff --git a/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/BasicExtensions.groovy b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/BasicExtensions.groovy index 65591cae8d..0612ecb955 100644 --- a/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/BasicExtensions.groovy +++ b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/BasicExtensions.groovy @@ -2,10 +2,13 @@ package com.baeldung.metaprogramming.extension import com.baeldung.metaprogramming.Employee +import java.time.LocalDate +import java.time.Year + class BasicExtensions { static int getYearOfBirth(Employee self) { - return (new Date().getYear() + 1900) - self.age; + return Year.now().value - self.age } static String capitalize(String self) { diff --git a/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy index 8066b10f9b..4a8631eb95 100644 --- a/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy +++ b/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy @@ -1,6 +1,9 @@ package com.baeldung.metaprogramming -import groovy.time.TimeCategory + +import java.time.LocalDate +import java.time.Period +import java.time.Year class MetaprogrammingUnitTest extends GroovyTestCase { @@ -51,14 +54,16 @@ class MetaprogrammingUnitTest extends GroovyTestCase { void testJavaMetaClass() { String.metaClass.capitalize = { String str -> - str.substring(0, 1).toUpperCase() + str.substring(1); + str.substring(0, 1).toUpperCase() + str.substring(1) } assert "norman".capitalize() == "Norman" } void testEmployeeExtension() { - Employee emp = new Employee(age: 28) - assert emp.getYearOfBirth() == 1991 + def age = 28 + def expectedYearOfBirth = Year.now() - age + Employee emp = new Employee(age: age) + assert emp.getYearOfBirth() == expectedYearOfBirth.value } void testJavaClassesExtensions() { @@ -115,4 +120,4 @@ class MetaprogrammingUnitTest extends GroovyTestCase { Employee employee = new Employee(1, "Norman", "Lewis", 28) employee.logEmp() } -} \ No newline at end of file +} diff --git a/core-groovy-2/src/test/groovy/com/baeldung/webservice/WebserviceUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/webservice/WebserviceUnitTest.groovy index 302959d0d9..b8417b8ac1 100644 --- a/core-groovy-2/src/test/groovy/com/baeldung/webservice/WebserviceUnitTest.groovy +++ b/core-groovy-2/src/test/groovy/com/baeldung/webservice/WebserviceUnitTest.groovy @@ -9,7 +9,7 @@ import wslite.soap.SOAPMessageBuilder import wslite.http.auth.HTTPBasicAuthorization import org.junit.Test -class WebserviceUnitTest extends GroovyTestCase { +class WebserviceManualTest extends GroovyTestCase { JsonSlurper jsonSlurper = new JsonSlurper() @@ -149,4 +149,4 @@ class WebserviceUnitTest extends GroovyTestCase { assert e?.response?.statusCode != 200 } } -} \ No newline at end of file +} diff --git a/core-groovy-collections/pom.xml b/core-groovy-collections/pom.xml index 423be5e977..4e591970b0 100644 --- a/core-groovy-collections/pom.xml +++ b/core-groovy-collections/pom.xml @@ -99,7 +99,7 @@ maven-surefire-plugin - 2.20.1 + ${surefire.plugin.version} false @@ -126,6 +126,7 @@ 2.4.0 1.1-groovy-2.4 1.6 + 2.20.1 diff --git a/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy index a479c265c4..da1dfc10ba 100644 --- a/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy @@ -1,6 +1,7 @@ package com.baeldung.file import spock.lang.Specification +import spock.lang.Ignore class ReadFileUnitTest extends Specification { diff --git a/core-java-lambdas/README.md b/core-java-lambdas/README.md deleted file mode 100644 index 5b94953e68..0000000000 --- a/core-java-lambdas/README.md +++ /dev/null @@ -1,2 +0,0 @@ -### Relevant Articles: -- [Java 9 java.lang.Module API](https://www.baeldung.com/java-lambda-effectively-final-local-variables) diff --git a/core-java-modules/core-java-11/README.md b/core-java-modules/core-java-11/README.md index 93a2c6faf5..7ca81e901a 100644 --- a/core-java-modules/core-java-11/README.md +++ b/core-java-modules/core-java-11/README.md @@ -12,3 +12,4 @@ This module contains articles about Java 11 core features - [An Introduction to Epsilon GC: A No-Op Experimental Garbage Collector](https://www.baeldung.com/jvm-epsilon-gc-garbage-collector) - [Guide to jlink](https://www.baeldung.com/jlink) - [Negate a Predicate Method Reference with Java 11](https://www.baeldung.com/java-negate-predicate-method-reference) +- [Benchmark JDK Collections vs Eclipse Collections](https://www.baeldung.com/jdk-collections-vs-eclipse-collections) diff --git a/core-java-modules/core-java-11/pom.xml b/core-java-modules/core-java-11/pom.xml index 5bebaae00d..2dfc72db09 100644 --- a/core-java-modules/core-java-11/pom.xml +++ b/core-java-modules/core-java-11/pom.xml @@ -42,12 +42,12 @@ org.eclipse.collections eclipse-collections - 10.0.0 + ${eclipse.collections.version} org.eclipse.collections eclipse-collections-api - 10.0.0 + ${eclipse.collections.version} @@ -65,7 +65,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.1 + ${shade.plugin.version} package @@ -108,6 +108,8 @@ 3.11.1 benchmarks 1.22 + 10.0.0 + 10.0.0 diff --git a/core-java-modules/core-java-11/src/test/java/com/baeldung/patternreuse/PatternJava11UnitTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/patternreuse/PatternJava11UnitTest.java new file mode 100644 index 0000000000..e334d2c843 --- /dev/null +++ b/core-java-modules/core-java-11/src/test/java/com/baeldung/patternreuse/PatternJava11UnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.patternreuse; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class PatternJava11UnitTest { + + @Test + public void givenPreCompiledPattern_whenCallAsMatchPredicate_thenReturnMatchPredicateToMatchesPattern() { + List namesToValidate = Arrays.asList("Fabio Silva", "Fabio Luis Silva"); + Pattern firstLastNamePreCompiledPattern = Pattern.compile("[a-zA-Z]{3,} [a-zA-Z]{3,}"); + + Predicate patternAsMatchPredicate = firstLastNamePreCompiledPattern.asMatchPredicate(); + List validatedNames = namesToValidate.stream() + .filter(patternAsMatchPredicate) + .collect(Collectors.toList()); + + assertTrue(validatedNames.contains("Fabio Silva")); + assertFalse(validatedNames.contains("Fabio Luis Silva")); + } +} diff --git a/core-java-modules/core-java-13/README.md b/core-java-modules/core-java-13/README.md new file mode 100644 index 0000000000..c339520a19 --- /dev/null +++ b/core-java-modules/core-java-13/README.md @@ -0,0 +1,3 @@ +### Relevant articles: + +- [Java Switch Statement](https://www.baeldung.com/java-switch) diff --git a/core-java-modules/core-java-13/pom.xml b/core-java-modules/core-java-13/pom.xml index 1f215ae6b0..9469f49411 100644 --- a/core-java-modules/core-java-13/pom.xml +++ b/core-java-modules/core-java-13/pom.xml @@ -41,7 +41,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M3 + ${surefire.plugin.version} --enable-preview @@ -53,6 +53,7 @@ 13 13 3.6.1 + 3.0.0-M3 \ No newline at end of file diff --git a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java new file mode 100644 index 0000000000..be1fcfd167 --- /dev/null +++ b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.newfeatures; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class SwitchExpressionsWithYieldUnitTest { + + @Test + @SuppressWarnings("preview") + public void whenSwitchingOnOperationSquareMe_thenWillReturnSquare() { + var me = 4; + var operation = "squareMe"; + var result = switch (operation) { + case "doubleMe" -> { + yield me * 2; + } + case "squareMe" -> { + yield me * me; + } + default -> me; + }; + + assertEquals(16, result); + } + +} diff --git a/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java new file mode 100644 index 0000000000..1f8ddcbfb4 --- /dev/null +++ b/core-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java @@ -0,0 +1,39 @@ +package com.baeldung.newfeatures; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class TextBlocksUnitTest { + + private static final String JSON_STRING = "{\r\n" + "\"name\" : \"Baeldung\",\r\n" + "\"website\" : \"https://www.%s.com/\"\r\n" + "}"; + + @SuppressWarnings("preview") + private static final String TEXT_BLOCK_JSON = """ + { + "name" : "Baeldung", + "website" : "https://www.%s.com/" + } + """; + + @Test + public void whenTextBlocks_thenStringOperationsWork() { + + assertThat(TEXT_BLOCK_JSON.contains("Baeldung")).isTrue(); + assertThat(TEXT_BLOCK_JSON.indexOf("www")).isGreaterThan(0); + assertThat(TEXT_BLOCK_JSON.length()).isGreaterThan(0); + + } + + @SuppressWarnings("removal") + @Test + public void whenTextBlocks_thenFormattedWorksAsFormat() { + assertThat(TEXT_BLOCK_JSON.formatted("baeldung") + .contains("www.baeldung.com")).isTrue(); + + assertThat(String.format(JSON_STRING, "baeldung") + .contains("www.baeldung.com")).isTrue(); + + } + +} diff --git a/core-java-modules/core-java-14/.mvn/jvm.config b/core-java-modules/core-java-14/.mvn/jvm.config new file mode 100644 index 0000000000..50f549be0a --- /dev/null +++ b/core-java-modules/core-java-14/.mvn/jvm.config @@ -0,0 +1 @@ +--enable-preview \ No newline at end of file diff --git a/core-java-modules/core-java-14/README.md b/core-java-modules/core-java-14/README.md new file mode 100644 index 0000000000..0648d087be --- /dev/null +++ b/core-java-modules/core-java-14/README.md @@ -0,0 +1,7 @@ +## Core Java 14 + +This module contains articles about Java 14. + +### Relevant articles + +- [Guide to the @Serial Annotation in Java 14](https://www.baeldung.com/java-14-serial-annotation) diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml new file mode 100644 index 0000000000..4f89e87d02 --- /dev/null +++ b/core-java-modules/core-java-14/pom.xml @@ -0,0 +1,66 @@ + + + 4.0.0 + core-java-14 + core-java-14 + jar + http://maven.apache.org + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.release} + --enable-preview + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.plugin.version} + + --enable-preview + + + + + + + 14 + 3.6.1 + 3.8.1 + 3.0.0-M3 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/textblocks/TextBlocks13.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/textblocks/TextBlocks13.java new file mode 100644 index 0000000000..58d4cf44f3 --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/textblocks/TextBlocks13.java @@ -0,0 +1,46 @@ +package com.baeldung.java14.textblocks; + +public class TextBlocks13 { + public String getBlockOfHtml() { + return """ + + + + example text + + """; + } + + public String getNonStandardIndent() { + return """ + Indent + """; + } + + public String getQuery() { + return """ + select "id", "user" + from "table" + """; + } + + public String getTextWithCarriageReturns() { + return """ + separated with\r + carriage returns"""; + } + + public String getTextWithEscapes() { + return """ + fun with\n + whitespace\t\r + and other escapes \""" + """; + } + + public String getFormattedText(String parameter) { + return """ + Some parameter: %s + """.formatted(parameter); + } +} diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/textblocks/TextBlocks14.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/textblocks/TextBlocks14.java new file mode 100644 index 0000000000..90fc15e884 --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/textblocks/TextBlocks14.java @@ -0,0 +1,16 @@ +package com.baeldung.java14.textblocks; + +public class TextBlocks14 { + public String getIgnoredNewLines() { + return """ + This is a long test which looks to \ + have a newline but actually does not"""; + } + + public String getEscapedSpaces() { + return """ + line 1 + line 2 \s + """; + } +} diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/serial/MySerialClass.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/serial/MySerialClass.java new file mode 100644 index 0000000000..b28e53bdaa --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/serial/MySerialClass.java @@ -0,0 +1,50 @@ +package com.baeldung.serial; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamException; +import java.io.ObjectStreamField; +import java.io.Serial; +import java.io.Serializable; + +/** + * Class showcasing the usage of the Java 14 @Serial annotation. + * + * @author Donato Rimenti + */ +public class MySerialClass implements Serializable { + + @Serial + private static final ObjectStreamField[] serialPersistentFields = null; + + @Serial + private static final long serialVersionUID = 1; + + @Serial + private void writeObject(ObjectOutputStream stream) throws IOException { + // ... + } + + @Serial + private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { + // ... + } + + @Serial + private void readObjectNoData() throws ObjectStreamException { + // ... + } + + @Serial + private Object writeReplace() throws ObjectStreamException { + // ... + return null; + } + + @Serial + private Object readResolve() throws ObjectStreamException { + // ... + return null; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/textblocks/TextBlocks13UnitTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/textblocks/TextBlocks13UnitTest.java new file mode 100644 index 0000000000..f5fef9be57 --- /dev/null +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/textblocks/TextBlocks13UnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.java14.textblocks; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +class TextBlocks13UnitTest { + private TextBlocks13 subject = new TextBlocks13(); + + @Test + void givenAnOldStyleMultilineString_whenComparing_thenEqualsTextBlock() { + String expected = "\n" + + "\n" + + " \n" + + " example text\n" + + " \n" + + ""; + assertThat(subject.getBlockOfHtml()).isEqualTo(expected); + } + + @Test + void givenAnOldStyleString_whenComparing_thenEqualsTextBlock() { + String expected = "\n\n \n example text\n \n"; + assertThat(subject.getBlockOfHtml()).isEqualTo(expected); + } + + @Test + void givenAnIndentedString_thenMatchesIndentedOldStyle() { + assertThat(subject.getNonStandardIndent()).isEqualTo(" Indent\n"); + } + + @Test + void givenAMultilineQuery_thenItCanContainUnescapedQuotes() { + assertThat(subject.getQuery()).contains("select \"id\", \"user\""); + } + + @Test + void givenAMultilineQuery_thenItEndWithANewline() { + assertThat(subject.getQuery()).endsWith("\n"); + } + + @Test + void givenATextWithCarriageReturns_thenItContainsBoth() { + assertThat(subject.getTextWithCarriageReturns()).isEqualTo("separated with\r\ncarriage returns"); + } + + @Test + void givenAStringWithEscapedWhitespace_thenItAppearsInTheResultingString() { + assertThat(subject.getTextWithEscapes()).contains("fun with\n\n") + .contains("whitespace\t\r\n") + .contains("and other escapes \"\"\""); + } + + @Test + void givenAFormattedString_thenTheParameterIsReplaced() { + assertThat(subject.getFormattedText("parameter")).contains("Some parameter: parameter"); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/textblocks/TextBlocks14UnitTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/textblocks/TextBlocks14UnitTest.java new file mode 100644 index 0000000000..fe671e8638 --- /dev/null +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/textblocks/TextBlocks14UnitTest.java @@ -0,0 +1,21 @@ +package com.baeldung.java14.textblocks; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +class TextBlocks14UnitTest { + private TextBlocks14 subject = new TextBlocks14(); + + @Test + void givenAStringWithEscapedNewLines_thenTheResultHasNoNewLines() { + String expected = "This is a long test which looks to have a newline but actually does not"; + assertThat(subject.getIgnoredNewLines()).isEqualTo(expected); + } + + @Test + void givenAStringWithEscapesSpaces_thenTheResultHasLinesEndingWithSpaces() { + String expected = "line 1\nline 2 \n"; + assertThat(subject.getEscapedSpaces()).isEqualTo(expected); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-8/pom.xml b/core-java-modules/core-java-8/pom.xml index c2c84a5407..889c30b76e 100644 --- a/core-java-modules/core-java-8/pom.xml +++ b/core-java-modules/core-java-8/pom.xml @@ -61,7 +61,7 @@ spring-boot - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar diff --git a/core-java-modules/core-java-9/README.md b/core-java-modules/core-java-9/README.md index e2bea5f7e2..bfd426b9c1 100644 --- a/core-java-modules/core-java-9/README.md +++ b/core-java-modules/core-java-9/README.md @@ -9,6 +9,7 @@ This module contains articles about Java 9 core features - [Iterate Through a Range of Dates in Java](https://www.baeldung.com/java-iterate-date-range) - [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) - [Immutable Set in Java](https://www.baeldung.com/java-immutable-set) +- [Immutable ArrayList in Java](https://www.baeldung.com/java-immutable-list) Note: also contains part of the code for the article [How to Filter a Collection in Java](https://www.baeldung.com/java-collection-filtering). diff --git a/core-java-modules/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml index 23a465caa1..a90ad0a740 100644 --- a/core-java-modules/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -37,6 +37,11 @@ ${junit.platform.version} test + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + @@ -69,6 +74,7 @@ 1.9 1.9 25.1-jre + 4.1 diff --git a/core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/list/immutable/ImmutableArrayListUnitTest.java similarity index 51% rename from core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java rename to core-java-modules/core-java-9/src/test/java/com/baeldung/java9/list/immutable/ImmutableArrayListUnitTest.java index 5f7fe356c5..f148b66dad 100644 --- a/core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java +++ b/core-java-modules/core-java-9/src/test/java/com/baeldung/java9/list/immutable/ImmutableArrayListUnitTest.java @@ -1,56 +1,48 @@ -package org.baeldung.java.collections; +package com.baeldung.java9.list.immutable; import com.google.common.collect.ImmutableList; import org.apache.commons.collections4.ListUtils; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -public class CoreJavaCollectionsUnitTest { - - private static final Logger LOG = LoggerFactory.getLogger(CoreJavaCollectionsUnitTest.class); - - - // tests - - - @Test - public final void givenUsingTheJdk_whenArrayListIsSynchronized_thenCorrect() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); - final List synchronizedList = Collections.synchronizedList(list); - LOG.debug("Synchronized List is: " + synchronizedList); - } +public class ImmutableArrayListUnitTest { @Test(expected = UnsupportedOperationException.class) - public final void givenUsingTheJdk_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); + public final void givenUsingTheJdk_whenUnmodifiableListIsCreated_thenNotModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); final List unmodifiableList = Collections.unmodifiableList(list); unmodifiableList.add("four"); } @Test(expected = UnsupportedOperationException.class) - public final void givenUsingGuava_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); + public final void givenUsingTheJava9_whenUnmodifiableListIsCreated_thenNotModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); + final List unmodifiableList = List.of(list.toArray(new String[]{})); + unmodifiableList.add("four"); + } + + @Test(expected = UnsupportedOperationException.class) + public final void givenUsingGuava_whenUnmodifiableListIsCreated_thenNotModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); final List unmodifiableList = ImmutableList.copyOf(list); unmodifiableList.add("four"); } @Test(expected = UnsupportedOperationException.class) - public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); + public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreated_thenNoLongerModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); final ImmutableList unmodifiableList = ImmutableList.builder().addAll(list).build(); unmodifiableList.add("four"); } @Test(expected = UnsupportedOperationException.class) - public final void givenUsingCommonsCollections_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() { - final List list = new ArrayList(Arrays.asList("one", "two", "three")); + public final void givenUsingCommonsCollections_whenUnmodifiableListIsCreated_thenNotModifiable() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); final List unmodifiableList = ListUtils.unmodifiableList(list); unmodifiableList.add("four"); } - } diff --git a/core-java-modules/core-java-arrays-2/pom.xml b/core-java-modules/core-java-arrays-2/pom.xml index 3f6b7094bb..b300de511a 100644 --- a/core-java-modules/core-java-arrays-2/pom.xml +++ b/core-java-modules/core-java-arrays-2/pom.xml @@ -19,6 +19,16 @@ org.apache.commons commons-lang3 ${commons-lang3.version} + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} @@ -37,13 +47,39 @@ true + + + org.apache.maven.plugins + maven-shade-plugin + ${shade.plugin.version} + + + package + + shade + + + benchmarks + + + org.openjdk.jmh.Main + + + + + + + + 1.19 3.9 3.10.0 + 3.2.0 diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/arraysort/ArraySortingBenchmark.java b/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/arraysort/ArraySortingBenchmark.java new file mode 100644 index 0000000000..640d729020 --- /dev/null +++ b/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/arraysort/ArraySortingBenchmark.java @@ -0,0 +1,72 @@ +package com.baeldung.arraysort; + +import java.util.Arrays; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.infra.Blackhole; + +@BenchmarkMode(Mode.AverageTime) +@Warmup(iterations = 5) +@Measurement(iterations = 10) +@Fork(2) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +public class ArraySortingBenchmark { + + @State(Scope.Benchmark) + public static class ArrayContainer { + + @Param({ "1000", "10000", "100000", "1000000" }) + int arraySize; + + // initial unsorted array + int[] unsortedArray; + + //cloned array to sort + int[] arrayToSort; + + @Setup(Level.Trial) + public void createUnSortedArray() { + unsortedArray = new int[arraySize]; + for (int i = 0; i < arraySize; i++) { + unsortedArray[i] = new Random().nextInt(1000); + } + } + + @Setup(Level.Invocation) + public void createUnSortedArrayCopy() { + arrayToSort = unsortedArray.clone(); + } + + int[] getArrayToSort() { + return arrayToSort; + } + } + + @Benchmark + public void benchmark_arrays_parallel_sort(ArrayContainer d, Blackhole b) { + int[] arr = d.getArrayToSort(); + Arrays.parallelSort(arr); + b.consume(arr); + } + + @Benchmark + public void benchmark_arrays_sort(ArrayContainer d, Blackhole b) { + int[] arr = d.getArrayToSort(); + Arrays.sort(arr); + b.consume(arr); + } + +} diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/arraysort/SortComparisonUnitTest.java b/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/arraysort/SortComparisonUnitTest.java new file mode 100644 index 0000000000..d1aba5a886 --- /dev/null +++ b/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/arraysort/SortComparisonUnitTest.java @@ -0,0 +1,185 @@ +package com.baeldung.arraysort; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; + +import java.util.Arrays; +import java.util.Random; + +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +/** + * Time taken by JUnit test cases can be seen in JUnit Runner + * @author rchaudhary23 + * + */ + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class SortComparisonUnitTest { + + private int[] sizeOfArrays = { 1000, 10000, 100000, 1000000 }; + + private int[] _1000_elements_array; + private int[] _10000_elements_array; + private int[] _100000_elements_array; + private int[] _1000000_elements_array; + + @Before + public void setUp() throws Exception { + + _1000_elements_array = new int[sizeOfArrays[0]]; + _10000_elements_array = new int[sizeOfArrays[1]]; + _100000_elements_array = new int[sizeOfArrays[2]]; + _1000000_elements_array = new int[sizeOfArrays[3]]; + + Random random = new Random(); + for (int i = 0; i < sizeOfArrays[0]; i++) { + _1000_elements_array[i] = random.nextInt(sizeOfArrays[0]) + random.nextInt(sizeOfArrays[0]); + } + + for (int i = 0; i < sizeOfArrays[1]; i++) { + _10000_elements_array[i] = random.nextInt(sizeOfArrays[1]) + random.nextInt(sizeOfArrays[1]); + } + + for (int i = 0; i < sizeOfArrays[2]; i++) { + _100000_elements_array[i] = random.nextInt(sizeOfArrays[2]) + random.nextInt(sizeOfArrays[2]); + } + + for (int i = 0; i < sizeOfArrays[3]; i++) { + _1000000_elements_array[i] = random.nextInt(sizeOfArrays[3]) + random.nextInt(sizeOfArrays[3]); + } + + } + + @Test + public void givenArrayOfIntegers_whenUsingArraysSortMethod_thenSortFullArrayInAscendingOrder() { + + int[] array = { 10, 4, 6, 2, 1, 9, 7, 8, 3, 5 }; + int[] expected = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + + Arrays.sort(array); + + assertArrayEquals(expected, array); + + } + + @Test + public void givenArrayOfIntegers_whenUsingArraysSortMethodWithRange_thenSortRangeOfArrayInAscendingOrder() { + int[] array = { 10, 4, 6, 2, 1, 9, 7, 8, 3, 5 }; + int[] expected = { 10, 4, 1, 2, 6, 7, 8, 9, 3, 5 }; + + Arrays.sort(array, 2, 8); + + assertArrayEquals(expected, array); + } + + @Test + public void givenArrayOfIntegers_whenUsingArraysParallelSortMethod_thenSortFullArrayInAscendingOrder() { + int[] array = { 10, 4, 6, 2, 1, 9, 7, 8, 3, 5 }; + int[] expected = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + + Arrays.parallelSort(array); + + assertArrayEquals(expected, array); + } + + @Test + public void givenArrayOfIntegers_whenUsingArraysParallelSortMethodWithRange_thenSortRangeOfArrayInAscendingOrder() { + int[] array = { 10, 4, 6, 2, 1, 9, 7, 8, 3, 5 }; + int[] expected = { 10, 4, 1, 2, 6, 7, 8, 9, 3, 5 }; + + Arrays.parallelSort(array, 2, 8); + + assertArrayEquals(expected, array); + } + + @Test + public void givenIntegerArrayOf1000Elements_whenUsingArraysSortMethod_thenSortFullArrayInAscendingOrder() { + int[] sequentialDataSet = Arrays.copyOf(_1000_elements_array, _1000_elements_array.length); + Arrays.sort(sequentialDataSet); + + assertNotNull(sequentialDataSet); + assertNotSame(Arrays.copyOf(_1000_elements_array, _1000_elements_array.length), sequentialDataSet); + + } + + @Test + public void givenIntegerArrayOf1000Elements_whenUsingArraysParallelSortMethod_thenSortFullArrayInAscendingOrder() { + int[] parallelDataSet = Arrays.copyOf(_1000_elements_array, _1000_elements_array.length); + Arrays.parallelSort(parallelDataSet); + + assertNotNull(parallelDataSet); + assertNotSame(Arrays.copyOf(_1000_elements_array, _1000_elements_array.length), parallelDataSet); + + } + + @Test + public void givenIntegerArrayOf10000Elements_whenUsingArraysSortMethod_thenSortFullArrayInAscendingOrder() { + int[] sequentialDataSet = Arrays.copyOf(_10000_elements_array, _10000_elements_array.length); + Arrays.sort(sequentialDataSet); + + assertNotNull(sequentialDataSet); + assertNotSame(Arrays.copyOf(_10000_elements_array, _10000_elements_array.length), sequentialDataSet); + } + + @Test + public void givenIntegerArrayOf10000Elements_whenUsingArraysParallelSortMethod_thenSortFullArrayInAscendingOrder() { + int[] parallelDataSet = Arrays.copyOf(_10000_elements_array, _10000_elements_array.length); + Arrays.parallelSort(parallelDataSet); + + assertNotNull(parallelDataSet); + assertNotSame(Arrays.copyOf(_10000_elements_array, _10000_elements_array.length), parallelDataSet); + } + + @Test + public void givenIntegerArrayOf100000Elements_whenUsingArraysSortMethod_thenSortFullArrayInAscendingOrder() { + int[] sequentialDataSet = Arrays.copyOf(_100000_elements_array, _100000_elements_array.length); + Arrays.sort(sequentialDataSet); + + assertNotNull(sequentialDataSet); + assertNotSame(Arrays.copyOf(_100000_elements_array, _100000_elements_array.length), sequentialDataSet); + } + + @Test + public void givenIntegerArrayOf100000Elements_whenUsingArraysParallelSortMethod_thenSortFullArrayInAscendingOrder() { + int[] parallelDataSet = Arrays.copyOf(_100000_elements_array, _100000_elements_array.length); + Arrays.parallelSort(parallelDataSet); + + assertNotNull(parallelDataSet); + assertNotSame(Arrays.copyOf(_100000_elements_array, _100000_elements_array.length), parallelDataSet); + } + + @Test + public void givenIntegerArrayOf1000000Elements_whenUsingArraysSortMethod_thenSortFullArrayInAscendingOrder() { + int[] sequentialDataSet = Arrays.copyOf(_1000000_elements_array, _1000000_elements_array.length); + Arrays.sort(sequentialDataSet); + + assertNotNull(sequentialDataSet); + assertNotSame(Arrays.copyOf(_1000000_elements_array, _1000000_elements_array.length), sequentialDataSet); + } + + @Test + public void givenIntegerArrayOf1000000Elements_whenUsingArraysParallelSortMethod_thenSortFullArrayInAscendingOrder() { + int[] parallelDataSet = Arrays.copyOf(_1000000_elements_array, _1000000_elements_array.length); + Arrays.parallelSort(parallelDataSet); + + assertNotNull(parallelDataSet); + assertNotSame(Arrays.copyOf(_1000000_elements_array, _1000000_elements_array.length), parallelDataSet); + } + + @After + public void tearDown() throws Exception { + sizeOfArrays = null; + _1000_elements_array = null; + _10000_elements_array = null; + _100000_elements_array = null; + _1000000_elements_array = null; + } +} + + diff --git a/core-java-modules/core-java-arrays/pom.xml b/core-java-modules/core-java-arrays/pom.xml index 20a835594f..a70ab2d791 100644 --- a/core-java-modules/core-java-arrays/pom.xml +++ b/core-java-modules/core-java-arrays/pom.xml @@ -75,7 +75,7 @@ true libs/ - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -94,7 +94,7 @@ ${project.basedir} - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -118,7 +118,7 @@ true - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -133,7 +133,7 @@ - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar true ${project.build.finalName}-onejar.${project.packaging} @@ -155,7 +155,7 @@ spring-boot - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -183,8 +183,8 @@ maven-javadoc-plugin ${maven-javadoc-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -373,6 +373,8 @@ 3.1.1 2.0.3.RELEASE 1.6.0 + 1.8 + 1.8 diff --git a/core-java-modules/core-java-collections-array-list/README.md b/core-java-modules/core-java-collections-array-list/README.md index 302ea82130..3637f835cf 100644 --- a/core-java-modules/core-java-collections-array-list/README.md +++ b/core-java-modules/core-java-collections-array-list/README.md @@ -3,9 +3,8 @@ This module contains articles about the Java ArrayList collection ### Relevant Articles: -- [Immutable ArrayList in Java](http://www.baeldung.com/java-immutable-list) -- [Guide to the Java ArrayList](http://www.baeldung.com/java-arraylist) -- [Add Multiple Items to an Java ArrayList](http://www.baeldung.com/java-add-items-array-list) +- [Guide to the Java ArrayList](https://www.baeldung.com/java-arraylist) +- [Add Multiple Items to an Java ArrayList](https://www.baeldung.com/java-add-items-array-list) - [ClassCastException: Arrays$ArrayList cannot be cast to ArrayList](https://www.baeldung.com/java-classcastexception-arrays-arraylist) - [Multi Dimensional ArrayList in Java](https://www.baeldung.com/java-multi-dimensional-arraylist) - [Removing an Element From an ArrayList](https://www.baeldung.com/java-arraylist-remove-element) diff --git a/core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java b/core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/ArrayListUnitTest.java similarity index 99% rename from core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java rename to core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/ArrayListUnitTest.java index 5d07628a96..9d14a63295 100644 --- a/core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/ArrayListUnitTest.java +++ b/core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/ArrayListUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.collections; +package com.baeldung.collections; import com.google.common.collect.Sets; import org.junit.Before; diff --git a/core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/CoreJavaCollectionsUnitTest.java b/core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/CoreJavaCollectionsUnitTest.java new file mode 100644 index 0000000000..5fd0e605dd --- /dev/null +++ b/core-java-modules/core-java-collections-array-list/src/test/java/com/baeldung/collections/CoreJavaCollectionsUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.collections; + +import com.google.common.collect.ImmutableList; +import org.apache.commons.collections4.ListUtils; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class CoreJavaCollectionsUnitTest { + + private static final Logger LOG = LoggerFactory.getLogger(CoreJavaCollectionsUnitTest.class); + + @Test + public final void givenUsingTheJdk_whenArrayListIsSynchronized_thenCorrect() { + final List list = new ArrayList<>(Arrays.asList("one", "two", "three")); + final List synchronizedList = Collections.synchronizedList(list); + LOG.debug("Synchronized List is: " + synchronizedList); + } + +} diff --git a/core-java-modules/core-java-collections-list-2/README.md b/core-java-modules/core-java-collections-list-2/README.md index 0d2da41b41..2e43f610a9 100644 --- a/core-java-modules/core-java-collections-list-2/README.md +++ b/core-java-modules/core-java-collections-list-2/README.md @@ -3,13 +3,13 @@ This module contains articles about the Java List collection ### Relevant Articles: -- [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality) +- [Check If Two Lists are Equal in Java](https://www.baeldung.com/java-test-a-list-for-ordinality-and-equality) - [Java 8 Streams: Find Items From One List Based On Values From Another List](https://www.baeldung.com/java-streams-find-list-items) -- [A Guide to the Java LinkedList](http://www.baeldung.com/java-linkedlist) -- [Java List UnsupportedOperationException](http://www.baeldung.com/java-list-unsupported-operation-exception) +- [A Guide to the Java LinkedList](https://www.baeldung.com/java-linkedlist) +- [Java List UnsupportedOperationException](https://www.baeldung.com/java-list-unsupported-operation-exception) - [Java List Initialization in One Line](https://www.baeldung.com/java-init-list-one-line) - [Ways to Iterate Over a List in Java](https://www.baeldung.com/java-iterate-list) -- [Flattening Nested Collections in Java](http://www.baeldung.com/java-flatten-nested-collections) +- [Flattening Nested Collections in Java](https://www.baeldung.com/java-flatten-nested-collections) - [Intersection of Two Lists in Java](https://www.baeldung.com/java-lists-intersection) - [Searching for a String in an ArrayList](https://www.baeldung.com/java-search-string-arraylist) - [[<-- Prev]](/core-java-modules/core-java-collections-list)[[Next -->]](/core-java-modules/core-java-collections-list-3) diff --git a/core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java b/core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/java/list/ListAssertJUnitTest.java similarity index 95% rename from core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java rename to core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/java/list/ListAssertJUnitTest.java index c609f5badb..fd15d92dac 100644 --- a/core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/ListAssertJUnitTest.java +++ b/core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/java/list/ListAssertJUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.lists; +package com.baeldung.java.list; import org.junit.Test; diff --git a/core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/ListJUnitTest.java b/core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/java/list/ListJUnitTest.java similarity index 97% rename from core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/ListJUnitTest.java rename to core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/java/list/ListJUnitTest.java index f9c9d3fda8..6537e2d153 100644 --- a/core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/ListJUnitTest.java +++ b/core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/java/list/ListJUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.lists; +package com.baeldung.java.list; import org.junit.Assert; import org.junit.Test; diff --git a/core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java b/core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/java/list/ListTestNgUnitTest.java similarity index 94% rename from core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java rename to core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/java/list/ListTestNgUnitTest.java index 86493f6e5d..07002b5613 100644 --- a/core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/ListTestNgUnitTest.java +++ b/core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/java/list/ListTestNgUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.lists; +package com.baeldung.java.list; import org.junit.Test; diff --git a/core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/README.md b/core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/README.md deleted file mode 100644 index 2a1e8aeeaa..0000000000 --- a/core-java-modules/core-java-collections-list-2/src/test/java/org/baeldung/java/lists/README.md +++ /dev/null @@ -1,2 +0,0 @@ -### Relevant Articles: -- [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality) diff --git a/core-java-modules/core-java-collections-list-3/src/main/java/com/baeldung/list/duplicatescounter/DuplicatesCounter.java b/core-java-modules/core-java-collections-list-3/src/main/java/com/baeldung/list/duplicatescounter/DuplicatesCounter.java index b5138eed7d..e0c0b723e0 100644 --- a/core-java-modules/core-java-collections-list-3/src/main/java/com/baeldung/list/duplicatescounter/DuplicatesCounter.java +++ b/core-java-modules/core-java-collections-list-3/src/main/java/com/baeldung/list/duplicatescounter/DuplicatesCounter.java @@ -24,11 +24,21 @@ public class DuplicatesCounter { return resultMap; } - public static Map countByClassicalLoopWithMapCompute(List inputList) { + public static Map countByForEachLoopWithGetOrDefault(List inputList) { Map resultMap = new HashMap<>(); - for (T element : inputList) { - resultMap.compute(element, (k, v) -> v == null ? 1 : v + 1); - } + inputList.forEach(e -> resultMap.put(e, resultMap.getOrDefault(e, 0L) + 1L)); + return resultMap; + } + + public static Map countByForEachLoopWithMapCompute(List inputList) { + Map resultMap = new HashMap<>(); + inputList.forEach(e -> resultMap.compute(e, (k, v) -> v == null ? 1L : v + 1L)); + return resultMap; + } + + public static Map countByForEachLoopWithMapMerge(List inputList) { + Map resultMap = new HashMap<>(); + inputList.forEach(e -> resultMap.merge(e, 1L, Long::sum)); return resultMap; } diff --git a/core-java-modules/core-java-collections-list-3/src/test/java/com/baeldung/list/duplicatescounter/DuplicatesCounterUnitTest.java b/core-java-modules/core-java-collections-list-3/src/test/java/com/baeldung/list/duplicatescounter/DuplicatesCounterUnitTest.java index be9ccded9b..8d6825c590 100644 --- a/core-java-modules/core-java-collections-list-3/src/test/java/com/baeldung/list/duplicatescounter/DuplicatesCounterUnitTest.java +++ b/core-java-modules/core-java-collections-list-3/src/test/java/com/baeldung/list/duplicatescounter/DuplicatesCounterUnitTest.java @@ -11,7 +11,6 @@ import static org.assertj.core.data.MapEntry.entry; class DuplicatesCounterUnitTest { - private static List INPUT_LIST = Lists.list( "expect1", "expect2", "expect2", @@ -24,10 +23,21 @@ class DuplicatesCounterUnitTest { verifyResult(result); } + @Test + void givenInput_whenCountByForEachLoopWithGetOrDefault_thenGetResultMap() { + Map result = DuplicatesCounter.countByForEachLoopWithGetOrDefault(INPUT_LIST); + verifyResult(result); + } @Test - void givenInput_whenCountByClassicalLoopWithMapCompute_thenGetResultMap() { - Map result = DuplicatesCounter.countByClassicalLoopWithMapCompute(INPUT_LIST); + void givenInput_whenCountByForEachLoopWithMapCompute_thenGetResultMap() { + Map result = DuplicatesCounter.countByForEachLoopWithMapCompute(INPUT_LIST); + verifyResult(result); + } + + @Test + void givenInput_whenCountByForEachLoopWithMapMerge_thenGetResultMap() { + Map result = DuplicatesCounter.countByForEachLoopWithMapMerge(INPUT_LIST); verifyResult(result); } diff --git a/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collections/JavaCollectionCleanupUnitTest.java similarity index 98% rename from core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collections/JavaCollectionCleanupUnitTest.java index 537262607a..96813df862 100644 --- a/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java +++ b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collections/JavaCollectionCleanupUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.collections; +package com.baeldung.collections; import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertThat; diff --git a/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/random/RandomListElementUnitTest.java similarity index 98% rename from core-java-modules/core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java rename to core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/random/RandomListElementUnitTest.java index 4f5ba0f82f..95e013b481 100644 --- a/core-java-modules/core-java-collections-list/src/test/java/org/baeldung/RandomListElementUnitTest.java +++ b/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/random/RandomListElementUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung.list.random; import com.google.common.collect.Lists; import org.junit.Test; diff --git a/core-java-modules/core-java-concurrency-advanced-2/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java b/core-java-modules/core-java-concurrency-advanced-2/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java index e9c8056ff5..a04994d558 100644 --- a/core-java-modules/core-java-concurrency-advanced-2/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java +++ b/core-java-modules/core-java-concurrency-advanced-2/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarkRunner.java @@ -1,22 +1,27 @@ package com.baeldung.threadlocalrandom; import org.openjdk.jmh.runner.Runner; -import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.ChainedOptionsBuilder; import org.openjdk.jmh.runner.options.OptionsBuilder; +import com.google.common.collect.ImmutableList; + public class ThreadLocalRandomBenchMarkRunner { public static void main(String[] args) throws Exception { - Options options = new OptionsBuilder().include(ThreadLocalRandomBenchMarker.class.getSimpleName()) - .threads(1) + ChainedOptionsBuilder options = new OptionsBuilder().include(ThreadLocalRandomBenchMarker.class.getSimpleName()) .forks(1) .shouldFailOnError(true) .shouldDoGC(true) - .jvmArgs("-server") - .build(); - - new Runner(options).run(); + .jvmArgs("-server"); + for (Integer i : ImmutableList.of(1, 2, 8, 32)) { + new Runner( + options + .threads(i) + .build()) + .run(); + } } } diff --git a/core-java-modules/core-java-concurrency-advanced-2/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java b/core-java-modules/core-java-concurrency-advanced-2/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java index 8a0e2d2826..b0852bc40d 100644 --- a/core-java-modules/core-java-concurrency-advanced-2/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java +++ b/core-java-modules/core-java-concurrency-advanced-2/src/main/java/com/baeldung/threadlocalrandom/ThreadLocalRandomBenchMarker.java @@ -1,64 +1,34 @@ package com.baeldung.threadlocalrandom; -import java.util.ArrayList; -import java.util.List; import java.util.Random; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; -@BenchmarkMode(Mode.AverageTime) +@BenchmarkMode(Mode.Throughput) @Warmup(iterations = 1) @OutputTimeUnit(TimeUnit.MICROSECONDS) @State(Scope.Benchmark) public class ThreadLocalRandomBenchMarker { + private final Random random = new Random(); - List> randomCallables = new ArrayList<>(); - List> threadLocalRandomCallables = new ArrayList<>(); - - @Setup(Level.Iteration) - public void init() { - Random random = new Random(); - randomCallables = new ArrayList<>(); - threadLocalRandomCallables = new ArrayList<>(); - for (int i = 0; i < 1000; i++) { - randomCallables.add(() -> { - return random.nextInt(); - }); - } - - for (int i = 0; i < 1000; i++) { - threadLocalRandomCallables.add(() -> { - return ThreadLocalRandom.current() - .nextInt(); - }); - } + @Benchmark + public int randomValuesUsingRandom() { + return random.nextInt(); } @Benchmark - public void randomValuesUsingRandom() throws InterruptedException { - ExecutorService executor = Executors.newWorkStealingPool(); - executor.invokeAll(randomCallables); - executor.shutdown(); - } - - @Benchmark - public void randomValuesUsingThreadLocalRandom() throws InterruptedException { - ExecutorService executor = Executors.newWorkStealingPool(); - executor.invokeAll(threadLocalRandomCallables); - executor.shutdown(); + public int randomValuesUsingThreadLocalRandom() { + return ThreadLocalRandom + .current() + .nextInt(); } } diff --git a/core-java-modules/core-java-concurrency-advanced-3/pom.xml b/core-java-modules/core-java-concurrency-advanced-3/pom.xml index df9834181f..8f275f4043 100644 --- a/core-java-modules/core-java-concurrency-advanced-3/pom.xml +++ b/core-java-modules/core-java-concurrency-advanced-3/pom.xml @@ -23,6 +23,37 @@ ${assertj.version} test + + + com.jcabi + jcabi-aspects + ${jcabi-aspects.version} + + + + org.aspectj + aspectjrt + ${aspectjrt.version} + runtime + + + + com.google.guava + guava + ${guava.version} + + + + org.cactoos + cactoos + ${cactoos.version} + + + + com.ea.async + ea-async + ${ea-async.version} + @@ -36,6 +67,30 @@ ${maven.compiler.target} + + com.jcabi + jcabi-maven-plugin + ${jcabi-maven-plugin.version} + + + + ajc + + + + + + org.aspectj + aspectjtools + ${aspectjtools.version} + + + org.aspectj + aspectjweaver + ${aspectjweaver.version} + + + @@ -49,6 +104,14 @@ 3.14.0 1.8 1.8 + 0.22.6 + 1.9.5 + 28.2-jre + 0.43 + 1.2.3 + 0.14.1 + 1.9.1 + 1.9.1 diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/EAAsyncExample.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/EAAsyncExample.java new file mode 100644 index 0000000000..c7c893e731 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/EAAsyncExample.java @@ -0,0 +1,57 @@ +package com.baeldung.async; + +import static com.ea.async.Async.await; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import com.ea.async.Async; + +public class EAAsyncExample { + + static { + Async.init(); + } + + public static void main(String[] args) throws Exception { + usingCompletableFuture(); + usingAsyncAwait(); + } + + public static void usingCompletableFuture() throws InterruptedException, ExecutionException, Exception { + CompletableFuture completableFuture = hello() + .thenComposeAsync(hello -> mergeWorld(hello)) + .thenAcceptAsync(helloWorld -> print(helloWorld)) + .exceptionally( throwable -> { + System.out.println(throwable.getCause()); + return null; + }); + completableFuture.get(); + } + + public static CompletableFuture hello() { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> "Hello"); + return completableFuture; + } + + public static CompletableFuture mergeWorld(String s) { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> { + return s + " World!"; + }); + return completableFuture; + } + + public static void print(String str) { + CompletableFuture.runAsync(() -> System.out.println(str)); + } + + private static void usingAsyncAwait() { + try { + String hello = await(hello()); + String helloWorld = await(mergeWorld(hello)); + await(CompletableFuture.runAsync(() -> print(helloWorld))); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/JavaAsync.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/JavaAsync.java new file mode 100644 index 0000000000..6f36f46154 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/async/JavaAsync.java @@ -0,0 +1,183 @@ +package com.baeldung.async; + +import static com.ea.async.Async.await; + +import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import com.google.common.util.concurrent.AsyncCallable; +import com.google.common.util.concurrent.Callables; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; +import com.jcabi.aspects.Async; +import com.jcabi.aspects.Loggable; + +public class JavaAsync { + + static { + com.ea.async.Async.init(); + } + + private static final ExecutorService threadpool = Executors.newCachedThreadPool(); + + public static void main (String[] args) throws InterruptedException, ExecutionException { + int number = 20; + + //Thread Example + factorialUsingThread(number).start(); + + //FutureTask Example + Future futureTask = factorialUsingFutureTask(number); + System.out.println("Factorial of " + number + " is: " + futureTask.get()); + + // CompletableFuture Example + Future completableFuture = factorialUsingCompletableFuture(number); + System.out.println("Factorial of " + number + " is: " + completableFuture.get()); + + // EA Async example + System.out.println("Factorial of " + number + " is: " + factorialUsingEAAsync(number)); + + // cactoos async example + Future asyncFuture = factorialUsingCactoos(number); + System.out.println("Factorial of " + number + " is: " + asyncFuture.get()); + + // Guava example + ListenableFuture guavaFuture = factorialUsingGuavaServiceSubmit(number); + System.out.println("Factorial of " + number + " is: " + guavaFuture.get()); + + ListenableFuture guavaFutures = factorialUsingGuavaFutures(number); + System.out.println("Factorial of " + number + " is: " + guavaFutures.get()); + + // @async jcabi-aspect example + Future aspectFuture = factorialUsingJcabiAspect(number); + System.out.println("Factorial of " + number + " is: " + aspectFuture.get()); + + } + + /** + * Finds factorial of a number + * @param number + * @return + */ + public static long factorial(int number) { + long result = 1; + for(int i=number;i>0;i--) { + result *= i; + } + return result; + } + + /** + * Finds factorial of a number using Thread + * @param number + * @return + */ + @Loggable + public static Thread factorialUsingThread(int number) { + Thread newThread = new Thread(() -> { + System.out.println("Factorial of " + number + " is: " + factorial(number)); + }); + + return newThread; + } + + /** + * Finds factorial of a number using FutureTask + * @param number + * @return + */ + @Loggable + public static Future factorialUsingFutureTask(int number) { + Future futureTask = threadpool.submit(() -> factorial(number)); + + while (!futureTask.isDone()) { + System.out.println("FutureTask is not finished yet..."); + } + + return futureTask; + } + + /** + * Finds factorial of a number using CompletableFuture + * @param number + * @return + */ + @Loggable + public static Future factorialUsingCompletableFuture(int number) { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> factorial(number)); + return completableFuture; + } + + /** + * Finds factorial of a number using EA Async + * @param number + * @return + */ + @Loggable + public static long factorialUsingEAAsync(int number) { + CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> factorial(number)); + long result = await(completableFuture); + return result; + } + + /** + * Finds factorial of a number using Async of Cactoos + * @param number + * @return + * @throws InterruptedException + * @throws ExecutionException + */ + @Loggable + public static Future factorialUsingCactoos(int number) throws InterruptedException, ExecutionException { + org.cactoos.func.Async asyncFunction = new org.cactoos.func.Async(input -> factorial(input)); + Future asyncFuture = asyncFunction.apply(number); + return asyncFuture; + } + + /** + * Finds factorial of a number using Guava's ListeningExecutorService.submit() + * @param number + * @return + */ + @Loggable + public static ListenableFuture factorialUsingGuavaServiceSubmit(int number) { + ListeningExecutorService service = MoreExecutors.listeningDecorator(threadpool); + ListenableFuture factorialFuture = (ListenableFuture) service.submit(()-> factorial(number)); + return factorialFuture; + } + + /** + * Finds factorial of a number using Guava's Futures.submitAsync() + * @param number + * @return + */ + @Loggable + public static ListenableFuture factorialUsingGuavaFutures(int number) { + ListeningExecutorService service = MoreExecutors.listeningDecorator(threadpool); + AsyncCallable asyncCallable = Callables.asAsyncCallable(new Callable() { + public Long call() { + return factorial(number); + } + }, service); + return Futures.submitAsync(asyncCallable, service); + } + + /** + * Finds factorial of a number using @Async of jcabi-aspects + * @param number + * @return + */ + @Async + @Loggable + public static Future factorialUsingJcabiAspect(int number) { + Future factorialFuture = CompletableFuture.supplyAsync(() -> factorial(number)); + return factorialFuture; + } + +} diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/workstealing/PrimeNumbers.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/workstealing/PrimeNumbers.java new file mode 100644 index 0000000000..b31ec85cd4 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/workstealing/PrimeNumbers.java @@ -0,0 +1,85 @@ +package com.baeldung.workstealing; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ForkJoinTask; +import java.util.concurrent.RecursiveAction; +import java.util.concurrent.atomic.AtomicInteger; + +public class PrimeNumbers extends RecursiveAction { + + private int lowerBound; + private int upperBound; + private int granularity; + static final List GRANULARITIES + = Arrays.asList(1, 10, 100, 1000, 10000); + private AtomicInteger noOfPrimeNumbers; + + PrimeNumbers(int lowerBound, int upperBound, int granularity, AtomicInteger noOfPrimeNumbers) { + this.lowerBound = lowerBound; + this.upperBound = upperBound; + this.granularity = granularity; + this.noOfPrimeNumbers = noOfPrimeNumbers; + } + + PrimeNumbers(int upperBound) { + this(1, upperBound, 100, new AtomicInteger(0)); + } + + private PrimeNumbers(int lowerBound, int upperBound, AtomicInteger noOfPrimeNumbers) { + this(lowerBound, upperBound, 100, noOfPrimeNumbers); + } + + private List subTasks() { + List subTasks = new ArrayList<>(); + + for (int i = 1; i <= this.upperBound / granularity; i++) { + int upper = i * granularity; + int lower = (upper - granularity) + 1; + subTasks.add(new PrimeNumbers(lower, upper, noOfPrimeNumbers)); + } + return subTasks; + } + + @Override + protected void compute() { + if (((upperBound + 1) - lowerBound) > granularity) { + ForkJoinTask.invokeAll(subTasks()); + } else { + findPrimeNumbers(); + } + } + + void findPrimeNumbers() { + for (int num = lowerBound; num <= upperBound; num++) { + if (isPrime(num)) { + noOfPrimeNumbers.getAndIncrement(); + } + } + } + + private boolean isPrime(int number) { + if (number == 2) { + return true; + } + + if (number == 1 || number % 2 == 0) { + return false; + } + + int noOfNaturalNumbers = 0; + + for (int i = 1; i <= number; i++) { + if (number % i == 0) { + noOfNaturalNumbers++; + } + } + + return noOfNaturalNumbers == 2; + } + + public int noOfPrimeNumbers() { + return noOfPrimeNumbers.intValue(); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/rejection/SaturationPolicyUnitTest.java b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/rejection/SaturationPolicyUnitTest.java index 5016cc1d06..1301fe2778 100644 --- a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/rejection/SaturationPolicyUnitTest.java +++ b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/rejection/SaturationPolicyUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.rejection; import org.junit.After; +import org.junit.Ignore; import org.junit.Test; import java.util.ArrayList; @@ -28,24 +29,26 @@ public class SaturationPolicyUnitTest { } } + @Ignore @Test public void givenAbortPolicy_WhenSaturated_ThenShouldThrowRejectedExecutionException() { executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new AbortPolicy()); - executor.execute(() -> waitFor(100)); + executor.execute(() -> waitFor(250)); assertThatThrownBy(() -> executor.execute(() -> System.out.println("Will be rejected"))).isInstanceOf(RejectedExecutionException.class); } + @Ignore @Test public void givenCallerRunsPolicy_WhenSaturated_ThenTheCallerThreadRunsTheTask() { executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new CallerRunsPolicy()); - executor.execute(() -> waitFor(100)); + executor.execute(() -> waitFor(250)); - long startTime = System.nanoTime(); - executor.execute(() -> waitFor(100)); - double blockedDuration = (System.nanoTime() - startTime) / 1_000_000.0; + long startTime = System.currentTimeMillis(); + executor.execute(() -> waitFor(500)); + long blockedDuration = System.currentTimeMillis() - startTime; - assertThat(blockedDuration).isGreaterThanOrEqualTo(100); + assertThat(blockedDuration).isGreaterThanOrEqualTo(500); } @Test diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/workstealing/PrimeNumbersUnitTest.java b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/workstealing/PrimeNumbersUnitTest.java new file mode 100644 index 0000000000..66bc677345 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/workstealing/PrimeNumbersUnitTest.java @@ -0,0 +1,101 @@ +package com.baeldung.workstealing; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; + +import java.util.concurrent.Executors; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Logger; + +import static org.junit.Assert.fail; + +public class PrimeNumbersUnitTest { + + private static Logger logger = Logger.getAnonymousLogger(); + + @Test + public void givenPrimesCalculated_whenUsingPoolsAndOneThread_thenOneThreadSlowest() { + Options opt = new OptionsBuilder() + .include(Benchmarker.class.getSimpleName()) + .forks(1) + .build(); + + try { + new Runner(opt).run(); + } catch (RunnerException e) { + fail(); + } + } + + @Test + public void givenNewWorkStealingPool_whenGettingPrimes_thenStealCountChanges() { + StringBuilder info = new StringBuilder(); + + for (int granularity : PrimeNumbers.GRANULARITIES) { + int parallelism = ForkJoinPool.getCommonPoolParallelism(); + ForkJoinPool pool = + (ForkJoinPool) Executors.newWorkStealingPool(parallelism); + + stealCountInfo(info, granularity, pool); + } + logger.info("\nExecutors.newWorkStealingPool ->" + info.toString()); + } + + @Test + public void givenCommonPool_whenGettingPrimes_thenStealCountChangesSlowly() { + StringBuilder info = new StringBuilder(); + + for (int granularity : PrimeNumbers.GRANULARITIES) { + ForkJoinPool pool = ForkJoinPool.commonPool(); + stealCountInfo(info, granularity, pool); + } + logger.info("\nForkJoinPool.commonPool ->" + info.toString()); + } + + private void stealCountInfo(StringBuilder info, int granularity, ForkJoinPool forkJoinPool) { + PrimeNumbers primes = new PrimeNumbers(1, 10000, granularity, new AtomicInteger(0)); + forkJoinPool.invoke(primes); + forkJoinPool.shutdown(); + + long steals = forkJoinPool.getStealCount(); + String output = "\nGranularity: [" + granularity + "], Steals: [" + steals + "]"; + info.append(output); + } + + + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.MILLISECONDS) + @State(Scope.Benchmark) + @Fork(value = 2, warmups = 1, jvmArgs = {"-Xms2G", "-Xmx2G"}) + public static class Benchmarker { + + @Benchmark + public void singleThread() { + PrimeNumbers primes = new PrimeNumbers(10000); + primes.findPrimeNumbers(); // get prime numbers using a single thread + } + + @Benchmark + public void commonPoolBenchmark() { + PrimeNumbers primes = new PrimeNumbers(10000); + ForkJoinPool pool = ForkJoinPool.commonPool(); + pool.invoke(primes); + pool.shutdown(); + } + + @Benchmark + public void newWorkStealingPoolBenchmark() { + PrimeNumbers primes = new PrimeNumbers(10000); + int parallelism = ForkJoinPool.getCommonPoolParallelism(); + ForkJoinPool stealer = (ForkJoinPool) Executors.newWorkStealingPool(parallelism); + stealer.invoke(primes); + stealer.shutdown(); + } + } +} diff --git a/core-java-modules/core-java-concurrency-collections/src/test/java/org/baeldung/java/streams/ThreadPoolInParallelStreamIntegrationTest.java b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/stream/ThreadPoolInParallelStreamIntegrationTest.java similarity index 97% rename from core-java-modules/core-java-concurrency-collections/src/test/java/org/baeldung/java/streams/ThreadPoolInParallelStreamIntegrationTest.java rename to core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/stream/ThreadPoolInParallelStreamIntegrationTest.java index 502672dea1..7ee849b0a2 100644 --- a/core-java-modules/core-java-concurrency-collections/src/test/java/org/baeldung/java/streams/ThreadPoolInParallelStreamIntegrationTest.java +++ b/core-java-modules/core-java-concurrency-collections/src/test/java/com/baeldung/java/stream/ThreadPoolInParallelStreamIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.streams; +package com.baeldung.java.stream; import org.junit.Test; diff --git a/core-java-modules/core-java-datetime-computations/README.md b/core-java-modules/core-java-date-operations-1/README.md similarity index 84% rename from core-java-modules/core-java-datetime-computations/README.md rename to core-java-modules/core-java-date-operations-1/README.md index 591ddeaa94..b63fab63db 100644 --- a/core-java-modules/core-java-datetime-computations/README.md +++ b/core-java-modules/core-java-date-operations-1/README.md @@ -1,6 +1,5 @@ -## Java Date/time computations Cookbooks and Examples - -This module contains articles about date and time computations in Java. +## Core Date Operations (Part 1) +This module contains articles about date operations in Java. ### Relevant Articles: - [Difference Between Two Dates in Java](http://www.baeldung.com/java-date-difference) @@ -13,3 +12,4 @@ This module contains articles about date and time computations in Java. - [Increment Date in Java](http://www.baeldung.com/java-increment-date) - [Add Hours To a Date In Java](http://www.baeldung.com/java-add-hours-date) - [Introduction to Joda-Time](http://www.baeldung.com/joda-time) +- [[Next -->]](/core-java-modules/core-java-date-operations-2) \ No newline at end of file diff --git a/core-java-modules/core-java-datetime-computations/pom.xml b/core-java-modules/core-java-date-operations-1/pom.xml similarity index 93% rename from core-java-modules/core-java-datetime-computations/pom.xml rename to core-java-modules/core-java-date-operations-1/pom.xml index af6b110296..83216f1ad8 100644 --- a/core-java-modules/core-java-datetime-computations/pom.xml +++ b/core-java-modules/core-java-date-operations-1/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - core-java-datetime-computations + core-java-date-operations-1 ${project.parent.version} - core-java-datetime-computations + core-java-date-operations-1 jar @@ -41,7 +41,7 @@ - core-java-datetime-computations + core-java-date-operations-1 src/main/resources diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/date/AgeCalculator.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/date/AgeCalculator.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/date/AgeCalculator.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/date/AgeCalculator.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/date/DateWithoutTime.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/date/DateWithoutTime.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/date/DateWithoutTime.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/date/DateWithoutTime.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/AddHoursToDate.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/AddHoursToDate.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/AddHoursToDate.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/AddHoursToDate.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/DateExtractYearMonthDayIntegerValues.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/DateExtractYearMonthDayIntegerValues.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/DateExtractYearMonthDayIntegerValues.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/DateExtractYearMonthDayIntegerValues.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/LocalDateExtractYearMonthDayIntegerValues.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/LocalDateExtractYearMonthDayIntegerValues.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/LocalDateExtractYearMonthDayIntegerValues.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/LocalDateExtractYearMonthDayIntegerValues.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/LocalDateTimeExtractYearMonthDayIntegerValues.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/LocalDateTimeExtractYearMonthDayIntegerValues.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/LocalDateTimeExtractYearMonthDayIntegerValues.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/LocalDateTimeExtractYearMonthDayIntegerValues.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/OffsetDateTimeExtractYearMonthDayIntegerValues.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/OffsetDateTimeExtractYearMonthDayIntegerValues.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/OffsetDateTimeExtractYearMonthDayIntegerValues.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/OffsetDateTimeExtractYearMonthDayIntegerValues.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/ZonedDateTimeExtractYearMonthDayIntegerValues.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/ZonedDateTimeExtractYearMonthDayIntegerValues.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/ZonedDateTimeExtractYearMonthDayIntegerValues.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/ZonedDateTimeExtractYearMonthDayIntegerValues.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/modify/DateIncrementer.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/modify/DateIncrementer.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/datetime/modify/DateIncrementer.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/datetime/modify/DateIncrementer.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/gregorian/calendar/GregorianCalendarExample.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/gregorian/calendar/GregorianCalendarExample.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/gregorian/calendar/GregorianCalendarExample.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/gregorian/calendar/GregorianCalendarExample.java diff --git a/core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/java9/time/TimeApi.java b/core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/java9/time/TimeApi.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/main/java/com/baeldung/java9/time/TimeApi.java rename to core-java-modules/core-java-date-operations-1/src/main/java/com/baeldung/java9/time/TimeApi.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/date/AgeCalculatorUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/AgeCalculatorUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/date/AgeCalculatorUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/AgeCalculatorUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/date/DateDiffUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/date/DateDiffUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateDiffUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/date/DateWithoutTimeUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateWithoutTimeUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/date/DateWithoutTimeUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/date/DateWithoutTimeUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/AddHoursToDateUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/AddHoursToDateUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/AddHoursToDateUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/AddHoursToDateUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/DateExtractYearMonthDayIntegerValuesUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/DateExtractYearMonthDayIntegerValuesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/DateExtractYearMonthDayIntegerValuesUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/DateExtractYearMonthDayIntegerValuesUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/LocalDateExtractYearMonthDayIntegerValuesUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/LocalDateExtractYearMonthDayIntegerValuesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/LocalDateExtractYearMonthDayIntegerValuesUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/LocalDateExtractYearMonthDayIntegerValuesUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/LocalDateTimeExtractYearMonthDayIntegerValuesUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/LocalDateTimeExtractYearMonthDayIntegerValuesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/LocalDateTimeExtractYearMonthDayIntegerValuesUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/LocalDateTimeExtractYearMonthDayIntegerValuesUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/OffsetDateTimeExtractYearMonthDayIntegerValuesUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/OffsetDateTimeExtractYearMonthDayIntegerValuesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/OffsetDateTimeExtractYearMonthDayIntegerValuesUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/OffsetDateTimeExtractYearMonthDayIntegerValuesUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/ZonedDateTimeExtractYearMonthDayIntegerValuesUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/ZonedDateTimeExtractYearMonthDayIntegerValuesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/ZonedDateTimeExtractYearMonthDayIntegerValuesUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/ZonedDateTimeExtractYearMonthDayIntegerValuesUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/modify/DateIncrementerUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/modify/DateIncrementerUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/datetime/modify/DateIncrementerUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/datetime/modify/DateIncrementerUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/dst/DaylightSavingTimeExamplesUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/dst/DaylightSavingTimeExamplesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/dst/DaylightSavingTimeExamplesUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/dst/DaylightSavingTimeExamplesUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/dst/DaylightSavingTimeJavaTimeExamplesUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/dst/DaylightSavingTimeJavaTimeExamplesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/dst/DaylightSavingTimeJavaTimeExamplesUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/dst/DaylightSavingTimeJavaTimeExamplesUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/gregorian/calendar/GregorianCalendarTester.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/gregorian/calendar/GregorianCalendarTester.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/gregorian/calendar/GregorianCalendarTester.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/gregorian/calendar/GregorianCalendarTester.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/java9/time/TimeApiUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/java9/time/TimeApiUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/java9/time/TimeApiUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/java9/time/TimeApiUnitTest.java diff --git a/core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/jodatime/JodaTimeUnitTest.java b/core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/jodatime/JodaTimeUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-computations/src/test/java/com/baeldung/jodatime/JodaTimeUnitTest.java rename to core-java-modules/core-java-date-operations-1/src/test/java/com/baeldung/jodatime/JodaTimeUnitTest.java diff --git a/core-java-modules/core-java-date-operations/README.md b/core-java-modules/core-java-date-operations-2/README.md similarity index 84% rename from core-java-modules/core-java-date-operations/README.md rename to core-java-modules/core-java-date-operations-2/README.md index 24bb493dce..478d3baf19 100644 --- a/core-java-modules/core-java-date-operations/README.md +++ b/core-java-modules/core-java-date-operations-2/README.md @@ -1,4 +1,4 @@ -## Core Date Operations +## Core Date Operations (Part 2) This module contains articles about date operations in Java. ### Relevant Articles: @@ -6,3 +6,4 @@ This module contains articles about date operations in Java. - [Skipping Weekends While Adding Days to LocalDate in Java 8](https://www.baeldung.com/java-localdate-add-days-skip-weekends) - [Checking If Two Java Dates Are on the Same Day](https://www.baeldung.com/java-check-two-dates-on-same-day) - [Converting Java Date to OffsetDateTime](https://www.baeldung.com/java-convert-date-to-offsetdatetime) +- [[<-- Prev]](/core-java-modules/core-java-date-operations-1) diff --git a/core-java-modules/core-java-date-operations/pom.xml b/core-java-modules/core-java-date-operations-2/pom.xml similarity index 78% rename from core-java-modules/core-java-date-operations/pom.xml rename to core-java-modules/core-java-date-operations-2/pom.xml index 4d267964ee..155b8ad0b7 100644 --- a/core-java-modules/core-java-date-operations/pom.xml +++ b/core-java-modules/core-java-date-operations-2/pom.xml @@ -3,9 +3,9 @@ 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"> 4.0.0 - core-java-date-operations + core-java-date-operations-2 ${project.parent.version} - core-java-date-operations + core-java-date-operations-2 jar @@ -31,11 +31,18 @@ hirondelle-date4j ${hirondelle-date4j.version} + + org.assertj + assertj-core + ${assertj.version} + test + 2.10 1.5.1 + 3.14.0 \ No newline at end of file diff --git a/core-java-modules/core-java-date-operations/src/main/java/com/baeldung/date/comparison/DateComparisonUtils.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/date/comparison/DateComparisonUtils.java similarity index 85% rename from core-java-modules/core-java-date-operations/src/main/java/com/baeldung/date/comparison/DateComparisonUtils.java rename to core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/date/comparison/DateComparisonUtils.java index ae8d21c29c..ab48934f1a 100644 --- a/core-java-modules/core-java-date-operations/src/main/java/com/baeldung/date/comparison/DateComparisonUtils.java +++ b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/date/comparison/DateComparisonUtils.java @@ -1,55 +1,65 @@ -package com.baeldung.date.comparison; - -import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.ZoneId; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - -import org.apache.commons.lang3.time.DateUtils; - -import hirondelle.date4j.DateTime; - -public class DateComparisonUtils { - - public static boolean isSameDayUsingLocalDate(Date date1, Date date2) { - LocalDate localDate1 = date1.toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDate(); - LocalDate localDate2 = date2.toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDate(); - return localDate1.isEqual(localDate2); - } - - public static boolean isSameDayUsingSimpleDateFormat(Date date1, Date date2) { - SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd"); - return fmt.format(date1) - .equals(fmt.format(date2)); - } - - public static boolean isSameDayUsingCalendar(Date date1, Date date2) { - Calendar calendar1 = Calendar.getInstance(); - calendar1.setTime(date1); - Calendar calendar2 = Calendar.getInstance(); - calendar2.setTime(date2); - return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH); - } - - public static boolean isSameDayUsingApacheCommons(Date date1, Date date2) { - return DateUtils.isSameDay(date1, date2); - } - - public static boolean isSameDayUsingJoda(Date date1, Date date2) { - org.joda.time.LocalDate localDate1 = new org.joda.time.LocalDate(date1); - org.joda.time.LocalDate localDate2 = new org.joda.time.LocalDate(date2); - return localDate1.equals(localDate2); - } - - public static boolean isSameDayUsingDate4j(Date date1, Date date2) { - DateTime dateObject1 = DateTime.forInstant(date1.getTime(), TimeZone.getDefault()); - DateTime dateObject2 = DateTime.forInstant(date2.getTime(), TimeZone.getDefault()); - return dateObject1.isSameDayAs(dateObject2); - } -} +package com.baeldung.date.comparison; + +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +import org.apache.commons.lang3.time.DateUtils; + +import hirondelle.date4j.DateTime; + +public class DateComparisonUtils { + + public static boolean isSameDayUsingLocalDate(Date date1, Date date2) { + LocalDate localDate1 = date1.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + LocalDate localDate2 = date2.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + return localDate1.isEqual(localDate2); + } + + public static boolean isSameDayUsingInstant(Date date1, Date date2) { + Instant instant1 = date1.toInstant() + .truncatedTo(ChronoUnit.DAYS); + Instant instant2 = date2.toInstant() + .truncatedTo(ChronoUnit.DAYS); + return instant1.equals(instant2); + } + + public static boolean isSameDayUsingSimpleDateFormat(Date date1, Date date2) { + SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd"); + return fmt.format(date1) + .equals(fmt.format(date2)); + } + + public static boolean isSameDayUsingCalendar(Date date1, Date date2) { + Calendar calendar1 = Calendar.getInstance(); + calendar1.setTime(date1); + Calendar calendar2 = Calendar.getInstance(); + calendar2.setTime(date2); + return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH); + } + + public static boolean isSameDayUsingApacheCommons(Date date1, Date date2) { + return DateUtils.isSameDay(date1, date2); + } + + public static boolean isSameDayUsingJoda(Date date1, Date date2) { + org.joda.time.LocalDate localDate1 = new org.joda.time.LocalDate(date1); + org.joda.time.LocalDate localDate2 = new org.joda.time.LocalDate(date2); + return localDate1.equals(localDate2); + } + + public static boolean isSameDayUsingDate4j(Date date1, Date date2) { + DateTime dateObject1 = DateTime.forInstant(date1.getTime(), TimeZone.getDefault()); + DateTime dateObject2 = DateTime.forInstant(date2.getTime(), TimeZone.getDefault()); + return dateObject1.isSameDayAs(dateObject2); + } +} diff --git a/core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/CalendarUtils.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/CalendarUtils.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/CalendarUtils.java rename to core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/CalendarUtils.java diff --git a/core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/DateUtils.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/DateUtils.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/DateUtils.java rename to core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/DateUtils.java diff --git a/core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/sql/DateUtils.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/sql/DateUtils.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/sql/DateUtils.java rename to core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/sql/DateUtils.java diff --git a/core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/sql/TimeUtils.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/sql/TimeUtils.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/sql/TimeUtils.java rename to core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/sql/TimeUtils.java diff --git a/core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/sql/TimestampUtils.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/sql/TimestampUtils.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/main/java/com/baeldung/datetime/sql/TimestampUtils.java rename to core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/datetime/sql/TimestampUtils.java diff --git a/core-java-modules/core-java-date-operations/src/main/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTime.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTime.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/main/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTime.java rename to core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTime.java diff --git a/core-java-modules/core-java-date-operations/src/main/java/com/baeldung/skipweekends/AddSubtractDaysSkippingWeekendsUtils.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/skipweekends/AddSubtractDaysSkippingWeekendsUtils.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/main/java/com/baeldung/skipweekends/AddSubtractDaysSkippingWeekendsUtils.java rename to core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/skipweekends/AddSubtractDaysSkippingWeekendsUtils.java diff --git a/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/timer/DatabaseMigrationTask.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/timer/DatabaseMigrationTask.java new file mode 100644 index 0000000000..322c1d2f4e --- /dev/null +++ b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/timer/DatabaseMigrationTask.java @@ -0,0 +1,19 @@ +package com.baeldung.timer; + +import java.util.List; +import java.util.TimerTask; + +public class DatabaseMigrationTask extends TimerTask { + private List oldDatabase; + private List newDatabase; + + public DatabaseMigrationTask(List oldDatabase, List newDatabase) { + this.oldDatabase = oldDatabase; + this.newDatabase = newDatabase; + } + + @Override + public void run() { + newDatabase.addAll(oldDatabase); + } +} diff --git a/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/timer/NewsletterTask.java b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/timer/NewsletterTask.java new file mode 100644 index 0000000000..16dd6c12ff --- /dev/null +++ b/core-java-modules/core-java-date-operations-2/src/main/java/com/baeldung/timer/NewsletterTask.java @@ -0,0 +1,14 @@ +package com.baeldung.timer; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.TimerTask; + +public class NewsletterTask extends TimerTask { + @Override + public void run() { + System.out.println("Email sent at: " + + LocalDateTime.ofInstant(Instant.ofEpochMilli(scheduledExecutionTime()), ZoneId.systemDefault())); + } +} diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/date/comparison/DateComparisonUtilsUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/date/comparison/DateComparisonUtilsUnitTest.java similarity index 90% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/date/comparison/DateComparisonUtilsUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/date/comparison/DateComparisonUtilsUnitTest.java index db55aadcca..477c348ea2 100644 --- a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/date/comparison/DateComparisonUtilsUnitTest.java +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/date/comparison/DateComparisonUtilsUnitTest.java @@ -1,53 +1,57 @@ -package com.baeldung.date.comparison; - -import org.junit.Test; - -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.Date; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class DateComparisonUtilsUnitTest { - - private Date day1Morning = toDate(LocalDateTime.of(2019, 10, 19, 6, 30, 40)); - private Date day1Evening = toDate(LocalDateTime.of(2019, 10, 19, 18, 30, 50)); - private Date day2Morning = toDate(LocalDateTime.of(2019, 10, 20, 6, 30, 50)); - - private Date toDate(LocalDateTime localDateTime) { - return Date.from(localDateTime.atZone(ZoneId.systemDefault()) - .toInstant()); - } - - @Test - public void givenDatesWithDifferentTime_whenIsSameDay_thenReturnsTrue() { - assertTrue(DateComparisonUtils.isSameDayUsingLocalDate(day1Morning, day1Evening)); - assertTrue(DateComparisonUtils.isSameDayUsingSimpleDateFormat(day1Morning, day1Evening)); - assertTrue(DateComparisonUtils.isSameDayUsingCalendar(day1Morning, day1Evening)); - assertTrue(DateComparisonUtils.isSameDayUsingApacheCommons(day1Morning, day1Evening)); - assertTrue(DateComparisonUtils.isSameDayUsingJoda(day1Morning, day1Evening)); - assertTrue(DateComparisonUtils.isSameDayUsingDate4j(day1Morning, day1Evening)); - } - - @Test - public void givenDates_whenIsDifferentDay_thenReturnsFalse() { - assertFalse(DateComparisonUtils.isSameDayUsingLocalDate(day1Morning, day2Morning)); - assertFalse(DateComparisonUtils.isSameDayUsingLocalDate(day1Evening, day2Morning)); - - assertFalse(DateComparisonUtils.isSameDayUsingSimpleDateFormat(day1Morning, day2Morning)); - assertFalse(DateComparisonUtils.isSameDayUsingSimpleDateFormat(day1Evening, day2Morning)); - - assertFalse(DateComparisonUtils.isSameDayUsingCalendar(day1Morning, day2Morning)); - assertFalse(DateComparisonUtils.isSameDayUsingCalendar(day1Evening, day2Morning)); - - assertFalse(DateComparisonUtils.isSameDayUsingApacheCommons(day1Morning, day2Morning)); - assertFalse(DateComparisonUtils.isSameDayUsingApacheCommons(day1Evening, day2Morning)); - - assertFalse(DateComparisonUtils.isSameDayUsingJoda(day1Morning, day2Morning)); - assertFalse(DateComparisonUtils.isSameDayUsingJoda(day1Evening, day2Morning)); - - assertFalse(DateComparisonUtils.isSameDayUsingDate4j(day1Morning, day2Morning)); - assertFalse(DateComparisonUtils.isSameDayUsingDate4j(day1Evening, day2Morning)); - } -} +package com.baeldung.date.comparison; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; + +import org.junit.Test; + +public class DateComparisonUtilsUnitTest { + + private Date day1Morning = toDate(LocalDateTime.of(2019, 10, 19, 6, 30, 40)); + private Date day1Evening = toDate(LocalDateTime.of(2019, 10, 19, 18, 30, 50)); + private Date day2Morning = toDate(LocalDateTime.of(2019, 10, 20, 6, 30, 50)); + + private Date toDate(LocalDateTime localDateTime) { + return Date.from(localDateTime.atZone(ZoneId.systemDefault()) + .toInstant()); + } + + @Test + public void givenDatesWithDifferentTime_whenIsSameDay_thenReturnsTrue() { + assertTrue(DateComparisonUtils.isSameDayUsingLocalDate(day1Morning, day1Evening)); + assertTrue(DateComparisonUtils.isSameDayUsingInstant(day1Morning, day1Evening)); + assertTrue(DateComparisonUtils.isSameDayUsingSimpleDateFormat(day1Morning, day1Evening)); + assertTrue(DateComparisonUtils.isSameDayUsingCalendar(day1Morning, day1Evening)); + assertTrue(DateComparisonUtils.isSameDayUsingApacheCommons(day1Morning, day1Evening)); + assertTrue(DateComparisonUtils.isSameDayUsingJoda(day1Morning, day1Evening)); + assertTrue(DateComparisonUtils.isSameDayUsingDate4j(day1Morning, day1Evening)); + } + + @Test + public void givenDates_whenIsDifferentDay_thenReturnsFalse() { + assertFalse(DateComparisonUtils.isSameDayUsingLocalDate(day1Morning, day2Morning)); + assertFalse(DateComparisonUtils.isSameDayUsingLocalDate(day1Evening, day2Morning)); + + assertFalse(DateComparisonUtils.isSameDayUsingInstant(day1Morning, day2Morning)); + assertFalse(DateComparisonUtils.isSameDayUsingInstant(day1Evening, day2Morning)); + + assertFalse(DateComparisonUtils.isSameDayUsingSimpleDateFormat(day1Morning, day2Morning)); + assertFalse(DateComparisonUtils.isSameDayUsingSimpleDateFormat(day1Evening, day2Morning)); + + assertFalse(DateComparisonUtils.isSameDayUsingCalendar(day1Morning, day2Morning)); + assertFalse(DateComparisonUtils.isSameDayUsingCalendar(day1Evening, day2Morning)); + + assertFalse(DateComparisonUtils.isSameDayUsingApacheCommons(day1Morning, day2Morning)); + assertFalse(DateComparisonUtils.isSameDayUsingApacheCommons(day1Evening, day2Morning)); + + assertFalse(DateComparisonUtils.isSameDayUsingJoda(day1Morning, day2Morning)); + assertFalse(DateComparisonUtils.isSameDayUsingJoda(day1Evening, day2Morning)); + + assertFalse(DateComparisonUtils.isSameDayUsingDate4j(day1Morning, day2Morning)); + assertFalse(DateComparisonUtils.isSameDayUsingDate4j(day1Evening, day2Morning)); + } +} diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/CalendarUtilsUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/CalendarUtilsUnitTest.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/CalendarUtilsUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/CalendarUtilsUnitTest.java diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/DateUtilsUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/DateUtilsUnitTest.java similarity index 73% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/DateUtilsUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/DateUtilsUnitTest.java index 8711455265..9bc2a17f28 100644 --- a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/DateUtilsUnitTest.java +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/DateUtilsUnitTest.java @@ -9,12 +9,6 @@ import static org.junit.Assert.assertEquals; public class DateUtilsUnitTest { - @Test - public void givenTimeMillis_thenDateIsReturned() { - Date now = DateUtils.getNow(); - assertEquals(DateUtils.getDate(now.getTime()), now); - } - @Test public void givenDateAndPattern_thenDateIsCorrectlyReturned() throws ParseException { long milliseconds = new Date(2020 - 1900, 0, 1).getTime(); diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/sql/DateUtilsUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/sql/DateUtilsUnitTest.java similarity index 80% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/sql/DateUtilsUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/sql/DateUtilsUnitTest.java index 945086c86f..9ccaa9a845 100644 --- a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/sql/DateUtilsUnitTest.java +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/sql/DateUtilsUnitTest.java @@ -9,11 +9,6 @@ import org.junit.Test; public class DateUtilsUnitTest { - @Test - public void givenCurrentDate_thenTodayIsReturned() { - assertEquals(DateUtils.getNow().toLocalDate(), LocalDate.now()); - } - @Test(expected = IllegalArgumentException.class) public void givenDateAsString_whenPatternIsNotRespected_thenExceptionIsThrown() { DateUtils.getDate("2020 01 01"); diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/sql/TimeUtilsUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/sql/TimeUtilsUnitTest.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/sql/TimeUtilsUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/sql/TimeUtilsUnitTest.java diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/sql/TimestampUtilsUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/sql/TimestampUtilsUnitTest.java similarity index 73% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/sql/TimestampUtilsUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/sql/TimestampUtilsUnitTest.java index 2faf8fab0e..836d0d55e7 100644 --- a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/datetime/sql/TimestampUtilsUnitTest.java +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/datetime/sql/TimestampUtilsUnitTest.java @@ -1,22 +1,13 @@ package com.baeldung.datetime.sql; -import static org.junit.Assert.assertEquals; - import org.junit.Test; -import com.baeldung.datetime.sql.TimestampUtils; - import java.text.ParseException; -import java.util.Date; + +import static org.junit.Assert.assertEquals; public class TimestampUtilsUnitTest { - @Test - public void givenCurrentTimestamp_thenNowIsReturned() { - assertEquals(TimestampUtils.getNow() - .getTime(), new Date().getTime()); - } - @Test(expected = IllegalArgumentException.class) public void givenTimestampAsString_whenPatternIsNotRespected_thenExceptionIsThrown() { TimestampUtils.getTimestamp("2020/01/01 10:11-12"); diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/timezone/ModifyDefaultTimezoneUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/jvmtimezone/ModifyDefaultTimezoneUnitTest.java similarity index 79% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/timezone/ModifyDefaultTimezoneUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/jvmtimezone/ModifyDefaultTimezoneUnitTest.java index 05d36d2c6c..7a266b46c3 100644 --- a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/timezone/ModifyDefaultTimezoneUnitTest.java +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/jvmtimezone/ModifyDefaultTimezoneUnitTest.java @@ -1,9 +1,8 @@ -package com.baeldung.timezone; +package com.baeldung.jvmtimezone; import org.junit.Test; import java.util.Calendar; -import java.util.Date; import java.util.TimeZone; import static org.junit.Assert.assertEquals; @@ -13,9 +12,7 @@ public class ModifyDefaultTimezoneUnitTest { @Test public void givenDefaultTimezoneSet_thenDateTimezoneIsCorrect() { TimeZone.setDefault(TimeZone.getTimeZone("Portugal")); - Date date = new Date(); Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); assertEquals(calendar.getTimeZone(), TimeZone.getTimeZone("Portugal")); } diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/timezone/ModifyTimezonePropertyUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/jvmtimezone/ModifyTimezonePropertyUnitTest.java similarity index 79% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/timezone/ModifyTimezonePropertyUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/jvmtimezone/ModifyTimezonePropertyUnitTest.java index 8f65f520f8..ec0d183e78 100644 --- a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/timezone/ModifyTimezonePropertyUnitTest.java +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/jvmtimezone/ModifyTimezonePropertyUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.timezone; +package com.baeldung.jvmtimezone; import org.junit.After; import org.junit.Before; @@ -14,7 +14,7 @@ public class ModifyTimezonePropertyUnitTest { @Before public void setup() { - System.setProperty("user.timezone", "IST"); + System.setProperty("user.timezone", "Asia/Kolkata"); TimeZone.setDefault(null); } @@ -25,10 +25,8 @@ public class ModifyTimezonePropertyUnitTest { @Test public void givenTimezonePropertySet_thenDateTimezoneIsCorrect() { - Date date = new Date(); Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - assertEquals(calendar.getTimeZone(), TimeZone.getTimeZone("IST")); + assertEquals(calendar.getTimeZone(), TimeZone.getTimeZone("Asia/Kolkata")); } } \ No newline at end of file diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTimeUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTimeUnitTest.java similarity index 75% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTimeUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTimeUnitTest.java index a6fd6c03c2..fa9ceca173 100644 --- a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTimeUnitTest.java +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/offsetdatetime/ConvertToOffsetDateTimeUnitTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.time.OffsetDateTime; import java.util.Date; +import java.util.TimeZone; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -18,12 +19,19 @@ public class ConvertToOffsetDateTimeUnitTest { @Test public void givenDate_whenHasOffset_thenConvertWithOffset() { + TimeZone prevTimezone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + Date date = new Date(); date.setHours(6); date.setMinutes(30); + OffsetDateTime odt = ConvertToOffsetDateTime.convert(date, 3, 30); assertEquals(10, odt.getHour()); assertEquals(0, odt.getMinute()); + + // Reset the timezone to its original value to prevent side effects + TimeZone.setDefault(prevTimezone); } } diff --git a/core-java-modules/core-java-date-operations/src/test/java/com/baeldung/skipweekends/AddSubtractDaysSkippingWeekendsUtilsUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/skipweekends/AddSubtractDaysSkippingWeekendsUtilsUnitTest.java similarity index 100% rename from core-java-modules/core-java-date-operations/src/test/java/com/baeldung/skipweekends/AddSubtractDaysSkippingWeekendsUtilsUnitTest.java rename to core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/skipweekends/AddSubtractDaysSkippingWeekendsUtilsUnitTest.java diff --git a/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/timer/DatabaseMigrationTaskUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/timer/DatabaseMigrationTaskUnitTest.java new file mode 100644 index 0000000000..5f3ae63901 --- /dev/null +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/timer/DatabaseMigrationTaskUnitTest.java @@ -0,0 +1,44 @@ +package com.baeldung.timer; + +import org.junit.jupiter.api.Test; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; + +class DatabaseMigrationTaskUnitTest { + @Test + void givenDatabaseMigrationTask_whenTimerScheduledForNowPlusTwoSeconds_thenDataMigratedAfterTwoSeconds() throws Exception { + List oldDatabase = Arrays.asList("Harrison Ford", "Carrie Fisher", "Mark Hamill"); + List newDatabase = new ArrayList<>(); + + LocalDateTime twoSecondsLater = LocalDateTime.now().plusSeconds(2); + Date twoSecondsLaterAsDate = Date.from(twoSecondsLater.atZone(ZoneId.systemDefault()).toInstant()); + + new Timer().schedule(new DatabaseMigrationTask(oldDatabase, newDatabase), twoSecondsLaterAsDate); + + while (LocalDateTime.now().isBefore(twoSecondsLater)) { + assertThat(newDatabase).isEmpty(); + Thread.sleep(500); + } + assertThat(newDatabase).containsExactlyElementsOf(oldDatabase); + } + + @Test + void givenDatabaseMigrationTask_whenTimerScheduledInTwoSeconds_thenDataMigratedAfterTwoSeconds() throws Exception { + List oldDatabase = Arrays.asList("Harrison Ford", "Carrie Fisher", "Mark Hamill"); + List newDatabase = new ArrayList<>(); + + new Timer().schedule(new DatabaseMigrationTask(oldDatabase, newDatabase), 2000); + + LocalDateTime twoSecondsLater = LocalDateTime.now().plusSeconds(2); + + while (LocalDateTime.now().isBefore(twoSecondsLater)) { + assertThat(newDatabase).isEmpty(); + Thread.sleep(500); + } + assertThat(newDatabase).containsExactlyElementsOf(oldDatabase); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/timer/NewsletterTaskUnitTest.java b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/timer/NewsletterTaskUnitTest.java new file mode 100644 index 0000000000..ffbe39c2bc --- /dev/null +++ b/core-java-modules/core-java-date-operations-2/src/test/java/com/baeldung/timer/NewsletterTaskUnitTest.java @@ -0,0 +1,33 @@ +package com.baeldung.timer; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +import java.util.Timer; + +class NewsletterTaskUnitTest { + private final Timer timer = new Timer(); + + @AfterEach + void afterEach() { + timer.cancel(); + } + + @Test + void givenNewsletterTask_whenTimerScheduledEachSecondFixedDelay_thenNewsletterSentEachSecond() throws Exception { + timer.schedule(new NewsletterTask(), 0, 1000); + + for (int i = 0; i < 3; i++) { + Thread.sleep(1000); + } + } + + @Test + void givenNewsletterTask_whenTimerScheduledEachSecondFixedRate_thenNewsletterSentEachSecond() throws Exception { + timer.scheduleAtFixedRate(new NewsletterTask(), 0, 1000); + + for (int i = 0; i < 3; i++) { + Thread.sleep(1000); + } + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-datetime-java8-2/pom.xml b/core-java-modules/core-java-datetime-java8-2/pom.xml new file mode 100644 index 0000000000..34323fe76c --- /dev/null +++ b/core-java-modules/core-java-datetime-java8-2/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + core-java-datetime-java8 + ${project.parent.version} + core-java-datetime-java8 + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + joda-time + joda-time + ${joda-time.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + log4j + log4j + ${log4j.version} + test + + + + + core-java-datetime-java8 + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + + 1.9 + 1.9 + 2.10 + + 3.6.1 + + + diff --git a/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/localdate/LocalDateExample.java b/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/localdate/LocalDateExample.java new file mode 100644 index 0000000000..f4c9e5431f --- /dev/null +++ b/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/localdate/LocalDateExample.java @@ -0,0 +1,31 @@ +package com.baeldung.localdate; + +import java.time.LocalDate; +import java.time.Month; +import java.time.format.DateTimeFormatter; + +public class LocalDateExample { + public LocalDate getCustomDateOne(int year, int month, int dayOfMonth) { + return LocalDate.of(year, month, dayOfMonth); + } + + public LocalDate getCustomDateTwo(int year, Month month, int dayOfMonth) { + return LocalDate.of(year, month, dayOfMonth); + } + + public LocalDate getDateFromEpochDay(long epochDay) { + return LocalDate.ofEpochDay(epochDay); + } + + public LocalDate getDateFromYearAndDayOfYear(int year, int dayOfYear) { + return LocalDate.ofYearDay(year, dayOfYear); + } + + public LocalDate getDateFromString(String date) { + return LocalDate.parse(date); + } + + public LocalDate getDateFromStringAndFormatter(String date, String pattern) { + return LocalDate.parse(date, DateTimeFormatter.ofPattern(pattern)); + } +} diff --git a/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java b/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java new file mode 100644 index 0000000000..dff15486a4 --- /dev/null +++ b/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java @@ -0,0 +1,41 @@ +package com.baeldung.localdate; + +import static org.junit.Assert.assertEquals; + +import java.time.Month; + +import org.junit.Test; + +public class LocalDateExampleUnitTest { + private LocalDateExample date = new LocalDateExample(); + + @Test + public void givenValues_whenUsingOfMethod_thenLocalDate() { + assertEquals("2020-01-08", date.getCustomDateOne(2020, 1, 8)); + } + + @Test + public void givenValuesWithMonthEnum_whenUsingOfMethod_thenLocalDate() { + assertEquals("2020-01-08", date.getCustomDateTwo(2020, Month.JANUARY, 8)); + } + + @Test + public void givenValues_whenUsingEpochDay_thenLocalDate() { + assertEquals("2020-01-08", date.getDateFromEpochDay(18269)); + } + + @Test + public void givenValues_whenUsingYearDay_thenLocalDate() { + assertEquals("2020-01-08", date.getDateFromYearAndDayOfYear(2020, 8)); + } + + @Test + public void givenValues_whenUsingParse_thenLocalDate() { + assertEquals("2020-01-08", date.getDateFromString("2020-01-08")); + } + + @Test + public void givenValuesWithFormatter_whenUsingParse_thenLocalDate() { + assertEquals("2020-01-08", date.getDateFromStringAndFormatter("8-Jan-2020", "d-MMM-yyyy")); + } +} diff --git a/java-dates/src/main/java/com/baeldung/datetime/UseDateTimeFormatter.java b/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseDateTimeFormatter.java similarity index 100% rename from java-dates/src/main/java/com/baeldung/datetime/UseDateTimeFormatter.java rename to core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseDateTimeFormatter.java diff --git a/java-dates/src/main/java/com/baeldung/datetime/UseOffsetDateTime.java b/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseOffsetDateTime.java similarity index 100% rename from java-dates/src/main/java/com/baeldung/datetime/UseOffsetDateTime.java rename to core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseOffsetDateTime.java diff --git a/java-dates/src/test/java/com/baeldung/datetime/UseDateTimeFormatterUnitTest.java b/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseDateTimeFormatterUnitTest.java similarity index 100% rename from java-dates/src/test/java/com/baeldung/datetime/UseDateTimeFormatterUnitTest.java rename to core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseDateTimeFormatterUnitTest.java diff --git a/java-dates/src/test/java/com/baeldung/datetime/UseOffsetDateTimeUnitTest.java b/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseOffsetDateTimeUnitTest.java similarity index 100% rename from java-dates/src/test/java/com/baeldung/datetime/UseOffsetDateTimeUnitTest.java rename to core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseOffsetDateTimeUnitTest.java diff --git a/java-dates/src/test/java/com/baeldung/datetime/UseToInstantUnitTest.java b/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseToInstantUnitTest.java similarity index 100% rename from java-dates/src/test/java/com/baeldung/datetime/UseToInstantUnitTest.java rename to core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseToInstantUnitTest.java diff --git a/core-java-modules/core-java-exceptions-2/README.md b/core-java-modules/core-java-exceptions-2/README.md index 3ad5189b5e..d3537edb40 100644 --- a/core-java-modules/core-java-exceptions-2/README.md +++ b/core-java-modules/core-java-exceptions-2/README.md @@ -2,4 +2,6 @@ This module contains articles about core java exceptions -### +### Relevant Articles: + +- [Is It a Bad Practice to Catch Throwable?](https://www.baeldung.com/java-catch-throwable-bad-practice) diff --git a/core-java-modules/core-java-exceptions-2/pom.xml b/core-java-modules/core-java-exceptions-2/pom.xml index 2f7f613faf..955d7153fa 100644 --- a/core-java-modules/core-java-exceptions-2/pom.xml +++ b/core-java-modules/core-java-exceptions-2/pom.xml @@ -13,12 +13,24 @@ 0.0.1-SNAPSHOT ../../parent-java + + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + http://maven.apache.org UTF-8 + + 3.10.0 diff --git a/core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/CatchingThrowable.java b/core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/CatchingThrowable.java new file mode 100644 index 0000000000..20b06cdd26 --- /dev/null +++ b/core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/CatchingThrowable.java @@ -0,0 +1,38 @@ +package com.baeldung.exceptions; + +import java.util.Set; +import java.util.UUID; + +public class CatchingThrowable { + + class CapacityException extends Exception { + CapacityException(String message) { + super(message); + } + } + + class StorageAPI { + + public void addIDsToStorage(int capacity, Set storage) throws CapacityException { + if (capacity < 1) { + throw new CapacityException("Capacity of less than 1 is not allowed"); + } + int count = 0; + while (count < capacity) { + storage.add(UUID.randomUUID().toString()); + count++; + } + } + + // other methods go here ... + } + + public void add(StorageAPI api, int capacity, Set storage) { + try { + api.addIDsToStorage(capacity, storage); + } catch (Throwable throwable) { + // do something here + } + } + +} diff --git a/core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/UnknownHostExceptionHandling.java b/core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/UnknownHostExceptionHandling.java new file mode 100644 index 0000000000..0e1c36f64c --- /dev/null +++ b/core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/UnknownHostExceptionHandling.java @@ -0,0 +1,28 @@ +package com.baeldung.exceptions; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.UnknownHostException; + +public class UnknownHostExceptionHandling { + + public static int getResponseCode(String hostname) throws IOException { + URL url = new URL(hostname.trim()); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + int resCode = -1; + try { + resCode = con.getResponseCode(); + } catch (UnknownHostException e){ + con.disconnect(); + } + return resCode; + } + + public static int getResponseCodeUnhandled(String hostname) throws IOException { + URL url = new URL(hostname.trim()); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + int resCode = con.getResponseCode(); + return resCode; + } +} diff --git a/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptions/UnknownHostExceptionHandlingUnitTest.java b/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptions/UnknownHostExceptionHandlingUnitTest.java new file mode 100644 index 0000000000..d4b53e2dce --- /dev/null +++ b/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptions/UnknownHostExceptionHandlingUnitTest.java @@ -0,0 +1,15 @@ +package com.baeldung.exceptions; + +import java.io.IOException; +import java.net.UnknownHostException; + +import org.junit.Test; + +public class UnknownHostExceptionHandlingUnitTest { + + @Test(expected = UnknownHostException.class) + public void givenUnknownHost_whenResolve_thenUnknownHostException() throws IOException { + UnknownHostExceptionHandling.getResponseCodeUnhandled("http://locaihost"); + } + +} diff --git a/core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassUnitTest.java b/core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassUnitTest.java index a4317af372..1883f40681 100644 --- a/core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassUnitTest.java +++ b/core-java-modules/core-java-io-apis/src/test/java/com/baeldung/file/FileClassUnitTest.java @@ -1,5 +1,6 @@ package com.baeldung.file; +import org.junit.Ignore; import org.junit.Test; import java.io.*; @@ -73,6 +74,7 @@ public class FileClassUnitTest { assertFalse(writable); } + @Ignore @Test public void givenWriteOnlyFile_whenCreateNewFile_thenCantReadFile() { File parentDir = makeDir("writeDir"); diff --git a/core-java-modules/core-java-io/README.md b/core-java-modules/core-java-io/README.md index 5c4978722f..2c6c3363cb 100644 --- a/core-java-modules/core-java-io/README.md +++ b/core-java-modules/core-java-io/README.md @@ -13,4 +13,5 @@ This module contains articles about core Java input and output (IO) - [Getting a File’s Mime Type in Java](https://www.baeldung.com/java-file-mime-type) - [How to Write to a CSV File in Java](https://www.baeldung.com/java-csv) - [How to Avoid the Java FileNotFoundException When Loading Resources](https://www.baeldung.com/java-classpath-resource-cannot-be-opened) +- [Create a Directory in Java](https://www.baeldung.com/java-create-directory) - [[More -->]](/core-java-modules/core-java-io-2) diff --git a/core-java-modules/core-java-jar/pom.xml b/core-java-modules/core-java-jar/pom.xml index a3e8941622..d035ee33e2 100644 --- a/core-java-modules/core-java-jar/pom.xml +++ b/core-java-modules/core-java-jar/pom.xml @@ -99,7 +99,7 @@ true libs/ - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -118,7 +118,7 @@ ${project.basedir} - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -142,7 +142,7 @@ true - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -157,7 +157,7 @@ - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar true ${project.build.finalName}-onejar.${project.packaging} @@ -179,7 +179,7 @@ spring-boot - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -207,8 +207,8 @@ maven-javadoc-plugin ${maven-javadoc-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -397,6 +397,8 @@ 3.1.1 2.0.3.RELEASE 1.6.0 + 1.8 + 1.8 diff --git a/core-java-modules/core-java-jndi/pom.xml b/core-java-modules/core-java-jndi/pom.xml index 13504886d6..482d07a999 100644 --- a/core-java-modules/core-java-jndi/pom.xml +++ b/core-java-modules/core-java-jndi/pom.xml @@ -9,44 +9,54 @@ core-java-jndi - com.baeldung - parent-modules + com.baeldung.core-java-modules + core-java-modules 1.0.0-SNAPSHOT - ../../ org.junit.jupiter junit-jupiter - 5.5.1 + ${jupiter.version} test + + org.junit.jupiter + junit-jupiter-api + ${jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${jupiter.version} + org.springframework spring-core - 5.0.9.RELEASE + ${spring.version} org.springframework spring-context - 5.0.9.RELEASE + ${spring.version} org.springframework spring-jdbc - 5.0.9.RELEASE + ${spring.version} org.springframework spring-test - 5.0.9.RELEASE + ${spring.version} test com.h2database h2 - 1.4.199 + ${h2.version} @@ -56,11 +66,19 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${source.version} + ${target.version} + + + 5.0.9.RELEASE + 1.4.199 + 5.5.1 + 1.8 + 1.8 + diff --git a/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/exceptions/JndiExceptionsUnitTest.java b/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/exceptions/JndiExceptionsUnitTest.java index 49d4facffb..218807568c 100644 --- a/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/exceptions/JndiExceptionsUnitTest.java +++ b/core-java-modules/core-java-jndi/src/test/java/com/baeldung/jndi/exceptions/JndiExceptionsUnitTest.java @@ -1,5 +1,12 @@ package com.baeldung.jndi.exceptions; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import javax.naming.InitialContext; +import javax.naming.NameNotFoundException; +import javax.naming.NoInitialContextException; + +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -7,12 +14,6 @@ import org.junit.jupiter.api.TestMethodOrder; import org.springframework.jndi.JndiTemplate; import org.springframework.mock.jndi.SimpleNamingContextBuilder; -import javax.naming.InitialContext; -import javax.naming.NameNotFoundException; -import javax.naming.NoInitialContextException; - -import static org.junit.jupiter.api.Assertions.assertThrows; - @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class JndiExceptionsUnitTest { diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml index ddf52d8fef..e708502dee 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern1/consumermodule/pom.xml @@ -16,7 +16,7 @@ com.baeldung.servicemodule servicemodule - 1.0 + ${servicemodule.version} @@ -29,4 +29,8 @@ + + 1.0 + + diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml index 78a9d1eaad..3c03643a2c 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern1/pom.xml @@ -19,10 +19,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 11 - 11 + ${source.version} + ${target.version} @@ -31,6 +31,9 @@ UTF-8 + 3.8.0 + 11 + 11 \ No newline at end of file diff --git a/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml index ece85fd5dc..3fe6f735eb 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern1/servicemodule/pom.xml @@ -2,7 +2,6 @@ 4.0.0 - com.baeldung.servicemodule servicemodule jar diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml index 734774af0e..a042ee4562 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/consumermodule/pom.xml @@ -8,8 +8,8 @@ 1.0 - decoupling-pattern2 - com.baeldung.decoupling-pattern2 + com.baeldung.decoupling-pattern2 + decoupling-pattern2 1.0-SNAPSHOT @@ -17,12 +17,12 @@ com.baeldung.servicemodule servicemodule - 1.0 + ${servicemodule.version} com.baeldung.providermodule providermodule - 1.0 + ${providermodule.version} @@ -34,5 +34,10 @@ + + + 1.0 + 1.0 + \ No newline at end of file diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml index 2f84c69fd6..f6b4e5b0df 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/pom.xml @@ -20,14 +20,20 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 11 - 11 + ${source.version} + ${target.version} + + + 3.8.0 + 11 + 11 + \ No newline at end of file diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml index 5ec36c581e..20e97fca0f 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/providermodule/pom.xml @@ -8,8 +8,8 @@ 1.0 - decoupling-pattern2 - com.baeldung.decoupling-pattern2 + com.baeldung.decoupling-pattern2 + decoupling-pattern2 1.0-SNAPSHOT @@ -17,7 +17,7 @@ com.baeldung.servicemodule servicemodule - 1.0 + ${servicemodule.version} @@ -30,4 +30,9 @@ + + 1.0 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml b/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml index 9249ea5d89..f65ebb0b55 100644 --- a/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml +++ b/core-java-modules/core-java-jpms/decoupling-pattern2/servicemodule/pom.xml @@ -3,13 +3,12 @@ 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"> 4.0.0 - com.baeldung.servicemodule servicemodule 1.0 - decoupling-pattern2 - >com.baeldung.decoupling-pattern2 + com.baeldung.decoupling-pattern2 + decoupling-pattern2 1.0-SNAPSHOT diff --git a/core-java-modules/core-java-security-manager/pom.xml b/core-java-modules/core-java-jpms/pom.xml similarity index 64% rename from core-java-modules/core-java-security-manager/pom.xml rename to core-java-modules/core-java-jpms/pom.xml index 52f1554ace..dfb3c71229 100644 --- a/core-java-modules/core-java-security-manager/pom.xml +++ b/core-java-modules/core-java-jpms/pom.xml @@ -2,10 +2,10 @@ 4.0.0 - core-java-security-manager - 0.1.0-SNAPSHOT - core-java-security-manager - jar + core-java-jpms + 0.0.1-SNAPSHOT + core-java-jpms + pom com.baeldung.core-java-modules @@ -13,4 +13,9 @@ 1.0.0-SNAPSHOT + + decoupling-pattern1 + decoupling-pattern2 + + diff --git a/core-java-modules/core-java-jvm/README.md b/core-java-modules/core-java-jvm/README.md index 89600ad924..2f80ea7372 100644 --- a/core-java-modules/core-java-jvm/README.md +++ b/core-java-modules/core-java-jvm/README.md @@ -10,3 +10,5 @@ This module contains articles about working with the Java Virtual Machine (JVM). - [Class Loaders in Java](https://www.baeldung.com/java-classloaders) - [A Guide to System.exit()](https://www.baeldung.com/java-system-exit) - [Guide to System.gc()](https://www.baeldung.com/java-system-gc) +- [Runtime.getRuntime().halt() vs System.exit() in Java](https://www.baeldung.com/java-runtime-halt-vs-system-exit) +- [Adding Shutdown Hooks for JVM Applications](https://www.baeldung.com/jvm-shutdown-hooks) diff --git a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoUnitTest.java b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoManualTest.java similarity index 88% rename from core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoUnitTest.java rename to core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoManualTest.java index 0c50651af0..d56dea62f4 100644 --- a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoUnitTest.java +++ b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmExitDemoManualTest.java @@ -2,7 +2,7 @@ package com.baeldung.exitvshalt; import org.junit.Test; -public class JvmExitDemoUnitTest { +public class JvmExitDemoManualTest { JvmExitAndHaltDemo jvmExitAndHaltDemo = new JvmExitAndHaltDemo(); diff --git a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoUnitTest.java b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoManualTest.java similarity index 88% rename from core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoUnitTest.java rename to core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoManualTest.java index 9f08e95c6a..4fe0999a9c 100644 --- a/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoUnitTest.java +++ b/core-java-modules/core-java-jvm/src/test/java/com/baeldung/exitvshalt/JvmHaltDemoManualTest.java @@ -2,7 +2,7 @@ package com.baeldung.exitvshalt; import org.junit.Test; -public class JvmHaltDemoUnitTest { +public class JvmHaltDemoManualTest { JvmExitAndHaltDemo jvmExitAndHaltDemo = new JvmExitAndHaltDemo(); diff --git a/core-java-modules/core-java-lang-2/pom.xml b/core-java-modules/core-java-lang-2/pom.xml index 5657e64b17..a5fb5ca859 100644 --- a/core-java-modules/core-java-lang-2/pom.xml +++ b/core-java-modules/core-java-lang-2/pom.xml @@ -15,10 +15,15 @@ + + org.apache.commons + commons-lang3 + 3.9 + commons-beanutils commons-beanutils - 1.9.4 + ${commons.beanutils.version} org.openjdk.jmh @@ -57,6 +62,7 @@ 1.19 1.19 3.12.2 + 1.9.4 diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/FinallyExample.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/FinallyExample.java new file mode 100644 index 0000000000..bb0bad8cf4 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/FinallyExample.java @@ -0,0 +1,14 @@ +package com.baeldung.finallykeyword; + +public class FinallyExample { + + public void printCount(String count) { + try { + System.out.println("The count is " + Integer.parseInt(count)); + } catch (NumberFormatException e) { + System.out.println("No count"); + } finally { + System.out.println("In finally"); + } + } +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/FinallyExecutedCases.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/FinallyExecutedCases.java new file mode 100644 index 0000000000..68a3763da0 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/FinallyExecutedCases.java @@ -0,0 +1,53 @@ +package com.baeldung.finallykeyword; + +public class FinallyExecutedCases { + + public void noExceptionFinally() { + try { + System.out.println("Inside try"); + } finally { + System.out.println("Inside finally"); + } + } + + public void unhandledException() throws Exception { + try { + System.out.println("Inside try"); + throw new Exception(); + } finally { + System.out.println("Inside finally"); + } + } + + public void handledException() { + try { + System.out.println("Inside try"); + throw new Exception(); + } catch (Exception e) { + System.out.println("Inside catch"); + } finally { + System.out.println("Inside finally"); + } + } + + public String returnFromTry() { + try { + System.out.println("Inside try"); + return "from try"; + } finally { + System.out.println("Inside finally"); + } + } + + public String returnFromCatch() { + try { + System.out.println("Inside try"); + throw new Exception(); + } catch (Exception e) { + System.out.println("Inside catch"); + return "from catch"; + } finally { + System.out.println("Inside finally"); + } + } +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/FinallyNotExecutedCases.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/FinallyNotExecutedCases.java new file mode 100644 index 0000000000..92c0ea729d --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/FinallyNotExecutedCases.java @@ -0,0 +1,54 @@ +package com.baeldung.finallykeyword; + +public class FinallyNotExecutedCases { + + public void callingSystemExit() { + try { + System.out.println("Inside try"); + System.exit(1); + } finally { + System.out.println("Inside finally"); + } + } + + public void callingRuntimeHalt() { + try { + System.out.println("Inside try"); + Runtime.getRuntime() + .halt(1); + } finally { + System.out.println("Inside finally"); + } + } + + public void infiniteLoop() { + try { + System.out.println("Inside try"); + while (true) { + } + } finally { + System.out.println("Inside finally"); + } + } + + public void daemonThread() throws InterruptedException { + Runnable runnable = () -> { + try { + System.out.println("Inside try"); + } finally { + try { + Thread.sleep(1000); + System.out.println("Inside finally"); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }; + Thread regular = new Thread(runnable); + Thread daemon = new Thread(runnable); + daemon.setDaemon(true); + regular.start(); + Thread.sleep(300); + daemon.start(); + } +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/PitfallsWhenUsingFinally.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/PitfallsWhenUsingFinally.java new file mode 100644 index 0000000000..f1a56441f2 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/finallykeyword/PitfallsWhenUsingFinally.java @@ -0,0 +1,33 @@ +package com.baeldung.finallykeyword; + +public class PitfallsWhenUsingFinally { + + public String disregardsUnCaughtException() { + try { + System.out.println("Inside try"); + throw new RuntimeException(); + } finally { + System.out.println("Inside finally"); + return "from finally"; + } + } + + public String ignoringOtherReturns() { + try { + System.out.println("Inside try"); + return "from try"; + } finally { + System.out.println("Inside finally"); + return "from finally"; + } + } + + public String throwsException() { + try { + System.out.println("Inside try"); + return "from try"; + } finally { + throw new RuntimeException(); + } + } +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/Coordinates.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/Coordinates.java new file mode 100644 index 0000000000..4a292b9b18 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/Coordinates.java @@ -0,0 +1,49 @@ +package com.baeldung.methodmultiplereturnvalues; + +public class Coordinates { + + private double longitude; + private double latitude; + private String placeName; + + public Coordinates() {} + + public Coordinates(double longitude, double latitude, String placeName) { + this.longitude = longitude; + this.latitude = latitude; + this.placeName = placeName; + } + + public double calculateDistance(Coordinates c) { + + double s1 = Math.abs(this.longitude - c.longitude); + double s2 = Math.abs(this.latitude - c.latitude); + + return Math.hypot(s1, s2); + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getPlaceName() { + return placeName; + } + + public void setPlaceName(String placeName) { + this.placeName = placeName; + } + +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsPair.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsPair.java new file mode 100644 index 0000000000..2f505443c2 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsPair.java @@ -0,0 +1,20 @@ +package com.baeldung.methodmultiplereturnvalues; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.Comparator; +import java.util.List; + +class MultipleReturnValuesUsingApacheCommonsPair { + + static ImmutablePair getMostDistantPoint( + List coordinatesList, + Coordinates target) { + return coordinatesList.stream() + .map(coordinates -> ImmutablePair.of(coordinates, coordinates.calculateDistance(target))) + .max(Comparator.comparingDouble(Pair::getRight)) + .get(); + + } +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsTriple.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsTriple.java new file mode 100644 index 0000000000..4da297a51f --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsTriple.java @@ -0,0 +1,23 @@ +package com.baeldung.methodmultiplereturnvalues; + +import org.apache.commons.lang3.tuple.ImmutableTriple; + +import java.util.List; +import java.util.stream.Collectors; + +class MultipleReturnValuesUsingApacheCommonsTriple { + + static ImmutableTriple getMinAvgMaxTriple( + List coordinatesList, + Coordinates target) { + + List distanceList = coordinatesList.stream() + .map(coordinates -> coordinates.calculateDistance(target)) + .collect(Collectors.toList()); + Double minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble(); + Double avgDistance = distanceList.stream().mapToDouble(Double::doubleValue).average().orElse(0.0D); + Double maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().getAsDouble(); + + return ImmutableTriple.of(minDistance, avgDistance, maxDistance); + } +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingArrays.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingArrays.java new file mode 100644 index 0000000000..9763422618 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingArrays.java @@ -0,0 +1,27 @@ +package com.baeldung.methodmultiplereturnvalues; + +class MultipleReturnValuesUsingArrays { + + + static double[] getCoordinatesDoubleArray() { + + double[] coordinates = new double[2]; + + coordinates[0] = 10; + coordinates[1] = 12.5; + + return coordinates; + } + + + static Number[] getCoordinatesNumberArray() { + + Number[] coordinates = new Number[2]; + + coordinates[0] = 10; //Integer + coordinates[1] = 12.5; //Double + + return coordinates; + } + +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingCollections.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingCollections.java new file mode 100644 index 0000000000..ccd5a4b74e --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingCollections.java @@ -0,0 +1,30 @@ +package com.baeldung.methodmultiplereturnvalues; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +class MultipleReturnValuesUsingCollections { + + static List getCoordinatesList() { + + List coordinates = new ArrayList<>(); + + coordinates.add(10); + coordinates.add(12.5); + + return coordinates; + } + + static Map getCoordinatesMap() { + + Map coordinates = new HashMap<>(); + + coordinates.put("longitude", 10); + coordinates.put("latitude", 12.5); + + return coordinates; + } + +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingContainer.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingContainer.java new file mode 100644 index 0000000000..617f0df17c --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingContainer.java @@ -0,0 +1,14 @@ +package com.baeldung.methodmultiplereturnvalues; + +class MultipleReturnValuesUsingContainer { + + static Coordinates getCoordinates() { + + double longitude = 10; + double latitude = 12.5; + String placeName = "home"; + + return new Coordinates(longitude, latitude, placeName); + } + +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingTuples.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingTuples.java new file mode 100644 index 0000000000..59984f777e --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingTuples.java @@ -0,0 +1,17 @@ +package com.baeldung.methodmultiplereturnvalues; + +import java.util.List; + +class MultipleReturnValuesUsingTuples { + + static Tuple2 getMostDistantPoint(List coordinatesList, + Coordinates target) { + + return coordinatesList.stream() + .map(coor -> new Tuple2<>(coor, coor.calculateDistance(target))) + .max((d1, d2) -> Double.compare(d1.getSecond(), d2.getSecond())) + .get(); + + } + +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/Tuple2.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/Tuple2.java new file mode 100644 index 0000000000..57ef20d572 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/methodmultiplereturnvalues/Tuple2.java @@ -0,0 +1,31 @@ +package com.baeldung.methodmultiplereturnvalues; + +public class Tuple2 { + + private K first; + private V second; + + public Tuple2() {} + + public Tuple2(K first, V second) { + this.first = first; + this.second = second; + } + + public K getFirst() { + return first; + } + + public V getSecond() { + return second; + } + + public void setFirst(K first) { + this.first = first; + } + + public void setSecond(V second) { + this.second = second; + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/finallykeyword/PitfallsWhenUsingFinallyUnitTest.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/finallykeyword/PitfallsWhenUsingFinallyUnitTest.java new file mode 100644 index 0000000000..7e7a7241ec --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/finallykeyword/PitfallsWhenUsingFinallyUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.finallykeyword; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class PitfallsWhenUsingFinallyUnitTest { + + PitfallsWhenUsingFinally instance = new PitfallsWhenUsingFinally(); + + @Test + public void testIgnoresException() { + String result = instance.disregardsUnCaughtException(); + assertEquals("from finally", result); + } + + @Test + public void testIgnoresOtherReturns() { + String result = instance.ignoringOtherReturns(); + assertEquals("from finally", result); + } + + @Test(expected = RuntimeException.class) + public void testThrowsException() { + instance.throwsException(); + } +} diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsPairUnitTest.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsPairUnitTest.java new file mode 100644 index 0000000000..ca5736fe50 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsPairUnitTest.java @@ -0,0 +1,34 @@ +package com.baeldung.methodmultiplereturnvalues; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class MultipleReturnValuesUsingApacheCommonsPairUnitTest { + + @Test + void whenUsingPair_thenMultipleFieldsAreReturned() { + + List coordinatesList = new ArrayList<>(); + coordinatesList.add(new Coordinates(1, 1, "home")); + coordinatesList.add(new Coordinates(2, 2, "school")); + coordinatesList.add(new Coordinates(3, 3, "hotel")); + + Coordinates target = new Coordinates(5, 5, "gym"); + + ImmutablePair mostDistantPoint = MultipleReturnValuesUsingApacheCommonsPair.getMostDistantPoint(coordinatesList, target); + + assertEquals(1, mostDistantPoint.getLeft().getLongitude()); + assertEquals(1, mostDistantPoint.getLeft().getLatitude()); + assertEquals("home", mostDistantPoint.getLeft().getPlaceName()); + assertEquals(5.66, BigDecimal.valueOf(mostDistantPoint.getRight()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + + } + +} diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsTripleUnitTest.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsTripleUnitTest.java new file mode 100644 index 0000000000..d23036f5e6 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingApacheCommonsTripleUnitTest.java @@ -0,0 +1,35 @@ +package com.baeldung.methodmultiplereturnvalues; + +import org.apache.commons.lang3.tuple.ImmutableTriple; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class MultipleReturnValuesUsingApacheCommonsTripleUnitTest { + + @Test + void whenUsingTriple_thenMultipleFieldsAreReturned() { + + List coordinatesList = new ArrayList<>(); + coordinatesList.add(new Coordinates(1, 1, "home")); + coordinatesList.add(new Coordinates(2, 2, "school")); + coordinatesList.add(new Coordinates(3, 3, "hotel")); + + Coordinates target = new Coordinates(5, 5, "gym"); + + ImmutableTriple minAvgMax = MultipleReturnValuesUsingApacheCommonsTriple.getMinAvgMaxTriple(coordinatesList, target); + + assertEquals(2.83, scaleDouble(minAvgMax.left)); //min + assertEquals(4.24, scaleDouble(minAvgMax.middle)); //avg + assertEquals(5.66, scaleDouble(minAvgMax.right)); //max + } + + private double scaleDouble(Double d) { + return BigDecimal.valueOf(d).setScale(2, RoundingMode.HALF_UP).doubleValue(); + } +} diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingArraysUnitTest.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingArraysUnitTest.java new file mode 100644 index 0000000000..0cf90a8879 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingArraysUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.methodmultiplereturnvalues; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + +class MultipleReturnValuesUsingArraysUnitTest { + + @Test + void whenUsingArrayOfDoubles_thenMultipleDoubleFieldsAreReturned() { + + double[] coordinates = MultipleReturnValuesUsingArrays.getCoordinatesDoubleArray(); + assertEquals(10, coordinates[0]); + assertEquals(12.5, coordinates[1]); + } + + @Test + void whenUsingArrayOfNumbers_thenMultipleNumberFieldsAreReturned() { + + Number[] coordinates = MultipleReturnValuesUsingArrays.getCoordinatesNumberArray(); + assertEquals(10, coordinates[0]); + assertEquals(12.5, coordinates[1]); + + } + +} diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingCollectionsUnitTest.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingCollectionsUnitTest.java new file mode 100644 index 0000000000..8038601986 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingCollectionsUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.methodmultiplereturnvalues; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Test; + +class MultipleReturnValuesUsingCollectionsUnitTest { + + @Test + void whenUsingList_thenMultipleFieldsAreReturned() { + + List coordinates = MultipleReturnValuesUsingCollections.getCoordinatesList(); + assertEquals(Integer.valueOf(10), coordinates.get(0)); + assertEquals(Double.valueOf(12.5), coordinates.get(1)); + } + + @Test + void whenUsingMap_thenMultipleFieldsAreReturned() { + + Map coordinates = MultipleReturnValuesUsingCollections.getCoordinatesMap(); + assertEquals(Integer.valueOf(10), coordinates.get("longitude")); + assertEquals(Double.valueOf(12.5), coordinates.get("latitude")); + } +} diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingContainerUnitTest.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingContainerUnitTest.java new file mode 100644 index 0000000000..f7fd9bd108 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingContainerUnitTest.java @@ -0,0 +1,17 @@ +package com.baeldung.methodmultiplereturnvalues; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + +class MultipleReturnValuesUsingContainerUnitTest { + + @Test + void whenUsingContainerClass_thenMultipleFieldsAreReturned() { + + Coordinates coordinates = MultipleReturnValuesUsingContainer.getCoordinates(); + + assertEquals(10, coordinates.getLongitude()); + assertEquals(12.5, coordinates.getLatitude()); + assertEquals("home", coordinates.getPlaceName()); + } +} diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingTuplesUnitTest.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingTuplesUnitTest.java new file mode 100644 index 0000000000..52f30286bc --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/methodmultiplereturnvalues/MultipleReturnValuesUsingTuplesUnitTest.java @@ -0,0 +1,31 @@ +package com.baeldung.methodmultiplereturnvalues; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Test; + +class MultipleReturnValuesUsingTuplesUnitTest { + + @Test + void whenUsingTuple_thenMultipleFieldsAreReturned() { + + List coordinatesList = new ArrayList<>(); + coordinatesList.add(new Coordinates(1, 1, "home")); + coordinatesList.add(new Coordinates(2, 2, "school")); + coordinatesList.add(new Coordinates(3, 3, "hotel")); + + Coordinates target = new Coordinates(5, 5, "gym"); + + Tuple2 mostDistantPoint = MultipleReturnValuesUsingTuples.getMostDistantPoint(coordinatesList, target); + + assertEquals(1, mostDistantPoint.getFirst().getLongitude()); + assertEquals(1, mostDistantPoint.getFirst().getLatitude()); + assertEquals("home", mostDistantPoint.getFirst().getPlaceName()); + assertEquals(5.66, BigDecimal.valueOf(mostDistantPoint.getSecond()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + + } + +} diff --git a/core-java-modules/core-java-lang-math/README.md b/core-java-modules/core-java-lang-math/README.md index aec339574b..c72b69fcad 100644 --- a/core-java-modules/core-java-lang-math/README.md +++ b/core-java-modules/core-java-lang-math/README.md @@ -7,3 +7,5 @@ - [Java 8 Unsigned Arithmetic Support](https://www.baeldung.com/java-unsigned-arithmetic) - [How to Separate Double into Integer and Decimal Parts](https://www.baeldung.com/java-separate-double-into-integer-decimal-parts) - [The strictfp Keyword in Java](https://www.baeldung.com/java-strictfp) +- [Basic Calculator in Java](https://www.baeldung.com/java-basic-calculator) +- [Overflow and Underflow in Java](https://www.baeldung.com/java-overflow-underflow) diff --git a/core-java-modules/core-java-lang-math/src/main/java/com/baeldung/powerset/PowerSetUtility.java b/core-java-modules/core-java-lang-math/src/main/java/com/baeldung/powerset/PowerSetUtility.java new file mode 100644 index 0000000000..336276786a --- /dev/null +++ b/core-java-modules/core-java-lang-math/src/main/java/com/baeldung/powerset/PowerSetUtility.java @@ -0,0 +1,302 @@ +package com.baeldung.powerset; + +import javax.annotation.Nullable; +import java.util.AbstractSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; + +public class PowerSetUtility { + + private Map map = new HashMap<>(); + private List reverseMap = new ArrayList<>(); + + //Lazy Load PowerSet class + private static class PowerSet extends AbstractSet> { + private Map map = new HashMap<>(); + private List reverseMap = new ArrayList<>(); + private Set set; + + public PowerSet(Set set) { + this.set = set; + initializeMap(); + } + + abstract class ListIterator implements Iterator { + + protected int position = 0; + private int size; + + public ListIterator(int size) { + this.size = size; + } + + @Override + public boolean hasNext() { + return position < size; + } + } + + static class Subset extends AbstractSet { + private Map map; + private List reverseMap; + private int mask; + + public Subset(Map map, List reverseMap, int mask) { + this.map = map; + this.reverseMap = reverseMap; + this.mask = mask; + } + + @Override + public Iterator iterator() { + return new Iterator() { + int remainingSetBits = mask; + + @Override + public boolean hasNext() { + return remainingSetBits != 0; + } + + @Override + public E next() { + int index = Integer.numberOfTrailingZeros(remainingSetBits); + if (index == 32) { + throw new NoSuchElementException(); + } + remainingSetBits &= ~(1 << index); + return reverseMap.get(index); + } + }; + } + + @Override + public int size() { + return Integer.bitCount(mask); + } + + @Override + public boolean contains(@Nullable Object o) { + Integer index = map.get(o); + return index != null && (mask & (1 << index)) != 0; + } + } + + @Override + public Iterator> iterator() { + return new ListIterator>(this.size()) { + @Override + public Set next() { + return new Subset<>(map, reverseMap, position++); + } + }; + } + + @Override + public int size() { + return (1 << this.set.size()); + } + + @Override + public boolean contains(@Nullable Object obj) { + if (obj instanceof Set) { + Set set = (Set) obj; + return reverseMap.containsAll(set); + } + return false; + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj instanceof PowerSet) { + PowerSet that = (PowerSet) obj; + return set.equals(that.set);//Set equals check to have the same element regardless of the order of the items + } + return super.equals(obj); + } + + + private void initializeMap() { + int mapId = 0; + for (E c : this.set) { + map.put(c, mapId++); + reverseMap.add(c); + } + } + } + + public Set> lazyLoadPowerSet(Set set) { + return new PowerSet<>(set); + } + + public Set> recursivePowerSet(Set set) { + if (set.isEmpty()) { + Set> ret = new HashSet<>(); + ret.add(set); + return ret; + } + + T element = set.iterator().next(); + Set subSetWithoutElement = getSubSetWithoutElement(set, element); + Set> powerSetSubSetWithoutElement = recursivePowerSet(subSetWithoutElement); + + Set> powerSetSubSetWithElement = addElementToAll(powerSetSubSetWithoutElement, element); + + Set> powerSet = new HashSet<>(); + powerSet.addAll(powerSetSubSetWithoutElement); + powerSet.addAll(powerSetSubSetWithElement); + return powerSet; + } + + public Set> recursivePowerSetIndexRepresentation(Collection set) { + initializeMap(set); + Set> powerSetIndices = recursivePowerSetIndexRepresentation(0, set.size()); + return unMapIndex(powerSetIndices); + } + + private List> iterativePowerSetByLoopOverNumbers(int n) { + List> powerSet = new ArrayList<>(); + for (int i = 0; i < (1 << n); i++) { + List subset = new ArrayList<>(n); + for (int j = 0; j < n; j++) + subset.add(((1 << j) & i) > 0); + powerSet.add(subset); + } + return powerSet; + } + + private List> iterativePowerSetByLoopOverNumbersWithMinimalChange(int n) { + List> powerSet = new ArrayList<>(); + for (int i = 0; i < (1 << n); i++) { + List subset = new ArrayList<>(n); + for (int j = 0; j < n; j++) { + int grayEquivalent = i ^ (i >> 1); + subset.add(((1 << j) & grayEquivalent) > 0); + } + powerSet.add(subset); + } + return powerSet; + } + + public Set> recursivePowerSetBinaryRepresentation(Collection set) { + initializeMap(set); + Set> powerSetBoolean = recursivePowerSetBinaryRepresentation(0, set.size()); + return unMapBinary(powerSetBoolean); + } + + public List> iterativePowerSetByLoopOverNumbers(Set set) { + initializeMap(set); + List> sets = iterativePowerSetByLoopOverNumbers(set.size()); + return unMapListBinary(sets); + } + + public List> iterativePowerSetByLoopOverNumbersMinimalChange(Set set) { + initializeMap(set); + List> sets = iterativePowerSetByLoopOverNumbersWithMinimalChange(set.size()); + return unMapListBinary(sets); + } + + private Set> recursivePowerSetIndexRepresentation(int idx, int n) { + if (idx == n) { + Set> empty = new HashSet<>(); + empty.add(new HashSet<>()); + return empty; + } + Set> powerSetSubset = recursivePowerSetIndexRepresentation(idx + 1, n); + Set> powerSet = new HashSet<>(powerSetSubset); + for (Set s : powerSetSubset) { + HashSet subSetIdxInclusive = new HashSet<>(s); + subSetIdxInclusive.add(idx); + powerSet.add(subSetIdxInclusive); + } + return powerSet; + } + + private Set> recursivePowerSetBinaryRepresentation(int idx, int n) { + if (idx == n) { + Set> powerSetOfEmptySet = new HashSet<>(); + powerSetOfEmptySet.add(Arrays.asList(new Boolean[n])); + return powerSetOfEmptySet; + } + Set> powerSetSubset = recursivePowerSetBinaryRepresentation(idx + 1, n); + Set> powerSet = new HashSet<>(); + for (List s : powerSetSubset) { + List subSetIdxExclusive = new ArrayList<>(s); + subSetIdxExclusive.set(idx, false); + powerSet.add(subSetIdxExclusive); + List subSetIdxInclusive = new ArrayList<>(s); + subSetIdxInclusive.set(idx, true); + powerSet.add(subSetIdxInclusive); + } + return powerSet; + } + + private void initializeMap(Collection collection) { + int mapId = 0; + for (T c : collection) { + map.put(c, mapId++); + reverseMap.add(c); + } + } + + private Set> unMapIndex(Set> sets) { + Set> ret = new HashSet<>(); + for (Set s : sets) { + HashSet subset = new HashSet<>(); + for (Integer i : s) + subset.add(reverseMap.get(i)); + ret.add(subset); + } + return ret; + } + + private Set> unMapBinary(Collection> sets) { + Set> ret = new HashSet<>(); + for (List s : sets) { + HashSet subset = new HashSet<>(); + for (int i = 0; i < s.size(); i++) + if (s.get(i)) + subset.add(reverseMap.get(i)); + ret.add(subset); + } + return ret; + } + + private List> unMapListBinary(Collection> sets) { + List> ret = new ArrayList<>(); + for (List s : sets) { + List subset = new ArrayList<>(); + for (int i = 0; i < s.size(); i++) + if (s.get(i)) + subset.add(reverseMap.get(i)); + ret.add(subset); + } + return ret; + } + + private Set> addElementToAll(Set> powerSetSubSetWithoutElement, T element) { + Set> powerSetSubSetWithElement = new HashSet<>(); + for (Set subsetWithoutElement : powerSetSubSetWithoutElement) { + Set subsetWithElement = new HashSet<>(subsetWithoutElement); + subsetWithElement.add(element); + powerSetSubSetWithElement.add(subsetWithElement); + } + return powerSetSubSetWithElement; + } + + private Set getSubSetWithoutElement(Set set, T element) { + Set subsetWithoutElement = new HashSet<>(); + for (T s : set) { + if (!s.equals(element)) + subsetWithoutElement.add(s); + } + return subsetWithoutElement; + } +} diff --git a/core-java-modules/core-java-lang-math/src/test/java/com/baeldung/powerset/PowerSetUtilityUnitTest.java b/core-java-modules/core-java-lang-math/src/test/java/com/baeldung/powerset/PowerSetUtilityUnitTest.java new file mode 100644 index 0000000000..8b7c338479 --- /dev/null +++ b/core-java-modules/core-java-lang-math/src/test/java/com/baeldung/powerset/PowerSetUtilityUnitTest.java @@ -0,0 +1,189 @@ +package com.baeldung.powerset; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.hamcrest.collection.IsCollectionWithSize; +import org.junit.Test; +import org.junit.jupiter.api.Assertions; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; + +public class PowerSetUtilityUnitTest { + + @Test + public void givenSet_WhenGuavaLibraryGeneratePowerSet_ThenItContainsAllSubsets() { + ImmutableSet set = ImmutableSet.of("APPLE", "ORANGE", "MANGO"); + Set> powerSet = Sets.powerSet(set); + Assertions.assertEquals((1 << set.size()), powerSet.size()); + MatcherAssert.assertThat(powerSet, Matchers.containsInAnyOrder( + ImmutableSet.of(), + ImmutableSet.of("APPLE"), + ImmutableSet.of("ORANGE"), + ImmutableSet.of("APPLE", "ORANGE"), + ImmutableSet.of("MANGO"), + ImmutableSet.of("APPLE", "MANGO"), + ImmutableSet.of("ORANGE", "MANGO"), + ImmutableSet.of("APPLE", "ORANGE", "MANGO") + )); + } + + @Test + public void givenSet_WhenPowerSetIsLazyLoadGenerated_ThenItContainsAllSubsets() { + Set set = RandomSetOfStringGenerator.generateRandomSet(); + Set> powerSet = new PowerSetUtility().lazyLoadPowerSet(set); + + //To make sure that the size of power set is (2 power n) + MatcherAssert.assertThat(powerSet, IsCollectionWithSize.hasSize((1 << set.size()))); + //To make sure that number of occurrence of each element is (2 power n-1) + Map counter = new HashMap<>(); + for (Set subset : powerSet) { + for (String name : subset) { + int num = counter.getOrDefault(name, 0); + counter.put(name, num + 1); + } + } + counter.forEach((k, v) -> Assertions.assertEquals((1 << (set.size() - 1)), v.intValue())); + } + + @Test + public void givenSet_WhenPowerSetIsCalculated_ThenItContainsAllSubsets() { + Set set = RandomSetOfStringGenerator.generateRandomSet(); + + Set> powerSet = new PowerSetUtility().recursivePowerSet(set); + + //To make sure that the size of power set is (2 power n) + MatcherAssert.assertThat(powerSet, IsCollectionWithSize.hasSize((1 << set.size()))); + //To make sure that number of occurrence of each element is (2 power n-1) + Map counter = new HashMap<>(); + for (Set subset : powerSet) { + for (String name : subset) { + int num = counter.getOrDefault(name, 0); + counter.put(name, num + 1); + } + } + counter.forEach((k, v) -> Assertions.assertEquals((1 << (set.size() - 1)), v.intValue())); + } + + @Test + public void givenSet_WhenPowerSetIsCalculatedRecursiveByIndexRepresentation_ThenItContainsAllSubsets() { + Set set = RandomSetOfStringGenerator.generateRandomSet(); + + Set> powerSet = new PowerSetUtility().recursivePowerSetIndexRepresentation(set); + + //To make sure that the size of power set is (2 power n) + MatcherAssert.assertThat(powerSet, IsCollectionWithSize.hasSize((1 << set.size()))); + //To make sure that number of occurrence of each element is (2 power n-1) + Map counter = new HashMap<>(); + for (Set subset : powerSet) { + for (String name : subset) { + int num = counter.getOrDefault(name, 0); + counter.put(name, num + 1); + } + } + counter.forEach((k, v) -> Assertions.assertEquals((1 << (set.size() - 1)), v.intValue())); + } + + @Test + public void givenSet_WhenPowerSetIsCalculatedRecursiveByBinaryRepresentation_ThenItContainsAllSubsets() { + Set set = RandomSetOfStringGenerator.generateRandomSet(); + + Set> powerSet = new PowerSetUtility().recursivePowerSetBinaryRepresentation(set); + + //To make sure that the size of power set is (2 power n) + MatcherAssert.assertThat(powerSet, IsCollectionWithSize.hasSize((1 << set.size()))); + //To make sure that number of occurrence of each element is (2 power n-1) + Map counter = new HashMap<>(); + for (Set subset : powerSet) { + for (String name : subset) { + int num = counter.getOrDefault(name, 0); + counter.put(name, num + 1); + } + } + counter.forEach((k, v) -> Assertions.assertEquals((1 << (set.size() - 1)), v.intValue())); + } + + @Test + public void givenSet_WhenPowerSetIsCalculatedIterativePowerSetByLoopOverNumbers_ThenItContainsAllSubsets() { + Set set = RandomSetOfStringGenerator.generateRandomSet(); + + List> powerSet = new PowerSetUtility().iterativePowerSetByLoopOverNumbers(set); + + //To make sure that the size of power set is (2 power n) + MatcherAssert.assertThat(powerSet, IsCollectionWithSize.hasSize((1 << set.size()))); + //To make sure that number of occurrence of each element is (2 power n-1) + Map counter = new HashMap<>(); + for (List subset : powerSet) { + for (String name : subset) { + int num = counter.getOrDefault(name, 0); + counter.put(name, num + 1); + } + } + counter.forEach((k, v) -> Assertions.assertEquals((1 << (set.size() - 1)), v.intValue())); + //To make sure that one subset is not generated twice + Assertions.assertEquals(powerSet.size(), new HashSet<>(powerSet).size()); + //To make sure that each element in each subset is occurred once + for (List subset : powerSet) { + Assertions.assertEquals(subset.size(), new HashSet<>(subset).size()); + } + } + + @Test + public void givenSet_WhenPowerSetIsCalculatedIterativePowerSetByLoopOverNumbersWithMinimalChange_ThenItContainsAllSubsets() { + + Set set = RandomSetOfStringGenerator.generateRandomSet(); + List> powerSet = new PowerSetUtility().iterativePowerSetByLoopOverNumbersMinimalChange(set); + + //To make sure that the size of power set is (2 power n) + MatcherAssert.assertThat(powerSet, IsCollectionWithSize.hasSize((1 << set.size()))); + //To make sure that number of occurrence of each element is (2 power n-1) + Map counter = new HashMap<>(); + for (List subset : powerSet) { + for (String name : subset) { + int num = counter.getOrDefault(name, 0); + counter.put(name, num + 1); + } + } + counter.forEach((k, v) -> Assertions.assertEquals((1 << (set.size() - 1)), v.intValue())); + //To make sure that one subset is not generated twice + Assertions.assertEquals(powerSet.size(), new HashSet<>(powerSet).size()); + //To make sure that each element in each subset is occurred once + for (List subset : powerSet) { + Assertions.assertEquals(subset.size(), new HashSet<>(subset).size()); + } + //To make sure that difference of consecutive subsets is exactly 1 + for(int i=1; i fruits = Arrays.asList("Apples", "Avocados", "Banana", "Blueberry", "Cherry", "Clementine", "Cucumber", "Date", "Fig", + "Grapefruit"/*, "Grape", "Kiwi", "Lemon", "Mango", "Mulberry", "Melon", "Nectarine", "Olive", "Orange"*/); + + static Set generateRandomSet() { + Set set = new HashSet<>(); + Random random = new Random(); + int size = random.nextInt(fruits.size()); + while (set.size() != size) { + set.add(fruits.get(random.nextInt(fruits.size()))); + } + return set; + } + } +} diff --git a/core-java-modules/core-java-lang-oop-3/README.md b/core-java-modules/core-java-lang-oop-3/README.md index b1ca877ae0..3a0e588ad4 100644 --- a/core-java-modules/core-java-lang-oop-3/README.md +++ b/core-java-modules/core-java-lang-oop-3/README.md @@ -8,9 +8,9 @@ This module contains articles about Object-oriented programming (OOP) in Java - [Guide to the super Java Keyword](https://www.baeldung.com/java-super) - [Guide to the this Java Keyword](https://www.baeldung.com/java-this) - [Java ‘public’ Access Modifier](https://www.baeldung.com/java-public-keyword) -- [Composition, Aggregation and Association in Java](https://www.baeldung.com/java-composition-aggregation-association) +- [Composition, Aggregation, and Association in Java](https://www.baeldung.com/java-composition-aggregation-association) - [Nested Classes in Java](https://www.baeldung.com/java-nested-classes) - [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces) - [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) - [Java Interfaces](https://www.baeldung.com/java-interfaces) -- [[<-- Prev]](/core-java-modules/core-java-lang-oop-2)[[More -->]](/core-java-modules/core-java-lang-oop-4) \ No newline at end of file +- [[<-- Prev]](/core-java-modules/core-java-lang-oop-2)[[More -->]](/core-java-modules/core-java-lang-oop-4) diff --git a/core-java-modules/core-java-lang-operators/README.md b/core-java-modules/core-java-lang-operators/README.md index 1fe524948c..3af2c8885b 100644 --- a/core-java-modules/core-java-lang-operators/README.md +++ b/core-java-modules/core-java-lang-operators/README.md @@ -11,4 +11,5 @@ This module contains articles about Java operators - [Java Compound Operators](https://www.baeldung.com/java-compound-operators) - [The XOR Operator in Java](https://www.baeldung.com/java-xor-operator) - [Java Bitwise Operators](https://www.baeldung.com/java-bitwise-operators) +- [Bitwise & vs Logical && Operators](https://www.baeldung.com/bitwise-vs-logical-operators/) diff --git a/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/andoperators/BitwiseAndLogicalANDOperatorsUnitTest.java b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/andoperators/BitwiseAndLogicalANDOperatorsUnitTest.java new file mode 100644 index 0000000000..6158c2870d --- /dev/null +++ b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/andoperators/BitwiseAndLogicalANDOperatorsUnitTest.java @@ -0,0 +1,71 @@ +package com.baeldung.andoperators; + +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.*; + +public class BitwiseAndLogicalANDOperatorsUnitTest { + + @Test + public void givenTwoTrueBooleans_whenBitwiseAndOperator_thenTrue() { + boolean trueBool = true; + boolean anotherTrueBool = true; + boolean trueANDTrue = trueBool & anotherTrueBool; + assertTrue(trueANDTrue); + } + + @Test + public void givenOneFalseAndOneTrueBooleans_whenBitwiseAndOperator_thenFalse() { + boolean trueBool = true; + boolean falseBool = false; + boolean trueANDFalse = trueBool & falseBool; + assertFalse(trueANDFalse); + } + + @Test + public void givenTwoFalseBooleans_whenBitwiseAndOperator_thenFalse() { + boolean falseBool = false; + boolean anotherFalseBool = false; + boolean falseANDFalse = falseBool & anotherFalseBool; + assertFalse(falseANDFalse); + } + + @Test + public void givenTwoIntegers_whenBitwiseAndOperator_thenNewDecimalNumber() { + int six = 6; + int five = 5; + int shouldBeFour = six & five; + assertEquals(4, shouldBeFour); + } + + @Test + public void givenTwoTrueBooleans_whenLogicalAndOperator_thenTrue() { + boolean trueBool = true; + boolean anotherTrueBool = true; + boolean trueANDTrue = trueBool && anotherTrueBool; + assertTrue(trueANDTrue); + } + + @Test + public void givenOneFalseAndOneTrueBooleans_whenLogicalAndOperator_thenFalse() { + boolean trueBool = true; + boolean falseBool = false; + boolean trueANDFalse = trueBool && falseBool; + assertFalse(trueANDFalse); + } + + @Test + public void givenTwoFalseBooleans_whenLogicalAndOperator_thenFalse() { + boolean falseBool = false; + boolean anotherFalseBool = false; + boolean falseANDFalse = falseBool && anotherFalseBool; + assertFalse(falseANDFalse); + } + + @Test + public void givenTwoFalseExpressions_whenLogicalAndOperator_thenShortCircuitFalse() { + boolean shortCircuitResult = (2<1) && (4<5); + assertFalse(shortCircuitResult); + } + +} diff --git a/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java index 6b292ad8ab..728c83a107 100644 --- a/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java +++ b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/ternaryoperator/TernaryOperatorUnitTest.java @@ -6,7 +6,7 @@ import org.junit.Test; public class TernaryOperatorUnitTest { @Test - public void givenACondition_whenUsingTernaryOperator_thenItEvaluatesConditionAndReturnsAValue() { + public void whenUsingTernaryOperator_thenConditionIsEvaluatedAndValueReturned() { int number = 10; String msg = number > 10 ? "Number is greater than 10" : "Number is less than or equal to 10"; @@ -14,7 +14,7 @@ public class TernaryOperatorUnitTest { } @Test - public void givenATrueCondition_whenUsingTernaryOperator_thenOnlyExpression1IsEvaluated() { + public void whenConditionIsTrue_thenOnlyFirstExpressionIsEvaluated() { int exp1 = 0, exp2 = 0; int result = 12 > 10 ? ++exp1 : ++exp2; @@ -24,7 +24,7 @@ public class TernaryOperatorUnitTest { } @Test - public void givenAFalseCondition_whenUsingTernaryOperator_thenOnlyExpression2IsEvaluated() { + public void whenConditionIsFalse_thenOnlySecondExpressionIsEvaluated() { int exp1 = 0, exp2 = 0; int result = 8 > 10 ? ++exp1 : ++exp2; diff --git a/core-java-modules/core-java-lang-syntax-2/src/main/java/com/baeldung/core/operators/notoperator/NotOperator.java b/core-java-modules/core-java-lang-syntax-2/src/main/java/com/baeldung/core/operators/notoperator/NotOperator.java new file mode 100644 index 0000000000..4e0cf98ff2 --- /dev/null +++ b/core-java-modules/core-java-lang-syntax-2/src/main/java/com/baeldung/core/operators/notoperator/NotOperator.java @@ -0,0 +1,99 @@ +package com.baeldung.core.operators.notoperator; + +/** + * Examples used in the article `Using the Not Operator in If Conditions in Java`. + */ +public class NotOperator { + + public static void ifElseStatementExample() { + boolean isValid = true; + + if (isValid) { + System.out.println("Valid"); + } else { + System.out.println("Invalid"); + } + } + + public static void checkIsValidIsFalseWithEmptyIfBlock() { + boolean isValid = true; + + if (isValid) { + + } else { + System.out.println("Invalid"); + } + } + + public static void checkIsValidIsFalseWithJustTheIfBlock() { + boolean isValid = true; + + if (isValid == false) { + System.out.println("Invalid"); + } + } + + public static void checkIsValidIsFalseWithTheNotOperator() { + boolean isValid = true; + + if (!isValid) { + System.out.println("Invalid"); + } + } + + public static void notOperatorWithBooleanValueAsOperand() { + System.out.println(!true); // prints false + System.out.println(!false); // prints true + System.out.println(!!false); // prints false + } + + public static void applyNotOperatorToAnExpression_example1() { + int count = 2; + + System.out.println(!(count > 2)); // prints true + System.out.println(!(count <= 2)); // prints false + } + + public static void applyNotOperatorToAnExpression_LogicalOperators() { + boolean x = true; + boolean y = false; + + System.out.println(!(x && y)); // prints true + System.out.println(!(x || y)); // prints false + } + + public static void precedence_example() { + boolean x = true; + boolean y = false; + + System.out.println(!x && y); // prints false + System.out.println(!(x && y)); // prints true + } + + public static void pitfalls_ComplexConditionsExample() { + int count = 9; + int total = 100; + + if (!(count >= 10 || total >= 1000)) { + System.out.println("Some more work to do"); + } + } + + public static void pitfalls_simplifyComplexConditionsByReversingLogicExample() { + int count = 9; + int total = 100; + + if (count < 10 && total < 1000) { + System.out.println("Some more work to do"); + } + } + + public static void exitEarlyExample() { + boolean isValid = false; + + if(!isValid) { + throw new IllegalArgumentException("Invalid input"); + } + // Code to execute when isValid == true goes here + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java b/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java index 47473c29ea..f9fbc5dc3a 100644 --- a/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java +++ b/core-java-modules/core-java-optional/src/main/java/com/baeldung/optional/Person.java @@ -1,6 +1,8 @@ package com.baeldung.optional; +import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; public class Person { private String name; @@ -21,7 +23,7 @@ public class Person { } public Optional getAge() { - return Optional.ofNullable(age); + return Optional.of(age); } public void setAge(int age) { @@ -36,4 +38,37 @@ public class Person { return Optional.ofNullable(password); } + public static List search(List people, String name, Optional age) { + // Null checks for people and name + return people.stream() + .filter(p -> p.getName().equals(name)) + .filter(p -> p.getAge().get() >= age.orElse(0)) + .collect(Collectors.toList()); + } + + public static List search(List people, String name, Integer age) { + // Null checks for people and name + final Integer ageFilter = age != null ? age : 0; + + return people.stream() + .filter(p -> p.getName().equals(name)) + .filter(p -> p.getAge().get() >= ageFilter) + .collect(Collectors.toList()); + } + + public static List search(List people, String name) { + return doSearch(people, name, 0); + } + + public static List search(List people, String name, int age) { + return doSearch(people, name, age); + } + + private static List doSearch(List people, String name, int age) { + // Null checks for people and name + return people.stream() + .filter(p -> p.getName().equals(name)) + .filter(p -> p.getAge().get().intValue() >= age) + .collect(Collectors.toList()); + } } diff --git a/core-java-modules/core-java-perf/README.md b/core-java-modules/core-java-perf/README.md index d1d646ac7f..4204c2b012 100644 --- a/core-java-modules/core-java-perf/README.md +++ b/core-java-modules/core-java-perf/README.md @@ -9,3 +9,4 @@ This module contains articles about performance of Java applications - [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded) - [Basic Introduction to JMX](http://www.baeldung.com/java-management-extensions) - [Monitoring Java Applications with Flight Recorder](https://www.baeldung.com/java-flight-recorder-monitoring) +- [Branch Prediction in Java](https://www.baeldung.com/java-branch-prediction) diff --git a/core-java-modules/core-java-perf/src/test/java/com/baeldung/branchprediction/CombiningUnitTest.java b/core-java-modules/core-java-perf/src/test/java/com/baeldung/branchprediction/CombiningUnitTest.java new file mode 100644 index 0000000000..c98eef5ed1 --- /dev/null +++ b/core-java-modules/core-java-perf/src/test/java/com/baeldung/branchprediction/CombiningUnitTest.java @@ -0,0 +1,57 @@ +package com.baeldung.branchprediction; + +import java.util.stream.LongStream; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CombiningUnitTest { + private static final Logger LOG = LoggerFactory.getLogger(CombiningUnitTest.class); + + public static final int TOP = 10000000; + public static final double FRACTION = 0.1; + + @Test + public void combined() { + long[] first = LongStream.range(0, TOP) + .map(n -> Math.random() < FRACTION ? 0 : n) + .toArray(); + long[] second = LongStream.range(0, TOP) + .map(n -> Math.random() < FRACTION ? 0 : n) + .toArray(); + + long count = 0; + long start = System.currentTimeMillis(); + for (int i = 0; i < TOP; i++) { + if (first[i] * second[i] != 0) { + ++count; + } + } + long end = System.currentTimeMillis(); + + LOG.info("Counted {}/{} numbers using combined mode in {}ms", count, TOP, end - start); + + } + + @Test + public void separate() { + long[] first = LongStream.range(0, TOP) + .map(n -> Math.random() < FRACTION ? 0 : n) + .toArray(); + long[] second = LongStream.range(0, TOP) + .map(n -> Math.random() < FRACTION ? 0 : n) + .toArray(); + + long count = 0; + long start = System.currentTimeMillis(); + for (int i = 0; i < TOP; i++) { + if (first[i] != 0 && second[i] != 0) { + ++count; + } + } + long end = System.currentTimeMillis(); + + LOG.info("Counted {}/{} numbers using separate mode in {}ms", count, TOP, end - start); + } +} diff --git a/core-java-modules/core-java-perf/src/test/java/com/baeldung/branchprediction/IfUnitTest.java b/core-java-modules/core-java-perf/src/test/java/com/baeldung/branchprediction/IfUnitTest.java new file mode 100644 index 0000000000..6f80624502 --- /dev/null +++ b/core-java-modules/core-java-perf/src/test/java/com/baeldung/branchprediction/IfUnitTest.java @@ -0,0 +1,92 @@ +package com.baeldung.branchprediction; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.LongStream; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IfUnitTest { + private static final Logger LOG = LoggerFactory.getLogger(IfUnitTest.class); + + public static final int TOP = 10000000; + + @Test + public void majorBranchSorted() { + test(TOP, 0.9, false); + } + + @Test + public void minorBranchSorted() { + test(TOP, 0.1, false); + } + + @Test + public void equalBranchSorted() { + test(TOP, 0.5, false); + } + + @Test + public void allBranchSorted() { + test(TOP, 1, false); + } + + @Test + public void noneBranchSorted() { + test(TOP, 0, false); + } + + @Test + public void majorBranchShuffled() { + test(TOP, 0.9, true); + } + + @Test + public void minorBranchShuffled() { + test(TOP, 0.1, true); + } + + @Test + public void equalBranchShuffled() { + test(TOP, 0.5, true); + } + + @Test + public void allBranchShuffled() { + test(TOP, 1, true); + } + + @Test + public void noneBranchShuffled() { + test(TOP, 0, true); + } + + private void test(long top, double cutoffPercentage, boolean shuffle) { + List numbers = LongStream.range(0, top) + .boxed() + .collect(Collectors.toList()); + if (shuffle) { + Collections.shuffle(numbers); + } + + long cutoff = (long)(top * cutoffPercentage); + long low = 0; + long high = 0; + + long start = System.currentTimeMillis(); + for (Long number : numbers) { + if (number < cutoff) { + ++low; + } else { + ++high; + } + } + long end = System.currentTimeMillis(); + + LOG.info("Counted {}/{} {} numbers in {}ms", low, high, shuffle ? "shuffled" : "sorted", end - start); + + } +} diff --git a/core-java-modules/core-java-perf/src/test/java/com/baeldung/branchprediction/SortingUnitTest.java b/core-java-modules/core-java-perf/src/test/java/com/baeldung/branchprediction/SortingUnitTest.java new file mode 100644 index 0000000000..6af40bd57a --- /dev/null +++ b/core-java-modules/core-java-perf/src/test/java/com/baeldung/branchprediction/SortingUnitTest.java @@ -0,0 +1,60 @@ +package com.baeldung.branchprediction; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.LongStream; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SortingUnitTest { + private static final Logger LOG = LoggerFactory.getLogger(SortingUnitTest.class); + public static final int BIG = 10000000; + public static final int SMALL = 100000; + + @Test + public void sortedBig() { + test(BIG, false); + } + + @Test + public void shuffledBig() { + test(BIG, true); + } + + @Test + public void sortedSmall() { + test(SMALL, false); + } + + @Test + public void shuffledSmall() { + test(SMALL, true); + } + + private void test(long top, boolean shuffle) { + List numbers = LongStream.range(0, top) + .boxed() + .collect(Collectors.toList()); + + if (shuffle) { + Collections.shuffle(numbers); + } + + long cutoff = top / 2; + long count = 0; + + long start = System.currentTimeMillis(); + for (Long number : numbers) { + if (number < cutoff) { + ++count; + } + } + long end = System.currentTimeMillis(); + + LOG.info("Counted {}/{} {} numbers in {}ms", + count, top, shuffle ? "shuffled" : "sorted", end - start); + } +} diff --git a/core-java-modules/core-java-reflection/pom.xml b/core-java-modules/core-java-reflection/pom.xml index b3c3390df8..64086ef5b8 100644 --- a/core-java-modules/core-java-reflection/pom.xml +++ b/core-java-modules/core-java-reflection/pom.xml @@ -37,8 +37,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} -parameters @@ -48,5 +48,7 @@ 3.8.0 3.10.0 + 1.8 + 1.8 \ No newline at end of file diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java new file mode 100644 index 0000000000..a20ee527f8 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetExample.java @@ -0,0 +1,7 @@ +package com.baeldung.reflection.exception.invocationtarget; + +public class InvocationTargetExample { + public int divideByZeroExample() { + return 1 / 0; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java new file mode 100644 index 0000000000..b4cabebcef --- /dev/null +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exception/invocationtarget/InvocationTargetUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.reflection.exception.invocationtarget; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.junit.jupiter.api.Test; + +public class InvocationTargetUnitTest { + + @Test + public void whenCallingMethodThrowsException_thenAssertCauseOfInvocationTargetException() throws Exception { + + InvocationTargetExample targetExample = new InvocationTargetExample(); + Method method = InvocationTargetExample.class.getMethod("divideByZeroExample"); + + Exception exception = assertThrows(InvocationTargetException.class, () -> method.invoke(targetExample)); + + assertEquals(ArithmeticException.class, exception.getCause().getClass()); + } +} diff --git a/core-java-modules/core-java-security-manager/README.md b/core-java-modules/core-java-security-manager/README.md deleted file mode 100644 index a4abe7f80a..0000000000 --- a/core-java-modules/core-java-security-manager/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Intro to the Java SecurityManager](https://www.baeldung.com/java-security-manager) diff --git a/core-java-modules/core-java-security-manager/src/test/java/com/baeldung/security/manager/SecurityManagerUnitTest.java b/core-java-modules/core-java-security-manager/src/test/java/com/baeldung/security/manager/SecurityManagerUnitTest.java deleted file mode 100644 index a845f233b5..0000000000 --- a/core-java-modules/core-java-security-manager/src/test/java/com/baeldung/security/manager/SecurityManagerUnitTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.baeldung.security.manager; - -import org.junit.Test; - -import java.net.URL; -import java.security.AccessControlException; -import java.util.concurrent.Callable; - -public class SecurityManagerUnitTest { - - @Test(expected = AccessControlException.class) - public void whenSecurityManagerIsActive_thenNetworkIsNotAccessibleByDefault() throws Exception { - doTest(() -> { - new URL("http://www.google.com").openConnection().connect(); - return null; - }); - } - - @Test(expected = AccessControlException.class) - public void whenUnauthorizedClassTriesToAccessProtectedOperation_thenAnExceptionIsThrown() throws Exception { - doTest(() -> { - new Service().operation(); - return null; - }); - } - - private void doTest(Callable action) throws Exception { - System.setSecurityManager(new SecurityManager()); - try { - action.call(); - } finally { - System.setSecurityManager(null); - } - } -} diff --git a/core-java-modules/core-java-security/README.md b/core-java-modules/core-java-security/README.md index 7386d04e8e..ff9b1eef14 100644 --- a/core-java-modules/core-java-security/README.md +++ b/core-java-modules/core-java-security/README.md @@ -15,4 +15,5 @@ This module contains articles about core Java Security - [The Java SecureRandom Class](https://www.baeldung.com/java-secure-random) - [An Introduction to Java SASL](https://www.baeldung.com/java-sasl) - [A Guide to Java GSS API](https://www.baeldung.com/java-gss) +- [Intro to the Java SecurityManager](https://www.baeldung.com/java-security-manager) diff --git a/core-java-modules/core-java-security-manager/src/main/java/com/baeldung/security/manager/CustomPermission.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/securitymanager/CustomPermission.java similarity index 87% rename from core-java-modules/core-java-security-manager/src/main/java/com/baeldung/security/manager/CustomPermission.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/securitymanager/CustomPermission.java index 5f9c43336f..fa46353893 100644 --- a/core-java-modules/core-java-security-manager/src/main/java/com/baeldung/security/manager/CustomPermission.java +++ b/core-java-modules/core-java-security/src/main/java/com/baeldung/securitymanager/CustomPermission.java @@ -1,4 +1,4 @@ -package com.baeldung.security.manager; +package com.baeldung.securitymanager; import java.security.BasicPermission; diff --git a/core-java-modules/core-java-security-manager/src/main/java/com/baeldung/security/manager/Service.java b/core-java-modules/core-java-security/src/main/java/com/baeldung/securitymanager/Service.java similarity index 92% rename from core-java-modules/core-java-security-manager/src/main/java/com/baeldung/security/manager/Service.java rename to core-java-modules/core-java-security/src/main/java/com/baeldung/securitymanager/Service.java index 1b9f14e3b8..21e0c0a657 100644 --- a/core-java-modules/core-java-security-manager/src/main/java/com/baeldung/security/manager/Service.java +++ b/core-java-modules/core-java-security/src/main/java/com/baeldung/securitymanager/Service.java @@ -1,4 +1,4 @@ -package com.baeldung.security.manager; +package com.baeldung.securitymanager; public class Service { diff --git a/core-java-modules/core-java-security/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java similarity index 98% rename from core-java-modules/core-java-security/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java rename to core-java-modules/core-java-security/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java index 55e71470c8..67d6918c09 100644 --- a/core-java-modules/core-java-security/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java +++ b/core-java-modules/core-java-security/src/test/java/com/baeldung/java/md5/JavaMD5UnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.md5; +package com.baeldung.java.md5; import static org.assertj.core.api.Assertions.assertThat; diff --git a/core-java-modules/core-java-security/src/test/java/com/baeldung/securitymanager/SecurityManagerUnitTest.java b/core-java-modules/core-java-security/src/test/java/com/baeldung/securitymanager/SecurityManagerUnitTest.java new file mode 100644 index 0000000000..a7dcc949d2 --- /dev/null +++ b/core-java-modules/core-java-security/src/test/java/com/baeldung/securitymanager/SecurityManagerUnitTest.java @@ -0,0 +1,35 @@ +package com.baeldung.securitymanager; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.net.URL; +import java.security.AccessControlException; + +public class SecurityManagerUnitTest { + + private static final String TESTING_SECURITY_POLICY = "file:src/test/resources/testing.policy"; + + @Before + public void setUp() { + System.setProperty("java.security.policy", TESTING_SECURITY_POLICY); + System.setSecurityManager(new SecurityManager()); + } + + @After + public void tearDown() { + System.setSecurityManager(null); + } + + @Test(expected = AccessControlException.class) + public void whenSecurityManagerIsActive_thenNetworkIsNotAccessibleByDefault() throws IOException { + new URL("http://www.google.com").openConnection().connect(); + } + + @Test(expected = AccessControlException.class) + public void whenUnauthorizedClassTriesToAccessProtectedOperation_thenAnExceptionIsThrown() { + new Service().operation(); + } +} diff --git a/core-java-modules/core-java-security/src/test/resources/testing.policy b/core-java-modules/core-java-security/src/test/resources/testing.policy new file mode 100644 index 0000000000..16ab8a1869 --- /dev/null +++ b/core-java-modules/core-java-security/src/test/resources/testing.policy @@ -0,0 +1,5 @@ +grant { + // This is for testing purposes only. + // It allows us to properly reset the security manager after the unit test completes. + permission java.lang.RuntimePermission "setSecurityManager"; +}; \ No newline at end of file diff --git a/core-java-modules/core-java-string-algorithms-3/README.md b/core-java-modules/core-java-string-algorithms-3/README.md index 3aa31cea53..c7b17a6720 100644 --- a/core-java-modules/core-java-string-algorithms-3/README.md +++ b/core-java-modules/core-java-string-algorithms-3/README.md @@ -3,3 +3,5 @@ This module contains articles about string-related algorithms. ### Relevant Articles: + +- [Check if Two Strings are Anagrams in Java](https://www.baeldung.com/java-strings-anagrams) diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index a5dd31c762..43dc040591 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -25,7 +25,7 @@ com.google.guava guava - 28.1-jre + ${guava.version} @@ -62,7 +62,7 @@ 3.8.1 3.6.1 - 27.0.1-jre + 28.1-jre 5.3.1 diff --git a/core-java-modules/core-java-string-operations-2/README.md b/core-java-modules/core-java-string-operations-2/README.md index 50f40ac2af..6e88eda122 100644 --- a/core-java-modules/core-java-string-operations-2/README.md +++ b/core-java-modules/core-java-string-operations-2/README.md @@ -8,4 +8,5 @@ This module contains articles about string operations. - [String Initialization in Java](https://www.baeldung.com/java-string-initialization) - [String toLowerCase and toUpperCase Methods in Java](https://www.baeldung.com/java-string-convert-case) - [Java String equalsIgnoreCase()](https://www.baeldung.com/java-string-equalsignorecase) +- [How to avoid String contains() Case Insensitive in Java](https://www.baeldung.com/how-to-avoid-string-contains-case-insensitive-in-java) - More articles: [[<-- prev]](../core-java-string-operations) diff --git a/core-java-modules/core-java-string-operations-2/pom.xml b/core-java-modules/core-java-string-operations-2/pom.xml index bd1a34f89f..7bb687ea2b 100644 --- a/core-java-modules/core-java-string-operations-2/pom.xml +++ b/core-java-modules/core-java-string-operations-2/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 core-java-string-operations-2 0.1.0-SNAPSHOT @@ -51,6 +52,18 @@ ${org.hamcrest.version} test + + org.openjdk.jmh + jmh-core + ${jmh-core.version} + + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh-generator.version} + + org.assertj assertj-core @@ -61,6 +74,29 @@ core-java-string-operations-2 + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.0 + + + package + + shade + + + + + org.openjdk.jmh.Main + + + + + + + src/main/resources diff --git a/core-java-modules/core-java-string-operations-2/src/main/java/com/baeldung/contains/CaseInsensitiveWorkarounds.java b/core-java-modules/core-java-string-operations-2/src/main/java/com/baeldung/contains/CaseInsensitiveWorkarounds.java new file mode 100644 index 0000000000..e4089a4f53 --- /dev/null +++ b/core-java-modules/core-java-string-operations-2/src/main/java/com/baeldung/contains/CaseInsensitiveWorkarounds.java @@ -0,0 +1,78 @@ +package com.baeldung.contains; + +import java.util.concurrent.TimeUnit; +import java.util.regex.Pattern; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; + +/** + * Based on https://github.com/tedyoung/indexof-contains-benchmark + */ +@Fork(5) +@State(Scope.Benchmark) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +public class CaseInsensitiveWorkarounds { + + private String src; + private String dest; + private Pattern pattern; + + public static void main(String[] args) throws Exception { + org.openjdk.jmh.Main.main(args); + } + + @Setup + public void setup() { + src = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"; + dest = "eiusmod"; + pattern = Pattern.compile(Pattern.quote(dest), Pattern.CASE_INSENSITIVE); + } + + // toLowerCase() and contains() + @Benchmark + public boolean lowerCaseContains() { + return src.toLowerCase() + .contains(dest.toLowerCase()); + } + + // matches() with Regular Expressions + @Benchmark + public boolean matchesRegularExpression() { + return src.matches("(?i).*" + dest + ".*"); + } + + public boolean processRegionMatches(String localSrc, String localDest) { + for (int i = localSrc.length() - localDest.length(); i >= 0; i--) + if (localSrc.regionMatches(true, i, localDest, 0, localDest.length())) + return true; + return false; + } + + // String regionMatches() + @Benchmark + public boolean regionMatches() { + return processRegionMatches(src, dest); + } + + // Pattern CASE_INSENSITIVE with regexp + @Benchmark + public boolean patternCaseInsensitiveRegexp() { + return pattern.matcher(src) + .find(); + } + + // Apache Commons StringUtils containsIgnoreCase + @Benchmark + public boolean apacheCommonsStringUtils() { + return org.apache.commons.lang3.StringUtils.containsIgnoreCase(src, dest); + } + +} diff --git a/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/contains/CaseInsensitiveWorkaroundsUnitTest.java b/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/contains/CaseInsensitiveWorkaroundsUnitTest.java new file mode 100644 index 0000000000..30b2ca9fa5 --- /dev/null +++ b/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/contains/CaseInsensitiveWorkaroundsUnitTest.java @@ -0,0 +1,53 @@ +package com.baeldung.contains; + +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import org.junit.Test; + +import java.util.regex.Pattern; + +/** + * BAEL-3739: Different ways to solve the contains() case insensitive behavior. + */ +public class CaseInsensitiveWorkaroundsUnitTest { + + private String src = "Lorem ipsum dolor sit amet"; + private String dest = "lorem"; + + @Test + public void givenString_whenCallingContainsWithToLowerOrUpperCase_shouldReturnTrue() { + // Use toLowerCase to avoid case insensitive issues + Assert.assertTrue(src.toLowerCase().contains(dest.toLowerCase())); + + // Use toUpperCase to avoid case insensitive issues + Assert.assertTrue(src.toUpperCase().contains(dest.toUpperCase())); + } + + @Test + public void givenString_whenCallingStringMatches_thenReturnsTrue() { + // Use String Matches to avoid case insensitive issues + Assert.assertTrue(src.matches("(?i).*" + dest + ".*")); + } + + @Test + public void givenString_whenCallingStringRegionMatches_thenReturnsTrue() { + // Use String Region Matches to avoid case insensitive issues + CaseInsensitiveWorkarounds comparator = new CaseInsensitiveWorkarounds(); + Assert.assertTrue(comparator.processRegionMatches(src, dest)); + } + + + @Test + public void givenString_whenCallingPaternCompileMatcherFind_thenReturnsTrue() { + // Use Pattern Compile Matcher and Find to avoid case insensitive issues + Assert.assertTrue(Pattern.compile(Pattern.quote(dest), + Pattern.CASE_INSENSITIVE) .matcher(src) .find()); + } + + @Test + public void givenString_whenCallingStringUtilsContainsIgnoreCase_thenReturnsTrue() { + // Use StringUtils containsIgnoreCase to avoid case insensitive issues + Assert.assertTrue(StringUtils.containsIgnoreCase(src, dest)); + } + +} diff --git a/core-java-modules/core-java-strings/src/test/java/com/baeldung/randomstrings/RandomStringsUnitTest.java b/core-java-modules/core-java-strings/src/test/java/com/baeldung/randomstrings/RandomStringsUnitTest.java index 2806635d03..edfabc8777 100644 --- a/core-java-modules/core-java-strings/src/test/java/com/baeldung/randomstrings/RandomStringsUnitTest.java +++ b/core-java-modules/core-java-strings/src/test/java/com/baeldung/randomstrings/RandomStringsUnitTest.java @@ -1,72 +1,103 @@ -package com.baeldung.randomstrings; - -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.nio.charset.Charset; -import java.util.Random; - -public class RandomStringsUnitTest { - - private static final Logger LOG = LoggerFactory.getLogger(RandomStringsUnitTest.class); - - @Test - public void givenUsingPlainJava_whenGeneratingRandomStringUnbounded_thenCorrect() { - final byte[] array = new byte[7]; // length is bounded by 7 - new Random().nextBytes(array); - final String generatedString = new String(array, Charset.forName("UTF-8")); - - LOG.debug(generatedString); - } - - @Test - public void givenUsingPlainJava_whenGeneratingRandomStringBounded_thenCorrect() { - final int leftLimit = 97; // letter 'a' - final int rightLimit = 122; // letter 'z' - final int targetStringLength = 10; - final Random random = new Random(); - final StringBuilder buffer = new StringBuilder(targetStringLength); - - for (int i = 0; i < targetStringLength; i++) { - final int randomLimitedInt = leftLimit + (int) (random.nextFloat() * (rightLimit - leftLimit + 1)); - buffer.append((char) randomLimitedInt); - } - final String generatedString = buffer.toString(); - - LOG.debug(generatedString); - } - - @Test - public void givenUsingApache_whenGeneratingRandomString_thenCorrect() { - final String generatedString = RandomStringUtils.random(10); - - LOG.debug(generatedString); - } - - @Test - public void givenUsingApache_whenGeneratingRandomAlphabeticString_thenCorrect() { - final String generatedString = RandomStringUtils.randomAlphabetic(10); - - LOG.debug(generatedString); - } - - @Test - public void givenUsingApache_whenGeneratingRandomAlphanumericString_thenCorrect() { - final String generatedString = RandomStringUtils.randomAlphanumeric(10); - - LOG.debug(generatedString); - } - - @Test - public void givenUsingApache_whenGeneratingRandomStringBounded_thenCorrect() { - final int length = 10; - final boolean useLetters = true; - final boolean useNumbers = false; - final String generatedString = RandomStringUtils.random(length, useLetters, useNumbers); - - LOG.debug(generatedString); - } - -} +package com.baeldung.randomstrings; + +import org.apache.commons.lang3.RandomStringUtils; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.charset.Charset; +import java.util.Random; + +public class RandomStringsUnitTest { + + private static final Logger LOG = LoggerFactory.getLogger(RandomStringsUnitTest.class); + + @Test + public void givenUsingPlainJava_whenGeneratingRandomStringUnbounded_thenCorrect() { + byte[] array = new byte[7]; // length is bounded by 7 + new Random().nextBytes(array); + String generatedString = new String(array, Charset.forName("UTF-8")); + + LOG.debug(generatedString); + } + + @Test + public void givenUsingPlainJava_whenGeneratingRandomStringBounded_thenCorrect() { + int leftLimit = 97; // letter 'a' + int rightLimit = 122; // letter 'z' + int targetStringLength = 10; + Random random = new Random(); + StringBuilder buffer = new StringBuilder(targetStringLength); + + for (int i = 0; i < targetStringLength; i++) { + int randomLimitedInt = leftLimit + (int) (random.nextFloat() * (rightLimit - leftLimit + 1)); + buffer.append((char) randomLimitedInt); + } + String generatedString = buffer.toString(); + + LOG.debug(generatedString); + } + + @Test + public void givenUsingJava8_whenGeneratingRandomAlphabeticString_thenCorrect() { + int leftLimit = 97; // letter 'a' + int rightLimit = 122; // letter 'z' + int targetStringLength = 10; + Random random = new Random(); + + String generatedString = random.ints(leftLimit, rightLimit + 1) + .limit(targetStringLength) + .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) + .toString(); + + LOG.debug(generatedString); + } + + @Test + public void givenUsingJava8_whenGeneratingRandomAlphanumericString_thenCorrect() { + int leftLimit = 48; // numeral '0' + int rightLimit = 122; // letter 'z' + int targetStringLength = 10; + Random random = new Random(); + + String generatedString = random.ints(leftLimit, rightLimit + 1) + .filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97)) + .limit(targetStringLength) + .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) + .toString(); + + LOG.debug(generatedString); + } + + @Test + public void givenUsingApache_whenGeneratingRandomString_thenCorrect() { + String generatedString = RandomStringUtils.random(10); + + LOG.debug(generatedString); + } + + @Test + public void givenUsingApache_whenGeneratingRandomAlphabeticString_thenCorrect() { + String generatedString = RandomStringUtils.randomAlphabetic(10); + + LOG.debug(generatedString); + } + + @Test + public void givenUsingApache_whenGeneratingRandomAlphanumericString_thenCorrect() { + String generatedString = RandomStringUtils.randomAlphanumeric(10); + + LOG.debug(generatedString); + } + + @Test + public void givenUsingApache_whenGeneratingRandomStringBounded_thenCorrect() { + int length = 10; + boolean useLetters = true; + boolean useNumbers = false; + String generatedString = RandomStringUtils.random(length, useLetters, useNumbers); + + LOG.debug(generatedString); + } + +} diff --git a/core-java-modules/core-java-sun/pom.xml b/core-java-modules/core-java-sun/pom.xml index 03b6646fec..c17bb6b8fc 100644 --- a/core-java-modules/core-java-sun/pom.xml +++ b/core-java-modules/core-java-sun/pom.xml @@ -49,7 +49,7 @@ true libs/ - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar diff --git a/core-java-modules/core-java-text/pom.xml b/core-java-modules/core-java-text/pom.xml index 640b90764a..442fecd298 100644 --- a/core-java-modules/core-java-text/pom.xml +++ b/core-java-modules/core-java-text/pom.xml @@ -14,6 +14,19 @@ ../../parent-java + + + org.openjdk.jmh + jmh-core + ${jmh-core.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh-core.version} + + + core-java-text diff --git a/core-java-modules/core-java-text/src/main/java/com/baeldung/patternreuse/PatternPerformanceComparison.java b/core-java-modules/core-java-text/src/main/java/com/baeldung/patternreuse/PatternPerformanceComparison.java new file mode 100644 index 0000000000..01f8df9ec6 --- /dev/null +++ b/core-java-modules/core-java-text/src/main/java/com/baeldung/patternreuse/PatternPerformanceComparison.java @@ -0,0 +1,92 @@ +package com.baeldung.patternreuse; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.runner.RunnerException; + +import java.io.IOException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Fork(value = 1, warmups = 1) +@Warmup(iterations = 5) +@State(Scope.Benchmark) +public class PatternPerformanceComparison { + + private static final String PATTERN = "\\d*[02468]"; + private static List values; + + private static Matcher matcherFromPreCompiledPattern; + private static Pattern preCompiledPattern; + + public static void main(String[] args) throws IOException, RunnerException { + org.openjdk.jmh.Main.main(args); + } + + @Benchmark + public void matcherFromPreCompiledPatternResetMatches(Blackhole bh) { + //With pre-compiled pattern and reusing the matcher + // 1 Pattern object created + // 1 Matcher objects created + for (String value : values) { + bh.consume(matcherFromPreCompiledPattern.reset(value).matches()); + } + } + + @Benchmark + public void preCompiledPatternMatcherMatches(Blackhole bh) { + // With pre-compiled pattern + // 1 Pattern object created + // 5_000_000 Matcher objects created + for (String value : values) { + bh.consume(preCompiledPattern.matcher(value).matches()); + } + } + + @Benchmark + public void patternCompileMatcherMatches(Blackhole bh) { + // Above approach "Pattern.matches(PATTERN, value)" makes this internally + // 5_000_000 Pattern objects created + // 5_000_000 Matcher objects created + for (String value : values) { + bh.consume(Pattern.compile(PATTERN).matcher(value).matches()); + } + } + + @Benchmark + public void patternMatches(Blackhole bh) { + // Above approach "value.matches(PATTERN)" makes this internally + // 5_000_000 Pattern objects created + // 5_000_000 Matcher objects created + for (String value : values) { + bh.consume(Pattern.matches(PATTERN, value)); + } + } + + @Benchmark + public void stringMatchs(Blackhole bh) { + // 5_000_000 Pattern objects created + // 5_000_000 Matcher objects created + Instant start = Instant.now(); + for (String value : values) { + bh.consume(value.matches(PATTERN)); + } + } + + @Setup() + public void setUp() { + preCompiledPattern = Pattern.compile(PATTERN); + matcherFromPreCompiledPattern = preCompiledPattern.matcher(""); + + values = new ArrayList<>(); + for (int x = 1; x <= 5_000_000; x++) { + values.add(String.valueOf(x)); + } + } +} diff --git a/core-java-modules/core-java-text/src/test/java/com/baeldung/patternreuse/PatternUnitTest.java b/core-java-modules/core-java-text/src/test/java/com/baeldung/patternreuse/PatternUnitTest.java new file mode 100644 index 0000000000..c7331471ec --- /dev/null +++ b/core-java-modules/core-java-text/src/test/java/com/baeldung/patternreuse/PatternUnitTest.java @@ -0,0 +1,63 @@ +package com.baeldung.patternreuse; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.junit.Assert.*; + +public class PatternUnitTest { + + private static final Pattern FIRST_LAST_NAME_PRE_COMPILED_PATTERN = Pattern.compile("[a-zA-Z]{3,} [a-zA-Z]{3,}"); + private static final Pattern SPLIT_PRE_COMPILED_PATTERN = Pattern.compile("__"); + + @Test + public void givenPreCompiledPattern_whenCallMatcher_thenReturnAMatcherToMatches() { + Matcher matcherName1 = FIRST_LAST_NAME_PRE_COMPILED_PATTERN.matcher("Fabio Silva"); + Matcher matcherName2 = FIRST_LAST_NAME_PRE_COMPILED_PATTERN.matcher("Mr. Silva"); + + boolean matchesName1 = matcherName1.matches(); + boolean matchesName2 = matcherName2.matches(); + + assertTrue(matchesName1); + assertFalse(matchesName2); + } + + @Test + public void givenPreCompiledPattern_whenCallAsPredicate_thenReturnPredicateToFindPatternInTheList() { + List namesToValidate = Arrays.asList("Fabio Silva", "Mr. Silva"); + Predicate patternsAsPredicate = FIRST_LAST_NAME_PRE_COMPILED_PATTERN.asPredicate(); + + List validNames = namesToValidate.stream() + .filter(patternsAsPredicate) + .collect(Collectors.toList()); + + assertEquals(1, validNames.size()); + assertTrue(validNames.contains("Fabio Silva")); + } + + @Test + public void givenPreCompiledPattern_whenCallSplit_thenReturnArrayWithValuesSplitByThePattern() { + String[] textSplit = SPLIT_PRE_COMPILED_PATTERN.split("My_Name__is__Fabio_Silva"); + + assertEquals("My_Name", textSplit[0]); + assertEquals("is", textSplit[1]); + assertEquals("Fabio_Silva", textSplit[2]); + } + + @Test + public void givenPreCompiledPattern_whenCallSplitAsStream_thenReturnArraySplitByThePattern() { + Stream textSplitAsStream = SPLIT_PRE_COMPILED_PATTERN.splitAsStream("My_Name__is__Fabio_Silva"); + String[] textSplit = textSplitAsStream.toArray(String[]::new); + + assertEquals("My_Name", textSplit[0]); + assertEquals("is", textSplit[1]); + assertEquals("Fabio_Silva", textSplit[2]); + } +} diff --git a/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java b/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java new file mode 100644 index 0000000000..304b9f2f1d --- /dev/null +++ b/core-java-modules/core-java-text/src/test/java/com/baeldung/regex/matcher/MatcherUnitTest.java @@ -0,0 +1,63 @@ +package com.baeldung.regex.matcher; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.jupiter.api.Test; + +public class MatcherUnitTest { + + @Test + public void whenFindFourDigitWorks_thenCorrect() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020"); + + assertTrue(m.find()); + assertEquals(8, m.start()); + assertEquals("2019", m.group()); + assertEquals(12, m.end()); + + assertTrue(m.find()); + assertEquals(25, m.start()); + assertEquals("2020", m.group()); + assertEquals(29, m.end()); + + assertFalse(m.find()); + } + + @Test + public void givenStartIndex_whenFindFourDigitWorks_thenCorrect() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020"); + + assertTrue(m.find(20)); + assertEquals(25, m.start()); + assertEquals("2020", m.group()); + assertEquals(29, m.end()); + } + + @Test + public void whenMatchFourDigitWorks_thenFail() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("goodbye 2019 and welcome 2020"); + assertFalse(m.matches()); + } + + @Test + public void whenMatchFourDigitWorks_thenCorrect() { + Pattern stringPattern = Pattern.compile("\\d\\d\\d\\d"); + Matcher m = stringPattern.matcher("2019"); + + assertTrue(m.matches()); + assertEquals(0, m.start()); + assertEquals("2019", m.group()); + assertEquals(4, m.end()); + + assertTrue(m.matches());// matches will always return the same return + } + +} diff --git a/core-java-modules/core-java/pom.xml b/core-java-modules/core-java/pom.xml index 341363f8ed..5f60b43f79 100644 --- a/core-java-modules/core-java/pom.xml +++ b/core-java-modules/core-java/pom.xml @@ -99,7 +99,7 @@ true libs/ - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -118,7 +118,7 @@ ${project.basedir} - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -142,7 +142,7 @@ true - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -157,7 +157,7 @@ - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar true ${project.build.finalName}-onejar.${project.packaging} @@ -179,7 +179,7 @@ spring-boot - org.baeldung.executable.ExecutableMavenJar + com.baeldung.executable.ExecutableMavenJar @@ -207,8 +207,8 @@ maven-javadoc-plugin ${maven-javadoc-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -397,6 +397,8 @@ 3.1.1 2.0.3.RELEASE 1.6.0 + 1.8 + 1.8 diff --git a/core-java-modules/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java b/core-java-modules/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java deleted file mode 100644 index d291ac0d3b..0000000000 --- a/core-java-modules/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.baeldung.executable; - -import javax.swing.*; - -public class ExecutableMavenJar { - - public static void main(String[] args) { - JOptionPane.showMessageDialog(null, "It worked!", "Executable Jar with Maven", 1); - } -} diff --git a/core-java-modules/core-java/src/test/java/org/baeldung/java/JavaTimerLongRunningUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/JavaTimerLongRunningUnitTest.java similarity index 99% rename from core-java-modules/core-java/src/test/java/org/baeldung/java/JavaTimerLongRunningUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/JavaTimerLongRunningUnitTest.java index 826106a09e..7063bafb1d 100644 --- a/core-java-modules/core-java/src/test/java/org/baeldung/java/JavaTimerLongRunningUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/JavaTimerLongRunningUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java; +package com.baeldung; import org.junit.Test; import org.slf4j.Logger; diff --git a/core-java-modules/core-java/src/test/java/org/baeldung/java/arrays/ArraysJoinAndSplitJUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/arrays/ArraysJoinAndSplitJUnitTest.java similarity index 97% rename from core-java-modules/core-java/src/test/java/org/baeldung/java/arrays/ArraysJoinAndSplitJUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/arrays/ArraysJoinAndSplitJUnitTest.java index 885c3bcd6c..b31a829f34 100644 --- a/core-java-modules/core-java/src/test/java/org/baeldung/java/arrays/ArraysJoinAndSplitJUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/arrays/ArraysJoinAndSplitJUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.arrays; +package com.baeldung.arrays; import java.util.Arrays; diff --git a/core-java-modules/core-java/src/test/java/org/baeldung/java/rawtypes/RawTypesUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/rawtypes/RawTypesUnitTest.java similarity index 90% rename from core-java-modules/core-java/src/test/java/org/baeldung/java/rawtypes/RawTypesUnitTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/rawtypes/RawTypesUnitTest.java index 161c053cea..3871368c07 100644 --- a/core-java-modules/core-java/src/test/java/org/baeldung/java/rawtypes/RawTypesUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/rawtypes/RawTypesUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.rawtypes; +package com.baeldung.rawtypes; import java.util.ArrayList; import java.util.List; diff --git a/core-java-modules/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaManualTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/sandbox/SandboxJavaManualTest.java similarity index 98% rename from core-java-modules/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaManualTest.java rename to core-java-modules/core-java/src/test/java/com/baeldung/sandbox/SandboxJavaManualTest.java index 877122ce40..a58c2d4e6c 100644 --- a/core-java-modules/core-java/src/test/java/org/baeldung/java/sandbox/SandboxJavaManualTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/sandbox/SandboxJavaManualTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.sandbox; +package com.baeldung.sandbox; import org.junit.Test; import org.slf4j.Logger; diff --git a/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml index fa2d92d67f..e8a8203f33 100644 --- a/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/mainappmodule/pom.xml @@ -17,17 +17,17 @@ com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version} com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} com.baeldung.userdaomodule userdaomodule - 1.0 + ${userdaomodule.version} @@ -43,6 +43,9 @@ 9 9 + 1.0 + 1.0 + 1.0 \ No newline at end of file diff --git a/core-java-modules/multimodulemavenproject/pom.xml b/core-java-modules/multimodulemavenproject/pom.xml index 1d4aebf32e..dcf9f7311e 100644 --- a/core-java-modules/multimodulemavenproject/pom.xml +++ b/core-java-modules/multimodulemavenproject/pom.xml @@ -45,10 +45,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 1.9 - 1.9 + ${source.version} + ${target.version} @@ -56,6 +56,9 @@ + 3.8.0 + 1.9 + 1.9 UTF-8 3.12.2 diff --git a/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml index 19012708cf..8f4cc3d945 100644 --- a/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml +++ b/core-java-modules/multimodulemavenproject/userdaomodule/pom.xml @@ -17,12 +17,12 @@ com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version} com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} @@ -38,6 +38,8 @@ 9 9 + 1.0 + 1.0 \ No newline at end of file diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index dcc98d77f6..904cec2815 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -14,12 +14,110 @@ - pre-jpms - core-java-optional + core-java + + + + + core-java-8 + core-java-8-2 + + + + + + + + core-java-annotations + core-java-arrays + core-java-arrays-2 + + core-java-collections + core-java-collections-2 + core-java-collections-3 + core-java-collections-array-list + core-java-collections-list + core-java-collections-list-2 + core-java-collections-list-3 + core-java-collections-set + + core-java-concurrency-2 + core-java-concurrency-advanced + core-java-concurrency-advanced-2 + core-java-concurrency-advanced-3 + core-java-concurrency-basic + core-java-concurrency-basic-2 + core-java-concurrency-collections + + + core-java-date-operations-2 + + + + core-java-exceptions + core-java-exceptions-2 + + core-java-function + + core-java-io + core-java-io-2 + core-java-io-apis + core-java-io-conversions + + core-java-jar + core-java-jndi + + core-java-jvm + + core-java-lambdas + core-java-lang + core-java-lang-2 + core-java-lang-math + core-java-lang-oop + core-java-lang-oop-2 + core-java-lang-oop-3 + core-java-lang-oop-4 core-java-lang-operators + core-java-lang-syntax + core-java-lang-syntax-2 + + core-java-networking core-java-networking-2 - core-java-security-manager - core-java-date-operations + core-java-nio + core-java-nio-2 + + core-java-optional + + + core-java-perf + + core-java-reflection + + core-java-security + core-java-streams + core-java-streams-2 + core-java-streams-3 + core-java-string-algorithms + core-java-string-algorithms-2 + core-java-string-algorithms-3 + core-java-string-apis + core-java-string-conversions + core-java-string-conversions-2 + core-java-string-operations + core-java-string-operations-2 + core-java-strings + core-java-sun + + core-java-text + + + + pre-jpms diff --git a/core-java-modules/pre-jpms/pom.xml b/core-java-modules/pre-jpms/pom.xml index cb23427138..9833dc2ff7 100644 --- a/core-java-modules/pre-jpms/pom.xml +++ b/core-java-modules/pre-jpms/pom.xml @@ -29,16 +29,16 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} org.apache.maven.plugins maven-dependency-plugin - 3.1.1 + ${dependency.plugin.version} copy-dependencies @@ -69,5 +69,12 @@ + + + 3.1.1 + 3.8.0 + 1.8 + 1.8 + diff --git a/core-kotlin-2/.gitignore b/core-kotlin-2/.gitignore deleted file mode 100644 index 0c017e8f8c..0000000000 --- a/core-kotlin-2/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -/bin/ - -#ignore gradle -.gradle/ - - -#ignore build and generated files -build/ -node/ -out/ - -#ignore installed node modules and package lock file -node_modules/ -package-lock.json diff --git a/core-kotlin-2/README.md b/core-kotlin-2/README.md deleted file mode 100644 index 5a443c1831..0000000000 --- a/core-kotlin-2/README.md +++ /dev/null @@ -1,14 +0,0 @@ -## Core Kotlin - -This module contains articles about core Kotlin. - -### Relevant articles: - -- [Void Type in Kotlin](https://www.baeldung.com/kotlin-void-type) -- [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges) -- [Creating a Kotlin Range Iterator on a Custom Object](https://www.baeldung.com/kotlin-custom-range-iterator) -- [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions) -- [Kotlin Annotations](https://www.baeldung.com/kotlin-annotations) -- [Split a List into Parts in Kotlin](https://www.baeldung.com/kotlin-split-list-into-parts) -- [Finding an Element in a List Using Kotlin](https://www.baeldung.com/kotlin-finding-element-in-list) -- More articles: [[<-- prev]](/core-kotlin) diff --git a/core-kotlin-2/build.gradle b/core-kotlin-2/build.gradle deleted file mode 100644 index 1c52172404..0000000000 --- a/core-kotlin-2/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ - - -group 'com.baeldung.ktor' -version '1.0-SNAPSHOT' - - -buildscript { - ext.kotlin_version = '1.3.30' - - repositories { - mavenCentral() - } - dependencies { - - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -apply plugin: 'java' -apply plugin: 'kotlin' -apply plugin: 'application' - -mainClassName = 'APIServer.kt' - -sourceCompatibility = 1.8 -compileKotlin { kotlinOptions.jvmTarget = "1.8" } -compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } - -repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/ktor" } -} -sourceSets { - main{ - kotlin{ - srcDirs 'com/baeldung/ktor' - } - } -} - -test { - useJUnitPlatform() - testLogging { - events "passed", "skipped", "failed" - } -} - -dependencies { - implementation "ch.qos.logback:logback-classic:1.2.1" - implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" - testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2' - testImplementation 'junit:junit:4.12' - testImplementation 'org.assertj:assertj-core:3.12.2' - testImplementation 'org.mockito:mockito-core:2.27.0' - testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" - testImplementation "org.jetbrains.kotlin:kotlin-test-junit5:${kotlin_version}" -} diff --git a/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar b/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 5c2d1cf016..0000000000 Binary files a/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/core-kotlin-2/gradle/wrapper/gradle-wrapper.properties b/core-kotlin-2/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 5f1b1201a7..0000000000 --- a/core-kotlin-2/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/core-kotlin-2/gradlew b/core-kotlin-2/gradlew deleted file mode 100644 index b0d6d0ab5d..0000000000 --- a/core-kotlin-2/gradlew +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/core-kotlin-2/gradlew.bat b/core-kotlin-2/gradlew.bat deleted file mode 100644 index 9991c50326..0000000000 --- a/core-kotlin-2/gradlew.bat +++ /dev/null @@ -1,100 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem http://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/core-kotlin-2/pom.xml b/core-kotlin-2/pom.xml deleted file mode 100644 index be2f5fa68f..0000000000 --- a/core-kotlin-2/pom.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - 4.0.0 - core-kotlin-2 - core-kotlin-2 - jar - - - com.baeldung - parent-kotlin - 1.0.0-SNAPSHOT - ../parent-kotlin - - - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - - - org.junit.jupiter - junit-jupiter - ${junit.jupiter.version} - test - - - org.mockito - mockito-core - ${mockito.version} - test - - - net.bytebuddy - byte-buddy - ${byte-buddy.version} - test - - - org.assertj - assertj-core - ${assertj.version} - test - - - org.jetbrains.kotlin - kotlin-test - ${kotlin.version} - test - - - org.jetbrains.kotlin - kotlin-test-junit5 - ${kotlin.version} - test - - - - - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - compile - compile - - compile - - - - test-compile - test-compile - - test-compile - - - - - 1.8 - - - - - - - 1.3.30 - 5.4.2 - 2.27.0 - 1.9.12 - 3.10.0 - - - diff --git a/core-kotlin-2/resources/logback.xml b/core-kotlin-2/resources/logback.xml deleted file mode 100644 index 9452207268..0000000000 --- a/core-kotlin-2/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - \ No newline at end of file diff --git a/core-kotlin-2/settings.gradle b/core-kotlin-2/settings.gradle deleted file mode 100644 index c91c993971..0000000000 --- a/core-kotlin-2/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'KtorWithKotlin' - diff --git a/core-kotlin-2/src/test/resources/Kotlin.in b/core-kotlin-2/src/test/resources/Kotlin.in deleted file mode 100644 index d140d4429e..0000000000 --- a/core-kotlin-2/src/test/resources/Kotlin.in +++ /dev/null @@ -1,5 +0,0 @@ -Hello to Kotlin. Its: -1. Concise -2. Safe -3. Interoperable -4. Tool-friendly \ No newline at end of file diff --git a/core-kotlin-2/src/test/resources/Kotlin.out b/core-kotlin-2/src/test/resources/Kotlin.out deleted file mode 100644 index 63d15d2528..0000000000 --- a/core-kotlin-2/src/test/resources/Kotlin.out +++ /dev/null @@ -1,2 +0,0 @@ -Kotlin -Concise, Safe, Interoperable, Tool-friendly \ No newline at end of file diff --git a/core-kotlin-modules/core-kotlin-2/README.md b/core-kotlin-modules/core-kotlin-2/README.md new file mode 100644 index 0000000000..11593062c5 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-2/README.md @@ -0,0 +1,8 @@ +## Core Kotlin 2 + +This module contains articles about Kotlin core features. + +### Relevant articles: +- [Working with Dates in Kotlin](https://www.baeldung.com/kotlin-dates) +- [Kotlin Ternary Conditional Operator](https://www.baeldung.com/kotlin-ternary-conditional-operator) +- [[<-- Prev]](/core-kotlin-modules/core-kotlin) diff --git a/core-kotlin-modules/core-kotlin-2/pom.xml b/core-kotlin-modules/core-kotlin-2/pom.xml new file mode 100644 index 0000000000..ae6e2d175a --- /dev/null +++ b/core-kotlin-modules/core-kotlin-2/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + core-kotlin-2 + core-kotlin-2 + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + \ No newline at end of file diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseDuration.kt b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseDuration.kt similarity index 90% rename from core-kotlin/src/main/kotlin/com/baeldung/datetime/UseDuration.kt rename to core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseDuration.kt index 40fb161c08..922c3a1988 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseDuration.kt +++ b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseDuration.kt @@ -1,4 +1,4 @@ -package com.baeldung.datetime +package com.baeldung.dates.datetime import java.time.Duration import java.time.LocalTime diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseLocalDate.kt b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseLocalDate.kt similarity index 96% rename from core-kotlin/src/main/kotlin/com/baeldung/datetime/UseLocalDate.kt rename to core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseLocalDate.kt index 250c071bbe..81d50a70b2 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseLocalDate.kt +++ b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseLocalDate.kt @@ -1,4 +1,4 @@ -package com.baeldung.datetime +package com.baeldung.dates.datetime import java.time.DayOfWeek import java.time.LocalDate diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseLocalDateTime.kt b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseLocalDateTime.kt similarity index 84% rename from core-kotlin/src/main/kotlin/com/baeldung/datetime/UseLocalDateTime.kt rename to core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseLocalDateTime.kt index ab7bbfcee1..5d0eb6a911 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseLocalDateTime.kt +++ b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseLocalDateTime.kt @@ -1,4 +1,4 @@ -package com.baeldung.datetime +package com.baeldung.dates.datetime import java.time.LocalDateTime diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseLocalTime.kt b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseLocalTime.kt similarity index 92% rename from core-kotlin/src/main/kotlin/com/baeldung/datetime/UseLocalTime.kt rename to core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseLocalTime.kt index 152515621f..24402467e8 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseLocalTime.kt +++ b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseLocalTime.kt @@ -1,6 +1,5 @@ -package com.baeldung.datetime +package com.baeldung.dates.datetime -import java.time.LocalDateTime import java.time.LocalTime import java.time.temporal.ChronoUnit diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UsePeriod.kt b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UsePeriod.kt similarity index 90% rename from core-kotlin/src/main/kotlin/com/baeldung/datetime/UsePeriod.kt rename to core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UsePeriod.kt index df66a3d546..d15e02eb37 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UsePeriod.kt +++ b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UsePeriod.kt @@ -1,4 +1,4 @@ -package com.baeldung.datetime +package com.baeldung.dates.datetime import java.time.LocalDate import java.time.Period diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseZonedDateTime.kt b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseZonedDateTime.kt similarity index 88% rename from core-kotlin/src/main/kotlin/com/baeldung/datetime/UseZonedDateTime.kt rename to core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseZonedDateTime.kt index fd1838bd2d..e2f3a207c4 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/datetime/UseZonedDateTime.kt +++ b/core-kotlin-modules/core-kotlin-2/src/main/kotlin/com/baeldung/dates/datetime/UseZonedDateTime.kt @@ -1,4 +1,4 @@ -package com.baeldung.datetime +package com.baeldung.dates.datetime import java.time.LocalDateTime import java.time.ZoneId diff --git a/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/CreateDateUnitTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/CreateDateUnitTest.kt similarity index 96% rename from kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/CreateDateUnitTest.kt rename to core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/CreateDateUnitTest.kt index d52a2f0f19..af5e08ea2d 100644 --- a/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/CreateDateUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/CreateDateUnitTest.kt @@ -1,34 +1,34 @@ -package com.baeldung.kotlin.dates - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import java.time.LocalDate -import java.time.format.DateTimeFormatter - -class CreateDateUnitTest { - - @Test - fun givenString_whenDefaultFormat_thenCreated() { - - var date = LocalDate.parse("2018-12-31") - - assertThat(date).isEqualTo("2018-12-31") - } - - @Test - fun givenString_whenCustomFormat_thenCreated() { - - var formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy") - var date = LocalDate.parse("31-12-2018", formatter) - - assertThat(date).isEqualTo("2018-12-31") - } - - @Test - fun givenYMD_whenUsingOf_thenCreated() { - var date = LocalDate.of(2018, 12, 31) - - assertThat(date).isEqualTo("2018-12-31") - } - +package com.baeldung.kotlin.dates + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import java.time.LocalDate +import java.time.format.DateTimeFormatter + +class CreateDateUnitTest { + + @Test + fun givenString_whenDefaultFormat_thenCreated() { + + var date = LocalDate.parse("2018-12-31") + + assertThat(date).isEqualTo("2018-12-31") + } + + @Test + fun givenString_whenCustomFormat_thenCreated() { + + var formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy") + var date = LocalDate.parse("31-12-2018", formatter) + + assertThat(date).isEqualTo("2018-12-31") + } + + @Test + fun givenYMD_whenUsingOf_thenCreated() { + var date = LocalDate.of(2018, 12, 31) + + assertThat(date).isEqualTo("2018-12-31") + } + } \ No newline at end of file diff --git a/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/ExtractDateUnitTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/ExtractDateUnitTest.kt similarity index 96% rename from kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/ExtractDateUnitTest.kt rename to core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/ExtractDateUnitTest.kt index ef3841752b..d297f4b6c3 100644 --- a/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/ExtractDateUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/ExtractDateUnitTest.kt @@ -1,29 +1,29 @@ -package com.baeldung.kotlin.dates - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import java.time.DayOfWeek -import java.time.LocalDate -import java.time.Month - -class ExtractDateUnitTest { - - @Test - fun givenDate_thenExtractedYMD() { - var date = LocalDate.parse("2018-12-31") - - assertThat(date.year).isEqualTo(2018) - assertThat(date.month).isEqualTo(Month.DECEMBER) - assertThat(date.dayOfMonth).isEqualTo(31) - } - - @Test - fun givenDate_thenExtractedEraDowDoy() { - var date = LocalDate.parse("2018-12-31") - - assertThat(date.era.toString()).isEqualTo("CE") - assertThat(date.dayOfWeek).isEqualTo(DayOfWeek.MONDAY) - assertThat(date.dayOfYear).isEqualTo(365) - } - +package com.baeldung.kotlin.dates + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import java.time.DayOfWeek +import java.time.LocalDate +import java.time.Month + +class ExtractDateUnitTest { + + @Test + fun givenDate_thenExtractedYMD() { + var date = LocalDate.parse("2018-12-31") + + assertThat(date.year).isEqualTo(2018) + assertThat(date.month).isEqualTo(Month.DECEMBER) + assertThat(date.dayOfMonth).isEqualTo(31) + } + + @Test + fun givenDate_thenExtractedEraDowDoy() { + var date = LocalDate.parse("2018-12-31") + + assertThat(date.era.toString()).isEqualTo("CE") + assertThat(date.dayOfWeek).isEqualTo(DayOfWeek.MONDAY) + assertThat(date.dayOfYear).isEqualTo(365) + } + } \ No newline at end of file diff --git a/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/FormatDateUnitTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/FormatDateUnitTest.kt similarity index 96% rename from kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/FormatDateUnitTest.kt rename to core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/FormatDateUnitTest.kt index 11ff6ec9f0..f7ca414aee 100644 --- a/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/FormatDateUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/FormatDateUnitTest.kt @@ -1,29 +1,29 @@ -package com.baeldung.kotlin.dates - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import java.time.LocalDate -import java.time.format.DateTimeFormatter - -class FormatDateUnitTest { - - @Test - fun givenDate_whenDefaultFormat_thenFormattedString() { - - var date = LocalDate.parse("2018-12-31") - - assertThat(date.toString()).isEqualTo("2018-12-31") - } - - @Test - fun givenDate_whenCustomFormat_thenFormattedString() { - - var date = LocalDate.parse("2018-12-31") - - var formatter = DateTimeFormatter.ofPattern("dd-MMMM-yyyy") - var formattedDate = date.format(formatter) - - assertThat(formattedDate).isEqualTo("31-December-2018") - } - +package com.baeldung.kotlin.dates + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import java.time.LocalDate +import java.time.format.DateTimeFormatter + +class FormatDateUnitTest { + + @Test + fun givenDate_whenDefaultFormat_thenFormattedString() { + + var date = LocalDate.parse("2018-12-31") + + assertThat(date.toString()).isEqualTo("2018-12-31") + } + + @Test + fun givenDate_whenCustomFormat_thenFormattedString() { + + var date = LocalDate.parse("2018-12-31") + + var formatter = DateTimeFormatter.ofPattern("dd-MMMM-yyyy") + var formattedDate = date.format(formatter) + + assertThat(formattedDate).isEqualTo("31-December-2018") + } + } \ No newline at end of file diff --git a/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/PeriodDateUnitTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/PeriodDateUnitTest.kt similarity index 96% rename from kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/PeriodDateUnitTest.kt rename to core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/PeriodDateUnitTest.kt index e6b66634d3..e8ca2971e8 100644 --- a/kotlin-libraries/src/test/kotlin/com/baeldung/kotlin/dates/PeriodDateUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/PeriodDateUnitTest.kt @@ -1,48 +1,48 @@ -package com.baeldung.kotlin.dates - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import java.time.LocalDate -import java.time.Period - -class PeriodDateUnitTest { - - @Test - fun givenYMD_thenCreatePeriod() { - var period = Period.of(1, 2, 3) - - assertThat(period.toString()).isEqualTo("P1Y2M3D") - } - - @Test - fun givenPeriod_whenAdd_thenModifiedDate() { - var period = Period.of(1, 2, 3) - - var date = LocalDate.of(2018, 6, 25) - var modifiedDate = date.plus(period) - - assertThat(modifiedDate).isEqualTo("2019-08-28") - } - - @Test - fun givenPeriod_whenSubtracted_thenModifiedDate() { - var period = Period.of(1, 2, 3) - - var date = LocalDate.of(2018, 6, 25) - var modifiedDate = date.minus(period) - - assertThat(modifiedDate).isEqualTo("2017-04-22") - } - - @Test - fun givenTwoDate_whenUsingBetween_thenDiffOfDates() { - - var date1 = LocalDate.parse("2018-06-25") - var date2 = LocalDate.parse("2018-12-25") - - var period = Period.between(date1, date2) - - assertThat(period.toString()).isEqualTo("P6M") - } - +package com.baeldung.kotlin.dates + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import java.time.LocalDate +import java.time.Period + +class PeriodDateUnitTest { + + @Test + fun givenYMD_thenCreatePeriod() { + var period = Period.of(1, 2, 3) + + assertThat(period.toString()).isEqualTo("P1Y2M3D") + } + + @Test + fun givenPeriod_whenAdd_thenModifiedDate() { + var period = Period.of(1, 2, 3) + + var date = LocalDate.of(2018, 6, 25) + var modifiedDate = date.plus(period) + + assertThat(modifiedDate).isEqualTo("2019-08-28") + } + + @Test + fun givenPeriod_whenSubtracted_thenModifiedDate() { + var period = Period.of(1, 2, 3) + + var date = LocalDate.of(2018, 6, 25) + var modifiedDate = date.minus(period) + + assertThat(modifiedDate).isEqualTo("2017-04-22") + } + + @Test + fun givenTwoDate_whenUsingBetween_thenDiffOfDates() { + + var date1 = LocalDate.parse("2018-06-25") + var date2 = LocalDate.parse("2018-12-25") + + var period = Period.between(date1, date2) + + assertThat(period.toString()).isEqualTo("P6M") + } + } \ No newline at end of file diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseLocalDateTimeUnitTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseLocalDateTimeUnitTest.kt similarity index 92% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseLocalDateTimeUnitTest.kt rename to core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseLocalDateTimeUnitTest.kt index 8f9f8374ed..f3615a527c 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseLocalDateTimeUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseLocalDateTimeUnitTest.kt @@ -1,14 +1,12 @@ package com.baeldung.kotlin.datetime -import com.baeldung.datetime.UseLocalDateTime +import com.baeldung.dates.datetime.UseLocalDateTime +import org.junit.Assert.assertEquals +import org.junit.Test import java.time.LocalDate import java.time.LocalTime import java.time.Month -import org.junit.Test - -import org.junit.Assert.assertEquals - class UseLocalDateTimeUnitTest { var useLocalDateTime = UseLocalDateTime() diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseLocalDateUnitTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseLocalDateUnitTest.kt similarity index 97% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseLocalDateUnitTest.kt rename to core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseLocalDateUnitTest.kt index ac42e91c6c..e6353c9dab 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseLocalDateUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseLocalDateUnitTest.kt @@ -1,6 +1,6 @@ package com.baeldung.kotlin.datetime -import com.baeldung.datetime.UseLocalDate +import com.baeldung.dates.datetime.UseLocalDate import org.junit.Assert import org.junit.Test import java.time.DayOfWeek diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseLocalTimeUnitTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseLocalTimeUnitTest.kt similarity index 95% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseLocalTimeUnitTest.kt rename to core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseLocalTimeUnitTest.kt index 83fc57f850..1afe03ca48 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseLocalTimeUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseLocalTimeUnitTest.kt @@ -1,10 +1,9 @@ package com.baeldung.kotlin.datetime -import com.baeldung.datetime.UseLocalTime -import java.time.LocalTime - +import com.baeldung.dates.datetime.UseLocalTime import org.junit.Assert import org.junit.Test +import java.time.LocalTime class UseLocalTimeUnitTest { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UsePeriodUnitTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UsePeriodUnitTest.kt similarity index 94% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UsePeriodUnitTest.kt rename to core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UsePeriodUnitTest.kt index 48be72feb0..36e1e5533a 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UsePeriodUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UsePeriodUnitTest.kt @@ -1,11 +1,10 @@ package com.baeldung.kotlin.datetime -import com.baeldung.datetime.UsePeriod -import java.time.LocalDate -import java.time.Period - +import com.baeldung.dates.datetime.UsePeriod import org.junit.Assert import org.junit.Test +import java.time.LocalDate +import java.time.Period class UsePeriodUnitTest { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseZonedDateTimeUnitTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseZonedDateTimeUnitTest.kt similarity index 90% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseZonedDateTimeUnitTest.kt rename to core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseZonedDateTimeUnitTest.kt index a9d7d973ef..aa2cdaa4f3 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/datetime/UseZonedDateTimeUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/dates/datetime/UseZonedDateTimeUnitTest.kt @@ -1,6 +1,6 @@ package com.baeldung.kotlin.datetime -import com.baeldung.datetime.UseZonedDateTime +import com.baeldung.dates.datetime.UseZonedDateTime import org.junit.Assert import org.junit.Test import java.time.LocalDateTime diff --git a/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt new file mode 100644 index 0000000000..a41e213c44 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/sequences/SequencesTest.kt @@ -0,0 +1,54 @@ +package com.baeldung.sequeces + +import org.junit.Test +import kotlin.test.assertEquals +import java.time.Instant + +class SequencesTest { + + @Test + fun shouldBuildSequenceWhenUsingFromElements() { + val seqOfElements = sequenceOf("first" ,"second", "third") + .toList() + assertEquals(3, seqOfElements.count()) + } + + @Test + fun shouldBuildSequenceWhenUsingFromFunction() { + val seqFromFunction = generateSequence(Instant.now()) {it.plusSeconds(1)} + .take(3) + .toList() + assertEquals(3, seqFromFunction.count()) + } + + @Test + fun shouldBuildSequenceWhenUsingFromChunks() { + val seqFromChunks = sequence { + yield(1) + yieldAll((2..5).toList()) + }.toList() + assertEquals(5, seqFromChunks.count()) + } + + @Test + fun shouldBuildSequenceWhenUsingFromCollection() { + val seqFromIterable = (1..10) + .asSequence() + .toList() + assertEquals(10, seqFromIterable.count()) + } + + @Test + fun shouldShowNoCountDiffWhenUsingWithAndWithoutSequence() { + val withSequence = (1..10).asSequence() + .filter{it % 2 == 1} + .map { it * 2 } + .toList() + val withoutSequence = (1..10) + .filter{it % 2 == 1} + .map { it * 2 } + .toList() + assertEquals(withSequence.count(), withoutSequence.count()) + } + +} \ No newline at end of file diff --git a/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/ternary/TernaryOperatorTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/ternary/TernaryOperatorTest.kt new file mode 100644 index 0000000000..21dfdd2ae0 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/ternary/TernaryOperatorTest.kt @@ -0,0 +1,24 @@ +package com.baeldung.ternary + +import org.junit.Test +import kotlin.test.assertEquals + +class TernaryOperatorTest { + + @Test + fun `using If`() { + val a = true + val result = if (a) "yes" else "no" + assertEquals("yes", result) + } + + @Test + fun `using When`() { + val a = true + val result = when(a) { + true -> "yes" + false -> "no" + } + assertEquals("yes", result) + } +} \ No newline at end of file diff --git a/core-kotlin-modules/core-kotlin-advanced/README.md b/core-kotlin-modules/core-kotlin-advanced/README.md new file mode 100644 index 0000000000..2e99e3b078 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-advanced/README.md @@ -0,0 +1,11 @@ +## Core Kotlin Advanced + +This module contains articles about advanced topics in Kotlin. + +### Relevant articles: +- [Building DSLs in Kotlin](https://www.baeldung.com/kotlin-dsl) +- [Regular Expressions in Kotlin](https://www.baeldung.com/kotlin-regular-expressions) +- [Idiomatic Logging in Kotlin](https://www.baeldung.com/kotlin-logging) +- [Mapping of Data Objects in Kotlin](https://www.baeldung.com/kotlin-data-objects) +- [Reflection with Kotlin](https://www.baeldung.com/kotlin-reflection) +- [Kotlin Contracts](https://www.baeldung.com/kotlin-contracts) diff --git a/core-kotlin-modules/core-kotlin-advanced/pom.xml b/core-kotlin-modules/core-kotlin-advanced/pom.xml new file mode 100644 index 0000000000..5ddfef23cc --- /dev/null +++ b/core-kotlin-modules/core-kotlin-advanced/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + core-kotlin-advanced + core-kotlin-advanced + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + + + 1.3.30 + 3.10.0 + + + \ No newline at end of file diff --git a/core-kotlin/src/main/kotlin/com/baeldung/contract/CallsInPlaceEffect.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/contract/CallsInPlaceEffect.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/contract/CallsInPlaceEffect.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/contract/CallsInPlaceEffect.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/contract/ReturnsEffect.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/contract/ReturnsEffect.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/contract/ReturnsEffect.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/contract/ReturnsEffect.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datamapping/User.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/datamapping/User.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/datamapping/User.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/datamapping/User.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datamapping/UserExtensions.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/datamapping/UserExtensions.kt similarity index 82% rename from core-kotlin/src/main/kotlin/com/baeldung/datamapping/UserExtensions.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/datamapping/UserExtensions.kt index 6113ed3591..1f3d7f3b47 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/datamapping/UserExtensions.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/datamapping/UserExtensions.kt @@ -3,10 +3,10 @@ package com.baeldung.datamapping import kotlin.reflect.full.memberProperties fun User.toUserView() = UserView( - name = "$firstName $lastName", - address = "$street $houseNumber", - telephone = phone, - age = age + name = "$firstName $lastName", + address = "$street $houseNumber", + telephone = phone, + age = age ) fun User.toUserViewReflection() = with(::UserView) { diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datamapping/UserView.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/datamapping/UserView.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/datamapping/UserView.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/datamapping/UserView.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/dsl/SqlDsl.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/dsl/SqlDsl.kt similarity index 99% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/dsl/SqlDsl.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/dsl/SqlDsl.kt index 5296d301a3..207e9dbd53 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/dsl/SqlDsl.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/dsl/SqlDsl.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.dsl +package com.baeldung.dsl abstract class Condition { diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsExtensionOnAny.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsExtensionOnAny.kt similarity index 94% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsExtensionOnAny.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsExtensionOnAny.kt index 32d968fff5..01edf5e871 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsExtensionOnAny.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsExtensionOnAny.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.logging +package com.baeldung.logging import org.slf4j.Logger diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsExtensionOnMarkerInterface.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsExtensionOnMarkerInterface.kt similarity index 95% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsExtensionOnMarkerInterface.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsExtensionOnMarkerInterface.kt index b33d4c9f93..8210361345 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsExtensionOnMarkerInterface.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsExtensionOnMarkerInterface.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.logging +package com.baeldung.logging import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsProperty.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsProperty.kt similarity index 88% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsProperty.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsProperty.kt index 979b3b3a10..60ac0800e2 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsProperty.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsProperty.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.logging +package com.baeldung.logging open class LoggerAsProperty { private val logger = getLogger(javaClass) diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsPropertyDelegate.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsPropertyDelegate.kt similarity index 92% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsPropertyDelegate.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsPropertyDelegate.kt index 23f04722be..83cde2b446 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerAsPropertyDelegate.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerAsPropertyDelegate.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.logging +package com.baeldung.logging import org.slf4j.Logger import kotlin.properties.ReadOnlyProperty @@ -43,5 +43,5 @@ fun main(args: Array) { class LoggerDelegate : ReadOnlyProperty { override fun getValue(thisRef: R, property: KProperty<*>) = - getLogger(getClassForLogging(thisRef.javaClass)) + getLogger(getClassForLogging(thisRef.javaClass)) } diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerInCompanionObject.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerInCompanionObject.kt similarity index 97% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerInCompanionObject.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerInCompanionObject.kt index f973606369..6a44675e45 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/LoggerInCompanionObject.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/LoggerInCompanionObject.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.logging +package com.baeldung.logging open class LoggerInCompanionObject { companion object { diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/Util.kt b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/Util.kt similarity index 91% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/Util.kt rename to core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/Util.kt index b9c0d9e34c..44dba53cb7 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/logging/Util.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/main/kotlin/com/baeldung/logging/Util.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.logging +package com.baeldung.logging import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/core-kotlin/src/test/kotlin/com/baeldung/datamapping/UserTest.kt b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/datamapping/UserTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/datamapping/UserTest.kt rename to core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/datamapping/UserTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/dsl/SqlDslTest.kt b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/dsl/SqlDslTest.kt similarity index 97% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/dsl/SqlDslTest.kt rename to core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/dsl/SqlDslTest.kt index 55ae44e4dc..a370e7f15d 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/dsl/SqlDslTest.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/dsl/SqlDslTest.kt @@ -1,8 +1,7 @@ -package com.baeldung.kotlin.dsl +package com.baeldung.dsl import org.assertj.core.api.Assertions.assertThat import org.junit.Test -import java.lang.Exception class SqlDslTest { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/reflection/JavaReflectionTest.kt b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/reflection/JavaReflectionTest.kt similarity index 95% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/reflection/JavaReflectionTest.kt rename to core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/reflection/JavaReflectionTest.kt index 0d0e7b724d..c77774dd81 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/reflection/JavaReflectionTest.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/reflection/JavaReflectionTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.reflection +package com.baeldung.reflection import org.junit.Ignore import org.junit.Test diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/reflection/KClassTest.kt b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/reflection/KClassTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/reflection/KClassTest.kt rename to core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/reflection/KClassTest.kt index 56183b50be..f5d83cd13d 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/reflection/KClassTest.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/reflection/KClassTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.reflection +package com.baeldung.reflection import org.junit.Assert import org.junit.Ignore diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/reflection/KMethodTest.kt b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/reflection/KMethodTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/reflection/KMethodTest.kt rename to core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/reflection/KMethodTest.kt index 17e9913731..b58c199a7c 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/reflection/KMethodTest.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/reflection/KMethodTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.reflection +package com.baeldung.reflection import org.junit.Assert import org.junit.Test diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/stdlib/RegexTest.kt b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/regex/RegexTest.kt similarity index 95% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/stdlib/RegexTest.kt rename to core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/regex/RegexTest.kt index eeb587ee22..5cb54b4dda 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/stdlib/RegexTest.kt +++ b/core-kotlin-modules/core-kotlin-advanced/src/test/kotlin/com/baeldung/regex/RegexTest.kt @@ -1,12 +1,7 @@ -package com.baeldung.kotlin.stdlib +package com.baeldung.regex import org.junit.Test -import java.beans.ExceptionListener -import java.beans.XMLEncoder -import java.io.* -import java.lang.Exception import kotlin.test.* -import kotlin.text.RegexOption.* class RegexTest { diff --git a/core-kotlin-modules/core-kotlin-collections/README.md b/core-kotlin-modules/core-kotlin-collections/README.md new file mode 100644 index 0000000000..bbea5869af --- /dev/null +++ b/core-kotlin-modules/core-kotlin-collections/README.md @@ -0,0 +1,10 @@ +## Core Kotlin Collections + +This module contains articles about core Kotlin collections. + +### Relevant articles: +- [Split a List Into Parts in Kotlin](https://www.baeldung.com/kotlin-split-list-into-parts) +- [Finding an Element in a List Using Kotlin](https://www.baeldung.com/kotlin-finding-element-in-list) +- [Overview of Kotlin Collections API](https://www.baeldung.com/kotlin-collections-api) +- [Converting a List to Map in Kotlin](https://www.baeldung.com/kotlin-list-to-map) +- [Filtering Kotlin Collections](https://www.baeldung.com/kotlin-filter-collection) diff --git a/core-kotlin-modules/core-kotlin-collections/pom.xml b/core-kotlin-modules/core-kotlin-collections/pom.xml new file mode 100644 index 0000000000..52401d267c --- /dev/null +++ b/core-kotlin-modules/core-kotlin-collections/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + core-kotlin-collections + core-kotlin-collections + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.apache.commons + commons-math3 + ${commons-math3.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + + + 1.3.30 + 3.6.1 + 3.10.0 + + + \ No newline at end of file diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/collections/CollectionsTest.kt similarity index 99% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/collections/CollectionsTest.kt index 59d6adccac..64b1f72eab 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt +++ b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/collections/CollectionsTest.kt @@ -1,9 +1,9 @@ -package com.baeldung.kotlin +package com.baeldung.collections import org.junit.Test -import kotlin.test.assertTrue -import kotlin.test.assertFalse import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue class CollectionsTest { @@ -142,5 +142,5 @@ class CollectionsTest { val finalResult = theList.fold( 1000, { oldResult, currentItem -> oldResult + (currentItem *currentItem)}) print(finalResult) assertEquals(1091, finalResult) - } + } } \ No newline at end of file diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/ChunkedTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/ChunkedTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/filter/ChunkedTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/ChunkedTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/DistinctTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/DistinctTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/filter/DistinctTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/DistinctTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/DropTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/DropTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/filter/DropTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/DropTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/FilterTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/FilterTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/filter/FilterTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/FilterTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/SliceTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/SliceTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/filter/SliceTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/SliceTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/TakeTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/TakeTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/filter/TakeTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/filter/TakeTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsUnitTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/findelement/FindAnElementInAListUnitTest.kt similarity index 95% rename from core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsUnitTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/findelement/FindAnElementInAListUnitTest.kt index 6fa7983689..52e7e2a5b5 100644 --- a/core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/findelement/FindAnElementInAListUnitTest.kt @@ -1,11 +1,11 @@ -package com.baeldung.lists +package com.baeldung.findelement import org.junit.jupiter.api.Test import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertTrue -class ListsUnitTest { +class FindAnElementInAListUnitTest { var batmans: List = listOf("Christian Bale", "Michael Keaton", "Ben Affleck", "George Clooney") diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListToMapTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/listtomap/ListToMapTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListToMapTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/listtomap/ListToMapTest.kt index e3477931bb..93e4f11fdf 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListToMapTest.kt +++ b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/listtomap/ListToMapTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.listtomap import org.junit.Test import kotlin.test.assertTrue diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/listtomap/User.kt similarity index 71% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/listtomap/User.kt index 759627b56e..89eb9ac701 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt +++ b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/listtomap/User.kt @@ -1,3 +1,3 @@ -package com.baeldung.kotlin +package com.baeldung.listtomap data class User(val name: String, val age: Int, val hobbies: List) diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/splitting/SplittingTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/splitlist/SplitListIntoPartsTest.kt similarity index 98% rename from core-kotlin-2/src/test/kotlin/com/baeldung/splitting/SplittingTest.kt rename to core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/splitlist/SplitListIntoPartsTest.kt index a9ddc99992..627c7eaacf 100644 --- a/core-kotlin-2/src/test/kotlin/com/baeldung/splitting/SplittingTest.kt +++ b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/splitlist/SplitListIntoPartsTest.kt @@ -1,9 +1,9 @@ -package com.baeldung.lambda +package com.baeldung.splitlist import org.junit.jupiter.api.Test import kotlin.test.assertEquals -class SplittingTest { +class SplitListIntoPartsTest { private val evenList = listOf(0, "a", 1, "b", 2, "c"); private val unevenList = listOf(0, "a", 1, "b", 2, "c", 3); diff --git a/core-kotlin-modules/core-kotlin-concurrency/README.md b/core-kotlin-modules/core-kotlin-concurrency/README.md new file mode 100644 index 0000000000..09d9055a2b --- /dev/null +++ b/core-kotlin-modules/core-kotlin-concurrency/README.md @@ -0,0 +1,7 @@ +## Core Kotlin Concurrency + +This module contains articles about concurrency in Kotlin. + +### Relevant articles: +- [Threads vs Coroutines in Kotlin](https://www.baeldung.com/kotlin-threads-coroutines) +- [Introduction to Kotlin Coroutines](https://www.baeldung.com/kotlin-coroutines) diff --git a/core-kotlin-modules/core-kotlin-concurrency/pom.xml b/core-kotlin-modules/core-kotlin-concurrency/pom.xml new file mode 100644 index 0000000000..7c3b0fb5b6 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-concurrency/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + core-kotlin-concurrency + core-kotlin-concurrency + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + + + 1.3.30 + 3.10.0 + + + \ No newline at end of file diff --git a/core-kotlin/src/main/kotlin/com/baeldung/thread/SimpleRunnable.kt b/core-kotlin-modules/core-kotlin-concurrency/src/main/kotlin/com/baeldung/threadsvscoroutines/SimpleRunnable.kt similarity index 74% rename from core-kotlin/src/main/kotlin/com/baeldung/thread/SimpleRunnable.kt rename to core-kotlin-modules/core-kotlin-concurrency/src/main/kotlin/com/baeldung/threadsvscoroutines/SimpleRunnable.kt index 7bc0528d06..80ffb4077a 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/thread/SimpleRunnable.kt +++ b/core-kotlin-modules/core-kotlin-concurrency/src/main/kotlin/com/baeldung/threadsvscoroutines/SimpleRunnable.kt @@ -1,4 +1,4 @@ -package com.baeldung.thread +package com.baeldung.threadsvscoroutines class SimpleRunnable: Runnable { diff --git a/core-kotlin/src/main/kotlin/com/baeldung/thread/SimpleThread.kt b/core-kotlin-modules/core-kotlin-concurrency/src/main/kotlin/com/baeldung/threadsvscoroutines/SimpleThread.kt similarity index 74% rename from core-kotlin/src/main/kotlin/com/baeldung/thread/SimpleThread.kt rename to core-kotlin-modules/core-kotlin-concurrency/src/main/kotlin/com/baeldung/threadsvscoroutines/SimpleThread.kt index 2b2827ae02..6647dac0ef 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/thread/SimpleThread.kt +++ b/core-kotlin-modules/core-kotlin-concurrency/src/main/kotlin/com/baeldung/threadsvscoroutines/SimpleThread.kt @@ -1,4 +1,4 @@ -package com.baeldung.thread +package com.baeldung.threadsvscoroutines class SimpleThread: Thread() { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/CoroutinesUnitTest.kt b/core-kotlin-modules/core-kotlin-concurrency/src/test/kotlin/com/baeldung/coroutines/CoroutinesUnitTest.kt similarity index 99% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/CoroutinesUnitTest.kt rename to core-kotlin-modules/core-kotlin-concurrency/src/test/kotlin/com/baeldung/coroutines/CoroutinesUnitTest.kt index 324cf1109b..6b9437a8ab 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/CoroutinesUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-concurrency/src/test/kotlin/com/baeldung/coroutines/CoroutinesUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.coroutines import kotlinx.coroutines.* import org.junit.Test diff --git a/core-kotlin/src/test/kotlin/com/baeldung/thread/CoroutineUnitTest.kt b/core-kotlin-modules/core-kotlin-concurrency/src/test/kotlin/com/baeldung/threadsvscoroutines/CoroutineUnitTest.kt similarity index 96% rename from core-kotlin/src/test/kotlin/com/baeldung/thread/CoroutineUnitTest.kt rename to core-kotlin-modules/core-kotlin-concurrency/src/test/kotlin/com/baeldung/threadsvscoroutines/CoroutineUnitTest.kt index 1f1609b06b..ff385d0869 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/thread/CoroutineUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-concurrency/src/test/kotlin/com/baeldung/threadsvscoroutines/CoroutineUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.thread +package com.baeldung.threadsvscoroutines import kotlinx.coroutines.* import org.junit.jupiter.api.Test diff --git a/core-kotlin/src/test/kotlin/com/baeldung/thread/ThreadUnitTest.kt b/core-kotlin-modules/core-kotlin-concurrency/src/test/kotlin/com/baeldung/threadsvscoroutines/ThreadUnitTest.kt similarity index 94% rename from core-kotlin/src/test/kotlin/com/baeldung/thread/ThreadUnitTest.kt rename to core-kotlin-modules/core-kotlin-concurrency/src/test/kotlin/com/baeldung/threadsvscoroutines/ThreadUnitTest.kt index fa2f1edc36..9503751fa3 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/thread/ThreadUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-concurrency/src/test/kotlin/com/baeldung/threadsvscoroutines/ThreadUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.thread +package com.baeldung.threadsvscoroutines import org.junit.jupiter.api.Test import kotlin.concurrent.thread diff --git a/core-kotlin-modules/core-kotlin-lang-2/README.md b/core-kotlin-modules/core-kotlin-lang-2/README.md new file mode 100644 index 0000000000..e64a39cb9b --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-2/README.md @@ -0,0 +1,13 @@ +## Core Kotlin Lang + +This module contains articles about core features in the Kotlin language. + +### Relevant articles: +- [Kotlin return, break, continue Keywords](https://www.baeldung.com/kotlin-return-break-continue) +- [Infix Functions in Kotlin](https://www.baeldung.com/kotlin-infix-functions) +- [Lambda Expressions in Kotlin](https://www.baeldung.com/kotlin-lambda-expressions) +- [Creating Java static final Equivalents in Kotlin](https://www.baeldung.com/kotlin-java-static-final) +- [Initializing Arrays in Kotlin](https://www.baeldung.com/kotlin-initialize-array) +- [Lazy Initialization in Kotlin](https://www.baeldung.com/kotlin-lazy-initialization) +- [Comprehensive Guide to Null Safety in Kotlin](https://www.baeldung.com/kotlin-null-safety) +- [[<-- Prev]](/core-kotlin-modules/core-kotlin-lang) diff --git a/core-kotlin-modules/core-kotlin-lang-2/pom.xml b/core-kotlin-modules/core-kotlin-lang-2/pom.xml new file mode 100644 index 0000000000..753147728d --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-2/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + core-kotlin-lang-2 + core-kotlin-lang-2 + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + \ No newline at end of file diff --git a/core-kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java b/core-kotlin-modules/core-kotlin-lang-2/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java similarity index 100% rename from core-kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java rename to core-kotlin-modules/core-kotlin-lang-2/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java diff --git a/core-kotlin/src/main/kotlin/com/baeldung/lambda/Lambda.kt b/core-kotlin-modules/core-kotlin-lang-2/src/main/kotlin/com/baeldung/lambda/Lambda.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/lambda/Lambda.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/main/kotlin/com/baeldung/lambda/Lambda.kt diff --git a/core-kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java b/core-kotlin-modules/core-kotlin-lang-2/src/test/java/com/baeldung/lazy/LazyJavaUnitTest.java similarity index 86% rename from core-kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java rename to core-kotlin-modules/core-kotlin-lang-2/src/test/java/com/baeldung/lazy/LazyJavaUnitTest.java index e2fe58d537..01c87d9543 100644 --- a/core-kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/java/com/baeldung/lazy/LazyJavaUnitTest.java @@ -1,7 +1,5 @@ -package com.baeldung.kotlin; +package com.baeldung.lazy; - -import com.baeldung.lazy.ClassWithHeavyInitialization; import org.junit.Test; import static junit.framework.TestCase.assertTrue; diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayInitializationTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/arrayinitialization/ArrayInitializationTest.kt similarity index 96% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayInitializationTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/arrayinitialization/ArrayInitializationTest.kt index ba3694c831..d4b9d607fb 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayInitializationTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/arrayinitialization/ArrayInitializationTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.arrayinitialization import org.junit.Test import kotlin.test.assertEquals diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/ConstantUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/ConstantUnitTest.kt similarity index 79% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/ConstantUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/ConstantUnitTest.kt index 51d45b8df0..d9bf433208 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/ConstantUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/ConstantUnitTest.kt @@ -1,5 +1,5 @@ -import com.baeldung.kotlin.constant.TestKotlinConstantClass -import com.baeldung.kotlin.constant.TestKotlinConstantObject +package com.baeldung.constant + import org.junit.jupiter.api.Test import kotlin.test.assertEquals diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantClass.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantClass.kt similarity index 75% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantClass.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantClass.kt index 8bcc327999..3c4d4db220 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantClass.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantClass.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.constant +package com.baeldung.constant class TestKotlinConstantClass { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantObject.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantObject.kt similarity index 87% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantObject.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantObject.kt index 815fdeaf14..a6951b4481 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantObject.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantObject.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.constant +package com.baeldung.constant object TestKotlinConstantObject { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/InfixFunctionsTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/infixfunctions/InfixFunctionsTest.kt similarity index 97% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/InfixFunctionsTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/infixfunctions/InfixFunctionsTest.kt index fc4286460a..0b09d34013 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/InfixFunctionsTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/infixfunctions/InfixFunctionsTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.infixfunctions import org.junit.Assert import org.junit.Test diff --git a/core-kotlin/src/test/java/com/baeldung/lambda/LambdaKotlinUnitTest.java b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaKotlinUnitTest.java similarity index 100% rename from core-kotlin/src/test/java/com/baeldung/lambda/LambdaKotlinUnitTest.java rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaKotlinUnitTest.java diff --git a/core-kotlin/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt similarity index 99% rename from core-kotlin/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt index 3af00c98ff..bddabee462 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test import kotlin.test.assertEquals class LambdaTest { + @Test fun whenCallingALambda_thenPerformTheAction() { assertEquals(9, inferredType(3)) diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lazy/LazyUnitTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lazy/LazyUnitTest.kt index 1169fb9193..b9b21ed4d9 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lazy/LazyUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.lazy import org.junit.Test import java.util.concurrent.CountDownLatch diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/nullsafety/NullSafetyTest.kt similarity index 99% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/nullsafety/NullSafetyTest.kt index 0ecc74b6fb..66fc043581 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/nullsafety/NullSafetyTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.nullsafety import org.junit.Test import kotlin.test.assertEquals @@ -8,6 +8,7 @@ import kotlin.test.assertTrue class NullSafetyTest { + @Test fun givenNonNullableField_whenAssignValueToIt_thenNotNeedToCheckAgainstNull() { //given diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/StructuralJumpUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/structuraljump/StructuralJumpUnitTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/StructuralJumpUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/structuraljump/StructuralJumpUnitTest.kt index 436dc9e2ba..88011ab396 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/StructuralJumpUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/structuraljump/StructuralJumpUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.structuraljump import org.junit.Test import kotlin.test.assertEquals diff --git a/core-kotlin-modules/core-kotlin-lang-oop-2/README.md b/core-kotlin-modules/core-kotlin-lang-oop-2/README.md new file mode 100644 index 0000000000..27536273dc --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-oop-2/README.md @@ -0,0 +1,10 @@ +## Core Kotlin Lang OOP + +This module contains articles about Object-Oriented Programming in Kotlin + +### Relevant articles: + +- [Generics in Kotlin](https://www.baeldung.com/kotlin-generics) +- [Delegated Properties in Kotlin](https://www.baeldung.com/kotlin-delegated-properties) +- [Delegation Pattern in Kotlin](https://www.baeldung.com/kotlin-delegation-pattern) +- [[<-- Prev]](/core-kotlin-modules/core-kotlin-lang-oop) diff --git a/core-kotlin-modules/core-kotlin-lang-oop-2/pom.xml b/core-kotlin-modules/core-kotlin-lang-oop-2/pom.xml new file mode 100644 index 0000000000..f0adea121e --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-oop-2/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + core-kotlin-lang-oop-2 + core-kotlin-lang-oop-2 + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + \ No newline at end of file diff --git a/core-kotlin/src/main/kotlin/com/baeldung/generic/Reified.kt b/core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/generic/Reified.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/generic/Reified.kt rename to core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/generic/Reified.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt b/core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt rename to core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/kotlin/delegates/Database.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt b/core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt rename to core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegate.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/InterfaceDelegation.kt b/core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/kotlin/delegates/InterfaceDelegation.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/InterfaceDelegation.kt rename to core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/kotlin/delegates/InterfaceDelegation.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/User.kt b/core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/kotlin/delegates/User.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/delegates/User.kt rename to core-kotlin-modules/core-kotlin-lang-oop-2/src/main/kotlin/com/baeldung/kotlin/delegates/User.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/GenericsTest.kt b/core-kotlin-modules/core-kotlin-lang-oop-2/src/test/kotlin/com/baeldung/GenericsTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/GenericsTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop-2/src/test/kotlin/com/baeldung/GenericsTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt b/core-kotlin-modules/core-kotlin-lang-oop-2/src/test/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop-2/src/test/kotlin/com/baeldung/kotlin/delegates/DatabaseDelegatesTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/delegates/InterfaceDelegationTest.kt b/core-kotlin-modules/core-kotlin-lang-oop-2/src/test/kotlin/com/baeldung/kotlin/delegates/InterfaceDelegationTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/delegates/InterfaceDelegationTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop-2/src/test/kotlin/com/baeldung/kotlin/delegates/InterfaceDelegationTest.kt diff --git a/core-kotlin-modules/core-kotlin-lang-oop/README.md b/core-kotlin-modules/core-kotlin-lang-oop/README.md new file mode 100644 index 0000000000..0c1aeb7850 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-oop/README.md @@ -0,0 +1,17 @@ +## Core Kotlin Lang OOP + +This module contains articles about Object-Oriented Programming in Kotlin + +### Relevant articles: + +- [Data Classes in Kotlin](https://www.baeldung.com/kotlin-data-classes) +- [Sealed Classes in Kotlin](https://www.baeldung.com/kotlin-sealed-classes) +- [Extension Methods in Kotlin](https://www.baeldung.com/kotlin-extension-methods) +- [Objects in Kotlin](https://www.baeldung.com/kotlin-objects) +- [Working with Enums in Kotlin](https://www.baeldung.com/kotlin-enum) +- [Kotlin Constructors](https://www.baeldung.com/kotlin-constructors) +- [Kotlin Nested and Inner Classes](https://www.baeldung.com/kotlin-inner-classes) +- [Guide to Kotlin Interfaces](https://www.baeldung.com/kotlin-interfaces) +- [Inline Classes in Kotlin](https://www.baeldung.com/kotlin-inline-classes) +- [Static Methods Behavior in Kotlin](https://www.baeldung.com/kotlin-static-methods) +- More articles: [[next -->]](/core-kotlin-modules/core-kotlin-lang-oop-2) diff --git a/core-kotlin-modules/core-kotlin-lang-oop/pom.xml b/core-kotlin-modules/core-kotlin-lang-oop/pom.xml new file mode 100644 index 0000000000..03fc80f07d --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-oop/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + core-kotlin-lang-oop + core-kotlin-lang-oop + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + \ No newline at end of file diff --git a/core-kotlin/src/main/java/com/baeldung/constructor/Car.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/java/com/baeldung/constructor/Car.kt similarity index 100% rename from core-kotlin/src/main/java/com/baeldung/constructor/Car.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/java/com/baeldung/constructor/Car.kt diff --git a/core-kotlin/src/main/java/com/baeldung/constructor/Employee.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/java/com/baeldung/constructor/Employee.kt similarity index 100% rename from core-kotlin/src/main/java/com/baeldung/constructor/Employee.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/java/com/baeldung/constructor/Employee.kt diff --git a/core-kotlin/src/main/java/com/baeldung/constructor/Person.java b/core-kotlin-modules/core-kotlin-lang-oop/src/main/java/com/baeldung/constructor/Person.java similarity index 100% rename from core-kotlin/src/main/java/com/baeldung/constructor/Person.java rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/java/com/baeldung/constructor/Person.java diff --git a/core-kotlin/src/main/java/com/baeldung/dataclass/Movie.java b/core-kotlin-modules/core-kotlin-lang-oop/src/main/java/com/baeldung/dataclass/Movie.java similarity index 100% rename from core-kotlin/src/main/java/com/baeldung/dataclass/Movie.java rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/java/com/baeldung/dataclass/Movie.java diff --git a/core-kotlin/src/main/kotlin/com/baeldung/constructor/Person.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/constructor/Person.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/constructor/Person.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/constructor/Person.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/dataclass/Movie.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/dataclass/Movie.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/dataclass/Movie.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/dataclass/Movie.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/dataclass/Sandbox.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/dataclass/Sandbox.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/dataclass/Sandbox.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/dataclass/Sandbox.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/enums/CardType.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/enums/CardType.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/enums/CardType.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/enums/CardType.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/enums/ICardLimit.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/enums/ICardLimit.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/enums/ICardLimit.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/enums/ICardLimit.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/inline/classes/CircleRadius.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/inline/classes/CircleRadius.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/inline/classes/CircleRadius.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/inline/classes/CircleRadius.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/inline/classes/InlineDoubleWrapper.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/inline/classes/InlineDoubleWrapper.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/inline/classes/InlineDoubleWrapper.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/inline/classes/InlineDoubleWrapper.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/interfaces/ConflictingInterfaces.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/interfaces/ConflictingInterfaces.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/interfaces/ConflictingInterfaces.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/interfaces/ConflictingInterfaces.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/interfaces/InterfaceDelegation.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/interfaces/InterfaceDelegation.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/interfaces/InterfaceDelegation.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/interfaces/InterfaceDelegation.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/interfaces/MultipleInterfaces.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/interfaces/MultipleInterfaces.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/interfaces/MultipleInterfaces.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/interfaces/MultipleInterfaces.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/interfaces/SimpleInterface.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/interfaces/SimpleInterface.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/interfaces/SimpleInterface.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/interfaces/SimpleInterface.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/Sealed.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/kotlin/Sealed.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/Sealed.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/kotlin/Sealed.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/StringUtil.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/kotlin/StringUtil.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/StringUtil.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/kotlin/StringUtil.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/nested/Computer.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/nested/Computer.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/nested/Computer.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/nested/Computer.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/static/ConsoleUtils.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/static/ConsoleUtils.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/static/ConsoleUtils.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/static/ConsoleUtils.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/static/LoggingUtils.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/static/LoggingUtils.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/static/LoggingUtils.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/main/kotlin/com/baeldung/static/LoggingUtils.kt diff --git a/core-kotlin/src/test/java/com/baeldung/kotlin/StringUtilUnitTest.java b/core-kotlin-modules/core-kotlin-lang-oop/src/test/java/com/baeldung/kotlin/StringUtilUnitTest.java similarity index 100% rename from core-kotlin/src/test/java/com/baeldung/kotlin/StringUtilUnitTest.java rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/java/com/baeldung/kotlin/StringUtilUnitTest.java diff --git a/core-kotlin/src/test/kotlin/com/baeldung/enums/CardTypeUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/enums/CardTypeUnitTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/enums/CardTypeUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/enums/CardTypeUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/inline/classes/CircleRadiusTest.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/inline/classes/CircleRadiusTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/inline/classes/CircleRadiusTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/inline/classes/CircleRadiusTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/inline/classes/InlineDoubleWrapperTest.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/inline/classes/InlineDoubleWrapperTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/inline/classes/InlineDoubleWrapperTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/inline/classes/InlineDoubleWrapperTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/interfaces/InterfaceExamplesUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/interfaces/InterfaceExamplesUnitTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/interfaces/InterfaceExamplesUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/interfaces/InterfaceExamplesUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ExtensionMethods.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/ExtensionMethods.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/ExtensionMethods.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/ExtensionMethods.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/SealedTest.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/SealedTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/SealedTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/SealedTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/Counter.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/Counter.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/Counter.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/Counter.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/ObjectsTest.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/ObjectsTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/ObjectsTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/ObjectsTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/OuterClass.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/OuterClass.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/OuterClass.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/OuterClass.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/ReverseStringComparator.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/ReverseStringComparator.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/ReverseStringComparator.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/ReverseStringComparator.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/SimpleSingleton.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/SimpleSingleton.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/SimpleSingleton.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/SimpleSingleton.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/StaticClass.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/StaticClass.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/objects/StaticClass.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/kotlin/objects/StaticClass.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/nested/ComputerUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/nested/ComputerUnitTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/nested/ComputerUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/nested/ComputerUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/static/ConsoleUtilsUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/static/ConsoleUtilsUnitTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/static/ConsoleUtilsUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/static/ConsoleUtilsUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/static/LoggingUtilsUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/static/LoggingUtilsUnitTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/static/LoggingUtilsUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-oop/src/test/kotlin/com/baeldung/static/LoggingUtilsUnitTest.kt diff --git a/core-kotlin-modules/core-kotlin-lang/README.md b/core-kotlin-modules/core-kotlin-lang/README.md new file mode 100644 index 0000000000..eaeae76854 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang/README.md @@ -0,0 +1,16 @@ +## Core Kotlin Lang + +This module contains articles about core features in the Kotlin language. + +### Relevant articles: +- [Guide to the “when{}” Block in Kotlin](https://www.baeldung.com/kotlin-when) +- [Difference Between “==” and “===” Operators in Kotlin](https://www.baeldung.com/kotlin-equality-operators) +- [Nested forEach in Kotlin](https://www.baeldung.com/kotlin-nested-foreach) +- [Destructuring Declarations in Kotlin](https://www.baeldung.com/kotlin-destructuring-declarations) +- [Try-with-resources in Kotlin](https://www.baeldung.com/kotlin-try-with-resources) +- [Operator Overloading in Kotlin](https://www.baeldung.com/kotlin-operator-overloading) +- [Inline Functions in Kotlin](https://www.baeldung.com/kotlin-inline-functions) +- [Void Type in Kotlin](https://www.baeldung.com/kotlin-void-type) +- [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges) +- [Creating a Kotlin Range Iterator on a Custom Object](https://www.baeldung.com/kotlin-custom-range-iterator) +- [[More --> ]](/core-kotlin-modules/core-kotlin-lang-2) diff --git a/core-kotlin-modules/core-kotlin-lang/pom.xml b/core-kotlin-modules/core-kotlin-lang/pom.xml new file mode 100644 index 0000000000..d3ac7f690c --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + core-kotlin-lang + core-kotlin-lang + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + \ No newline at end of file diff --git a/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt similarity index 94% rename from core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt index a5018d93c8..f845d01539 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt @@ -1,7 +1,5 @@ package com.baeldung.destructuringdeclarations -import com.baeldung.destructuringdeclarations.Person - fun main(args: Array) { //2.1. Objects diff --git a/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/equalityoperators/User.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/equalityoperators/User.kt new file mode 100644 index 0000000000..030169bb8a --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/equalityoperators/User.kt @@ -0,0 +1,3 @@ +package com.baeldung.equalityoperators + +data class User(val name: String, val age: Int, val hobbies: List) diff --git a/core-kotlin/src/main/kotlin/com/baeldung/forEach/forEach.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/forEach/forEach.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/forEach/forEach.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/forEach/forEach.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/functions/Inline.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt similarity index 95% rename from core-kotlin/src/main/kotlin/com/baeldung/functions/Inline.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt index 239c425c03..3b179642ba 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/functions/Inline.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt @@ -1,4 +1,4 @@ -package com.baeldung.functions +package com.baeldung.inline import kotlin.random.Random diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Money.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Money.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/operators/Money.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Money.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Page.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Page.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/operators/Page.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Page.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Point.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Point.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/operators/Point.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Point.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Utils.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Utils.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/operators/Utils.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Utils.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/CharRange.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/CharRange.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/CharRange.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/CharRange.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/Color.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Color.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/Color.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Color.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/Filter.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Filter.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/Filter.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Filter.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/FirstLast.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/FirstLast.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/FirstLast.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/FirstLast.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/OtherRangeFunctions.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/OtherRangeFunctions.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/OtherRangeFunctions.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/OtherRangeFunctions.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/Range.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Range.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/Range.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Range.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/ReverseRange.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/ReverseRange.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/ReverseRange.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/ReverseRange.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/Step.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Step.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/Step.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Step.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/UntilRange.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/UntilRange.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/UntilRange.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/UntilRange.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/CustomColor.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/rangeiterator/CustomColor.kt similarity index 84% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/CustomColor.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/rangeiterator/CustomColor.kt index b4fed13b18..c1ab8e1610 100644 --- a/core-kotlin-2/src/main/kotlin/com/baeldung/range/CustomColor.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/rangeiterator/CustomColor.kt @@ -1,4 +1,4 @@ -package com.baeldung.range +package com.baeldung.rangeiterator import java.lang.IllegalStateException @@ -8,7 +8,7 @@ class CustomColor(val rgb: Int): Comparable { return this.rgb.compareTo(other.rgb) } - operator fun rangeTo(that: CustomColor) = ColorRange(this,that) + operator fun rangeTo(that: CustomColor) = ColorRange(this, that) operator fun inc(): CustomColor { return CustomColor(rgb + 1) @@ -25,7 +25,7 @@ class CustomColor(val rgb: Int): Comparable { } } class ColorRange(override val start: CustomColor, - override val endInclusive: CustomColor) : ClosedRange, Iterable{ + override val endInclusive: CustomColor) : ClosedRange, Iterable{ override fun iterator(): Iterator { return ColorIterator(start, endInclusive) diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/whenblock/WhenBlockTypes.kt similarity index 95% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/whenblock/WhenBlockTypes.kt index 6180da10d9..a4cd7b98f0 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/whenblock/WhenBlockTypes.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.whenblock enum class UnixFileType { D, HYPHEN_MINUS, L diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/equalityoperators/EqualityTest.kt similarity index 97% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/equalityoperators/EqualityTest.kt index 6fb6d0a288..0728d55b73 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/equalityoperators/EqualityTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.equalityoperators import org.junit.Test import kotlin.test.assertFalse diff --git a/core-kotlin/src/test/kotlin/com/baeldung/operators/PageTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/PageTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/operators/PageTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/PageTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/operators/PointTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/PointTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/operators/PointTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/PointTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/operators/UtilsTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/UtilsTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/operators/UtilsTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/UtilsTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/CharRangeTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/CharRangeTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/CharRangeTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/CharRangeTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/ColorTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/ColorTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/ColorTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/ColorTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/FilterTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/FilterTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/FilterTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/FilterTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/FirstLastTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/FirstLastTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/FirstLastTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/FirstLastTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/OtherRangeFunctionsTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/OtherRangeFunctionsTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/OtherRangeFunctionsTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/OtherRangeFunctionsTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/RangeTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/RangeTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/RangeTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/RangeTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/ReverseRangeTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/ReverseRangeTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/ReverseRangeTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/ReverseRangeTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/StepTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/StepTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/StepTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/StepTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/UntilRangeTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/UntilRangeTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/UntilRangeTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/UntilRangeTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/CustomColorTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/rangeiterator/CustomColorTest.kt similarity index 95% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/CustomColorTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/rangeiterator/CustomColorTest.kt index 8c8795ac42..676b47ae7a 100644 --- a/core-kotlin-2/src/test/kotlin/com/baeldung/range/CustomColorTest.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/rangeiterator/CustomColorTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.range +package com.baeldung.rangeiterator import org.junit.Test import java.lang.IllegalStateException diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/UseTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/trywithresource/UseTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/UseTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/trywithresource/UseTest.kt index 15bdfcafd8..d17832b380 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/UseTest.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/trywithresource/UseTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.trywithresource import org.junit.Test import java.beans.ExceptionListener diff --git a/core-kotlin-2/src/test/kotlin/voidtypes/VoidTypesUnitTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/voidtypes/VoidTypesUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/whenblock/WhenBlockUnitTest.kt similarity index 99% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/whenblock/WhenBlockUnitTest.kt index aa1891fa46..31b6ad69f5 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/whenblock/WhenBlockUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.whenblock import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue diff --git a/core-kotlin-modules/core-kotlin/README.md b/core-kotlin-modules/core-kotlin/README.md new file mode 100644 index 0000000000..8815b0fadd --- /dev/null +++ b/core-kotlin-modules/core-kotlin/README.md @@ -0,0 +1,16 @@ +## Core Kotlin + +This module contains articles about Kotlin core features. + +### Relevant articles: +- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin) +- [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability) +- [Get a Random Number in Kotlin](https://www.baeldung.com/kotlin-random-number) +- [Create a Java and Kotlin Project with Maven](https://www.baeldung.com/kotlin-maven-java-project) +- [Guide to Sorting in Kotlin](https://www.baeldung.com/kotlin-sort) +- [Creational Design Patterns in Kotlin: Builder](https://www.baeldung.com/kotlin-builder-pattern) +- [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions) +- [Implementing a Binary Tree in Kotlin](https://www.baeldung.com/kotlin-binary-tree) +- [JUnit 5 for Kotlin Developers](https://www.baeldung.com/junit-5-kotlin) +- [Converting Kotlin Data Class from JSON using GSON](https://www.baeldung.com/kotlin-json-convert-data-class) +- [[More --> ]](/core-kotlin-modules/core-kotlin-2) diff --git a/core-kotlin-modules/core-kotlin/pom.xml b/core-kotlin-modules/core-kotlin/pom.xml new file mode 100644 index 0000000000..6e36b7c8ef --- /dev/null +++ b/core-kotlin-modules/core-kotlin/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + core-kotlin + core-kotlin + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + + + 1.1.1 + + + \ No newline at end of file diff --git a/core-kotlin/src/main/java/com/baeldung/java/ArrayExample.java b/core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/interoperability/ArrayExample.java similarity index 91% rename from core-kotlin/src/main/java/com/baeldung/java/ArrayExample.java rename to core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/interoperability/ArrayExample.java index ef91db517b..93b9a3984a 100644 --- a/core-kotlin/src/main/java/com/baeldung/java/ArrayExample.java +++ b/core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/interoperability/ArrayExample.java @@ -1,4 +1,4 @@ -package com.baeldung.java; +package com.baeldung.interoperability; import java.io.File; import java.io.FileReader; diff --git a/core-kotlin/src/main/java/com/baeldung/java/Customer.java b/core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/interoperability/Customer.java similarity index 91% rename from core-kotlin/src/main/java/com/baeldung/java/Customer.java rename to core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/interoperability/Customer.java index 0156bf7b44..4a070a0f97 100644 --- a/core-kotlin/src/main/java/com/baeldung/java/Customer.java +++ b/core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/interoperability/Customer.java @@ -1,4 +1,4 @@ -package com.baeldung.java; +package com.baeldung.interoperability; public class Customer { diff --git a/core-kotlin/src/main/java/com/baeldung/java/StringUtils.java b/core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/introduction/StringUtils.java similarity index 77% rename from core-kotlin/src/main/java/com/baeldung/java/StringUtils.java rename to core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/introduction/StringUtils.java index f405924cdf..1c477ce039 100644 --- a/core-kotlin/src/main/java/com/baeldung/java/StringUtils.java +++ b/core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/introduction/StringUtils.java @@ -1,4 +1,4 @@ -package com.baeldung.java; +package com.baeldung.introduction; public class StringUtils { public static String toUpperCase(String name) { diff --git a/core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/Application.java b/core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/Application.java similarity index 91% rename from core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/Application.java rename to core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/Application.java index e2cc0f1e01..ac933d6228 100644 --- a/core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/Application.java +++ b/core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/Application.java @@ -1,7 +1,6 @@ package com.baeldung.mavenjavakotlin; import com.baeldung.mavenjavakotlin.services.JavaService; -import com.baeldung.mavenjavakotlin.services.KotlinService; public class Application { diff --git a/core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/services/JavaService.java b/core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/services/JavaService.java similarity index 100% rename from core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/services/JavaService.java rename to core-kotlin-modules/core-kotlin/src/main/java/com/baeldung/mavenjavakotlin/services/JavaService.java diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datastructures/Main.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/binarytree/Main.kt similarity index 93% rename from core-kotlin/src/main/kotlin/com/baeldung/datastructures/Main.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/binarytree/Main.kt index 4fd8aa27c7..eee10fbd8b 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/datastructures/Main.kt +++ b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/binarytree/Main.kt @@ -1,4 +1,4 @@ -package com.baeldung.datastructures +package com.baeldung.binarytree /** * Example of how to use the {@link Node} class. diff --git a/core-kotlin/src/main/kotlin/com/baeldung/datastructures/Node.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/binarytree/Node.kt similarity index 99% rename from core-kotlin/src/main/kotlin/com/baeldung/datastructures/Node.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/binarytree/Node.kt index b81afe1e4c..77bb98f828 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/datastructures/Node.kt +++ b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/binarytree/Node.kt @@ -1,4 +1,4 @@ -package com.baeldung.datastructures +package com.baeldung.binarytree /** * An ADT for a binary search tree. diff --git a/core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrder.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrder.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrder.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrder.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrderApply.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrderApply.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrderApply.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrderApply.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrderNamed.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrderNamed.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrderNamed.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/builder/FoodOrderNamed.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/builder/Main.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/builder/Main.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/builder/Main.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/builder/Main.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/Example1.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/Example1.kt similarity index 63% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/Example1.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/Example1.kt index bca1e54a6c..aacd8f7915 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/Example1.kt +++ b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/Example1.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.introduction fun main(args: Array){ println("hello word") diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/Item.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/Item.kt similarity index 89% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/Item.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/Item.kt index 36994e4994..bb91dd1eae 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/Item.kt +++ b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/Item.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.introduction open class Item(val id: String, val name: String = "unknown_name") { open fun getIdOfItem(): String { diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/ItemService.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/ItemService.kt similarity index 98% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/ItemService.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/ItemService.kt index 88de1aa9be..dfcf17df7c 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/ItemService.kt +++ b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/ItemService.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.introduction import java.util.* diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/ListExtension.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/ListExtension.kt similarity index 90% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/ListExtension.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/ListExtension.kt index da1773b7c9..e71292c60a 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/ListExtension.kt +++ b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/ListExtension.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.introduction import java.util.concurrent.ThreadLocalRandom diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/MathematicsOperations.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/MathematicsOperations.kt similarity index 75% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/MathematicsOperations.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/MathematicsOperations.kt index 924f9d2323..0ed30ed5b4 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/MathematicsOperations.kt +++ b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/introduction/MathematicsOperations.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.introduction class MathematicsOperations { fun addTwoNumbers(a: Int, b: Int): Int { diff --git a/core-kotlin/src/main/kotlin/com/baeldung/mavenjavakotlin/services/KotlinService.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/mavenjavakotlin/KotlinService.kt similarity index 70% rename from core-kotlin/src/main/kotlin/com/baeldung/mavenjavakotlin/services/KotlinService.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/mavenjavakotlin/KotlinService.kt index 114b1c88df..10d6a792d8 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/mavenjavakotlin/services/KotlinService.kt +++ b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/mavenjavakotlin/KotlinService.kt @@ -1,4 +1,4 @@ -package com.baeldung.mavenjavakotlin.services +package com.baeldung.mavenjavakotlin class KotlinService { diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/scope/ScopeFunctions.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/scope/ScopeFunctions.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/scope/ScopeFunctions.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/scope/ScopeFunctions.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/sorting/SortingExample.kt b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/sorting/SortingExample.kt similarity index 97% rename from core-kotlin/src/main/kotlin/com/baeldung/sorting/SortingExample.kt rename to core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/sorting/SortingExample.kt index 2309d23c36..bf3163bc8f 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/sorting/SortingExample.kt +++ b/core-kotlin-modules/core-kotlin/src/main/kotlin/com/baeldung/sorting/SortingExample.kt @@ -1,7 +1,5 @@ package com.baeldung.sorting -import kotlin.comparisons.* - fun sortMethodUsage() { val sortedValues = mutableListOf(1, 2, 7, 6, 5, 6) sortedValues.sort() diff --git a/core-kotlin/src/test/java/com/baeldung/kotlin/JavaCallToKotlinUnitTest.java b/core-kotlin-modules/core-kotlin/src/test/java/com/baeldung/introduction/JavaCallToKotlinUnitTest.java similarity index 90% rename from core-kotlin/src/test/java/com/baeldung/kotlin/JavaCallToKotlinUnitTest.java rename to core-kotlin-modules/core-kotlin/src/test/java/com/baeldung/introduction/JavaCallToKotlinUnitTest.java index 370f24785a..2c386eaad3 100644 --- a/core-kotlin/src/test/java/com/baeldung/kotlin/JavaCallToKotlinUnitTest.java +++ b/core-kotlin-modules/core-kotlin/src/test/java/com/baeldung/introduction/JavaCallToKotlinUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.kotlin; +package com.baeldung.introduction; import org.junit.Test; diff --git a/core-kotlin/src/test/kotlin/com/baeldung/datastructures/NodeTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/binarytree/NodeTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/datastructures/NodeTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/binarytree/NodeTest.kt index 8a46c5f6ec..9414d7dde9 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/datastructures/NodeTest.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/binarytree/NodeTest.kt @@ -1,7 +1,8 @@ -package com.baeldung.datastructures +package com.baeldung.binarytree import org.junit.After -import org.junit.Assert.* +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull import org.junit.Before import org.junit.Test diff --git a/core-kotlin/src/test/kotlin/com/baeldung/builder/BuilderPatternUnitTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/builder/BuilderPatternUnitTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/builder/BuilderPatternUnitTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/builder/BuilderPatternUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/gson/GsonUnitTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/gson/GsonUnitTest.kt similarity index 87% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/gson/GsonUnitTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/gson/GsonUnitTest.kt index bdf44d3b49..9159be96be 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/gson/GsonUnitTest.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/gson/GsonUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.gson +package com.baeldung.gson import com.google.gson.Gson @@ -11,7 +11,7 @@ class GsonUnitTest { @Test fun givenObject_thenGetJSONString() { - var jsonString = gson.toJson(TestModel(1,"Test")) + var jsonString = gson.toJson(TestModel(1, "Test")) Assert.assertEquals(jsonString, "{\"id\":1,\"description\":\"Test\"}") } diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/interoperability/ArrayTest.kt similarity index 82% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/interoperability/ArrayTest.kt index f7d1c53b13..8e9467f92a 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayTest.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/interoperability/ArrayTest.kt @@ -1,7 +1,5 @@ -package com.baeldung.kotlin +package com.baeldung.interoperability -import com.baeldung.java.ArrayExample -import com.baeldung.java.Customer import org.junit.Test import kotlin.test.assertEquals @@ -29,7 +27,7 @@ class ArrayTest { val constructors = instance.constructors assertEquals(constructors.size, 1) - assertEquals(constructors[0].name, "com.baeldung.java.Customer") + assertEquals(constructors[0].name, "com.baeldung.interoperability.Customer") } fun makeReadFile() { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/CustomerTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/interoperability/CustomerTest.kt similarity index 88% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/CustomerTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/interoperability/CustomerTest.kt index 6395dfcfed..c1b09cd0c1 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/CustomerTest.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/interoperability/CustomerTest.kt @@ -1,6 +1,5 @@ -package com.baeldung.kotlin +package com.baeldung.interoperability -import com.baeldung.java.Customer import org.junit.Test import kotlin.test.assertEquals diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ItemServiceTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/ItemServiceTest.kt similarity index 92% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/ItemServiceTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/ItemServiceTest.kt index 3d730b1283..2ba14a7462 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ItemServiceTest.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/ItemServiceTest.kt @@ -1,9 +1,10 @@ -package com.baeldung.kotlin +package com.baeldung.introduction import org.junit.Test import kotlin.test.assertNotNull class ItemServiceTest { + @Test fun givenItemId_whenGetForOptionalItem_shouldMakeActionOnNonNullValue() { //given diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/KotlinJavaInteroperabilityTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/KotlinJavaInteroperabilityTest.kt similarity index 84% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/KotlinJavaInteroperabilityTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/KotlinJavaInteroperabilityTest.kt index 91ccaabf6f..5dddf9bfc9 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/KotlinJavaInteroperabilityTest.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/KotlinJavaInteroperabilityTest.kt @@ -1,6 +1,5 @@ -package com.baeldung.kotlin +package com.baeldung.introduction -import com.baeldung.java.StringUtils import org.junit.Test import kotlin.test.assertEquals diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/LambdaTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/LambdaTest.kt similarity index 91% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/LambdaTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/LambdaTest.kt index 34217336a0..5e5166074e 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/LambdaTest.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/LambdaTest.kt @@ -1,10 +1,11 @@ -package com.baeldung.kotlin +package com.baeldung.introduction import org.junit.Test import kotlin.test.assertEquals class LambdaTest { + @Test fun givenListOfNumber_whenDoingOperationsUsingLambda_shouldReturnProperResult() { //given diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListExtensionTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/ListExtensionTest.kt similarity index 79% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListExtensionTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/ListExtensionTest.kt index 7a496e7437..38f244297b 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ListExtensionTest.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/introduction/ListExtensionTest.kt @@ -1,12 +1,12 @@ -package com.baeldung.kotlin +package com.baeldung.introduction -import com.baeldung.kotlin.ListExtension import org.junit.Test import kotlin.test.assertTrue class ListExtensionTest { + @Test - fun givenList_whenExecuteExtensionFunctionOnList_shouldReturnRandomElementOfList(){ + fun givenList_whenExecuteExtensionFunctionOnList_shouldReturnRandomElementOfList() { //given val elements = listOf("a", "b", "c") diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/Calculator.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/Calculator.kt similarity index 91% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/Calculator.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/Calculator.kt index 1b61c05887..9f6e3ab2b9 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/Calculator.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/Calculator.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.junit5 +package com.baeldung.junit5 class Calculator { fun add(a: Int, b: Int) = a + b diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/CalculatorTest5.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/CalculatorUnitTest.kt similarity index 97% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/CalculatorTest5.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/CalculatorUnitTest.kt index daaedca5a3..07cab3b76e 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/CalculatorTest5.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/CalculatorUnitTest.kt @@ -1,9 +1,9 @@ -package com.baeldung.kotlin.junit5 +package com.baeldung.junit5 import org.junit.jupiter.api.* import org.junit.jupiter.api.function.Executable -class CalculatorTest5 { +class CalculatorUnitTest { private val calculator = Calculator() @Test diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/DivideByZeroException.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/DivideByZeroException.kt similarity index 64% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/DivideByZeroException.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/DivideByZeroException.kt index 60bc4e2944..5675367fd5 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/DivideByZeroException.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/DivideByZeroException.kt @@ -1,3 +1,3 @@ -package com.baeldung.kotlin.junit5 +package com.baeldung.junit5 class DivideByZeroException(val numerator: Int) : Exception() diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/SimpleTest5.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/SimpleUnitTest.kt similarity index 88% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/SimpleTest5.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/SimpleUnitTest.kt index 15ff201430..e3fe998efd 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/SimpleTest5.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/junit5/SimpleUnitTest.kt @@ -1,10 +1,10 @@ -package com.baeldung.kotlin.junit5 +package com.baeldung.junit5 import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -class SimpleTest5 { +class SimpleUnitTest { @Test fun `isEmpty should return true for empty lists`() { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/random/RandomNumberTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/random/RandomNumberTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/random/RandomNumberTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/random/RandomNumberTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/scope/ScopeFunctionsUnitTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/scope/ScopeFunctionsUnitTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/scope/ScopeFunctionsUnitTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/scope/ScopeFunctionsUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/sorting/SortingExampleKtTest.kt b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/sorting/SortingExampleKtTest.kt similarity index 86% rename from core-kotlin/src/test/kotlin/com/baeldung/sorting/SortingExampleKtTest.kt rename to core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/sorting/SortingExampleKtTest.kt index 8a94e29c2f..7ac0efa4ef 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/sorting/SortingExampleKtTest.kt +++ b/core-kotlin-modules/core-kotlin/src/test/kotlin/com/baeldung/sorting/SortingExampleKtTest.kt @@ -1,9 +1,8 @@ package com.baeldung.sorting +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test -import org.junit.jupiter.api.Assertions.* - class SortingExampleKtTest { @Test diff --git a/core-kotlin-modules/pom.xml b/core-kotlin-modules/pom.xml index 747e8b69de..24bdc189be 100644 --- a/core-kotlin-modules/pom.xml +++ b/core-kotlin-modules/pom.xml @@ -15,9 +15,18 @@ + core-kotlin + core-kotlin-2 + core-kotlin-advanced core-kotlin-annotations + core-kotlin-collections + core-kotlin-concurrency core-kotlin-io + core-kotlin-lang + core-kotlin-lang-2 core-kotlin-strings + core-kotlin-lang-oop + core-kotlin-lang-oop-2 diff --git a/core-kotlin/.gitignore b/core-kotlin/.gitignore deleted file mode 100644 index 0c017e8f8c..0000000000 --- a/core-kotlin/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -/bin/ - -#ignore gradle -.gradle/ - - -#ignore build and generated files -build/ -node/ -out/ - -#ignore installed node modules and package lock file -node_modules/ -package-lock.json diff --git a/core-kotlin/README.md b/core-kotlin/README.md deleted file mode 100644 index f75a4e764c..0000000000 --- a/core-kotlin/README.md +++ /dev/null @@ -1,57 +0,0 @@ -## Core Kotlin - -This module contains articles about core Kotlin. - -### Relevant articles: - -- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin) -- [Guide to the “when{}” Block in Kotlin](https://www.baeldung.com/kotlin-when) -- [Comprehensive Guide to Null Safety in Kotlin](https://www.baeldung.com/kotlin-null-safety) -- [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability) -- [Difference Between “==” and “===” operators in Kotlin](https://www.baeldung.com/kotlin-equality-operators) -- [Generics in Kotlin](https://www.baeldung.com/kotlin-generics) -- [Introduction to Kotlin Coroutines](https://www.baeldung.com/kotlin-coroutines) -- [Destructuring Declarations in Kotlin](https://www.baeldung.com/kotlin-destructuring-declarations) -- [Lazy Initialization in Kotlin](https://www.baeldung.com/kotlin-lazy-initialization) -- [Overview of Kotlin Collections API](https://www.baeldung.com/kotlin-collections-api) -- [Converting a List to Map in Kotlin](https://www.baeldung.com/kotlin-list-to-map) -- [Data Classes in Kotlin](https://www.baeldung.com/kotlin-data-classes) -- [Delegated Properties in Kotlin](https://www.baeldung.com/kotlin-delegated-properties) -- [Sealed Classes in Kotlin](https://www.baeldung.com/kotlin-sealed-classes) -- [JUnit 5 for Kotlin Developers](https://www.baeldung.com/junit-5-kotlin) -- [Extension Methods in Kotlin](https://www.baeldung.com/kotlin-extension-methods) -- [Infix Functions in Kotlin](https://www.baeldung.com/kotlin-infix-functions) -- [Try-with-resources in Kotlin](https://www.baeldung.com/kotlin-try-with-resources) -- [Regular Expressions in Kotlin](https://www.baeldung.com/kotlin-regular-expressions) -- [Objects in Kotlin](https://www.baeldung.com/kotlin-objects) -- [Filtering Kotlin Collections](https://www.baeldung.com/kotlin-filter-collection) -- [Lambda Expressions in Kotlin](https://www.baeldung.com/kotlin-lambda-expressions) -- [Working with Enums in Kotlin](https://www.baeldung.com/kotlin-enum) -- [Create a Java and Kotlin Project with Maven](https://www.baeldung.com/kotlin-maven-java-project) -- [Reflection with Kotlin](https://www.baeldung.com/kotlin-reflection) -- [Get a Random Number in Kotlin](https://www.baeldung.com/kotlin-random-number) -- [Idiomatic Logging in Kotlin](https://www.baeldung.com/kotlin-logging) -- [Kotlin Constructors](https://www.baeldung.com/kotlin-constructors) -- [Creational Design Patterns in Kotlin: Builder](https://www.baeldung.com/kotlin-builder-pattern) -- [Kotlin Nested and Inner Classes](https://www.baeldung.com/kotlin-inner-classes) -- [Fuel HTTP Library with Kotlin](https://www.baeldung.com/kotlin-fuel) -- [Introduction to Kovenant Library for Kotlin](https://www.baeldung.com/kotlin-kovenant) -- [Converting Kotlin Data Class from JSON using GSON](https://www.baeldung.com/kotlin-json-convert-data-class) -- [Kotlin return, break, continue Keywords](https://www.baeldung.com/kotlin-return-break-continue) -- [Mapping of Data Objects in Kotlin](https://www.baeldung.com/kotlin-data-objects) -- [Initializing Arrays in Kotlin](https://www.baeldung.com/kotlin-initialize-array) -- [Threads vs Coroutines in Kotlin](https://www.baeldung.com/kotlin-threads-coroutines) -- [Guide to Kotlin Interfaces](https://www.baeldung.com/kotlin-interfaces) -- [Guide to Sorting in Kotlin](https://www.baeldung.com/kotlin-sort) -- [Dependency Injection for Kotlin with Injekt](https://www.baeldung.com/kotlin-dependency-injection-with-injekt) -- [Implementing a Binary Tree in Kotlin](https://www.baeldung.com/kotlin-binary-tree) -- [Kotlin Contracts](https://www.baeldung.com/kotlin-contracts) -- [Operator Overloading in Kotlin](https://www.baeldung.com/kotlin-operator-overloading) -- [Inline Classes in Kotlin](https://www.baeldung.com/kotlin-inline-classes) -- [Creating Java static final Equivalents in Kotlin](https://www.baeldung.com/kotlin-java-static-final) -- [Nested forEach in Kotlin](https://www.baeldung.com/kotlin-nested-foreach) -- [Building DSLs in Kotlin](https://www.baeldung.com/kotlin-dsl) -- [Static Methods Behavior in Kotlin](https://www.baeldung.com/kotlin-static-methods) -- [Inline Functions in Kotlin](https://www.baeldung.com/kotlin-inline-functions) -- [Delegation Pattern in Kotlin](https://www.baeldung.com/kotlin-delegation-pattern) -- More articles: [[next -->]](/core-kotlin-2) diff --git a/core-kotlin/build.gradle b/core-kotlin/build.gradle deleted file mode 100755 index 2b6527fca7..0000000000 --- a/core-kotlin/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ - - -group 'com.baeldung.ktor' -version '1.0-SNAPSHOT' - - -buildscript { - ext.kotlin_version = '1.2.41' - - repositories { - mavenCentral() - } - dependencies { - - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -apply plugin: 'java' -apply plugin: 'kotlin' -apply plugin: 'application' - -mainClassName = 'APIServer.kt' - -sourceCompatibility = 1.8 -compileKotlin { kotlinOptions.jvmTarget = "1.8" } -compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } - -kotlin { experimental { coroutines "enable" } } - -repositories { - mavenCentral() - jcenter() - maven { url "https://dl.bintray.com/kotlin/ktor" } -} -sourceSets { - main{ - kotlin{ - srcDirs 'com/baeldung/ktor' - } - } - -} - -dependencies { - compile "ch.qos.logback:logback-classic:1.2.1" - testCompile group: 'junit', name: 'junit', version: '4.12' -} \ No newline at end of file diff --git a/core-kotlin/gradle/wrapper/gradle-wrapper.jar b/core-kotlin/gradle/wrapper/gradle-wrapper.jar deleted file mode 100755 index 01b8bf6b1f..0000000000 Binary files a/core-kotlin/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/core-kotlin/gradle/wrapper/gradle-wrapper.properties b/core-kotlin/gradle/wrapper/gradle-wrapper.properties deleted file mode 100755 index 0b83b5a3e3..0000000000 --- a/core-kotlin/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip diff --git a/core-kotlin/gradlew b/core-kotlin/gradlew deleted file mode 100755 index cccdd3d517..0000000000 --- a/core-kotlin/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/core-kotlin/pom.xml b/core-kotlin/pom.xml deleted file mode 100644 index 63a6d8035e..0000000000 --- a/core-kotlin/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - 4.0.0 - core-kotlin - core-kotlin - jar - - - com.baeldung - parent-kotlin - 1.0.0-SNAPSHOT - ../parent-kotlin - - - - - org.apache.commons - commons-math3 - ${commons-math3.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.junit.platform - junit-platform-runner - ${junit.platform.version} - test - - - org.assertj - assertj-core - ${assertj.version} - test - - - com.h2database - h2 - ${h2.version} - - - com.github.kittinunf.fuel - fuel - ${fuel.version} - - - com.github.kittinunf.fuel - fuel-gson - ${fuel.version} - - - com.github.kittinunf.fuel - fuel-rxjava - ${fuel.version} - - - com.github.kittinunf.fuel - fuel-coroutines - ${fuel.version} - - - nl.komponents.kovenant - kovenant - ${kovenant.version} - pom - - - uy.kohesive.injekt - injekt-core - ${injekt-core.version} - - - - - 3.6.1 - 1.1.1 - 5.2.0 - 3.10.0 - 1.15.0 - 3.3.0 - 1.16.1 - - - diff --git a/core-kotlin/resources/logback.xml b/core-kotlin/resources/logback.xml deleted file mode 100755 index 274cdcdb02..0000000000 --- a/core-kotlin/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - \ No newline at end of file diff --git a/core-kotlin/settings.gradle b/core-kotlin/settings.gradle deleted file mode 100755 index 13bbce9583..0000000000 --- a/core-kotlin/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'KtorWithKotlin' - diff --git a/core-scala/pom.xml b/core-scala/pom.xml index d6793cf4c6..d72727dd39 100644 --- a/core-scala/pom.xml +++ b/core-scala/pom.xml @@ -28,7 +28,7 @@ net.alchim31.maven scala-maven-plugin - 3.3.2 + ${scala.plugin.version} @@ -49,6 +49,7 @@ 2.12.7 + 3.3.2 diff --git a/core-scala/src/test/scala/com/baeldung/scala/RegexUnitTest.scala b/core-scala/src/test/scala/com/baeldung/scala/RegexUnitTest.scala new file mode 100644 index 0000000000..94263d620a --- /dev/null +++ b/core-scala/src/test/scala/com/baeldung/scala/RegexUnitTest.scala @@ -0,0 +1,73 @@ +package com.baeldung.scala + +import org.junit.Test +import org.junit.Assert.assertEquals + +class RegexUnitTest { + private val polishPostalCode = "([0-9]{2})\\-([0-9]{3})".r + private val timestamp = "([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{3})".r + private val timestampUnanchored = timestamp.unanchored + + @Test + def givenRegularExpression_whenCallingFindFirstIn_thenShouldFindCorrectMatches(): Unit = { + val postCode = polishPostalCode.findFirstIn("Warsaw 01-011, Jerusalem Avenue") + assertEquals(Some("01-011"), postCode) + } + + @Test + def givenRegularExpression_whenCallingFindFirstMatchIn_thenShouldFindCorrectMatches(): Unit = { + val postCodes = polishPostalCode.findFirstMatchIn("Warsaw 01-011, Jerusalem Avenue") + assertEquals(Some("011"), for (m <- postCodes) yield m.group(2)) + } + + @Test + def givenRegularExpression_whenCallingFindAllIn_thenShouldFindCorrectMatches(): Unit = { + val postCodes = polishPostalCode.findAllIn("Warsaw 01-011, Jerusalem Avenue, Cracow 30-059, Mickiewicza Avenue") + .toList + assertEquals(List("01-011", "30-059"), postCodes) + + polishPostalCode.findAllIn("Warsaw 01-011, Jerusalem Avenue, Cracow 30-059, Mickiewicza Avenue") + } + + @Test + def givenRegularExpression_whenCallingFindAlMatchlIn_thenShouldFindCorrectMatches(): Unit = { + val postCodes = polishPostalCode.findAllMatchIn("Warsaw 01-011, Jerusalem Avenue, Cracow 30-059, Mickiewicza Avenue") + .toList + val postalDistricts = for (m <- postCodes) yield m.group(1) + assertEquals(List("01", "30"), postalDistricts) + } + + @Test + def givenRegularExpression_whenExtractingValues_thenShouldExtractCorrectValues(): Unit = { + val description = "11:34:01.411" match { + case timestamp(hour, minutes, _, _) => s"It's $minutes minutes after $hour" + } + + assertEquals("It's 34 minutes after 11", description) + } + + @Test + def givenUnanchoredRegularExpression_whenExtractingValues_thenShouldExtractCorrectValues(): Unit = { + val description = "Timestamp: 11:34:01.411 error appeared" match { + case timestampUnanchored(hour, minutes, _, _) => s"It's $minutes minutes after $hour" + } + + assertEquals("It's 34 minutes after 11", description) + } + + @Test + def givenRegularExpression_whenCallingReplaceAllIn_thenShouldReplaceText(): Unit = { + val minutes = timestamp.replaceAllIn("11:34:01.311", m => m.group(2)) + + assertEquals("34", minutes) + } + + @Test + def givenRegularExpression_whenCallingReplaceAllInWithMatcher_thenShouldReplaceText(): Unit = { + val secondsThatDayInTotal = timestamp.replaceAllIn("11:34:01.311", _ match { + case timestamp(hours, minutes, seconds, _) => s"$hours-$minutes" + }) + + assertEquals("11-34", secondsThatDayInTotal) + } +} diff --git a/custom-pmd/pom.xml b/custom-pmd/pom.xml index 601eedf08f..a011b6a121 100644 --- a/custom-pmd/pom.xml +++ b/custom-pmd/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - org.baeldung.pmd + com.baeldung.pmd custom-pmd 0.0.1 custom-pmd diff --git a/custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java b/custom-pmd/src/main/java/com/baeldung/pmd/UnitTestNamingConventionRule.java similarity index 97% rename from custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java rename to custom-pmd/src/main/java/com/baeldung/pmd/UnitTestNamingConventionRule.java index 2cbab782ee..e30164ac4f 100644 --- a/custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java +++ b/custom-pmd/src/main/java/com/baeldung/pmd/UnitTestNamingConventionRule.java @@ -1,4 +1,4 @@ -package org.baeldung.pmd; +package com.baeldung.pmd; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; diff --git a/data-structures/README.md b/data-structures/README.md index 7eeda7c64f..fe81f4d2be 100644 --- a/data-structures/README.md +++ b/data-structures/README.md @@ -6,3 +6,4 @@ This module contains articles about data structures in Java - [The Trie Data Structure in Java](https://www.baeldung.com/trie-java) - [Implementing a Binary Tree in Java](https://www.baeldung.com/java-binary-tree) +- [Circular Linked List Java Implementation](https://www.baeldung.com/java-circular-linked-list) diff --git a/data-structures/pom.xml b/data-structures/pom.xml index e8f4628062..4468f3d21f 100644 --- a/data-structures/pom.xml +++ b/data-structures/pom.xml @@ -12,6 +12,21 @@ 1.0.0-SNAPSHOT + + + github.release.repo + https://raw.github.com/bulldog2011/bulldog-repo/master/repo/releases/ + + + + + + com.leansoft + bigqueue + ${bigqueue.version} + + + @@ -24,4 +39,8 @@ + + 0.7.0 + + diff --git a/data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java b/data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java new file mode 100644 index 0000000000..c0305a7ca3 --- /dev/null +++ b/data-structures/src/test/java/com/baeldung/bigqueue/BigQueueLiveTest.java @@ -0,0 +1,82 @@ +package com.baeldung.bigqueue; + +import com.leansoft.bigqueue.BigQueueImpl; +import com.leansoft.bigqueue.IBigQueue; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@RunWith(JUnit4.class) +public class BigQueueLiveTest { + + private IBigQueue bigQueue; + + @Before + public void setup() throws IOException { + String queueDir = System.getProperty("user.home"); + String queueName = "baeldung-queue"; + bigQueue = new BigQueueImpl(queueDir, queueName); + } + + @After + public void emptyQueue() throws IOException { + bigQueue.removeAll(); + bigQueue.gc(); + bigQueue.close(); + } + + @Test + public void whenAddingRecords_ThenTheSizeIsCorrect() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + + assertEquals(100, bigQueue.size()); + } + + @Test + public void whenAddingRecords_ThenTheyCanBeRetrieved() throws IOException { + bigQueue.enqueue(String.valueOf("new_record").getBytes()); + + String record = new String(bigQueue.dequeue()); + assertEquals("new_record", record); + } + + @Test + public void whenDequeueingRecords_ThenTheyAreConsumed() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + bigQueue.dequeue(); + + assertEquals(99, bigQueue.size()); + } + + @Test + public void whenPeekingRecords_ThenSizeDoesntChange() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + String firstRecord = new String(bigQueue.peek()); + + assertEquals("1", firstRecord); + assertEquals(100, bigQueue.size()); + } + + @Test + public void whenEmptyingTheQueue_ThenItSizeIs0() throws IOException { + for (int i = 1; i <= 100; i++) { + bigQueue.enqueue(String.valueOf(i).getBytes()); + } + bigQueue.removeAll(); + + assertEquals(0, bigQueue.size()); + } + +} diff --git a/deeplearning4j/pom.xml b/deeplearning4j/pom.xml index 0e84fa1516..c143b86ff8 100644 --- a/deeplearning4j/pom.xml +++ b/deeplearning4j/pom.xml @@ -44,12 +44,13 @@ org.apache.httpcomponents httpclient - 4.3.5 + ${httpclient.version} 0.9.1 + 4.3.5 diff --git a/dropwizard/README.md b/dropwizard/README.md new file mode 100644 index 0000000000..e713b2f1e6 --- /dev/null +++ b/dropwizard/README.md @@ -0,0 +1 @@ +# Dropwizard \ No newline at end of file diff --git a/dropwizard/pom.xml b/dropwizard/pom.xml new file mode 100644 index 0000000000..ddc9aa1949 --- /dev/null +++ b/dropwizard/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + dropwizard + 0.0.1-SNAPSHOT + dropwizard + jar + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + io.dropwizard + dropwizard-core + ${dropwizard.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + + true + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + package + + shade + + + + + + com.baeldung.dropwizard.introduction.IntroductionApplication + + + + + + + + + + + 2.0.0 + + + \ No newline at end of file diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/IntroductionApplication.java b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/IntroductionApplication.java new file mode 100644 index 0000000000..d9af590017 --- /dev/null +++ b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/IntroductionApplication.java @@ -0,0 +1,51 @@ +package com.baeldung.dropwizard.introduction; + +import com.baeldung.dropwizard.introduction.configuration.ApplicationHealthCheck; +import com.baeldung.dropwizard.introduction.configuration.BasicConfiguration; +import com.baeldung.dropwizard.introduction.domain.Brand; +import com.baeldung.dropwizard.introduction.repository.BrandRepository; +import com.baeldung.dropwizard.introduction.resource.BrandResource; +import io.dropwizard.Application; +import io.dropwizard.configuration.ResourceConfigurationSourceProvider; +import io.dropwizard.setup.Bootstrap; +import io.dropwizard.setup.Environment; + +import java.util.ArrayList; +import java.util.List; + +public class IntroductionApplication extends Application { + + public static void main(final String[] args) throws Exception { + new IntroductionApplication().run("server", "introduction-config.yml"); + } + + @Override + public void run(final BasicConfiguration basicConfiguration, final Environment environment) { + final int defaultSize = basicConfiguration.getDefaultSize(); + final BrandRepository brandRepository = new BrandRepository(initBrands()); + final BrandResource brandResource = new BrandResource(defaultSize, brandRepository); + environment + .jersey() + .register(brandResource); + + final ApplicationHealthCheck healthCheck = new ApplicationHealthCheck(); + environment + .healthChecks() + .register("application", healthCheck); + } + + @Override + public void initialize(final Bootstrap bootstrap) { + bootstrap.setConfigurationSourceProvider(new ResourceConfigurationSourceProvider()); + super.initialize(bootstrap); + } + + private List initBrands() { + final List brands = new ArrayList<>(); + brands.add(new Brand(1L, "Brand1")); + brands.add(new Brand(2L, "Brand2")); + brands.add(new Brand(3L, "Brand3")); + + return brands; + } +} diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/ApplicationHealthCheck.java b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/ApplicationHealthCheck.java new file mode 100644 index 0000000000..bf4b710937 --- /dev/null +++ b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/ApplicationHealthCheck.java @@ -0,0 +1,10 @@ +package com.baeldung.dropwizard.introduction.configuration; + +import com.codahale.metrics.health.HealthCheck; + +public class ApplicationHealthCheck extends HealthCheck { + @Override + protected Result check() throws Exception { + return Result.healthy(); + } +} diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/BasicConfiguration.java b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/BasicConfiguration.java new file mode 100644 index 0000000000..5098f89d62 --- /dev/null +++ b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/configuration/BasicConfiguration.java @@ -0,0 +1,20 @@ +package com.baeldung.dropwizard.introduction.configuration; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.dropwizard.Configuration; + +import javax.validation.constraints.NotNull; + +public class BasicConfiguration extends Configuration { + @NotNull private final int defaultSize; + + @JsonCreator + public BasicConfiguration(@JsonProperty("defaultSize") final int defaultSize) { + this.defaultSize = defaultSize; + } + + public int getDefaultSize() { + return defaultSize; + } +} diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/domain/Brand.java b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/domain/Brand.java new file mode 100644 index 0000000000..c83f67bb6e --- /dev/null +++ b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/domain/Brand.java @@ -0,0 +1,19 @@ +package com.baeldung.dropwizard.introduction.domain; + +public class Brand { + private final Long id; + private final String name; + + public Brand(final Long id, final String name) { + this.id = id; + this.name = name; + } + + public Long getId() { + return id; + } + + public String getName() { + return name; + } +} diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/repository/BrandRepository.java b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/repository/BrandRepository.java new file mode 100644 index 0000000000..3f187df3de --- /dev/null +++ b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/repository/BrandRepository.java @@ -0,0 +1,32 @@ +package com.baeldung.dropwizard.introduction.repository; + +import com.baeldung.dropwizard.introduction.domain.Brand; +import com.google.common.collect.ImmutableList; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +public class BrandRepository { + private final List brands; + + public BrandRepository(final List brands) { + this.brands = ImmutableList.copyOf(brands); + } + + public List findAll(final int size) { + return brands + .stream() + .limit(size) + .collect(Collectors.toList()); + } + + public Optional findById(final Long id) { + return brands + .stream() + .filter(brand -> brand + .getId() + .equals(id)) + .findFirst(); + } +} diff --git a/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/resource/BrandResource.java b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/resource/BrandResource.java new file mode 100644 index 0000000000..5f97e26faf --- /dev/null +++ b/dropwizard/src/main/java/com/baeldung/dropwizard/introduction/resource/BrandResource.java @@ -0,0 +1,35 @@ +package com.baeldung.dropwizard.introduction.resource; + +import com.baeldung.dropwizard.introduction.domain.Brand; +import com.baeldung.dropwizard.introduction.repository.BrandRepository; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Optional; + +@Path("/brands") +@Produces(MediaType.APPLICATION_JSON) +public class BrandResource { + private final int defaultSize; + private final BrandRepository brandRepository; + + public BrandResource(final int defaultSize, final BrandRepository brandRepository) { + this.defaultSize = defaultSize; + this.brandRepository = brandRepository; + + } + + @GET + public List getBrands(@QueryParam("size") final Optional size) { + return brandRepository.findAll(size.orElse(defaultSize)); + } + + @GET + @Path("/{id}") + public Brand getById(@PathParam("id") final Long id) { + return brandRepository + .findById(id) + .orElseThrow(RuntimeException::new); + } +} diff --git a/dropwizard/src/main/resources/introduction-config.yml b/dropwizard/src/main/resources/introduction-config.yml new file mode 100644 index 0000000000..02ff36de05 --- /dev/null +++ b/dropwizard/src/main/resources/introduction-config.yml @@ -0,0 +1 @@ +defaultSize: 5 \ No newline at end of file diff --git a/dropwizard/src/test/java/com/baeldung/dropwizard/introduction/repository/BrandRepositoryUnitTest.java b/dropwizard/src/test/java/com/baeldung/dropwizard/introduction/repository/BrandRepositoryUnitTest.java new file mode 100644 index 0000000000..b996883ee5 --- /dev/null +++ b/dropwizard/src/test/java/com/baeldung/dropwizard/introduction/repository/BrandRepositoryUnitTest.java @@ -0,0 +1,47 @@ +package com.baeldung.dropwizard.introduction.repository; + +import com.baeldung.dropwizard.introduction.domain.Brand; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class BrandRepositoryUnitTest { + + private static final Brand BRAND_1 = new Brand(1L, "Brand1"); + + private final BrandRepository brandRepository = new BrandRepository(getBrands()); + + @Test + void givenSize_whenFindingAll_thenReturnList() { + final int size = 2; + + final List result = brandRepository.findAll(size); + + assertEquals(size, result.size()); + } + + @Test + void givenId_whenFindingById_thenReturnFoundBrand() { + final Long id = BRAND_1.getId(); + + final Optional result = brandRepository.findById(id); + + Assertions.assertTrue(result.isPresent()); + assertEquals(BRAND_1, result.get()); + } + + + private List getBrands() { + final List brands = new ArrayList<>(); + brands.add(BRAND_1); + brands.add(new Brand(2L, "Brand2")); + brands.add(new Brand(3L, "Brand3")); + + return brands; + } +} \ No newline at end of file diff --git a/ethereum/pom.xml b/ethereum/pom.xml index 6fc31208d2..1449d9d95c 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -175,10 +175,10 @@ maven-compiler-plugin - 3.1 + ${compiler.plugin.version} - 1.8 - 1.8 + ${java.version} + ${java.version} @@ -189,7 +189,7 @@ org.apache.maven.plugins maven-war-plugin - 3.0.0 + ${maven-war-plugin.version} src/main/webapp false @@ -215,5 +215,6 @@ 1.2.3 1.7.25 2.0.4.RELEASE + 3.1 diff --git a/google-web-toolkit/pom.xml b/google-web-toolkit/pom.xml index e79b43c5e5..37e423b3af 100644 --- a/google-web-toolkit/pom.xml +++ b/google-web-toolkit/pom.xml @@ -63,7 +63,7 @@ net.ltgt.gwt.maven gwt-maven-plugin - 1.0-rc-8 + ${gwt.plugin.version} @@ -78,7 +78,7 @@ true - 1.8 + ${maven.compiler.source} @@ -98,7 +98,7 @@ maven-surefire-plugin - 2.17 + ${surefire.plugin.version} true @@ -119,6 +119,8 @@ UTF-8 UTF-8 2.8.2 + 1.0-rc-8 + 2.17 diff --git a/graphql/graphql-java/pom.xml b/graphql/graphql-java/pom.xml index 3613d89ae7..793a02458a 100644 --- a/graphql/graphql-java/pom.xml +++ b/graphql/graphql-java/pom.xml @@ -11,6 +11,7 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT + ../.. diff --git a/grpc/src/main/java/org/baeldung/grpc/client/GrpcClient.java b/grpc/src/main/java/com/baeldung/grpc/client/GrpcClient.java similarity index 81% rename from grpc/src/main/java/org/baeldung/grpc/client/GrpcClient.java rename to grpc/src/main/java/com/baeldung/grpc/client/GrpcClient.java index f653e17910..f10b24faa7 100644 --- a/grpc/src/main/java/org/baeldung/grpc/client/GrpcClient.java +++ b/grpc/src/main/java/com/baeldung/grpc/client/GrpcClient.java @@ -1,8 +1,8 @@ -package org.baeldung.grpc.client; +package com.baeldung.grpc.client; -import org.baeldung.grpc.HelloRequest; -import org.baeldung.grpc.HelloResponse; -import org.baeldung.grpc.HelloServiceGrpc; +import com.baeldung.grpc.HelloRequest; +import com.baeldung.grpc.HelloResponse; +import com.baeldung.grpc.HelloServiceGrpc; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; diff --git a/grpc/src/main/java/org/baeldung/grpc/server/GrpcServer.java b/grpc/src/main/java/com/baeldung/grpc/server/GrpcServer.java similarity index 93% rename from grpc/src/main/java/org/baeldung/grpc/server/GrpcServer.java rename to grpc/src/main/java/com/baeldung/grpc/server/GrpcServer.java index 8a2b94e53b..2380d73a8c 100644 --- a/grpc/src/main/java/org/baeldung/grpc/server/GrpcServer.java +++ b/grpc/src/main/java/com/baeldung/grpc/server/GrpcServer.java @@ -1,4 +1,4 @@ -package org.baeldung.grpc.server; +package com.baeldung.grpc.server; import java.io.IOException; diff --git a/grpc/src/main/java/org/baeldung/grpc/server/HelloServiceImpl.java b/grpc/src/main/java/com/baeldung/grpc/server/HelloServiceImpl.java similarity index 79% rename from grpc/src/main/java/org/baeldung/grpc/server/HelloServiceImpl.java rename to grpc/src/main/java/com/baeldung/grpc/server/HelloServiceImpl.java index b08ad02c97..8609477fe9 100644 --- a/grpc/src/main/java/org/baeldung/grpc/server/HelloServiceImpl.java +++ b/grpc/src/main/java/com/baeldung/grpc/server/HelloServiceImpl.java @@ -1,8 +1,8 @@ -package org.baeldung.grpc.server; +package com.baeldung.grpc.server; -import org.baeldung.grpc.HelloRequest; -import org.baeldung.grpc.HelloResponse; -import org.baeldung.grpc.HelloServiceGrpc.HelloServiceImplBase; +import com.baeldung.grpc.HelloRequest; +import com.baeldung.grpc.HelloResponse; +import com.baeldung.grpc.HelloServiceGrpc.HelloServiceImplBase; import io.grpc.stub.StreamObserver; diff --git a/grpc/src/main/proto/HelloService.proto b/grpc/src/main/proto/HelloService.proto index 4f53191ab9..a008fad4b0 100644 --- a/grpc/src/main/proto/HelloService.proto +++ b/grpc/src/main/proto/HelloService.proto @@ -1,6 +1,6 @@ syntax = "proto3"; option java_multiple_files = true; -package org.baeldung.grpc; +package com.baeldung.grpc; message HelloRequest { string firstName = 1; diff --git a/gson/src/main/java/org/baeldung/gson/entities/ActorGson.java b/gson/src/main/java/com/baeldung/gson/entities/ActorGson.java similarity index 97% rename from gson/src/main/java/org/baeldung/gson/entities/ActorGson.java rename to gson/src/main/java/com/baeldung/gson/entities/ActorGson.java index 92468683bf..a68dba2436 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/ActorGson.java +++ b/gson/src/main/java/com/baeldung/gson/entities/ActorGson.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.entities; +package com.baeldung.gson.entities; import java.text.DateFormat; import java.text.SimpleDateFormat; diff --git a/gson/src/main/java/org/baeldung/gson/entities/Animal.java b/gson/src/main/java/com/baeldung/gson/entities/Animal.java similarity index 65% rename from gson/src/main/java/org/baeldung/gson/entities/Animal.java rename to gson/src/main/java/com/baeldung/gson/entities/Animal.java index 2eec5f8704..6c0f4a6e4e 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/Animal.java +++ b/gson/src/main/java/com/baeldung/gson/entities/Animal.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.entities; +package com.baeldung.gson.entities; public abstract class Animal { public String type = "Animal"; diff --git a/gson/src/main/java/org/baeldung/gson/entities/Cow.java b/gson/src/main/java/com/baeldung/gson/entities/Cow.java similarity index 88% rename from gson/src/main/java/org/baeldung/gson/entities/Cow.java rename to gson/src/main/java/com/baeldung/gson/entities/Cow.java index 020bcd5860..5bd8d23f44 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/Cow.java +++ b/gson/src/main/java/com/baeldung/gson/entities/Cow.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.entities; +package com.baeldung.gson.entities; public class Cow extends Animal { private String breed; diff --git a/gson/src/main/java/org/baeldung/gson/entities/Dog.java b/gson/src/main/java/com/baeldung/gson/entities/Dog.java similarity index 88% rename from gson/src/main/java/org/baeldung/gson/entities/Dog.java rename to gson/src/main/java/com/baeldung/gson/entities/Dog.java index 042d73adcf..ac55573866 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/Dog.java +++ b/gson/src/main/java/com/baeldung/gson/entities/Dog.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.entities; +package com.baeldung.gson.entities; public class Dog extends Animal { private String petName; diff --git a/gson/src/main/java/org/baeldung/gson/entities/Employee.java b/gson/src/main/java/com/baeldung/gson/entities/Employee.java similarity index 94% rename from gson/src/main/java/org/baeldung/gson/entities/Employee.java rename to gson/src/main/java/com/baeldung/gson/entities/Employee.java index cedcd6572e..ecc4571dcc 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/Employee.java +++ b/gson/src/main/java/com/baeldung/gson/entities/Employee.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.entities; +package com.baeldung.gson.entities; public class Employee { private int id; diff --git a/gson/src/main/java/org/baeldung/gson/entities/Movie.java b/gson/src/main/java/com/baeldung/gson/entities/Movie.java similarity index 96% rename from gson/src/main/java/org/baeldung/gson/entities/Movie.java rename to gson/src/main/java/com/baeldung/gson/entities/Movie.java index ee688f228d..ebc4cff137 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/Movie.java +++ b/gson/src/main/java/com/baeldung/gson/entities/Movie.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.entities; +package com.baeldung.gson.entities; import java.util.List; diff --git a/gson/src/main/java/org/baeldung/gson/entities/MovieWithNullValue.java b/gson/src/main/java/com/baeldung/gson/entities/MovieWithNullValue.java similarity index 96% rename from gson/src/main/java/org/baeldung/gson/entities/MovieWithNullValue.java rename to gson/src/main/java/com/baeldung/gson/entities/MovieWithNullValue.java index fe62d51ffb..381d7cb83b 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/MovieWithNullValue.java +++ b/gson/src/main/java/com/baeldung/gson/entities/MovieWithNullValue.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.entities; +package com.baeldung.gson.entities; import com.google.gson.annotations.Expose; diff --git a/gson/src/main/java/org/baeldung/gson/entities/MyClass.java b/gson/src/main/java/com/baeldung/gson/entities/MyClass.java similarity index 96% rename from gson/src/main/java/org/baeldung/gson/entities/MyClass.java rename to gson/src/main/java/com/baeldung/gson/entities/MyClass.java index 4e717e72c3..66a1887414 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/MyClass.java +++ b/gson/src/main/java/com/baeldung/gson/entities/MyClass.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.entities; +package com.baeldung.gson.entities; import java.util.Objects; diff --git a/gson/src/main/java/org/baeldung/gson/entities/User.java b/gson/src/main/java/com/baeldung/gson/entities/User.java similarity index 84% rename from gson/src/main/java/org/baeldung/gson/entities/User.java rename to gson/src/main/java/com/baeldung/gson/entities/User.java index b413f3300e..d821ef5552 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/User.java +++ b/gson/src/main/java/com/baeldung/gson/entities/User.java @@ -1,19 +1,19 @@ -package org.baeldung.gson.entities; - -public class User { - - private int id; - private String name; - private transient String nationality; - - public User(int id, String name, String nationality) { - this.id = id; - this.name = name; - this.nationality = nationality; - } - - public User(int id, String name) { - this(id, name, null); - } - -} +package com.baeldung.gson.entities; + +public class User { + + private int id; + private String name; + private transient String nationality; + + public User(int id, String name, String nationality) { + this.id = id; + this.name = name; + this.nationality = nationality; + } + + public User(int id, String name) { + this(id, name, null); + } + +} diff --git a/gson/src/main/java/org/baeldung/gson/entities/Weather.java b/gson/src/main/java/com/baeldung/gson/entities/Weather.java similarity index 95% rename from gson/src/main/java/org/baeldung/gson/entities/Weather.java rename to gson/src/main/java/com/baeldung/gson/entities/Weather.java index 383e9ef41c..b68ec4c6d4 100644 --- a/gson/src/main/java/org/baeldung/gson/entities/Weather.java +++ b/gson/src/main/java/com/baeldung/gson/entities/Weather.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.entities; +package com.baeldung.gson.entities; import com.google.gson.annotations.SerializedName; diff --git a/gson/src/main/java/org/baeldung/gson/primitives/models/BooleanExample.java b/gson/src/main/java/com/baeldung/gson/primitives/models/BooleanExample.java similarity index 75% rename from gson/src/main/java/org/baeldung/gson/primitives/models/BooleanExample.java rename to gson/src/main/java/com/baeldung/gson/primitives/models/BooleanExample.java index 1fe87650de..1f05fc6119 100644 --- a/gson/src/main/java/org/baeldung/gson/primitives/models/BooleanExample.java +++ b/gson/src/main/java/com/baeldung/gson/primitives/models/BooleanExample.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.primitives.models; +package com.baeldung.gson.primitives.models; public class BooleanExample { public boolean value; diff --git a/gson/src/main/java/org/baeldung/gson/primitives/models/ByteExample.java b/gson/src/main/java/com/baeldung/gson/primitives/models/ByteExample.java similarity index 75% rename from gson/src/main/java/org/baeldung/gson/primitives/models/ByteExample.java rename to gson/src/main/java/com/baeldung/gson/primitives/models/ByteExample.java index 2e1c68ee51..6ec4e42ea3 100644 --- a/gson/src/main/java/org/baeldung/gson/primitives/models/ByteExample.java +++ b/gson/src/main/java/com/baeldung/gson/primitives/models/ByteExample.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.primitives.models; +package com.baeldung.gson.primitives.models; public class ByteExample { public byte value = (byte) 1; diff --git a/gson/src/main/java/org/baeldung/gson/primitives/models/CharExample.java b/gson/src/main/java/com/baeldung/gson/primitives/models/CharExample.java similarity index 74% rename from gson/src/main/java/org/baeldung/gson/primitives/models/CharExample.java rename to gson/src/main/java/com/baeldung/gson/primitives/models/CharExample.java index ccac913f23..69d1a95fcd 100644 --- a/gson/src/main/java/org/baeldung/gson/primitives/models/CharExample.java +++ b/gson/src/main/java/com/baeldung/gson/primitives/models/CharExample.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.primitives.models; +package com.baeldung.gson.primitives.models; public class CharExample { public char value; diff --git a/gson/src/main/java/org/baeldung/gson/primitives/models/DoubleExample.java b/gson/src/main/java/com/baeldung/gson/primitives/models/DoubleExample.java similarity index 75% rename from gson/src/main/java/org/baeldung/gson/primitives/models/DoubleExample.java rename to gson/src/main/java/com/baeldung/gson/primitives/models/DoubleExample.java index 5022b6a11e..7c9db2bd50 100644 --- a/gson/src/main/java/org/baeldung/gson/primitives/models/DoubleExample.java +++ b/gson/src/main/java/com/baeldung/gson/primitives/models/DoubleExample.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.primitives.models; +package com.baeldung.gson.primitives.models; public class DoubleExample { public double value; diff --git a/gson/src/main/java/org/baeldung/gson/primitives/models/FloatExample.java b/gson/src/main/java/com/baeldung/gson/primitives/models/FloatExample.java similarity index 74% rename from gson/src/main/java/org/baeldung/gson/primitives/models/FloatExample.java rename to gson/src/main/java/com/baeldung/gson/primitives/models/FloatExample.java index 00a97f68fc..86c0c4802c 100644 --- a/gson/src/main/java/org/baeldung/gson/primitives/models/FloatExample.java +++ b/gson/src/main/java/com/baeldung/gson/primitives/models/FloatExample.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.primitives.models; +package com.baeldung.gson.primitives.models; public class FloatExample { public float value; diff --git a/gson/src/main/java/org/baeldung/gson/primitives/models/InfinityValuesExample.java b/gson/src/main/java/com/baeldung/gson/primitives/models/InfinityValuesExample.java similarity index 70% rename from gson/src/main/java/org/baeldung/gson/primitives/models/InfinityValuesExample.java rename to gson/src/main/java/com/baeldung/gson/primitives/models/InfinityValuesExample.java index 163b0a3d95..90f10c0751 100644 --- a/gson/src/main/java/org/baeldung/gson/primitives/models/InfinityValuesExample.java +++ b/gson/src/main/java/com/baeldung/gson/primitives/models/InfinityValuesExample.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.primitives.models; +package com.baeldung.gson.primitives.models; public class InfinityValuesExample { public float negativeInfinity; diff --git a/gson/src/main/java/org/baeldung/gson/primitives/models/LongExample.java b/gson/src/main/java/com/baeldung/gson/primitives/models/LongExample.java similarity index 75% rename from gson/src/main/java/org/baeldung/gson/primitives/models/LongExample.java rename to gson/src/main/java/com/baeldung/gson/primitives/models/LongExample.java index e709650789..021de1d06d 100644 --- a/gson/src/main/java/org/baeldung/gson/primitives/models/LongExample.java +++ b/gson/src/main/java/com/baeldung/gson/primitives/models/LongExample.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.primitives.models; +package com.baeldung.gson.primitives.models; public class LongExample { public long value = 1; diff --git a/gson/src/main/java/org/baeldung/gson/primitives/models/PrimitiveBundle.java b/gson/src/main/java/com/baeldung/gson/primitives/models/PrimitiveBundle.java similarity index 93% rename from gson/src/main/java/org/baeldung/gson/primitives/models/PrimitiveBundle.java rename to gson/src/main/java/com/baeldung/gson/primitives/models/PrimitiveBundle.java index ad7309a2f7..10134110f3 100644 --- a/gson/src/main/java/org/baeldung/gson/primitives/models/PrimitiveBundle.java +++ b/gson/src/main/java/com/baeldung/gson/primitives/models/PrimitiveBundle.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.primitives.models; +package com.baeldung.gson.primitives.models; public class PrimitiveBundle { public byte byteValue; diff --git a/gson/src/main/java/org/baeldung/gson/primitives/models/PrimitiveBundleInitialized.java b/gson/src/main/java/com/baeldung/gson/primitives/models/PrimitiveBundleInitialized.java similarity index 92% rename from gson/src/main/java/org/baeldung/gson/primitives/models/PrimitiveBundleInitialized.java rename to gson/src/main/java/com/baeldung/gson/primitives/models/PrimitiveBundleInitialized.java index 2780f7fd18..c6eb6ca267 100644 --- a/gson/src/main/java/org/baeldung/gson/primitives/models/PrimitiveBundleInitialized.java +++ b/gson/src/main/java/com/baeldung/gson/primitives/models/PrimitiveBundleInitialized.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.primitives.models; +package com.baeldung.gson.primitives.models; public class PrimitiveBundleInitialized { // @formatter:off diff --git a/gson/src/main/java/org/baeldung/gson/serialization/ActorGsonDeserializer.java b/gson/src/main/java/com/baeldung/gson/serialization/ActorGsonDeserializer.java similarity index 94% rename from gson/src/main/java/org/baeldung/gson/serialization/ActorGsonDeserializer.java rename to gson/src/main/java/com/baeldung/gson/serialization/ActorGsonDeserializer.java index 016e3ba1e2..34c9f83888 100644 --- a/gson/src/main/java/org/baeldung/gson/serialization/ActorGsonDeserializer.java +++ b/gson/src/main/java/com/baeldung/gson/serialization/ActorGsonDeserializer.java @@ -1,11 +1,11 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; import java.lang.reflect.Type; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import org.baeldung.gson.entities.ActorGson; +import com.baeldung.gson.entities.ActorGson; import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; diff --git a/gson/src/main/java/org/baeldung/gson/serialization/ActorGsonSerializer.java b/gson/src/main/java/com/baeldung/gson/serialization/ActorGsonSerializer.java similarity index 93% rename from gson/src/main/java/org/baeldung/gson/serialization/ActorGsonSerializer.java rename to gson/src/main/java/com/baeldung/gson/serialization/ActorGsonSerializer.java index 8f2cd10f5a..4ca653f76b 100644 --- a/gson/src/main/java/org/baeldung/gson/serialization/ActorGsonSerializer.java +++ b/gson/src/main/java/com/baeldung/gson/serialization/ActorGsonSerializer.java @@ -1,10 +1,10 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import org.baeldung.gson.entities.ActorGson; +import com.baeldung.gson.entities.ActorGson; import java.lang.reflect.Type; import java.text.SimpleDateFormat; diff --git a/gson/src/main/java/org/baeldung/gson/serialization/AnimalDeserializer.java b/gson/src/main/java/com/baeldung/gson/serialization/AnimalDeserializer.java similarity index 93% rename from gson/src/main/java/org/baeldung/gson/serialization/AnimalDeserializer.java rename to gson/src/main/java/com/baeldung/gson/serialization/AnimalDeserializer.java index 9dcef0e10b..6c72ddb0da 100644 --- a/gson/src/main/java/org/baeldung/gson/serialization/AnimalDeserializer.java +++ b/gson/src/main/java/com/baeldung/gson/serialization/AnimalDeserializer.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; import com.google.gson.Gson; import com.google.gson.JsonDeserializationContext; @@ -8,7 +8,7 @@ import com.google.gson.JsonObject; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; -import org.baeldung.gson.entities.Animal; +import com.baeldung.gson.entities.Animal; public class AnimalDeserializer implements JsonDeserializer { private String animalTypeElementName; diff --git a/gson/src/main/java/org/baeldung/gson/serialization/MapDeserializer.java b/gson/src/main/java/com/baeldung/gson/serialization/MapDeserializer.java similarity index 94% rename from gson/src/main/java/org/baeldung/gson/serialization/MapDeserializer.java rename to gson/src/main/java/com/baeldung/gson/serialization/MapDeserializer.java index cdeb2e23c8..1954986547 100644 --- a/gson/src/main/java/org/baeldung/gson/serialization/MapDeserializer.java +++ b/gson/src/main/java/com/baeldung/gson/serialization/MapDeserializer.java @@ -1,12 +1,11 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; import java.lang.reflect.Type; import java.math.BigDecimal; -import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; -import org.baeldung.gson.entities.Employee; +import com.baeldung.gson.entities.Employee; import com.google.gson.*; diff --git a/gson/src/main/java/org/baeldung/gson/serialization/StringDateMapDeserializer.java b/gson/src/main/java/com/baeldung/gson/serialization/StringDateMapDeserializer.java similarity index 97% rename from gson/src/main/java/org/baeldung/gson/serialization/StringDateMapDeserializer.java rename to gson/src/main/java/com/baeldung/gson/serialization/StringDateMapDeserializer.java index f18bdbc84f..fa9d7d2240 100644 --- a/gson/src/main/java/org/baeldung/gson/serialization/StringDateMapDeserializer.java +++ b/gson/src/main/java/com/baeldung/gson/serialization/StringDateMapDeserializer.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; import java.lang.reflect.Type; import java.text.ParseException; diff --git a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/Exclude.java b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/Exclude.java similarity index 82% rename from gson/src/main/java/org/baeldung/gson/serializationwithexclusions/Exclude.java rename to gson/src/main/java/com/baeldung/gson/serializationwithexclusions/Exclude.java index 429cb9d1b5..d3067e3482 100644 --- a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/Exclude.java +++ b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/Exclude.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClass.java b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClass.java similarity index 79% rename from gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClass.java rename to gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClass.java index cc6c498458..8919792721 100644 --- a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClass.java +++ b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClass.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClassWithAnnotatedFields.java b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClassWithAnnotatedFields.java similarity index 85% rename from gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClassWithAnnotatedFields.java rename to gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClassWithAnnotatedFields.java index 5d41f8a224..4c38df1eac 100644 --- a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClassWithAnnotatedFields.java +++ b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClassWithAnnotatedFields.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import com.google.gson.annotations.Expose; diff --git a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClassWithCustomAnnotatedFields.java b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClassWithCustomAnnotatedFields.java similarity index 83% rename from gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClassWithCustomAnnotatedFields.java rename to gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClassWithCustomAnnotatedFields.java index ace3583013..85871be03d 100644 --- a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClassWithCustomAnnotatedFields.java +++ b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClassWithCustomAnnotatedFields.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClassWithTransientFields.java b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClassWithTransientFields.java similarity index 82% rename from gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClassWithTransientFields.java rename to gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClassWithTransientFields.java index 5e781a6287..dfb9d4bd6e 100644 --- a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MyClassWithTransientFields.java +++ b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MyClassWithTransientFields.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClass.java b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClass.java similarity index 78% rename from gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClass.java rename to gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClass.java index 5adac0697e..6b8a287020 100644 --- a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClass.java +++ b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClass.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClassWithAnnotatedFields.java b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClassWithAnnotatedFields.java similarity index 83% rename from gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClassWithAnnotatedFields.java rename to gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClassWithAnnotatedFields.java index a0f7b5d277..0c94e8f2cc 100644 --- a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClassWithAnnotatedFields.java +++ b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClassWithAnnotatedFields.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import com.google.gson.annotations.Expose; diff --git a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClassWithCustomAnnotatedFields.java b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClassWithCustomAnnotatedFields.java similarity index 81% rename from gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClassWithCustomAnnotatedFields.java rename to gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClassWithCustomAnnotatedFields.java index f6aa4651b3..0bd9a149cb 100644 --- a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClassWithCustomAnnotatedFields.java +++ b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClassWithCustomAnnotatedFields.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClassWithTransientFields.java b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClassWithTransientFields.java similarity index 80% rename from gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClassWithTransientFields.java rename to gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClassWithTransientFields.java index d4e31b0bc8..817d2ee557 100644 --- a/gson/src/main/java/org/baeldung/gson/serializationwithexclusions/MySubClassWithTransientFields.java +++ b/gson/src/main/java/com/baeldung/gson/serializationwithexclusions/MySubClassWithTransientFields.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/gson/src/test/java/org/baeldung/gson/advance/GsonAdvanceUnitTest.java b/gson/src/test/java/com/baeldung/gson/advance/GsonAdvanceUnitTest.java similarity index 94% rename from gson/src/test/java/org/baeldung/gson/advance/GsonAdvanceUnitTest.java rename to gson/src/test/java/com/baeldung/gson/advance/GsonAdvanceUnitTest.java index 5b787f1956..d4adb6e406 100644 --- a/gson/src/test/java/org/baeldung/gson/advance/GsonAdvanceUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/advance/GsonAdvanceUnitTest.java @@ -1,8 +1,9 @@ -package org.baeldung.gson.advance; +package com.baeldung.gson.advance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import com.baeldung.gson.entities.Dog; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; @@ -10,11 +11,10 @@ import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.baeldung.gson.entities.Animal; -import org.baeldung.gson.entities.Cow; -import org.baeldung.gson.entities.Dog; -import org.baeldung.gson.entities.MyClass; -import org.baeldung.gson.serialization.AnimalDeserializer; +import com.baeldung.gson.entities.Animal; +import com.baeldung.gson.entities.Cow; +import com.baeldung.gson.entities.MyClass; +import com.baeldung.gson.serialization.AnimalDeserializer; import org.junit.Test; public class GsonAdvanceUnitTest { diff --git a/gson/src/test/java/org/baeldung/gson/advance/RuntimeTypeAdapterFactory.java b/gson/src/test/java/com/baeldung/gson/advance/RuntimeTypeAdapterFactory.java similarity index 99% rename from gson/src/test/java/org/baeldung/gson/advance/RuntimeTypeAdapterFactory.java rename to gson/src/test/java/com/baeldung/gson/advance/RuntimeTypeAdapterFactory.java index 739dd889c7..aab3f5f3f1 100644 --- a/gson/src/test/java/org/baeldung/gson/advance/RuntimeTypeAdapterFactory.java +++ b/gson/src/test/java/com/baeldung/gson/advance/RuntimeTypeAdapterFactory.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.advance; +package com.baeldung.gson.advance; /* * Copyright (C) 2011 Google Inc. diff --git a/gson/src/test/java/org/baeldung/gson/conversion/JsonObjectConversionsUnitTest.java b/gson/src/test/java/com/baeldung/gson/conversion/JsonObjectConversionsUnitTest.java similarity index 96% rename from gson/src/test/java/org/baeldung/gson/conversion/JsonObjectConversionsUnitTest.java rename to gson/src/test/java/com/baeldung/gson/conversion/JsonObjectConversionsUnitTest.java index 847ec1b85d..9f07617969 100644 --- a/gson/src/test/java/org/baeldung/gson/conversion/JsonObjectConversionsUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/conversion/JsonObjectConversionsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.conversion; +package com.baeldung.gson.conversion; import com.google.gson.*; import org.junit.Assert; diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/Foo.java b/gson/src/test/java/com/baeldung/gson/deserialization/Foo.java similarity index 97% rename from gson/src/test/java/org/baeldung/gson/deserialization/Foo.java rename to gson/src/test/java/com/baeldung/gson/deserialization/Foo.java index 84f8aaef13..e556786020 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/Foo.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.deserialization; +package com.baeldung.gson.deserialization; public class Foo { public int intValue; diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/FooDeserializer.java b/gson/src/test/java/com/baeldung/gson/deserialization/FooDeserializer.java similarity index 95% rename from gson/src/test/java/org/baeldung/gson/deserialization/FooDeserializer.java rename to gson/src/test/java/com/baeldung/gson/deserialization/FooDeserializer.java index 17c1dfae19..1ccb3f7de9 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/FooDeserializer.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/FooDeserializer.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.deserialization; +package com.baeldung.gson.deserialization; import java.lang.reflect.Type; diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/FooDeserializerFromJsonWithDifferentFields.java b/gson/src/test/java/com/baeldung/gson/deserialization/FooDeserializerFromJsonWithDifferentFields.java similarity index 94% rename from gson/src/test/java/org/baeldung/gson/deserialization/FooDeserializerFromJsonWithDifferentFields.java rename to gson/src/test/java/com/baeldung/gson/deserialization/FooDeserializerFromJsonWithDifferentFields.java index d4eaa39ac5..289f71820c 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/FooDeserializerFromJsonWithDifferentFields.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/FooDeserializerFromJsonWithDifferentFields.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.deserialization; +package com.baeldung.gson.deserialization; import java.lang.reflect.Type; diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/FooInstanceCreator.java b/gson/src/test/java/com/baeldung/gson/deserialization/FooInstanceCreator.java similarity index 84% rename from gson/src/test/java/org/baeldung/gson/deserialization/FooInstanceCreator.java rename to gson/src/test/java/com/baeldung/gson/deserialization/FooInstanceCreator.java index 4df3986ec3..e3ebc09874 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/FooInstanceCreator.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/FooInstanceCreator.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.deserialization; +package com.baeldung.gson.deserialization; import java.lang.reflect.Type; diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/FooWithInner.java b/gson/src/test/java/com/baeldung/gson/deserialization/FooWithInner.java similarity index 92% rename from gson/src/test/java/org/baeldung/gson/deserialization/FooWithInner.java rename to gson/src/test/java/com/baeldung/gson/deserialization/FooWithInner.java index 705e534e77..ddad97b4ab 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/FooWithInner.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/FooWithInner.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.deserialization; +package com.baeldung.gson.deserialization; public class FooWithInner { public int intValue; diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/GenericFoo.java b/gson/src/test/java/com/baeldung/gson/deserialization/GenericFoo.java similarity index 85% rename from gson/src/test/java/org/baeldung/gson/deserialization/GenericFoo.java rename to gson/src/test/java/com/baeldung/gson/deserialization/GenericFoo.java index 954cf007cf..9a81d5ae7a 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/GenericFoo.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/GenericFoo.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.deserialization; +package com.baeldung.gson.deserialization; public class GenericFoo { diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/GsonAlternateUnitTest.java b/gson/src/test/java/com/baeldung/gson/deserialization/GsonAlternateUnitTest.java similarity index 92% rename from gson/src/test/java/org/baeldung/gson/deserialization/GsonAlternateUnitTest.java rename to gson/src/test/java/com/baeldung/gson/deserialization/GsonAlternateUnitTest.java index f3a5d24e3e..c49a1ea568 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/GsonAlternateUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/GsonAlternateUnitTest.java @@ -1,8 +1,8 @@ -package org.baeldung.gson.deserialization; +package com.baeldung.gson.deserialization; import static org.junit.Assert.assertEquals; -import org.baeldung.gson.entities.Weather; +import com.baeldung.gson.entities.Weather; import org.junit.Test; import com.google.gson.Gson; diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/GsonDeserializeUnitTest.java b/gson/src/test/java/com/baeldung/gson/deserialization/GsonDeserializeUnitTest.java similarity index 90% rename from gson/src/test/java/org/baeldung/gson/deserialization/GsonDeserializeUnitTest.java rename to gson/src/test/java/com/baeldung/gson/deserialization/GsonDeserializeUnitTest.java index 40e8524744..73e76967b9 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/GsonDeserializeUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/GsonDeserializeUnitTest.java @@ -1,10 +1,10 @@ -package org.baeldung.gson.deserialization; +package com.baeldung.gson.deserialization; import java.text.ParseException; -import org.baeldung.gson.entities.ActorGson; -import org.baeldung.gson.entities.Movie; -import org.baeldung.gson.serialization.ActorGsonDeserializer; +import com.baeldung.gson.entities.Movie; +import com.baeldung.gson.serialization.ActorGsonDeserializer; +import com.baeldung.gson.entities.ActorGson; import org.junit.Assert; import org.junit.Test; diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/MapDeserializationUnitTest.java b/gson/src/test/java/com/baeldung/gson/deserialization/MapDeserializationUnitTest.java similarity index 95% rename from gson/src/test/java/org/baeldung/gson/deserialization/MapDeserializationUnitTest.java rename to gson/src/test/java/com/baeldung/gson/deserialization/MapDeserializationUnitTest.java index a5ae4194e8..77c934283a 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/MapDeserializationUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/MapDeserializationUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.deserialization; +package com.baeldung.gson.deserialization; import java.lang.reflect.Type; import java.text.ParseException; @@ -6,9 +6,9 @@ import java.util.Date; import java.util.Map; import org.apache.commons.lang3.time.DateUtils; -import org.baeldung.gson.entities.Employee; -import org.baeldung.gson.serialization.MapDeserializer; -import org.baeldung.gson.serialization.StringDateMapDeserializer; +import com.baeldung.gson.entities.Employee; +import com.baeldung.gson.serialization.MapDeserializer; +import com.baeldung.gson.serialization.StringDateMapDeserializer; import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; diff --git a/gson/src/test/java/org/baeldung/gson/deserialization/test/GsonDeserializationUnitTest.java b/gson/src/test/java/com/baeldung/gson/deserialization/test/GsonDeserializationUnitTest.java similarity index 93% rename from gson/src/test/java/org/baeldung/gson/deserialization/test/GsonDeserializationUnitTest.java rename to gson/src/test/java/com/baeldung/gson/deserialization/test/GsonDeserializationUnitTest.java index 784bb45a6a..adc046ed8e 100644 --- a/gson/src/test/java/org/baeldung/gson/deserialization/test/GsonDeserializationUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/deserialization/test/GsonDeserializationUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.deserialization.test; +package com.baeldung.gson.deserialization.test; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.instanceOf; @@ -10,11 +10,11 @@ import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; -import org.baeldung.gson.deserialization.Foo; -import org.baeldung.gson.deserialization.FooDeserializerFromJsonWithDifferentFields; -import org.baeldung.gson.deserialization.FooInstanceCreator; -import org.baeldung.gson.deserialization.FooWithInner; -import org.baeldung.gson.deserialization.GenericFoo; +import com.baeldung.gson.deserialization.Foo; +import com.baeldung.gson.deserialization.FooDeserializerFromJsonWithDifferentFields; +import com.baeldung.gson.deserialization.FooInstanceCreator; +import com.baeldung.gson.deserialization.FooWithInner; +import com.baeldung.gson.deserialization.GenericFoo; import org.junit.Test; import com.google.common.collect.Lists; diff --git a/gson/src/test/java/org/baeldung/gson/primitives/PrimitiveValuesUnitTest.java b/gson/src/test/java/com/baeldung/gson/primitives/PrimitiveValuesUnitTest.java similarity index 99% rename from gson/src/test/java/org/baeldung/gson/primitives/PrimitiveValuesUnitTest.java rename to gson/src/test/java/com/baeldung/gson/primitives/PrimitiveValuesUnitTest.java index 7d249bc55c..e1241fa92a 100644 --- a/gson/src/test/java/org/baeldung/gson/primitives/PrimitiveValuesUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/primitives/PrimitiveValuesUnitTest.java @@ -1,7 +1,7 @@ -package org.baeldung.gson.primitives; +package com.baeldung.gson.primitives; +import com.baeldung.gson.primitives.models.*; import com.google.gson.*; -import org.baeldung.gson.primitives.models.*; import org.junit.Test; import java.lang.reflect.Type; diff --git a/gson/src/test/java/org/baeldung/gson/serialization/DifferentNameSerializer.java b/gson/src/test/java/com/baeldung/gson/serialization/DifferentNameSerializer.java similarity index 94% rename from gson/src/test/java/org/baeldung/gson/serialization/DifferentNameSerializer.java rename to gson/src/test/java/com/baeldung/gson/serialization/DifferentNameSerializer.java index 9cef1da37b..b82f90f476 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/DifferentNameSerializer.java +++ b/gson/src/test/java/com/baeldung/gson/serialization/DifferentNameSerializer.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; import java.lang.reflect.Type; diff --git a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializeUnitTest.java b/gson/src/test/java/com/baeldung/gson/serialization/GsonSerializeUnitTest.java similarity index 92% rename from gson/src/test/java/org/baeldung/gson/serialization/GsonSerializeUnitTest.java rename to gson/src/test/java/com/baeldung/gson/serialization/GsonSerializeUnitTest.java index 4392ea1631..d5051060c4 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/GsonSerializeUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/serialization/GsonSerializeUnitTest.java @@ -1,11 +1,11 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; +import com.baeldung.gson.entities.Movie; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonParser; -import org.baeldung.gson.entities.ActorGson; -import org.baeldung.gson.entities.Movie; -import org.baeldung.gson.entities.MovieWithNullValue; +import com.baeldung.gson.entities.ActorGson; +import com.baeldung.gson.entities.MovieWithNullValue; import org.junit.Assert; import org.junit.Test; diff --git a/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java b/gson/src/test/java/com/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java similarity index 95% rename from gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java rename to gson/src/test/java/com/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java index 769a4d33a7..554d63b29b 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java +++ b/gson/src/test/java/com/baeldung/gson/serialization/IgnoringFieldsNotMatchingCriteriaSerializer.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; import com.google.gson.JsonElement; import com.google.gson.JsonObject; diff --git a/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java b/gson/src/test/java/com/baeldung/gson/serialization/IgnoringFieldsSerializer.java similarity index 93% rename from gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java rename to gson/src/test/java/com/baeldung/gson/serialization/IgnoringFieldsSerializer.java index bd1928cb18..7f251894a0 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/IgnoringFieldsSerializer.java +++ b/gson/src/test/java/com/baeldung/gson/serialization/IgnoringFieldsSerializer.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; import java.lang.reflect.Type; diff --git a/gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java b/gson/src/test/java/com/baeldung/gson/serialization/SourceClass.java similarity index 96% rename from gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java rename to gson/src/test/java/com/baeldung/gson/serialization/SourceClass.java index 02de2636c2..181f1134b5 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/SourceClass.java +++ b/gson/src/test/java/com/baeldung/gson/serialization/SourceClass.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serialization; +package com.baeldung.gson.serialization; public class SourceClass { private int intValue; diff --git a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationUnitTest.java b/gson/src/test/java/com/baeldung/gson/serialization/test/GsonSerializationUnitTest.java similarity index 91% rename from gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationUnitTest.java rename to gson/src/test/java/com/baeldung/gson/serialization/test/GsonSerializationUnitTest.java index 6806c470b9..4780b8a6bf 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/test/GsonSerializationUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/serialization/test/GsonSerializationUnitTest.java @@ -1,18 +1,16 @@ -package org.baeldung.gson.serialization.test; +package com.baeldung.gson.serialization.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.lang.reflect.Type; -import java.util.Calendar; import java.util.Collection; import java.util.Date; -import java.util.GregorianCalendar; -import org.baeldung.gson.serialization.DifferentNameSerializer; -import org.baeldung.gson.serialization.IgnoringFieldsNotMatchingCriteriaSerializer; -import org.baeldung.gson.serialization.IgnoringFieldsSerializer; -import org.baeldung.gson.serialization.SourceClass; +import com.baeldung.gson.serialization.DifferentNameSerializer; +import com.baeldung.gson.serialization.IgnoringFieldsNotMatchingCriteriaSerializer; +import com.baeldung.gson.serialization.IgnoringFieldsSerializer; +import com.baeldung.gson.serialization.SourceClass; import org.joda.time.DateTime; import org.junit.Test; diff --git a/gson/src/test/java/org/baeldung/gson/serialization/test/JsonFileUnitTest.java b/gson/src/test/java/com/baeldung/gson/serialization/test/JsonFileUnitTest.java similarity index 88% rename from gson/src/test/java/org/baeldung/gson/serialization/test/JsonFileUnitTest.java rename to gson/src/test/java/com/baeldung/gson/serialization/test/JsonFileUnitTest.java index f6a8de080c..8e58435520 100644 --- a/gson/src/test/java/org/baeldung/gson/serialization/test/JsonFileUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/serialization/test/JsonFileUnitTest.java @@ -1,43 +1,43 @@ -package org.baeldung.gson.serialization.test; - -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.nio.file.Files; -import java.nio.file.Paths; - -import org.baeldung.gson.entities.User; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -@RunWith(Parameterized.class) -public class JsonFileUnitTest { - - @Parameter - public Object object; - - @Parameters - public static Object[] data() { - return new Object[] { 123.45, new User(1, "Tom", "American") }; - } - - @Test - public void givenProperData_whenStoredInFile_shouldSaveJsonSuccessfully() { - String filePath = "target/output.json"; - try (Writer writer = new FileWriter(filePath)) { - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - gson.toJson(object, writer); - Assert.assertTrue(Files.exists(Paths.get(filePath))); - } catch (IOException e) { - e.printStackTrace(); - } - } - -} +package com.baeldung.gson.serialization.test; + +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Paths; + +import com.baeldung.gson.entities.User; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +@RunWith(Parameterized.class) +public class JsonFileUnitTest { + + @Parameter + public Object object; + + @Parameters + public static Object[] data() { + return new Object[] { 123.45, new User(1, "Tom", "American") }; + } + + @Test + public void givenProperData_whenStoredInFile_shouldSaveJsonSuccessfully() { + String filePath = "target/output.json"; + try (Writer writer = new FileWriter(filePath)) { + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + gson.toJson(object, writer); + Assert.assertTrue(Files.exists(Paths.get(filePath))); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/gson/src/test/java/org/baeldung/gson/serializationwithexclusions/SerializationWithExclusionsUnitTest.java b/gson/src/test/java/com/baeldung/gson/serializationwithexclusions/SerializationWithExclusionsUnitTest.java similarity index 98% rename from gson/src/test/java/org/baeldung/gson/serializationwithexclusions/SerializationWithExclusionsUnitTest.java rename to gson/src/test/java/com/baeldung/gson/serializationwithexclusions/SerializationWithExclusionsUnitTest.java index 632d06946b..d677f0b271 100644 --- a/gson/src/test/java/org/baeldung/gson/serializationwithexclusions/SerializationWithExclusionsUnitTest.java +++ b/gson/src/test/java/com/baeldung/gson/serializationwithexclusions/SerializationWithExclusionsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.gson.serializationwithexclusions; +package com.baeldung.gson.serializationwithexclusions; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSet.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSet.java similarity index 98% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSet.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSet.java index f474fcb17b..d2c772080d 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSet.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSet.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.base.Function; diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSetUnitTest.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSetUnitTest.java similarity index 98% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSetUnitTest.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSetUnitTest.java index 03f2d8f891..71a526601b 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSetUnitTest.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSetUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.base.Function; import org.junit.Test; diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMultiSetUnitTest.java similarity index 99% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaMultiSetUnitTest.java index e74db29881..dc1489f7ea 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMultiSetUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaRangeSetUnitTest.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaRangeSetUnitTest.java similarity index 99% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaRangeSetUnitTest.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaRangeSetUnitTest.java index edefc61fc4..bd9aa09941 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaRangeSetUnitTest.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaRangeSetUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.collect.ImmutableRangeSet; import com.google.common.collect.Range; diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaSetOperationsUnitTest.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaSetOperationsUnitTest.java similarity index 99% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaSetOperationsUnitTest.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaSetOperationsUnitTest.java index dfd90ad738..eaa6d8a832 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaSetOperationsUnitTest.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaSetOperationsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.base.Function; import com.google.common.base.Joiner; diff --git a/guava-io/src/main/test/java/com/baeldung/guava/GuavaCountingOutputStreamUnitTest.java b/guava-io/src/main/test/java/com/baeldung/guava/GuavaCountingOutputStreamUnitTest.java index 7293b1631e..5d846933f9 100644 --- a/guava-io/src/main/test/java/com/baeldung/guava/GuavaCountingOutputStreamUnitTest.java +++ b/guava-io/src/main/test/java/com/baeldung/guava/GuavaCountingOutputStreamUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/guava-io/src/main/test/java/com/baeldung/guava/GuavaIOUnitTest.java b/guava-io/src/main/test/java/com/baeldung/guava/GuavaIOUnitTest.java index 4a827dfbc0..7d7b0ea04d 100644 --- a/guava-io/src/main/test/java/com/baeldung/guava/GuavaIOUnitTest.java +++ b/guava-io/src/main/test/java/com/baeldung/guava/GuavaIOUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.hamcrest.Matchers.contains; import static org.junit.Assert.assertEquals; diff --git a/guava/src/main/java/org/baeldung/guava/CustomEvent.java b/guava/src/main/java/com/baeldung/guava/CustomEvent.java similarity index 90% rename from guava/src/main/java/org/baeldung/guava/CustomEvent.java rename to guava/src/main/java/com/baeldung/guava/CustomEvent.java index 8534d7da1c..a154790374 100644 --- a/guava/src/main/java/org/baeldung/guava/CustomEvent.java +++ b/guava/src/main/java/com/baeldung/guava/CustomEvent.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; public class CustomEvent { private String action; diff --git a/guava/src/main/java/org/baeldung/guava/EventListener.java b/guava/src/main/java/com/baeldung/guava/EventListener.java similarity index 97% rename from guava/src/main/java/org/baeldung/guava/EventListener.java rename to guava/src/main/java/com/baeldung/guava/EventListener.java index 60beebeea5..7bcfbcb8e9 100644 --- a/guava/src/main/java/org/baeldung/guava/EventListener.java +++ b/guava/src/main/java/com/baeldung/guava/EventListener.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.eventbus.DeadEvent; import com.google.common.eventbus.Subscribe; diff --git a/guava/src/main/java/org/baeldung/guava/memoizer/CostlySupplier.java b/guava/src/main/java/com/baeldung/guava/memoizer/CostlySupplier.java similarity index 89% rename from guava/src/main/java/org/baeldung/guava/memoizer/CostlySupplier.java rename to guava/src/main/java/com/baeldung/guava/memoizer/CostlySupplier.java index 63b3fbd438..9a929a15bd 100644 --- a/guava/src/main/java/org/baeldung/guava/memoizer/CostlySupplier.java +++ b/guava/src/main/java/com/baeldung/guava/memoizer/CostlySupplier.java @@ -1,4 +1,4 @@ -package org.baeldung.guava.memoizer; +package com.baeldung.guava.memoizer; import java.math.BigInteger; import java.util.Random; diff --git a/guava/src/main/java/org/baeldung/guava/memoizer/Factorial.java b/guava/src/main/java/com/baeldung/guava/memoizer/Factorial.java similarity index 93% rename from guava/src/main/java/org/baeldung/guava/memoizer/Factorial.java rename to guava/src/main/java/com/baeldung/guava/memoizer/Factorial.java index 74fcbdcc14..6497979682 100644 --- a/guava/src/main/java/org/baeldung/guava/memoizer/Factorial.java +++ b/guava/src/main/java/com/baeldung/guava/memoizer/Factorial.java @@ -1,4 +1,4 @@ -package org.baeldung.guava.memoizer; +package com.baeldung.guava.memoizer; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; diff --git a/guava/src/main/java/org/baeldung/guava/memoizer/FibonacciSequence.java b/guava/src/main/java/com/baeldung/guava/memoizer/FibonacciSequence.java similarity index 90% rename from guava/src/main/java/org/baeldung/guava/memoizer/FibonacciSequence.java rename to guava/src/main/java/com/baeldung/guava/memoizer/FibonacciSequence.java index 0c70f08c23..d0462fb001 100644 --- a/guava/src/main/java/org/baeldung/guava/memoizer/FibonacciSequence.java +++ b/guava/src/main/java/com/baeldung/guava/memoizer/FibonacciSequence.java @@ -1,11 +1,10 @@ -package org.baeldung.guava.memoizer; +package com.baeldung.guava.memoizer; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import java.math.BigInteger; -import java.util.concurrent.TimeUnit; public class FibonacciSequence { diff --git a/guava/src/test/java/org/baeldung/guava/BloomFilterUnitTest.java b/guava/src/test/java/com/baeldung/guava/BloomFilterUnitTest.java similarity index 98% rename from guava/src/test/java/org/baeldung/guava/BloomFilterUnitTest.java rename to guava/src/test/java/com/baeldung/guava/BloomFilterUnitTest.java index ff3031a0cb..c11bf27256 100644 --- a/guava/src/test/java/org/baeldung/guava/BloomFilterUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/BloomFilterUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.hash.BloomFilter; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaBigIntegerMathUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaBigIntegerMathUnitTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/GuavaBigIntegerMathUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaBigIntegerMathUnitTest.java index f5afe20fc2..cca42a688f 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaBigIntegerMathUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaBigIntegerMathUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCacheLoaderUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaCacheLoaderUnitTest.java similarity index 98% rename from guava/src/test/java/org/baeldung/guava/GuavaCacheLoaderUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaCacheLoaderUnitTest.java index e27171bb84..bf9747ec18 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaCacheLoaderUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaCacheLoaderUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaCacheUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaCacheUnitTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/GuavaCacheUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaCacheUnitTest.java index 49ce6b1a09..8aa56c7c52 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaCacheUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaCacheUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaDoubleMathUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaDoubleMathUnitTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/GuavaDoubleMathUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaDoubleMathUnitTest.java index b39770e2e7..9c78fb36fa 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaDoubleMathUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaDoubleMathUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.junit.Assert.*; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaEventBusUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaEventBusUnitTest.java similarity index 97% rename from guava/src/test/java/org/baeldung/guava/GuavaEventBusUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaEventBusUnitTest.java index 1bc62af300..bb9d26fcce 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaEventBusUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaEventBusUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.eventbus.EventBus; import org.junit.After; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaFunctionalExamplesUnitTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaFunctionalExamplesUnitTest.java index c09ae696b3..b54a7c951a 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaFunctionalExamplesUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaFunctionalExamplesUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaIntMathUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaIntMathUnitTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/GuavaIntMathUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaIntMathUnitTest.java index 9270212929..547f423396 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaIntMathUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaIntMathUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.junit.Assert.*; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaLongMathUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaLongMathUnitTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/GuavaLongMathUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaLongMathUnitTest.java index 680f405149..33c28d4594 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaLongMathUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaLongMathUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.junit.Assert.*; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaMathUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaMathUnitTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/GuavaMathUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaMathUnitTest.java index 1e1f806628..fce0fec13b 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaMathUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaMathUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.Assert.*; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaMemoizerUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaMemoizerUnitTest.java similarity index 94% rename from guava/src/test/java/org/baeldung/guava/GuavaMemoizerUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaMemoizerUnitTest.java index 8c37ecf07c..9bafb7ad3f 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaMemoizerUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaMemoizerUnitTest.java @@ -1,9 +1,9 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.base.Suppliers; -import org.baeldung.guava.memoizer.CostlySupplier; -import org.baeldung.guava.memoizer.Factorial; -import org.baeldung.guava.memoizer.FibonacciSequence; +import com.baeldung.guava.memoizer.CostlySupplier; +import com.baeldung.guava.memoizer.Factorial; +import com.baeldung.guava.memoizer.FibonacciSequence; import org.junit.Test; import java.math.BigInteger; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaPreConditionsUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaPreConditionsUnitTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/GuavaPreConditionsUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaPreConditionsUnitTest.java index 6bf9e5c7a2..fe3be9abf0 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaPreConditionsUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaPreConditionsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.Arrays; diff --git a/guava/src/test/java/org/baeldung/guava/GuavaReflectionUtilsUnitTest.java b/guava/src/test/java/com/baeldung/guava/GuavaReflectionUtilsUnitTest.java similarity index 99% rename from guava/src/test/java/org/baeldung/guava/GuavaReflectionUtilsUnitTest.java rename to guava/src/test/java/com/baeldung/guava/GuavaReflectionUtilsUnitTest.java index f2d1c08ae9..36df241711 100644 --- a/guava/src/test/java/org/baeldung/guava/GuavaReflectionUtilsUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/GuavaReflectionUtilsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.collect.Lists; diff --git a/guava/src/test/java/org/baeldung/guava/RateLimiterLongRunningUnitTest.java b/guava/src/test/java/com/baeldung/guava/RateLimiterLongRunningUnitTest.java similarity index 98% rename from guava/src/test/java/org/baeldung/guava/RateLimiterLongRunningUnitTest.java rename to guava/src/test/java/com/baeldung/guava/RateLimiterLongRunningUnitTest.java index 914de01a6d..7372e9f6e9 100644 --- a/guava/src/test/java/org/baeldung/guava/RateLimiterLongRunningUnitTest.java +++ b/guava/src/test/java/com/baeldung/guava/RateLimiterLongRunningUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.util.concurrent.RateLimiter; diff --git a/guest/core-kotlin/pom.xml b/guest/core-kotlin/pom.xml index 2d4a0c6144..ad0368c6ab 100644 --- a/guest/core-kotlin/pom.xml +++ b/guest/core-kotlin/pom.xml @@ -46,19 +46,19 @@ org.jetbrains.spek spek-api - 1.1.5 + ${spek.api.version} test org.jetbrains.spek spek-subject-extension - 1.1.5 + ${spek.subject.version} test org.jetbrains.spek spek-junit-platform-engine - 1.1.5 + ${spek.junit.version} test @@ -195,6 +195,9 @@ 5.2.0 3.10.0 3.7.0 + 1.1.5 + 1.1.5 + 1.1.5 diff --git a/httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java b/httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java index 380ff9df6b..cafd8cfb7b 100644 --- a/httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java +++ b/httpclient-simple/src/main/java/com/baeldung/basic/MyBasicAuthenticationEntryPoint.java @@ -1,20 +1,20 @@ package com.baeldung.basic; +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; import org.springframework.stereotype.Component; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; - @Component public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { @Override - public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException { response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); final PrintWriter writer = response.getWriter(); @@ -22,7 +22,7 @@ public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoi } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { setRealmName("Baeldung"); super.afterPropertiesSet(); } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java b/httpclient/src/test/java/com/baeldung/httpclient/HttpAsyncClientLiveTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java rename to httpclient/src/test/java/com/baeldung/httpclient/HttpAsyncClientLiveTest.java index 47a587885e..082c282306 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/HttpAsyncClientLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java b/httpclient/src/test/java/com/baeldung/httpclient/HttpClientMultipartLiveTest.java similarity index 98% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java rename to httpclient/src/test/java/com/baeldung/httpclient/HttpClientMultipartLiveTest.java index 1752c27286..7576e49034 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/HttpClientMultipartLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; @@ -38,7 +38,7 @@ public class HttpClientMultipartLiveTest { private static final String TEXTFILENAME = "temp.txt"; private static final String IMAGEFILENAME = "image.jpg"; private static final String ZIPFILENAME = "zipFile.zip"; - private static final Logger LOGGER = Logger.getLogger("org.baeldung.httpclient.HttpClientMultipartLiveTest"); + private static final Logger LOGGER = Logger.getLogger("com.baeldung.httpclient.HttpClientMultipartLiveTest"); private CloseableHttpClient client; private HttpPost post; private BufferedReader rd; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java b/httpclient/src/test/java/com/baeldung/httpclient/HttpClientRedirectLiveTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java rename to httpclient/src/test/java/com/baeldung/httpclient/HttpClientRedirectLiveTest.java index a501367a6b..9a03ab02a5 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/HttpClientRedirectLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/ResponseUtil.java b/httpclient/src/test/java/com/baeldung/httpclient/ResponseUtil.java similarity index 94% rename from httpclient/src/test/java/org/baeldung/httpclient/ResponseUtil.java rename to httpclient/src/test/java/com/baeldung/httpclient/ResponseUtil.java index fd38b95cbe..e9ea08a723 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/ResponseUtil.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/ResponseUtil.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient; +package com.baeldung.httpclient; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java b/httpclient/src/test/java/com/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java rename to httpclient/src/test/java/com/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java index 77d5a298c1..2235d0e9d0 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.advancedconfig; +package com.baeldung.httpclient.advancedconfig; import com.github.tomakehurst.wiremock.junit.WireMockRule; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java b/httpclient/src/test/java/com/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java similarity index 95% rename from httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java rename to httpclient/src/test/java/com/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java index fe275be082..9d4573084b 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java @@ -1,5 +1,6 @@ -package org.baeldung.httpclient.base; +package com.baeldung.httpclient.base; +import com.baeldung.httpclient.ResponseUtil; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.methods.CloseableHttpResponse; @@ -8,7 +9,6 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; -import org.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java b/httpclient/src/test/java/com/baeldung/httpclient/base/HttpClientLiveTest.java similarity index 97% rename from httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java rename to httpclient/src/test/java/com/baeldung/httpclient/base/HttpClientLiveTest.java index 78097227e7..ef12c37412 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/base/HttpClientLiveTest.java @@ -1,5 +1,6 @@ -package org.baeldung.httpclient.base; +package com.baeldung.httpclient.base; +import com.baeldung.httpclient.ResponseUtil; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; @@ -11,7 +12,6 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.BasicHttpClientConnectionManager; -import org.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java b/httpclient/src/test/java/com/baeldung/httpclient/base/HttpClientSandboxLiveTest.java similarity index 94% rename from httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java rename to httpclient/src/test/java/com/baeldung/httpclient/base/HttpClientSandboxLiveTest.java index d945d075f2..c667ae36f6 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/base/HttpClientSandboxLiveTest.java @@ -1,5 +1,6 @@ -package org.baeldung.httpclient.base; +package com.baeldung.httpclient.base; +import com.baeldung.httpclient.ResponseUtil; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; @@ -8,7 +9,6 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; -import org.baeldung.httpclient.ResponseUtil; import org.junit.Test; import java.io.IOException; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java b/httpclient/src/test/java/com/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java rename to httpclient/src/test/java/com/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java index cf945098db..823b506113 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.conn; +package com.baeldung.httpclient.conn; import org.apache.http.HeaderElement; import org.apache.http.HeaderElementIterator; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java b/httpclient/src/test/java/com/baeldung/httpclient/conn/IdleConnectionMonitorThread.java similarity index 96% rename from httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java rename to httpclient/src/test/java/com/baeldung/httpclient/conn/IdleConnectionMonitorThread.java index ffe4155a78..f1d7cbc427 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/conn/IdleConnectionMonitorThread.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.conn; +package com.baeldung.httpclient.conn; import java.util.concurrent.TimeUnit; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java b/httpclient/src/test/java/com/baeldung/httpclient/conn/MultiHttpClientConnThread.java similarity index 98% rename from httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java rename to httpclient/src/test/java/com/baeldung/httpclient/conn/MultiHttpClientConnThread.java index 3794943f02..acadd1f240 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/conn/MultiHttpClientConnThread.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.conn; +package com.baeldung.httpclient.conn; import java.io.IOException; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java b/httpclient/src/test/java/com/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java similarity index 97% rename from httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java rename to httpclient/src/test/java/com/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java index 9cc6480e74..a50858672e 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.conn; +package com.baeldung.httpclient.conn; import java.io.IOException; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java b/httpclient/src/test/java/com/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java similarity index 99% rename from httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java rename to httpclient/src/test/java/com/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java index 8fc79baed9..efa7953ba8 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java +++ b/httpclient/src/test/java/com/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.httpclient.rare; +package com.baeldung.httpclient.rare; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; diff --git a/intelliJ/remote-debugging/README.adoc b/intelliJ/remote-debugging/README.adoc deleted file mode 100644 index 6a4b80959f..0000000000 --- a/intelliJ/remote-debugging/README.adoc +++ /dev/null @@ -1,84 +0,0 @@ -:toc: -:spring_version: current -:icons: font -:source-highlighter: prettify -:project_id: gs-scheduling-tasks -This guide walks you through the steps for scheduling tasks with Spring. - -== What you'll build - -You'll build an application that prints out the current time every five seconds using Spring's `@Scheduled` annotation. - -== What you'll need - -:java_version: 1.8 -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/prereq_editor_jdk_buildtools.adoc[] - - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/how_to_complete_this_guide.adoc[] - - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-gradle.adoc[] - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-maven.adoc[] - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-sts.adoc[] - - - -[[initial]] -== Create a scheduled task -Now that you've set up your project, you can create a scheduled task. - -`src/main/java/hello/ScheduledTasks.java` -[source,java] ----- -include::complete/src/main/java/hello/ScheduledTasks.java[] ----- - -The `Scheduled` annotation defines when a particular method runs. -NOTE: This example uses `fixedRate`, which specifies the interval between method invocations measured from the start time of each invocation. There are https://docs.spring.io/spring/docs/{spring_version}/spring-framework-reference/html/scheduling.html#scheduling-annotation-support-scheduled[other options], like `fixedDelay`, which specifies the interval between invocations measured from the completion of the task. You can also https://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html[use `@Scheduled(cron=". . .")` expressions for more sophisticated task scheduling]. - -== Enable Scheduling - -Although scheduled tasks can be embedded in web apps and WAR files, the simpler approach demonstrated below creates a standalone application. You package everything in a single, executable JAR file, driven by a good old Java `main()` method. - -`src/main/java/hello/Application.java` -[source,java] ----- -include::complete/src/main/java/hello/Application.java[] ----- - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/spring-boot-application.adoc[] - -https://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#scheduling-enable-annotation-support[`@EnableScheduling`] ensures that a background task executor is created. Without it, nothing gets scheduled. - - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_subhead.adoc[] - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/build_an_executable_jar_with_both.adoc[] - - - -Logging output is displayed and you can see from the logs that it is on a background thread. You should see your scheduled task fire every 5 seconds: - -.... -[...] -2016-08-25 13:10:00.143 INFO 31565 --- [pool-1-thread-1] hello.ScheduledTasks : The time is now 13:10:00 -2016-08-25 13:10:05.143 INFO 31565 --- [pool-1-thread-1] hello.ScheduledTasks : The time is now 13:10:05 -2016-08-25 13:10:10.143 INFO 31565 --- [pool-1-thread-1] hello.ScheduledTasks : The time is now 13:10:10 -2016-08-25 13:10:15.143 INFO 31565 --- [pool-1-thread-1] hello.ScheduledTasks : The time is now 13:10:15 -.... - -== Summary - -Congratulations! You created an application with a scheduled task. Heck, the actual code was shorter than the build file! This technique works in any type of application. - -== See Also - -The following guides may also be helpful: - -* https://spring.io/guides/gs/spring-boot/[Building an Application with Spring Boot] -* https://spring.io/guides/gs/batch-processing/[Creating a Batch Service] - -include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/footer.adoc[] diff --git a/intelliJ/remote-debugging/README.md b/intelliJ/remote-debugging/README.md new file mode 100644 index 0000000000..54e3e00ace --- /dev/null +++ b/intelliJ/remote-debugging/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Remote Debugging with IntelliJ IDEA](https://www.baeldung.com/intellij-remote-debugging) diff --git a/intelliJ/remote-debugging/pom.xml b/intelliJ/remote-debugging/pom.xml index d18625e8f6..b8845e49d2 100644 --- a/intelliJ/remote-debugging/pom.xml +++ b/intelliJ/remote-debugging/pom.xml @@ -9,13 +9,16 @@ gs-scheduling-tasks - org.springframework.boot - spring-boot-starter-parent - 2.1.6.RELEASE + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 1.8 + 3.1.2 + 2.1.6.RELEASE @@ -31,7 +34,7 @@ org.awaitility awaitility - 3.1.2 + ${awaitility.version} test @@ -44,5 +47,4 @@ - diff --git a/jackson-annotations/README.md b/jackson-modules/jackson-annotations/README.md similarity index 100% rename from jackson-annotations/README.md rename to jackson-modules/jackson-annotations/README.md diff --git a/jackson-annotations/pom.xml b/jackson-modules/jackson-annotations/pom.xml similarity index 76% rename from jackson-annotations/pom.xml rename to jackson-modules/jackson-annotations/pom.xml index a259d895da..e4a41a5825 100644 --- a/jackson-annotations/pom.xml +++ b/jackson-modules/jackson-annotations/pom.xml @@ -8,22 +8,11 @@ com.baeldung - parent-java + jackson-modules 0.0.1-SNAPSHOT - ../parent-java - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - ${jackson.version} - com.fasterxml.jackson.module jackson-module-jsonSchema diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/CustomListDeserializer.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/CustomListDeserializer.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/CustomListDeserializer.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/CustomListDeserializer.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/CustomListSerializer.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/CustomListSerializer.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/CustomListSerializer.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/CustomListSerializer.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/Item.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/Item.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/Item.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/Item.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithIdentity.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithIgnore.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithRef.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithRef.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithRef.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithRef.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithSerializer.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithSerializer.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithSerializer.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithSerializer.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithView.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithView.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithView.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/ItemWithView.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/User.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/User.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/User.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/User.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithIdentity.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithIdentity.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithIdentity.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithIdentity.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithIgnore.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithIgnore.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithIgnore.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithIgnore.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithRef.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithRef.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithRef.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithRef.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithSerializer.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithSerializer.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithSerializer.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithSerializer.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithView.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithView.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithView.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/UserWithView.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/jsonview/Views.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/jsonview/Views.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/jsonview/Views.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/bidirection/jsonview/Views.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/domain/Person.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/domain/Person.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/domain/Person.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/domain/Person.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/format/User.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/format/User.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/format/User.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/format/User.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/Item.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/Item.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/Item.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/Item.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/MyBeanSerializerModifier.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/MyBeanSerializerModifier.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/MyBeanSerializerModifier.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/MyBeanSerializerModifier.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/UpperCasingWriter.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/UpperCasingWriter.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/UpperCasingWriter.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/UpperCasingWriter.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/User.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/User.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/User.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/User.java diff --git a/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/Views.java b/jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/Views.java similarity index 100% rename from jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/Views.java rename to jackson-modules/jackson-annotations/src/main/java/com/baeldung/jackson/jsonview/Views.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/AdvancedAnnotationsUnitTest.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/AdvancedAnnotationsUnitTest.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/AdvancedAnnotationsUnitTest.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/AdvancedAnnotationsUnitTest.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/AppendBeans.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/AppendBeans.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/AppendBeans.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/AppendBeans.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/IdentityReferenceBeans.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/IdentityReferenceBeans.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/IdentityReferenceBeans.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/IdentityReferenceBeans.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/NamingBean.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/NamingBean.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/NamingBean.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/NamingBean.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/POJOBuilderBean.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/POJOBuilderBean.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/POJOBuilderBean.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/POJOBuilderBean.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/PropertyDescriptionBean.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/PropertyDescriptionBean.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/PropertyDescriptionBean.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/PropertyDescriptionBean.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/TypeIdBean.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/TypeIdBean.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/TypeIdBean.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/TypeIdBean.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/TypeIdResolverStructure.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/TypeIdResolverStructure.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/TypeIdResolverStructure.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/advancedannotations/TypeIdResolverStructure.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/bidirection/JacksonBidirectionRelationUnitTest.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/bidirection/JacksonBidirectionRelationUnitTest.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/bidirection/JacksonBidirectionRelationUnitTest.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/bidirection/JacksonBidirectionRelationUnitTest.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/format/JsonFormatUnitTest.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/format/JsonFormatUnitTest.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/format/JsonFormatUnitTest.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/format/JsonFormatUnitTest.java diff --git a/jackson-annotations/src/test/java/com/baeldung/jackson/jsonview/JacksonJsonViewUnitTest.java b/jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/jsonview/JacksonJsonViewUnitTest.java similarity index 100% rename from jackson-annotations/src/test/java/com/baeldung/jackson/jsonview/JacksonJsonViewUnitTest.java rename to jackson-modules/jackson-annotations/src/test/java/com/baeldung/jackson/jsonview/JacksonJsonViewUnitTest.java diff --git a/jackson-conversions-2/README.md b/jackson-modules/jackson-conversions-2/README.md similarity index 100% rename from jackson-conversions-2/README.md rename to jackson-modules/jackson-conversions-2/README.md diff --git a/jackson-conversions-2/pom.xml b/jackson-modules/jackson-conversions-2/pom.xml similarity index 77% rename from jackson-conversions-2/pom.xml rename to jackson-modules/jackson-conversions-2/pom.xml index 732c89c1e5..43c9d1478b 100644 --- a/jackson-conversions-2/pom.xml +++ b/jackson-modules/jackson-conversions-2/pom.xml @@ -8,23 +8,11 @@ com.baeldung - parent-java + jackson-modules 0.0.1-SNAPSHOT - ../parent-java - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - ${jackson.version} - com.fasterxml.jackson.dataformat diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/JsonCsvConverter.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/JsonCsvConverter.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/JsonCsvConverter.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/JsonCsvConverter.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/OrderLine.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/OrderLine.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/OrderLine.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/OrderLine.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/OrderLineForCsv.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/OrderLineForCsv.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/OrderLineForCsv.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/csv/OrderLineForCsv.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/Product.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/Product.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/Product.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/Product.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/ProductJsonNode.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/ProductJsonNode.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/ProductJsonNode.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/ProductJsonNode.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/ProductMap.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/ProductMap.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/ProductMap.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/dynamicobject/ProductMap.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/multiplefields/Weather.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/multiplefields/Weather.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/multiplefields/Weather.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/multiplefields/Weather.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/xmlToJson/Color.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/xmlToJson/Color.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/xmlToJson/Color.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/xmlToJson/Color.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/xmlToJson/Flower.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/xmlToJson/Flower.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/xmlToJson/Flower.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/xmlToJson/Flower.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/yaml/Order.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/yaml/Order.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/yaml/Order.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/yaml/Order.java diff --git a/jackson-conversions-2/src/main/java/com/baeldung/jackson/yaml/OrderLine.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/yaml/OrderLine.java similarity index 100% rename from jackson-conversions-2/src/main/java/com/baeldung/jackson/yaml/OrderLine.java rename to jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/yaml/OrderLine.java diff --git a/jackson-conversions-2/src/main/resources/csv/orderLines.csv b/jackson-modules/jackson-conversions-2/src/main/resources/csv/orderLines.csv similarity index 100% rename from jackson-conversions-2/src/main/resources/csv/orderLines.csv rename to jackson-modules/jackson-conversions-2/src/main/resources/csv/orderLines.csv diff --git a/jackson-conversions-2/src/main/resources/csv/orderLines.json b/jackson-modules/jackson-conversions-2/src/main/resources/csv/orderLines.json similarity index 100% rename from jackson-conversions-2/src/main/resources/csv/orderLines.json rename to jackson-modules/jackson-conversions-2/src/main/resources/csv/orderLines.json diff --git a/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java similarity index 100% rename from jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java rename to jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java diff --git a/jackson-conversions-2/src/test/java/com/baeldung/jackson/dynamicobject/DynamicObjectDeserializationUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/dynamicobject/DynamicObjectDeserializationUnitTest.java similarity index 100% rename from jackson-conversions-2/src/test/java/com/baeldung/jackson/dynamicobject/DynamicObjectDeserializationUnitTest.java rename to jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/dynamicobject/DynamicObjectDeserializationUnitTest.java diff --git a/jackson-conversions-2/src/test/java/com/baeldung/jackson/multiplefields/MapMultipleFieldsToSingleFieldUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/multiplefields/MapMultipleFieldsToSingleFieldUnitTest.java similarity index 100% rename from jackson-conversions-2/src/test/java/com/baeldung/jackson/multiplefields/MapMultipleFieldsToSingleFieldUnitTest.java rename to jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/multiplefields/MapMultipleFieldsToSingleFieldUnitTest.java diff --git a/jackson-conversions-2/src/test/java/com/baeldung/jackson/streaming/StreamingAPIUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/streaming/StreamingAPIUnitTest.java similarity index 100% rename from jackson-conversions-2/src/test/java/com/baeldung/jackson/streaming/StreamingAPIUnitTest.java rename to jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/streaming/StreamingAPIUnitTest.java diff --git a/jackson-conversions-2/src/test/java/com/baeldung/jackson/xmlToJson/XmlToJsonUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/xmlToJson/XmlToJsonUnitTest.java similarity index 100% rename from jackson-conversions-2/src/test/java/com/baeldung/jackson/xmlToJson/XmlToJsonUnitTest.java rename to jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/xmlToJson/XmlToJsonUnitTest.java diff --git a/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java similarity index 100% rename from jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java rename to jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java diff --git a/jackson-conversions-2/src/test/resources/csv/expectedCsvFromJson.csv b/jackson-modules/jackson-conversions-2/src/test/resources/csv/expectedCsvFromJson.csv similarity index 100% rename from jackson-conversions-2/src/test/resources/csv/expectedCsvFromJson.csv rename to jackson-modules/jackson-conversions-2/src/test/resources/csv/expectedCsvFromJson.csv diff --git a/jackson-conversions-2/src/test/resources/csv/expectedFormattedCsvFromJson.csv b/jackson-modules/jackson-conversions-2/src/test/resources/csv/expectedFormattedCsvFromJson.csv similarity index 100% rename from jackson-conversions-2/src/test/resources/csv/expectedFormattedCsvFromJson.csv rename to jackson-modules/jackson-conversions-2/src/test/resources/csv/expectedFormattedCsvFromJson.csv diff --git a/jackson-conversions-2/src/test/resources/csv/expectedJsonFromCsv.json b/jackson-modules/jackson-conversions-2/src/test/resources/csv/expectedJsonFromCsv.json similarity index 100% rename from jackson-conversions-2/src/test/resources/csv/expectedJsonFromCsv.json rename to jackson-modules/jackson-conversions-2/src/test/resources/csv/expectedJsonFromCsv.json diff --git a/jackson-conversions-2/src/test/resources/deserialize-dynamic-object/embedded.json b/jackson-modules/jackson-conversions-2/src/test/resources/deserialize-dynamic-object/embedded.json similarity index 100% rename from jackson-conversions-2/src/test/resources/deserialize-dynamic-object/embedded.json rename to jackson-modules/jackson-conversions-2/src/test/resources/deserialize-dynamic-object/embedded.json diff --git a/jackson-conversions-2/src/test/resources/deserialize-dynamic-object/flat.json b/jackson-modules/jackson-conversions-2/src/test/resources/deserialize-dynamic-object/flat.json similarity index 100% rename from jackson-conversions-2/src/test/resources/deserialize-dynamic-object/flat.json rename to jackson-modules/jackson-conversions-2/src/test/resources/deserialize-dynamic-object/flat.json diff --git a/jackson-conversions-2/src/test/resources/yaml/orderInput.yaml b/jackson-modules/jackson-conversions-2/src/test/resources/yaml/orderInput.yaml similarity index 100% rename from jackson-conversions-2/src/test/resources/yaml/orderInput.yaml rename to jackson-modules/jackson-conversions-2/src/test/resources/yaml/orderInput.yaml diff --git a/jackson-conversions/README.md b/jackson-modules/jackson-conversions/README.md similarity index 100% rename from jackson-conversions/README.md rename to jackson-modules/jackson-conversions/README.md diff --git a/jackson-conversions/pom.xml b/jackson-modules/jackson-conversions/pom.xml similarity index 69% rename from jackson-conversions/pom.xml rename to jackson-modules/jackson-conversions/pom.xml index c45d88bedd..fafb731cc9 100644 --- a/jackson-conversions/pom.xml +++ b/jackson-modules/jackson-conversions/pom.xml @@ -8,17 +8,11 @@ com.baeldung - parent-java + jackson-modules 0.0.1-SNAPSHOT - ../parent-java - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - com.fasterxml.jackson.datatype jackson-datatype-joda @@ -29,12 +23,6 @@ jackson-datatype-jsr310 ${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - ${jackson.version} - diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateDeserializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateDeserializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateDeserializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateDeserializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateSerializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateSerializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateSerializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateSerializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateTimeSerializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateTimeSerializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateTimeSerializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomDateTimeSerializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomLocalDateTimeSerializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomLocalDateTimeSerializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomLocalDateTimeSerializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/CustomLocalDateTimeSerializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/date/Event.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/Event.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/date/Event.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/Event.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithFormat.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithFormat.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithFormat.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithFormat.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithJodaTime.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithJodaTime.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithJodaTime.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithJodaTime.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithLocalDateTime.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithLocalDateTime.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithLocalDateTime.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithLocalDateTime.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithSerializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithSerializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithSerializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/date/EventWithSerializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/City.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/City.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/City.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/City.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/Distance.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/Distance.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/Distance.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/Distance.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/City.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/City.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/City.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/City.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/CustomEnumDeserializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/CustomEnumDeserializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/CustomEnumDeserializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/CustomEnumDeserializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/Distance.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/Distance.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/Distance.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/customdeserializer/Distance.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsoncreator/City.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsoncreator/City.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsoncreator/City.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsoncreator/City.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsoncreator/Distance.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsoncreator/Distance.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsoncreator/Distance.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsoncreator/Distance.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonproperty/City.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonproperty/City.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonproperty/City.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonproperty/City.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonproperty/Distance.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonproperty/Distance.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonproperty/Distance.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonproperty/Distance.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonvalue/City.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonvalue/City.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonvalue/City.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonvalue/City.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonvalue/Distance.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonvalue/Distance.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonvalue/Distance.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/deserialization/jsonvalue/Distance.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/serialization/Distance.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/serialization/Distance.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/serialization/Distance.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/serialization/Distance.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/serialization/DistanceSerializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/serialization/DistanceSerializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/serialization/DistanceSerializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/serialization/DistanceSerializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumSimple.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumSimple.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumSimple.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumSimple.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumWithJsonFormat.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumWithJsonFormat.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumWithJsonFormat.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumWithJsonFormat.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumWithValue.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumWithValue.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumWithValue.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/DistanceEnumWithValue.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/MyDtoWithEnumCustom.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/MyDtoWithEnumCustom.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/MyDtoWithEnumCustom.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/MyDtoWithEnumCustom.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/MyDtoWithEnumJsonFormat.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/MyDtoWithEnumJsonFormat.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/MyDtoWithEnumJsonFormat.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/enums/withEnum/MyDtoWithEnumJsonFormat.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDto.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDto.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDto.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDto.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoAccessLevel.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoAccessLevel.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoAccessLevel.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoAccessLevel.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoWithGetter.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoWithGetter.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoWithGetter.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoWithGetter.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoWithSetter.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoWithSetter.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoWithSetter.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/field/MyDtoWithSetter.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/immutable/Employee.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/immutable/Employee.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/immutable/Employee.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/immutable/Employee.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/immutable/Person.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/immutable/Person.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/immutable/Person.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/immutable/Person.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/map/ClassWithAMap.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/map/ClassWithAMap.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/map/ClassWithAMap.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/map/ClassWithAMap.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPair.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPair.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPair.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPair.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPairDeserializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPairDeserializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPairDeserializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPairDeserializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPairSerializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPairSerializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPairSerializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/map/MyPairSerializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/mapnull/MyDto.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/mapnull/MyDto.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/mapnull/MyDto.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/mapnull/MyDto.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/mapnull/MyDtoNullKeySerializer.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/mapnull/MyDtoNullKeySerializer.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/mapnull/MyDtoNullKeySerializer.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/mapnull/MyDtoNullKeySerializer.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/tocollection/MyDto.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/tocollection/MyDto.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/tocollection/MyDto.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/tocollection/MyDto.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/xml/Address.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/xml/Address.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/xml/Address.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/xml/Address.java diff --git a/jackson-conversions/src/main/java/com/baeldung/jackson/xml/Person.java b/jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/xml/Person.java similarity index 100% rename from jackson-conversions/src/main/java/com/baeldung/jackson/xml/Person.java rename to jackson-modules/jackson-conversions/src/main/java/com/baeldung/jackson/xml/Person.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/DefaultEnumDeserializationUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/DefaultEnumDeserializationUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/DefaultEnumDeserializationUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/DefaultEnumDeserializationUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/customdeserializer/EnumCustomDeserializationUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/customdeserializer/EnumCustomDeserializationUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/customdeserializer/EnumCustomDeserializationUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/customdeserializer/EnumCustomDeserializationUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsoncreator/EnumDeserializationUsingJsonCreatorUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsoncreator/EnumDeserializationUsingJsonCreatorUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsoncreator/EnumDeserializationUsingJsonCreatorUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsoncreator/EnumDeserializationUsingJsonCreatorUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsonproperty/EnumDeserializationUsingJsonPropertyUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsonproperty/EnumDeserializationUsingJsonPropertyUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsonproperty/EnumDeserializationUsingJsonPropertyUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsonproperty/EnumDeserializationUsingJsonPropertyUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsonvalue/EnumDeserializationUsingJsonValueUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsonvalue/EnumDeserializationUsingJsonValueUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsonvalue/EnumDeserializationUsingJsonValueUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/deserialization/jsonvalue/EnumDeserializationUsingJsonValueUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/enums/serialization/JacksonEnumSerializationUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/serialization/JacksonEnumSerializationUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/enums/serialization/JacksonEnumSerializationUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/serialization/JacksonEnumSerializationUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/enums/serialization/JacksonSerializationEnumsUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/serialization/JacksonSerializationEnumsUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/enums/serialization/JacksonSerializationEnumsUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/enums/serialization/JacksonSerializationEnumsUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/field/JacksonFieldUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/field/JacksonFieldUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/field/JacksonFieldUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/field/JacksonFieldUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/immutable/ImmutableObjectDeserializationUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/immutable/ImmutableObjectDeserializationUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/immutable/ImmutableObjectDeserializationUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/immutable/ImmutableObjectDeserializationUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/map/JacksonMapDeserializeUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/map/JacksonMapDeserializeUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/map/JacksonMapDeserializeUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/map/JacksonMapDeserializeUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/map/JacksonMapSerializeUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/map/JacksonMapSerializeUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/map/JacksonMapSerializeUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/map/JacksonMapSerializeUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/mapnull/JacksonMapNullUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/mapnull/JacksonMapNullUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/mapnull/JacksonMapNullUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/mapnull/JacksonMapNullUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/nested/DeserializeWithNestedPropertiesUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/nested/DeserializeWithNestedPropertiesUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/nested/DeserializeWithNestedPropertiesUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/nested/DeserializeWithNestedPropertiesUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/nested/Product.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/nested/Product.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/nested/Product.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/nested/Product.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/nested/ProductDeserializer.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/nested/ProductDeserializer.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/nested/ProductDeserializer.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/nested/ProductDeserializer.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/tocollection/JacksonCollectionDeserializationUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/tocollection/JacksonCollectionDeserializationUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/tocollection/JacksonCollectionDeserializationUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/tocollection/JacksonCollectionDeserializationUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/tojsonnode/StringToJsonNodeUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/tojsonnode/StringToJsonNodeUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/tojsonnode/StringToJsonNodeUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/tojsonnode/StringToJsonNodeUnitTest.java diff --git a/jackson-conversions/src/test/java/com/baeldung/jackson/xml/XMLSerializeDeserializeUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/xml/XMLSerializeDeserializeUnitTest.java similarity index 100% rename from jackson-conversions/src/test/java/com/baeldung/jackson/xml/XMLSerializeDeserializeUnitTest.java rename to jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/xml/XMLSerializeDeserializeUnitTest.java diff --git a/jackson-conversions/src/test/resources/simple_bean.xml b/jackson-modules/jackson-conversions/src/test/resources/simple_bean.xml similarity index 100% rename from jackson-conversions/src/test/resources/simple_bean.xml rename to jackson-modules/jackson-conversions/src/test/resources/simple_bean.xml diff --git a/jackson-custom-conversions/README.md b/jackson-modules/jackson-custom-conversions/README.md similarity index 100% rename from jackson-custom-conversions/README.md rename to jackson-modules/jackson-custom-conversions/README.md diff --git a/jackson-custom-conversions/pom.xml b/jackson-modules/jackson-custom-conversions/pom.xml similarity index 81% rename from jackson-custom-conversions/pom.xml rename to jackson-modules/jackson-custom-conversions/pom.xml index 68c785e972..c319891da9 100644 --- a/jackson-custom-conversions/pom.xml +++ b/jackson-modules/jackson-custom-conversions/pom.xml @@ -8,17 +8,11 @@ com.baeldung - parent-java + jackson-modules 0.0.1-SNAPSHOT - ../parent-java - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/File.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/File.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/File.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/File.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/Folder.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/Folder.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/Folder.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/Folder.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderBeanSerializerModifier.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderBeanSerializerModifier.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderBeanSerializerModifier.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderBeanSerializerModifier.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializer.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializer.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializer.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializer.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithCallingOwnSerializer.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithCallingOwnSerializer.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithCallingOwnSerializer.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithCallingOwnSerializer.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithDefaultSerializerStored.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithDefaultSerializerStored.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithDefaultSerializerStored.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithDefaultSerializerStored.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithInternalObjectMapper.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithInternalObjectMapper.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithInternalObjectMapper.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithInternalObjectMapper.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithSerializerProvider.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithSerializerProvider.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithSerializerProvider.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/defaultserializercustomserializer/FolderSerializerWithSerializerProvider.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ActorJackson.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ActorJackson.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ActorJackson.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ActorJackson.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/Item.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/Item.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/deserialization/Item.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/Item.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemDeserializer.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemDeserializer.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemDeserializer.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemDeserializer.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemDeserializerOnClass.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemDeserializerOnClass.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemDeserializerOnClass.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemDeserializerOnClass.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemWithDeserializer.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemWithDeserializer.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemWithDeserializer.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/ItemWithDeserializer.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/Movie.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/Movie.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/deserialization/Movie.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/Movie.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/User.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/User.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/deserialization/User.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/deserialization/User.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/serialization/Item.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/Item.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/serialization/Item.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/Item.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemSerializer.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemSerializer.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemSerializer.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemSerializer.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemSerializerOnClass.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemSerializerOnClass.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemSerializerOnClass.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemSerializerOnClass.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemWithSerializer.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemWithSerializer.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemWithSerializer.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/ItemWithSerializer.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/serialization/User.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/User.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/serialization/User.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/serialization/User.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Address.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Address.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Address.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Address.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Hidable.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Hidable.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Hidable.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Hidable.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/HidableSerializer.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/HidableSerializer.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/skipfields/HidableSerializer.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/HidableSerializer.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/MyDtoWithFilter.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/MyDtoWithFilter.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/skipfields/MyDtoWithFilter.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/MyDtoWithFilter.java diff --git a/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Person.java b/jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Person.java similarity index 100% rename from jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Person.java rename to jackson-modules/jackson-custom-conversions/src/main/java/com/baeldung/skipfields/Person.java diff --git a/jackson-custom-conversions/src/test/java/com/baeldung/defaultserializercustomserializer/CallingDefaultSerializerUnitTest.java b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/defaultserializercustomserializer/CallingDefaultSerializerUnitTest.java similarity index 100% rename from jackson-custom-conversions/src/test/java/com/baeldung/defaultserializercustomserializer/CallingDefaultSerializerUnitTest.java rename to jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/defaultserializercustomserializer/CallingDefaultSerializerUnitTest.java diff --git a/jackson-custom-conversions/src/test/java/com/baeldung/deserialization/CustomDeserializationUnitTest.java b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/deserialization/CustomDeserializationUnitTest.java similarity index 100% rename from jackson-custom-conversions/src/test/java/com/baeldung/deserialization/CustomDeserializationUnitTest.java rename to jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/deserialization/CustomDeserializationUnitTest.java diff --git a/jackson-custom-conversions/src/test/java/com/baeldung/serialization/CustomSerializationUnitTest.java b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/serialization/CustomSerializationUnitTest.java similarity index 100% rename from jackson-custom-conversions/src/test/java/com/baeldung/serialization/CustomSerializationUnitTest.java rename to jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/serialization/CustomSerializationUnitTest.java diff --git a/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/IgnoreFieldsWithFilterUnitTest.java b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/IgnoreFieldsWithFilterUnitTest.java similarity index 100% rename from jackson-custom-conversions/src/test/java/com/baeldung/skipfields/IgnoreFieldsWithFilterUnitTest.java rename to jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/IgnoreFieldsWithFilterUnitTest.java diff --git a/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/JacksonDynamicIgnoreUnitTest.java b/jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/JacksonDynamicIgnoreUnitTest.java similarity index 100% rename from jackson-custom-conversions/src/test/java/com/baeldung/skipfields/JacksonDynamicIgnoreUnitTest.java rename to jackson-modules/jackson-custom-conversions/src/test/java/com/baeldung/skipfields/JacksonDynamicIgnoreUnitTest.java diff --git a/jackson-exceptions/README.md b/jackson-modules/jackson-exceptions/README.md similarity index 100% rename from jackson-exceptions/README.md rename to jackson-modules/jackson-exceptions/README.md diff --git a/jackson-exceptions/pom.xml b/jackson-modules/jackson-exceptions/pom.xml similarity index 70% rename from jackson-exceptions/pom.xml rename to jackson-modules/jackson-exceptions/pom.xml index 3cf4796fa7..1a52892523 100644 --- a/jackson-exceptions/pom.xml +++ b/jackson-modules/jackson-exceptions/pom.xml @@ -8,19 +8,10 @@ com.baeldung - parent-java + jackson-modules 0.0.1-SNAPSHOT - ../parent-java - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - jackson-exceptions diff --git a/jackson-exceptions/src/main/java/com/baeldung/exceptions/User.java b/jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/User.java similarity index 100% rename from jackson-exceptions/src/main/java/com/baeldung/exceptions/User.java rename to jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/User.java diff --git a/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithConflict.java b/jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithConflict.java similarity index 100% rename from jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithConflict.java rename to jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithConflict.java diff --git a/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithNoDefaultConstructor.java b/jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithNoDefaultConstructor.java similarity index 100% rename from jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithNoDefaultConstructor.java rename to jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithNoDefaultConstructor.java diff --git a/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithPrivateFields.java b/jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithPrivateFields.java similarity index 100% rename from jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithPrivateFields.java rename to jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithPrivateFields.java diff --git a/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithRoot.java b/jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithRoot.java similarity index 100% rename from jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithRoot.java rename to jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/UserWithRoot.java diff --git a/jackson-exceptions/src/main/java/com/baeldung/exceptions/Zoo.java b/jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/Zoo.java similarity index 100% rename from jackson-exceptions/src/main/java/com/baeldung/exceptions/Zoo.java rename to jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/Zoo.java diff --git a/jackson-exceptions/src/main/java/com/baeldung/exceptions/ZooConfigured.java b/jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/ZooConfigured.java similarity index 100% rename from jackson-exceptions/src/main/java/com/baeldung/exceptions/ZooConfigured.java rename to jackson-modules/jackson-exceptions/src/main/java/com/baeldung/exceptions/ZooConfigured.java diff --git a/jackson-exceptions/src/main/java/com/baeldung/mappingexception/MyDtoNoAccessors.java b/jackson-modules/jackson-exceptions/src/main/java/com/baeldung/mappingexception/MyDtoNoAccessors.java similarity index 100% rename from jackson-exceptions/src/main/java/com/baeldung/mappingexception/MyDtoNoAccessors.java rename to jackson-modules/jackson-exceptions/src/main/java/com/baeldung/mappingexception/MyDtoNoAccessors.java diff --git a/jackson-exceptions/src/main/java/com/baeldung/mappingexception/MyDtoNoAccessorsAndFieldVisibility.java b/jackson-modules/jackson-exceptions/src/main/java/com/baeldung/mappingexception/MyDtoNoAccessorsAndFieldVisibility.java similarity index 100% rename from jackson-exceptions/src/main/java/com/baeldung/mappingexception/MyDtoNoAccessorsAndFieldVisibility.java rename to jackson-modules/jackson-exceptions/src/main/java/com/baeldung/mappingexception/MyDtoNoAccessorsAndFieldVisibility.java diff --git a/jackson-exceptions/src/test/java/com/baeldung/exceptions/JacksonExceptionsUnitTest.java b/jackson-modules/jackson-exceptions/src/test/java/com/baeldung/exceptions/JacksonExceptionsUnitTest.java similarity index 100% rename from jackson-exceptions/src/test/java/com/baeldung/exceptions/JacksonExceptionsUnitTest.java rename to jackson-modules/jackson-exceptions/src/test/java/com/baeldung/exceptions/JacksonExceptionsUnitTest.java diff --git a/jackson-exceptions/src/test/java/com/baeldung/mappingexception/JacksonMappingExceptionUnitTest.java b/jackson-modules/jackson-exceptions/src/test/java/com/baeldung/mappingexception/JacksonMappingExceptionUnitTest.java similarity index 100% rename from jackson-exceptions/src/test/java/com/baeldung/mappingexception/JacksonMappingExceptionUnitTest.java rename to jackson-modules/jackson-exceptions/src/test/java/com/baeldung/mappingexception/JacksonMappingExceptionUnitTest.java diff --git a/jackson/README.md b/jackson-modules/jackson/README.md similarity index 100% rename from jackson/README.md rename to jackson-modules/jackson/README.md diff --git a/jackson/pom.xml b/jackson-modules/jackson/pom.xml similarity index 86% rename from jackson/pom.xml rename to jackson-modules/jackson/pom.xml index d7fc3aac9a..615076fc93 100644 --- a/jackson/pom.xml +++ b/jackson-modules/jackson/pom.xml @@ -3,26 +3,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 jackson - 0.1-SNAPSHOT + 0.0.1-SNAPSHOT jackson com.baeldung - parent-java + jackson-modules 0.0.1-SNAPSHOT - ../parent-java - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - ${jackson.version} - - - com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/jackson/src/main/java/com/baeldung/jackson/deserialization/jacksoninject/Person.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/deserialization/jacksoninject/Person.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/deserialization/jacksoninject/Person.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/deserialization/jacksoninject/Person.java diff --git a/jackson/src/main/java/com/baeldung/jackson/deserialization/jsonanysetter/Inventory.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/deserialization/jsonanysetter/Inventory.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/deserialization/jsonanysetter/Inventory.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/deserialization/jsonanysetter/Inventory.java diff --git a/jackson/src/main/java/com/baeldung/jackson/deserialization/jsondeserialize/Book.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/deserialization/jsondeserialize/Book.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/deserialization/jsondeserialize/Book.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/deserialization/jsondeserialize/Book.java diff --git a/jackson/src/main/java/com/baeldung/jackson/deserialization/jsondeserialize/CustomDateDeserializer.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/deserialization/jsondeserialize/CustomDateDeserializer.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/deserialization/jsondeserialize/CustomDateDeserializer.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/deserialization/jsondeserialize/CustomDateDeserializer.java diff --git a/jackson/src/main/java/com/baeldung/jackson/domain/Person.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/domain/Person.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/domain/Person.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/domain/Person.java diff --git a/jackson/src/main/java/com/baeldung/jackson/inheritance/Event.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/Event.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/inheritance/Event.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/Event.java diff --git a/jackson/src/main/java/com/baeldung/jackson/inheritance/IgnoranceAnnotationStructure.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/IgnoranceAnnotationStructure.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/inheritance/IgnoranceAnnotationStructure.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/IgnoranceAnnotationStructure.java diff --git a/jackson/src/main/java/com/baeldung/jackson/inheritance/IgnoranceMixinOrIntrospection.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/IgnoranceMixinOrIntrospection.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/inheritance/IgnoranceMixinOrIntrospection.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/IgnoranceMixinOrIntrospection.java diff --git a/jackson/src/main/java/com/baeldung/jackson/inheritance/ItemIdAddedToUser.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/ItemIdAddedToUser.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/inheritance/ItemIdAddedToUser.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/ItemIdAddedToUser.java diff --git a/jackson/src/main/java/com/baeldung/jackson/inheritance/ItemIdRemovedFromUser.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/ItemIdRemovedFromUser.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/inheritance/ItemIdRemovedFromUser.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/ItemIdRemovedFromUser.java diff --git a/jackson/src/main/java/com/baeldung/jackson/inheritance/SubTypeConstructorStructure.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/SubTypeConstructorStructure.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/inheritance/SubTypeConstructorStructure.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/SubTypeConstructorStructure.java diff --git a/jackson/src/main/java/com/baeldung/jackson/inheritance/SubTypeConversionStructure.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/SubTypeConversionStructure.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/inheritance/SubTypeConversionStructure.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/SubTypeConversionStructure.java diff --git a/jackson/src/main/java/com/baeldung/jackson/inheritance/TypeInfoAnnotatedStructure.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/TypeInfoAnnotatedStructure.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/inheritance/TypeInfoAnnotatedStructure.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/TypeInfoAnnotatedStructure.java diff --git a/jackson/src/main/java/com/baeldung/jackson/inheritance/TypeInfoStructure.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/TypeInfoStructure.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/inheritance/TypeInfoStructure.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/inheritance/TypeInfoStructure.java diff --git a/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/ActorJackson.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/ActorJackson.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/ActorJackson.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/ActorJackson.java diff --git a/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/ActorJacksonSerializer.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/ActorJacksonSerializer.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/ActorJacksonSerializer.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/ActorJacksonSerializer.java diff --git a/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/Movie.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/Movie.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/Movie.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/Movie.java diff --git a/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/MovieWithNullValue.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/MovieWithNullValue.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/MovieWithNullValue.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/jacksonvsgson/MovieWithNullValue.java diff --git a/jackson/src/main/java/com/baeldung/jackson/node/JsonNodeIterator.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/node/JsonNodeIterator.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/node/JsonNodeIterator.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/node/JsonNodeIterator.java diff --git a/jackson/src/main/java/com/baeldung/jackson/optionalwithjackson/Book.java b/jackson-modules/jackson/src/main/java/com/baeldung/jackson/optionalwithjackson/Book.java similarity index 100% rename from jackson/src/main/java/com/baeldung/jackson/optionalwithjackson/Book.java rename to jackson-modules/jackson/src/main/java/com/baeldung/jackson/optionalwithjackson/Book.java diff --git a/jackson/src/main/resources/example1.json b/jackson-modules/jackson/src/main/resources/example1.json similarity index 100% rename from jackson/src/main/resources/example1.json rename to jackson-modules/jackson/src/main/resources/example1.json diff --git a/jackson/src/main/resources/example2.json b/jackson-modules/jackson/src/main/resources/example2.json similarity index 100% rename from jackson/src/main/resources/example2.json rename to jackson-modules/jackson/src/main/resources/example2.json diff --git a/jackson/src/main/resources/logback.xml b/jackson-modules/jackson/src/main/resources/logback.xml similarity index 100% rename from jackson/src/main/resources/logback.xml rename to jackson-modules/jackson/src/main/resources/logback.xml diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/Address.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/dtos/Address.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/Address.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/dtos/Address.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/MyDto.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/dtos/MyDto.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/MyDto.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/dtos/MyDto.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/Person.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/dtos/Person.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/Person.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/dtos/Person.java diff --git a/jackson/src/test/java/com/baeldung/jackson/dtos/User.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/dtos/User.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/dtos/User.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/dtos/User.java diff --git a/jackson/src/test/java/com/baeldung/jackson/inheritance/IgnoranceUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/IgnoranceUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/inheritance/IgnoranceUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/IgnoranceUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/inheritance/ItemIdRemovedFromUserUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/ItemIdRemovedFromUserUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/inheritance/ItemIdRemovedFromUserUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/ItemIdRemovedFromUserUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/inheritance/SubTypeHandlingUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/SubTypeHandlingUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/inheritance/SubTypeHandlingUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/SubTypeHandlingUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/inheritance/TypeInfoInclusionUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/TypeInfoInclusionUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/inheritance/TypeInfoInclusionUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/inheritance/TypeInfoInclusionUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/jacksonvsgson/JacksonDeserializeUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jacksonvsgson/JacksonDeserializeUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/jacksonvsgson/JacksonDeserializeUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/jacksonvsgson/JacksonDeserializeUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/jacksonvsgson/JacksonSerializeUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jacksonvsgson/JacksonSerializeUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/jacksonvsgson/JacksonSerializeUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/jacksonvsgson/JacksonSerializeUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/jsoncompare/JsonCompareUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsoncompare/JsonCompareUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/jsoncompare/JsonCompareUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/jsoncompare/JsonCompareUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/node/ExampleStructure.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/node/ExampleStructure.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/node/ExampleStructure.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/node/ExampleStructure.java diff --git a/jackson/src/test/java/com/baeldung/jackson/node/JsonNodeIteratorUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/node/JsonNodeIteratorUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/node/JsonNodeIteratorUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/node/JsonNodeIteratorUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/node/NodeBean.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/node/NodeBean.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/node/NodeBean.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/node/NodeBean.java diff --git a/jackson/src/test/java/com/baeldung/jackson/node/NodeOperationUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/node/NodeOperationUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/node/NodeOperationUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/node/NodeOperationUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/optionalwithjackson/OptionalTypeUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/optionalwithjackson/OptionalTypeUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/optionalwithjackson/OptionalTypeUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/optionalwithjackson/OptionalTypeUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/sandbox/JacksonPrettyPrintUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/sandbox/JacksonPrettyPrintUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/sandbox/JacksonPrettyPrintUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/sandbox/JacksonPrettyPrintUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/sandbox/SandboxUnitTest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/sandbox/SandboxUnitTest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/sandbox/SandboxUnitTest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/sandbox/SandboxUnitTest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/sandbox/TestElement.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/sandbox/TestElement.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/sandbox/TestElement.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/sandbox/TestElement.java diff --git a/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/test/UnitTestSuite.java diff --git a/jackson/src/test/java/com/baeldung/jackson/try1/IEntity.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/try1/IEntity.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/try1/IEntity.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/try1/IEntity.java diff --git a/jackson/src/test/java/com/baeldung/jackson/try1/RestLoaderRequest.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/try1/RestLoaderRequest.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/try1/RestLoaderRequest.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/try1/RestLoaderRequest.java diff --git a/jackson/src/test/java/com/baeldung/jackson/try1/RestLoaderRequestDeserializer.java b/jackson-modules/jackson/src/test/java/com/baeldung/jackson/try1/RestLoaderRequestDeserializer.java similarity index 100% rename from jackson/src/test/java/com/baeldung/jackson/try1/RestLoaderRequestDeserializer.java rename to jackson-modules/jackson/src/test/java/com/baeldung/jackson/try1/RestLoaderRequestDeserializer.java diff --git a/jackson/src/test/resources/author-jsonpropertyorder-schema.json b/jackson-modules/jackson/src/test/resources/author-jsonpropertyorder-schema.json similarity index 100% rename from jackson/src/test/resources/author-jsonpropertyorder-schema.json rename to jackson-modules/jackson/src/test/resources/author-jsonpropertyorder-schema.json diff --git a/jackson/src/test/resources/node_example.json b/jackson-modules/jackson/src/test/resources/node_example.json similarity index 100% rename from jackson/src/test/resources/node_example.json rename to jackson-modules/jackson/src/test/resources/node_example.json diff --git a/jackson-modules/pom.xml b/jackson-modules/pom.xml new file mode 100644 index 0000000000..4281710ac9 --- /dev/null +++ b/jackson-modules/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + jackson-modules + jackson-modules + pom + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + jackson + jackson-annotations + jackson-conversions + jackson-conversions-2 + jackson-custom-conversions + jackson-exceptions + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + ${jackson.version} + + + + \ No newline at end of file diff --git a/jackson-simple/README.md b/jackson-simple/README.md index ffc76ead22..41aee8cac9 100644 --- a/jackson-simple/README.md +++ b/jackson-simple/README.md @@ -16,4 +16,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### NOTE: -Since this is a module tied to an e-book, it should **not** be used to store the code for any further article. +Since this is a module tied to an e-book, it should **not** be moved or used to store the code for any further article. diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml index cdda031e0f..f41df7085c 100644 --- a/jackson-simple/pom.xml +++ b/jackson-simple/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 jackson-simple - 0.1-SNAPSHOT + 0.0.1-SNAPSHOT jackson-simple @@ -20,7 +20,6 @@ jackson-dataformat-xml ${jackson.version} - org.assertj diff --git a/java-ee-8-security-api/README.md b/java-ee-8-security-api/README.md index b01a073e35..17142f8102 100644 --- a/java-ee-8-security-api/README.md +++ b/java-ee-8-security-api/README.md @@ -4,4 +4,4 @@ This module contains articles about the Security API in Java EE 8. ### Relevant articles - - [Java EE 8 Security API](https://www.baeldung.com/java-ee-8-security) + - [Jakarta EE 8 Security API](https://www.baeldung.com/java-ee-8-security) diff --git a/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml b/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml index 912a2cabac..a2d9443d67 100644 --- a/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml +++ b/java-ee-8-security-api/app-auth-form-store-ldap/pom.xml @@ -12,12 +12,16 @@ java-ee-8-security-api 1.0-SNAPSHOT + + + 4.0.4 + com.unboundid unboundid-ldapsdk - 4.0.4 + ${unboundid.ldapsdk.version} diff --git a/java-numbers-2/README.md b/java-numbers-2/README.md index e200c4aa03..2d0d5443b1 100644 --- a/java-numbers-2/README.md +++ b/java-numbers-2/README.md @@ -15,4 +15,5 @@ This module contains articles about numbers in Java. - [Binary Numbers in Java](https://www.baeldung.com/java-binary-numbers) - [Generating Random Numbers in a Range in Java](https://www.baeldung.com/java-generating-random-numbers) - [Listing Numbers Within a Range in Java](https://www.baeldung.com/java-listing-numbers-within-a-range) +- [Fibonacci Series in Java](https://www.baeldung.com/java-fibonacci) - More articles: [[<-- prev]](/../java-numbers) diff --git a/java-numbers-2/pom.xml b/java-numbers-2/pom.xml index ba40ef0a38..5c81b00756 100644 --- a/java-numbers-2/pom.xml +++ b/java-numbers-2/pom.xml @@ -21,6 +21,11 @@ jmh-generator-annprocess ${jmh-generator.version} + + it.unimi.dsi + dsiutils + ${dsiutils.version} + @@ -33,4 +38,8 @@ + + 2.6.0 + + diff --git a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java index 68382c26ea..7af8c5d58d 100644 --- a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java +++ b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/BruteForcePrimeChecker.java @@ -7,7 +7,7 @@ public class BruteForcePrimeChecker implements PrimeChecker { @Override public boolean isPrime(Integer number) { - return number > 2 ? IntStream.range(2, number) + return number > 1 ? IntStream.range(2, number) .noneMatch(n -> (number % n == 0)) : false; } diff --git a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java index 3dc372ad22..3019c76eb4 100644 --- a/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java +++ b/java-numbers-2/src/main/java/com/baeldung/algorithms/primechecker/OptimisedPrimeChecker.java @@ -6,7 +6,7 @@ public class OptimisedPrimeChecker implements PrimeChecker { @Override public boolean isPrime(Integer number) { - return number > 2 ? IntStream.rangeClosed(2, (int) Math.sqrt(number)) + return number > 1 ? IntStream.rangeClosed(2, (int) Math.sqrt(number)) .noneMatch(n -> (number % n == 0)) : false; } diff --git a/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java b/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java index 9f8ba8defd..6e425b3051 100644 --- a/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java +++ b/java-numbers-2/src/test/java/com/baeldung/algorithms/primechecker/PrimeCheckerUnitTest.java @@ -11,22 +11,24 @@ public class PrimeCheckerUnitTest { @Test public void whenCheckIsPrime_thenTrue() { - assertTrue(primeChecker.isPrime(13l)); + assertTrue(primeChecker.isPrime(2L)); + assertTrue(primeChecker.isPrime(13L)); assertTrue(primeChecker.isPrime(1009L)); assertTrue(primeChecker.isPrime(74207281L)); } @Test public void whenCheckIsPrime_thenFalse() { - assertTrue(!primeChecker.isPrime(50L)); - assertTrue(!primeChecker.isPrime(1001L)); - assertTrue(!primeChecker.isPrime(74207282L)); + assertFalse(primeChecker.isPrime(50L)); + assertFalse(primeChecker.isPrime(1001L)); + assertFalse(primeChecker.isPrime(74207282L)); } private final BruteForcePrimeChecker bfPrimeChecker = new BruteForcePrimeChecker(); @Test public void whenBFCheckIsPrime_thenTrue() { + assertTrue(bfPrimeChecker.isPrime(2)); assertTrue(bfPrimeChecker.isPrime(13)); assertTrue(bfPrimeChecker.isPrime(1009)); } @@ -41,6 +43,7 @@ public class PrimeCheckerUnitTest { @Test public void whenOptCheckIsPrime_thenTrue() { + assertTrue(optimisedPrimeChecker.isPrime(2)); assertTrue(optimisedPrimeChecker.isPrime(13)); assertTrue(optimisedPrimeChecker.isPrime(1009)); } @@ -55,6 +58,7 @@ public class PrimeCheckerUnitTest { @Test public void whenPrimesCheckIsPrime_thenTrue() { + assertTrue(primesPrimeChecker.isPrime(2)); assertTrue(primesPrimeChecker.isPrime(13)); assertTrue(primesPrimeChecker.isPrime(1009)); } diff --git a/java-numbers-3/pom.xml b/java-numbers-3/pom.xml new file mode 100644 index 0000000000..bf5fe9b0e7 --- /dev/null +++ b/java-numbers-3/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + java-numbers-3 + java-numbers-3 + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + it.unimi.dsi + dsiutils + ${dsiutils.version} + + + + + java-numbers-3 + + + src/main/resources + true + + + + + + 2.6.0 + + + diff --git a/java-numbers-3/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java b/java-numbers-3/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java new file mode 100644 index 0000000000..50a072371e --- /dev/null +++ b/java-numbers-3/src/main/java/com/baeldung/randomnumbers/RandomNumbersGenerator.java @@ -0,0 +1,103 @@ +package com.baeldung.randomnumbers; + +import java.security.SecureRandom; +import java.util.Random; +import java.util.SplittableRandom; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.IntStream; + +import org.apache.commons.math3.random.RandomDataGenerator; + +import it.unimi.dsi.util.XoRoShiRo128PlusRandom; + +public class RandomNumbersGenerator { + + public Integer generateRandomWithMathRandom(int max, int min) { + return (int) ((Math.random() * (max - min)) + min); + } + + public Integer generateRandomWithNextInt() { + Random random = new Random(); + int randomWithNextInt = random.nextInt(); + return randomWithNextInt; + } + + public Integer generateRandomWithNextIntWithinARange(int min, int max) { + Random random = new Random(); + int randomWintNextIntWithinARange = random.nextInt(max - min) + min; + return randomWintNextIntWithinARange; + } + + public IntStream generateRandomUnlimitedIntStream() { + Random random = new Random(); + IntStream unlimitedIntStream = random.ints(); + return unlimitedIntStream; + } + + public IntStream generateRandomLimitedIntStream(long streamSize) { + Random random = new Random(); + IntStream limitedIntStream = random.ints(streamSize); + return limitedIntStream; + } + + public IntStream generateRandomLimitedIntStreamWithinARange(int min, int max, long streamSize) { + Random random = new Random(); + IntStream limitedIntStreamWithinARange = random.ints(streamSize, min, max); + return limitedIntStreamWithinARange; + } + + public Integer generateRandomWithThreadLocalRandom() { + int randomWithThreadLocalRandom = ThreadLocalRandom.current() + .nextInt(); + return randomWithThreadLocalRandom; + } + + public Integer generateRandomWithThreadLocalRandomInARange(int min, int max) { + int randomWithThreadLocalRandomInARange = ThreadLocalRandom.current() + .nextInt(min, max); + return randomWithThreadLocalRandomInARange; + } + + public Integer generateRandomWithThreadLocalRandomFromZero(int max) { + int randomWithThreadLocalRandomFromZero = ThreadLocalRandom.current() + .nextInt(max); + return randomWithThreadLocalRandomFromZero; + } + + public Integer generateRandomWithSplittableRandom(int min, int max) { + SplittableRandom splittableRandom = new SplittableRandom(); + int randomWithSplittableRandom = splittableRandom.nextInt(min, max); + return randomWithSplittableRandom; + } + + public IntStream generateRandomWithSplittableRandomLimitedIntStreamWithinARange(int min, int max, long streamSize) { + SplittableRandom splittableRandom = new SplittableRandom(); + IntStream limitedIntStreamWithinARangeWithSplittableRandom = splittableRandom.ints(streamSize, min, max); + return limitedIntStreamWithinARangeWithSplittableRandom; + } + + public Integer generateRandomWithSecureRandom() { + SecureRandom secureRandom = new SecureRandom(); + int randomWithSecureRandom = secureRandom.nextInt(); + return randomWithSecureRandom; + } + + public Integer generateRandomWithSecureRandomWithinARange(int min, int max) { + SecureRandom secureRandom = new SecureRandom(); + int randomWithSecureRandomWithinARange = secureRandom.nextInt(max - min) + min; + return randomWithSecureRandomWithinARange; + } + + public Integer generateRandomWithRandomDataGenerator(int min, int max) { + RandomDataGenerator randomDataGenerator = new RandomDataGenerator(); + int randomWithRandomDataGenerator = randomDataGenerator.nextInt(min, max); + return randomWithRandomDataGenerator; + } + + public Integer generateRandomWithXoRoShiRo128PlusRandom(int min, int max) { + XoRoShiRo128PlusRandom xoroRandom = new XoRoShiRo128PlusRandom(); + int randomWithXoRoShiRo128PlusRandom = xoroRandom.nextInt(max - min) + min; + return randomWithXoRoShiRo128PlusRandom; + } + +} diff --git a/java-numbers-3/src/test/java/com/baeldung/doubletolong/DoubleToLongUnitTest.java b/java-numbers-3/src/test/java/com/baeldung/doubletolong/DoubleToLongUnitTest.java new file mode 100644 index 0000000000..702c59c12b --- /dev/null +++ b/java-numbers-3/src/test/java/com/baeldung/doubletolong/DoubleToLongUnitTest.java @@ -0,0 +1,64 @@ +package com.baeldung.doubletolong; + +import org.junit.Assert; +import org.junit.Test; + +public class DoubleToLongUnitTest { + + final static double VALUE = 9999.999; + + @Test + public void givenDoubleValue_whenLongValueCalled_thenLongValueReturned() { + Assert.assertEquals(9999L, Double.valueOf(VALUE).longValue()); + } + + @Test + public void givenDoubleValue_whenMathRoundUsed_thenRoundUp() { + Assert.assertEquals(10000L, Math.round(VALUE)); + } + + @Test + public void givenDoubleValue_whenMathRoundUsed_thenRoundDown() { + Assert.assertEquals(9999L, Math.round(9999.444)); + } + + @Test + public void givenDoubleValue_whenMathRoundUsed_thenSameValueReturned() { + Assert.assertEquals(9999L, Math.round(9999.0)); + } + + @Test + public void givenDoubleValue_whenMathCeilUsed_thenLongValueReturned() { + Assert.assertEquals(10000L, Math.ceil(VALUE), 0); + } + + @Test + public void givenDoubleValue_whenMathCeilUsed_thenSameValueReturned() { + Assert.assertEquals(9999L, Math.ceil(9999.0), 0); + } + + @Test + public void givenDoubleValue_whenMathCeilUsed_thenDifferentThanRound() { + Assert.assertEquals(10000L, Math.ceil(9999.444), 0); + } + + @Test + public void givenDoubleValue_whenMathFloorUsed_thenLongValueReturned() { + Assert.assertEquals(9999L, Math.floor(VALUE), 0); + } + + @Test + public void givenDoubleValue_whenMathFloorUsed_thenSameValueReturned() { + Assert.assertEquals(9999L, Math.floor(9999.0), 0); + } + + @Test + public void givenDoubleValue_whenMathFloorUsed_thenDifferentThanCeil() { + Assert.assertEquals(9999L, Math.floor(9999.444), 0); + } + + @Test + public void givenDoubleValue_whenTypeCasted_thenLongValueReturned() { + Assert.assertEquals(9999L, (long) VALUE); + } +} diff --git a/java-numbers-3/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java b/java-numbers-3/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java new file mode 100644 index 0000000000..bdd955a4ee --- /dev/null +++ b/java-numbers-3/src/test/java/com/baeldung/randomnumbers/RandomNumbersGeneratorUnitTest.java @@ -0,0 +1,154 @@ +package com.baeldung.randomnumbers; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.stream.IntStream; + +import org.junit.Test; + +public class RandomNumbersGeneratorUnitTest { + + private static final int MIN_RANGE = 1; + private static final int MAX_RANGE = 10; + private static final int MIN_RANGE_NEGATIVE = -10; + private static final int ITERATIONS = 50; + private static final long STREAM_SIZE = 50; + + @Test + public void whenGenerateRandomWithMathRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumer = generator.generateRandomWithMathRandom(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumer, MIN_RANGE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithNextInt_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithNextInt(); + assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + } + + @Test + public void whenGenerateRandomWithNextIntWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithNextIntWithinARange(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomUnlimitedIntStream_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + IntStream stream = generator.generateRandomUnlimitedIntStream(); + assertNotNull(stream); + Integer randomNumber = stream.findFirst() + .getAsInt(); + assertNotNull(randomNumber); + assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + + @Test + public void whenGenerateRandomLimitedIntStream_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + generator.generateRandomLimitedIntStream(STREAM_SIZE) + .forEach(randomNumber -> assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE))); + } + + @Test + public void whenGenerateRandomLimitedIntStreamWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + generator.generateRandomLimitedIntStreamWithinARange(MIN_RANGE, MAX_RANGE, STREAM_SIZE) + .forEach(randomNumber -> assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE))); + } + + @Test + public void whenGenerateRandomWithThreadLocalRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithThreadLocalRandom(); + assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + } + + @Test + public void whenGenerateRandomWithThreadLocalRandomInARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithThreadLocalRandomInARange(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithThreadLocalRandomFromZero_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithThreadLocalRandomFromZero(MAX_RANGE); + assertTrue(isInRange(randomNumber, 0, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithSplittableRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithSplittableRandom(MIN_RANGE_NEGATIVE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE_NEGATIVE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithSplittableRandomLimitedIntStreamWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + generator.generateRandomWithSplittableRandomLimitedIntStreamWithinARange(MIN_RANGE, MAX_RANGE, STREAM_SIZE) + .forEach(randomNumber -> assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE))); + } + + @Test + public void whenGenerateRandomWithSecureRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithSecureRandom(); + assertTrue(isInRange(randomNumber, Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + } + + @Test + public void whenGenerateRandomWithSecureRandomWithinARange_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithSecureRandomWithinARange(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + } + } + + @Test + public void whenGenerateRandomWithRandomDataGenerator_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithRandomDataGenerator(MIN_RANGE, MAX_RANGE); + // RandomDataGenerator top is inclusive + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE + 1)); + } + } + + @Test + public void whenGenerateRandomWithXoRoShiRo128PlusRandom_returnsSuccessfully() { + RandomNumbersGenerator generator = new RandomNumbersGenerator(); + for (int i = 0; i < ITERATIONS; i++) { + int randomNumber = generator.generateRandomWithXoRoShiRo128PlusRandom(MIN_RANGE, MAX_RANGE); + assertTrue(isInRange(randomNumber, MIN_RANGE, MAX_RANGE)); + } + } + + private boolean isInRange(int number, int min, int max) { + return min <= number && number < max; + } + +} diff --git a/javax-servlets/README.md b/javax-servlets/README.md index 085cc04f87..7dbe1a02ad 100644 --- a/javax-servlets/README.md +++ b/javax-servlets/README.md @@ -9,6 +9,6 @@ This module contains articles about Servlets. - [Uploading Files with Servlets and JSP](https://www.baeldung.com/upload-file-servlet) - [Example of Downloading File in a Servlet](https://www.baeldung.com/servlet-download-file) - [Returning a JSON Response from a Servlet](https://www.baeldung.com/servlet-json-response) -- [Java EE Servlet Exception Handling](https://www.baeldung.com/servlet-exceptions) +- [Jakarta EE Servlet Exception Handling](https://www.baeldung.com/servlet-exceptions) - [Context and Servlet Initialization Parameters](https://www.baeldung.com/context-servlet-initialization-param) - [The Difference between getRequestURI and getPathInfo in HttpServletRequest](https://www.baeldung.com/http-servlet-request-requesturi-pathinfo) diff --git a/javaxval/src/main/java/org/baeldung/javaxval/beanvalidation/User.java b/javaxval/src/main/java/com/baeldung/javaxval/beanvalidation/User.java similarity index 97% rename from javaxval/src/main/java/org/baeldung/javaxval/beanvalidation/User.java rename to javaxval/src/main/java/com/baeldung/javaxval/beanvalidation/User.java index 8303edd033..d583ac51d2 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/beanvalidation/User.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/beanvalidation/User.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.beanvalidation; +package com.baeldung.javaxval.beanvalidation; import java.time.LocalDate; import java.util.List; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/bigdecimal/Invoice.java b/javaxval/src/main/java/com/baeldung/javaxval/bigdecimal/Invoice.java similarity index 91% rename from javaxval/src/main/java/org/baeldung/javaxval/bigdecimal/Invoice.java rename to javaxval/src/main/java/com/baeldung/javaxval/bigdecimal/Invoice.java index 087701f166..c14a6bd2b1 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/bigdecimal/Invoice.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/bigdecimal/Invoice.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.bigdecimal; +package com.baeldung.javaxval.bigdecimal; import java.math.BigDecimal; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/container/validation/Customer.java b/javaxval/src/main/java/com/baeldung/javaxval/container/validation/Customer.java similarity index 96% rename from javaxval/src/main/java/org/baeldung/javaxval/container/validation/Customer.java rename to javaxval/src/main/java/com/baeldung/javaxval/container/validation/Customer.java index 6ca5ba3ee1..03811635ee 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/container/validation/Customer.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/container/validation/Customer.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.container.validation; +package com.baeldung.javaxval.container.validation; import java.util.List; import java.util.Optional; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/container/validation/CustomerMap.java b/javaxval/src/main/java/com/baeldung/javaxval/container/validation/CustomerMap.java similarity index 89% rename from javaxval/src/main/java/org/baeldung/javaxval/container/validation/CustomerMap.java rename to javaxval/src/main/java/com/baeldung/javaxval/container/validation/CustomerMap.java index 82cf0f2b0c..554285fbae 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/container/validation/CustomerMap.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/container/validation/CustomerMap.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.container.validation; +package com.baeldung.javaxval.container.validation; import java.util.Map; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/container/validation/Profile.java b/javaxval/src/main/java/com/baeldung/javaxval/container/validation/Profile.java similarity index 81% rename from javaxval/src/main/java/org/baeldung/javaxval/container/validation/Profile.java rename to javaxval/src/main/java/com/baeldung/javaxval/container/validation/Profile.java index 41260540fc..252e671250 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/container/validation/Profile.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/container/validation/Profile.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.container.validation; +package com.baeldung.javaxval.container.validation; public class Profile { private String companyName; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/container/validation/valueextractors/ProfileValueExtractor.java b/javaxval/src/main/java/com/baeldung/javaxval/container/validation/valueextractors/ProfileValueExtractor.java similarity index 79% rename from javaxval/src/main/java/org/baeldung/javaxval/container/validation/valueextractors/ProfileValueExtractor.java rename to javaxval/src/main/java/com/baeldung/javaxval/container/validation/valueextractors/ProfileValueExtractor.java index ebc618e80e..03e0c7aac4 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/container/validation/valueextractors/ProfileValueExtractor.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/container/validation/valueextractors/ProfileValueExtractor.java @@ -1,10 +1,10 @@ -package org.baeldung.javaxval.container.validation.valueextractors; +package com.baeldung.javaxval.container.validation.valueextractors; import javax.validation.valueextraction.ExtractedValue; import javax.validation.valueextraction.UnwrapByDefault; import javax.validation.valueextraction.ValueExtractor; -import org.baeldung.javaxval.container.validation.Profile; +import com.baeldung.javaxval.container.validation.Profile; @UnwrapByDefault public class ProfileValueExtractor implements ValueExtractor<@ExtractedValue(type = String.class) Profile> { diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/CustomerTypeSubSetValidator.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/CustomerTypeSubSetValidator.java similarity index 79% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/CustomerTypeSubSetValidator.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/CustomerTypeSubSetValidator.java index c730cb937f..c91f449bad 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/CustomerTypeSubSetValidator.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/CustomerTypeSubSetValidator.java @@ -1,12 +1,12 @@ -package org.baeldung.javaxval.enums; +package com.baeldung.javaxval.enums; import java.util.Arrays; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import org.baeldung.javaxval.enums.constraints.CustomerTypeSubset; -import org.baeldung.javaxval.enums.demo.CustomerType; +import com.baeldung.javaxval.enums.constraints.CustomerTypeSubset; +import com.baeldung.javaxval.enums.demo.CustomerType; public class CustomerTypeSubSetValidator implements ConstraintValidator { private CustomerType[] subset; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/EnumNamePatternValidator.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/EnumNamePatternValidator.java similarity index 89% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/EnumNamePatternValidator.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/EnumNamePatternValidator.java index a279813461..3d56d40563 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/EnumNamePatternValidator.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/EnumNamePatternValidator.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums; +package com.baeldung.javaxval.enums; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -7,7 +7,7 @@ import java.util.regex.PatternSyntaxException; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import org.baeldung.javaxval.enums.constraints.EnumNamePattern; +import com.baeldung.javaxval.enums.constraints.EnumNamePattern; public class EnumNamePatternValidator implements ConstraintValidator> { private Pattern pattern; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/EnumSubSetValidator.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/EnumSubSetValidator.java similarity index 94% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/EnumSubSetValidator.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/EnumSubSetValidator.java index 339b4fb03b..04cccb8b0c 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/EnumSubSetValidator.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/EnumSubSetValidator.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums; +package com.baeldung.javaxval.enums; import java.lang.annotation.Annotation; import java.util.Arrays; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/InheritedCustomerTypeSubSetValidator.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/InheritedCustomerTypeSubSetValidator.java similarity index 61% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/InheritedCustomerTypeSubSetValidator.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/InheritedCustomerTypeSubSetValidator.java index 1cd31c4187..b49bc11541 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/InheritedCustomerTypeSubSetValidator.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/InheritedCustomerTypeSubSetValidator.java @@ -1,7 +1,7 @@ -package org.baeldung.javaxval.enums; +package com.baeldung.javaxval.enums; -import org.baeldung.javaxval.enums.constraints.CustomerTypeSubset; -import org.baeldung.javaxval.enums.demo.CustomerType; +import com.baeldung.javaxval.enums.constraints.CustomerTypeSubset; +import com.baeldung.javaxval.enums.demo.CustomerType; public class InheritedCustomerTypeSubSetValidator extends EnumSubSetValidator { @Override diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/ValueOfEnumValidator.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/ValueOfEnumValidator.java similarity index 89% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/ValueOfEnumValidator.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/ValueOfEnumValidator.java index 7184dae49b..0203d63923 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/ValueOfEnumValidator.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/ValueOfEnumValidator.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums; +package com.baeldung.javaxval.enums; import java.util.List; import java.util.stream.Collectors; @@ -7,7 +7,7 @@ import java.util.stream.Stream; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import org.baeldung.javaxval.enums.constraints.ValueOfEnum; +import com.baeldung.javaxval.enums.constraints.ValueOfEnum; public class ValueOfEnumValidator implements ConstraintValidator { private List acceptedValues; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/constraints/CustomerTypeSubset.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/constraints/CustomerTypeSubset.java similarity index 88% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/constraints/CustomerTypeSubset.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/constraints/CustomerTypeSubset.java index 44009e6723..97c2137f6a 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/constraints/CustomerTypeSubset.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/constraints/CustomerTypeSubset.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums.constraints; +package com.baeldung.javaxval.enums.constraints; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; import static java.lang.annotation.ElementType.CONSTRUCTOR; @@ -15,8 +15,8 @@ import java.lang.annotation.Target; import javax.validation.Constraint; import javax.validation.Payload; -import org.baeldung.javaxval.enums.CustomerTypeSubSetValidator; -import org.baeldung.javaxval.enums.demo.CustomerType; +import com.baeldung.javaxval.enums.CustomerTypeSubSetValidator; +import com.baeldung.javaxval.enums.demo.CustomerType; @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE }) @Retention(RUNTIME) diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/constraints/EnumNamePattern.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/constraints/EnumNamePattern.java similarity index 91% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/constraints/EnumNamePattern.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/constraints/EnumNamePattern.java index 403cdcd0b4..29fff857c8 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/constraints/EnumNamePattern.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/constraints/EnumNamePattern.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums.constraints; +package com.baeldung.javaxval.enums.constraints; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; import static java.lang.annotation.ElementType.CONSTRUCTOR; @@ -15,7 +15,7 @@ import java.lang.annotation.Target; import javax.validation.Constraint; import javax.validation.Payload; -import org.baeldung.javaxval.enums.EnumNamePatternValidator; +import com.baeldung.javaxval.enums.EnumNamePatternValidator; @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE }) @Retention(RUNTIME) diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/constraints/ValueOfEnum.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/constraints/ValueOfEnum.java similarity index 92% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/constraints/ValueOfEnum.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/constraints/ValueOfEnum.java index 0f9677d982..29b44a1793 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/constraints/ValueOfEnum.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/constraints/ValueOfEnum.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums.constraints; +package com.baeldung.javaxval.enums.constraints; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; import static java.lang.annotation.ElementType.CONSTRUCTOR; @@ -15,7 +15,7 @@ import java.lang.annotation.Target; import javax.validation.Constraint; import javax.validation.Payload; -import org.baeldung.javaxval.enums.ValueOfEnumValidator; +import com.baeldung.javaxval.enums.ValueOfEnumValidator; @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE }) @Retention(RUNTIME) diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/demo/Customer.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/demo/Customer.java similarity index 91% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/demo/Customer.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/demo/Customer.java index db3486ab5f..15cd9e0da7 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/demo/Customer.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/demo/Customer.java @@ -1,10 +1,10 @@ -package org.baeldung.javaxval.enums.demo; +package com.baeldung.javaxval.enums.demo; import javax.validation.constraints.NotNull; -import org.baeldung.javaxval.enums.constraints.CustomerTypeSubset; -import org.baeldung.javaxval.enums.constraints.EnumNamePattern; -import org.baeldung.javaxval.enums.constraints.ValueOfEnum; +import com.baeldung.javaxval.enums.constraints.CustomerTypeSubset; +import com.baeldung.javaxval.enums.constraints.EnumNamePattern; +import com.baeldung.javaxval.enums.constraints.ValueOfEnum; public class Customer { @ValueOfEnum(enumClass = CustomerType.class) diff --git a/javaxval/src/main/java/org/baeldung/javaxval/enums/demo/CustomerType.java b/javaxval/src/main/java/com/baeldung/javaxval/enums/demo/CustomerType.java similarity index 55% rename from javaxval/src/main/java/org/baeldung/javaxval/enums/demo/CustomerType.java rename to javaxval/src/main/java/com/baeldung/javaxval/enums/demo/CustomerType.java index 937f3a3817..88eb1b359f 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/enums/demo/CustomerType.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/enums/demo/CustomerType.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums.demo; +package com.baeldung.javaxval.enums.demo; public enum CustomerType { NEW, OLD, DEFAULT diff --git a/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/application/Application.java b/javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/application/Application.java similarity index 77% rename from javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/application/Application.java rename to javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/application/Application.java index 22095084c5..22157f351c 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/application/Application.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/application/Application.java @@ -1,9 +1,9 @@ -package org.baeldung.javaxval.javabeanconstraints.application; +package com.baeldung.javaxval.javabeanconstraints.application; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.javabeanconstraints.entities.UserNotBlank; +import com.baeldung.javaxval.javabeanconstraints.entities.UserNotBlank; public class Application { diff --git a/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotBlank.java b/javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/entities/UserNotBlank.java similarity index 86% rename from javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotBlank.java rename to javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/entities/UserNotBlank.java index d86b6a65d2..5542be8c25 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotBlank.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/entities/UserNotBlank.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.javabeanconstraints.entities; +package com.baeldung.javaxval.javabeanconstraints.entities; import javax.validation.constraints.NotBlank; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotEmpty.java b/javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/entities/UserNotEmpty.java similarity index 86% rename from javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotEmpty.java rename to javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/entities/UserNotEmpty.java index 2082265145..e3dbe27b0e 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotEmpty.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/entities/UserNotEmpty.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.javabeanconstraints.entities; +package com.baeldung.javaxval.javabeanconstraints.entities; import javax.validation.constraints.NotEmpty; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotNull.java b/javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/entities/UserNotNull.java similarity index 86% rename from javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotNull.java rename to javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/entities/UserNotNull.java index e2f9e7ec57..b3a0f90d36 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/javabeanconstraints/entities/UserNotNull.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/javabeanconstraints/entities/UserNotNull.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.javabeanconstraints.entities; +package com.baeldung.javaxval.javabeanconstraints.entities; import javax.validation.constraints.NotNull; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/messageinterpolator/Person.java b/javaxval/src/main/java/com/baeldung/javaxval/messageinterpolator/Person.java similarity index 94% rename from javaxval/src/main/java/org/baeldung/javaxval/messageinterpolator/Person.java rename to javaxval/src/main/java/com/baeldung/javaxval/messageinterpolator/Person.java index b9fcfdf4d4..387af48c20 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/messageinterpolator/Person.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/messageinterpolator/Person.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.messageinterpolator; +package com.baeldung.javaxval.messageinterpolator; import javax.validation.constraints.Email; import javax.validation.constraints.Min; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/MethodValidationConfig.java b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/MethodValidationConfig.java similarity index 82% rename from javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/MethodValidationConfig.java rename to javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/MethodValidationConfig.java index 817f2370ef..d4046bf5f9 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/MethodValidationConfig.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/MethodValidationConfig.java @@ -1,9 +1,9 @@ -package org.baeldung.javaxval.methodvalidation; +package com.baeldung.javaxval.methodvalidation; import java.time.LocalDate; -import org.baeldung.javaxval.methodvalidation.model.Customer; -import org.baeldung.javaxval.methodvalidation.model.Reservation; +import com.baeldung.javaxval.methodvalidation.model.Customer; +import com.baeldung.javaxval.methodvalidation.model.Reservation; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -12,7 +12,7 @@ import org.springframework.context.annotation.Scope; import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; @Configuration -@ComponentScan({ "org.baeldung.javaxval.methodvalidation.model" }) +@ComponentScan({ "com.baeldung.javaxval.methodvalidation.model" }) public class MethodValidationConfig { @Bean diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java similarity index 94% rename from javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java rename to javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java index df09cfa906..6b48046b5c 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameterValidator.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.methodvalidation.constraints; +package com.baeldung.javaxval.methodvalidation.constraints; import java.time.LocalDate; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java similarity index 92% rename from javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java rename to javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java index bdfabe05ba..83f551d45f 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ConsistentDateParameters.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.methodvalidation.constraints; +package com.baeldung.javaxval.methodvalidation.constraints; import static java.lang.annotation.ElementType.CONSTRUCTOR; import static java.lang.annotation.ElementType.METHOD; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java similarity index 92% rename from javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java rename to javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java index 842f9e0621..c28cc79004 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ValidReservation.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.methodvalidation.constraints; +package com.baeldung.javaxval.methodvalidation.constraints; import static java.lang.annotation.ElementType.CONSTRUCTOR; import static java.lang.annotation.ElementType.METHOD; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java similarity index 88% rename from javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java rename to javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java index c139d1affc..541fc15e9c 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/constraints/ValidReservationValidator.java @@ -1,11 +1,11 @@ -package org.baeldung.javaxval.methodvalidation.constraints; +package com.baeldung.javaxval.methodvalidation.constraints; import java.time.LocalDate; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import org.baeldung.javaxval.methodvalidation.model.Reservation; +import com.baeldung.javaxval.methodvalidation.model.Reservation; public class ValidReservationValidator implements ConstraintValidator { diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Customer.java b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/model/Customer.java similarity index 94% rename from javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Customer.java rename to javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/model/Customer.java index 99a32d6277..e0b7fcf917 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Customer.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/model/Customer.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.methodvalidation.model; +package com.baeldung.javaxval.methodvalidation.model; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Reservation.java b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/model/Reservation.java similarity index 86% rename from javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Reservation.java rename to javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/model/Reservation.java index 5775bdd66b..49cf1306a9 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/Reservation.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/model/Reservation.java @@ -1,12 +1,12 @@ -package org.baeldung.javaxval.methodvalidation.model; +package com.baeldung.javaxval.methodvalidation.model; import java.time.LocalDate; import javax.validation.Valid; import javax.validation.constraints.Positive; -import org.baeldung.javaxval.methodvalidation.constraints.ConsistentDateParameters; -import org.baeldung.javaxval.methodvalidation.constraints.ValidReservation; +import com.baeldung.javaxval.methodvalidation.constraints.ValidReservation; +import com.baeldung.javaxval.methodvalidation.constraints.ConsistentDateParameters; import org.springframework.validation.annotation.Validated; @Validated diff --git a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/ReservationManagement.java b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/model/ReservationManagement.java similarity index 91% rename from javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/ReservationManagement.java rename to javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/model/ReservationManagement.java index e480e7912d..41fc4c3840 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/methodvalidation/model/ReservationManagement.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/methodvalidation/model/ReservationManagement.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.methodvalidation.model; +package com.baeldung.javaxval.methodvalidation.model; import java.time.LocalDate; import java.util.List; @@ -9,7 +9,7 @@ import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import org.baeldung.javaxval.methodvalidation.constraints.ConsistentDateParameters; +import com.baeldung.javaxval.methodvalidation.constraints.ConsistentDateParameters; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Controller; diff --git a/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/AdvanceInfo.java b/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/AdvanceInfo.java new file mode 100644 index 0000000000..0be96f1341 --- /dev/null +++ b/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/AdvanceInfo.java @@ -0,0 +1,5 @@ +package com.baeldung.javaxval.validationgroup; + +public interface AdvanceInfo { + +} diff --git a/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/BasicInfo.java b/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/BasicInfo.java new file mode 100644 index 0000000000..7413c10cda --- /dev/null +++ b/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/BasicInfo.java @@ -0,0 +1,5 @@ +package com.baeldung.javaxval.validationgroup; + +public interface BasicInfo { + +} diff --git a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/CompleteInfo.java b/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/CompleteInfo.java similarity index 73% rename from javaxval/src/main/java/org/baeldung/javaxval/validationgroup/CompleteInfo.java rename to javaxval/src/main/java/com/baeldung/javaxval/validationgroup/CompleteInfo.java index e34f318b5f..4ecdc3c5f1 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/CompleteInfo.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/CompleteInfo.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.validationgroup; +package com.baeldung.javaxval.validationgroup; import javax.validation.GroupSequence; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/RegistrationForm.java b/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/RegistrationForm.java similarity index 98% rename from javaxval/src/main/java/org/baeldung/javaxval/validationgroup/RegistrationForm.java rename to javaxval/src/main/java/com/baeldung/javaxval/validationgroup/RegistrationForm.java index 190a0c1280..a30a074556 100644 --- a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/RegistrationForm.java +++ b/javaxval/src/main/java/com/baeldung/javaxval/validationgroup/RegistrationForm.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.validationgroup; +package com.baeldung.javaxval.validationgroup; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; diff --git a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/AdvanceInfo.java b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/AdvanceInfo.java deleted file mode 100644 index 9a398e9e7e..0000000000 --- a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/AdvanceInfo.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.javaxval.validationgroup; - -public interface AdvanceInfo { - -} diff --git a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/BasicInfo.java b/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/BasicInfo.java deleted file mode 100644 index 6959f52bfa..0000000000 --- a/javaxval/src/main/java/org/baeldung/javaxval/validationgroup/BasicInfo.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.javaxval.validationgroup; - -public interface BasicInfo { - -} diff --git a/javaxval/src/main/resources/META-INF/services/javax.validation.valueextraction.ValueExtractor b/javaxval/src/main/resources/META-INF/services/javax.validation.valueextraction.ValueExtractor index 16bacf1097..0c1fcddd9b 100644 --- a/javaxval/src/main/resources/META-INF/services/javax.validation.valueextraction.ValueExtractor +++ b/javaxval/src/main/resources/META-INF/services/javax.validation.valueextraction.ValueExtractor @@ -1 +1 @@ -org.baeldung.javaxval.container.validation.valueextractors.ProfileValueExtractor \ No newline at end of file +com.baeldung.javaxval.container.validation.valueextractors.ProfileValueExtractor \ No newline at end of file diff --git a/javaxval/src/test/java/org/baeldung/javaxval/LocaleAwareUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/LocaleAwareUnitTest.java similarity index 93% rename from javaxval/src/test/java/org/baeldung/javaxval/LocaleAwareUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/LocaleAwareUnitTest.java index 5623b50a72..ebf1ca3dc6 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/LocaleAwareUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/LocaleAwareUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval; +package com.baeldung.javaxval; import java.util.Locale; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java b/javaxval/src/test/java/com/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java similarity index 98% rename from javaxval/src/test/java/org/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java index 3d54955177..3e60fa7acd 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/beanvalidation/ValidationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.beanvalidation; +package com.baeldung.javaxval.beanvalidation; import static org.junit.Assert.assertEquals; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java similarity index 96% rename from javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java index 6a53d67f30..2df0cf81af 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/bigdecimal/InvoiceUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.bigdecimal; +package com.baeldung.javaxval.bigdecimal; import static org.assertj.core.api.Assertions.assertThat; @@ -9,7 +9,7 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.LocaleAwareUnitTest; +import com.baeldung.javaxval.LocaleAwareUnitTest; import org.junit.BeforeClass; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java b/javaxval/src/test/java/com/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java similarity index 96% rename from javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java index 25c8111732..d96b641442 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/container/validation/ContainerValidationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.container.validation; +package com.baeldung.javaxval.container.validation; import static org.junit.Assert.assertEquals; @@ -11,7 +11,7 @@ import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -import org.baeldung.javaxval.container.validation.valueextractors.ProfileValueExtractor; +import com.baeldung.javaxval.container.validation.valueextractors.ProfileValueExtractor; import org.junit.Before; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/enums/CustomerTypeSubSetValidatorUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/enums/CustomerTypeSubSetValidatorUnitTest.java similarity index 87% rename from javaxval/src/test/java/org/baeldung/javaxval/enums/CustomerTypeSubSetValidatorUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/enums/CustomerTypeSubSetValidatorUnitTest.java index 5aae504b23..08a51de81e 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/enums/CustomerTypeSubSetValidatorUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/enums/CustomerTypeSubSetValidatorUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums; +package com.baeldung.javaxval.enums; import static org.assertj.core.api.Assertions.assertThat; @@ -8,9 +8,9 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.enums.demo.Customer; -import org.baeldung.javaxval.enums.demo.CustomerType; -import org.baeldung.javaxval.enums.demo.CustomerUnitTest; +import com.baeldung.javaxval.enums.demo.CustomerUnitTest; +import com.baeldung.javaxval.enums.demo.Customer; +import com.baeldung.javaxval.enums.demo.CustomerType; import org.junit.BeforeClass; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/enums/EnumNamePatternValidatorUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/enums/EnumNamePatternValidatorUnitTest.java similarity index 86% rename from javaxval/src/test/java/org/baeldung/javaxval/enums/EnumNamePatternValidatorUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/enums/EnumNamePatternValidatorUnitTest.java index 48f7de2c34..03bb1f73ba 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/enums/EnumNamePatternValidatorUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/enums/EnumNamePatternValidatorUnitTest.java @@ -1,8 +1,8 @@ -package org.baeldung.javaxval.enums; +package com.baeldung.javaxval.enums; import static org.assertj.core.api.Assertions.assertThat; -import static org.baeldung.javaxval.enums.demo.CustomerType.DEFAULT; -import static org.baeldung.javaxval.enums.demo.CustomerType.OLD; +import static com.baeldung.javaxval.enums.demo.CustomerType.DEFAULT; +import static com.baeldung.javaxval.enums.demo.CustomerType.OLD; import java.util.Set; @@ -10,8 +10,8 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.enums.demo.Customer; -import org.baeldung.javaxval.enums.demo.CustomerUnitTest; +import com.baeldung.javaxval.enums.demo.CustomerUnitTest; +import com.baeldung.javaxval.enums.demo.Customer; import org.junit.BeforeClass; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/enums/ValueOfEnumValidatorUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/enums/ValueOfEnumValidatorUnitTest.java similarity index 89% rename from javaxval/src/test/java/org/baeldung/javaxval/enums/ValueOfEnumValidatorUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/enums/ValueOfEnumValidatorUnitTest.java index 0784b58b77..723ac3cc32 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/enums/ValueOfEnumValidatorUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/enums/ValueOfEnumValidatorUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums; +package com.baeldung.javaxval.enums; import static org.assertj.core.api.Assertions.assertThat; @@ -8,8 +8,8 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.enums.demo.Customer; -import org.baeldung.javaxval.enums.demo.CustomerUnitTest; +import com.baeldung.javaxval.enums.demo.CustomerUnitTest; +import com.baeldung.javaxval.enums.demo.Customer; import org.junit.BeforeClass; import org.junit.Test; @@ -47,6 +47,6 @@ public class ValueOfEnumValidatorUnitTest { assertThat(violations.size()).isEqualTo(1); assertThat(violations).anyMatch(CustomerUnitTest.havingPropertyPath("customerTypeString") - .and(CustomerUnitTest.havingMessage("must be any of enum class org.baeldung.javaxval.enums.demo.CustomerType"))); + .and(CustomerUnitTest.havingMessage("must be any of enum class com.baeldung.javaxval.enums.demo.CustomerType"))); } } \ No newline at end of file diff --git a/javaxval/src/test/java/org/baeldung/javaxval/enums/demo/CustomerUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/enums/demo/CustomerUnitTest.java similarity index 92% rename from javaxval/src/test/java/org/baeldung/javaxval/enums/demo/CustomerUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/enums/demo/CustomerUnitTest.java index 6a064b640f..2c810bc2fe 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/enums/demo/CustomerUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/enums/demo/CustomerUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.enums.demo; +package com.baeldung.javaxval.enums.demo; import static org.assertj.core.api.Assertions.assertThat; @@ -9,7 +9,7 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.LocaleAwareUnitTest; +import com.baeldung.javaxval.LocaleAwareUnitTest; import org.junit.BeforeClass; import org.junit.Test; @@ -50,7 +50,7 @@ public class CustomerUnitTest extends LocaleAwareUnitTest { Set> violations = validator.validate(customer); assertThat(violations.size()).isEqualTo(3); - assertThat(violations).anyMatch(havingPropertyPath("customerTypeString").and(havingMessage("must be any of enum class org.baeldung.javaxval.enums.demo.CustomerType"))); + assertThat(violations).anyMatch(havingPropertyPath("customerTypeString").and(havingMessage("must be any of enum class com.baeldung.javaxval.enums.demo.CustomerType"))); assertThat(violations).anyMatch(havingPropertyPath("customerTypeOfSubset").and(havingMessage("must be any of [NEW, OLD]"))); assertThat(violations).anyMatch(havingPropertyPath("customerTypeMatchesPattern").and(havingMessage("must match \"NEW|DEFAULT\""))); } diff --git a/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotBlankUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/javabeanconstraints/test/UserNotBlankUnitTest.java similarity index 93% rename from javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotBlankUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/javabeanconstraints/test/UserNotBlankUnitTest.java index e3a51d4e27..5219004c6d 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotBlankUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/javabeanconstraints/test/UserNotBlankUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.javabeanconstraints.test; +package com.baeldung.javaxval.javabeanconstraints.test; import static org.assertj.core.api.Assertions.assertThat; @@ -8,7 +8,7 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.javabeanconstraints.entities.UserNotBlank; +import com.baeldung.javaxval.javabeanconstraints.entities.UserNotBlank; import org.junit.BeforeClass; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotEmptyUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/javabeanconstraints/test/UserNotEmptyUnitTest.java similarity index 92% rename from javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotEmptyUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/javabeanconstraints/test/UserNotEmptyUnitTest.java index 22fbab6997..7017848756 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotEmptyUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/javabeanconstraints/test/UserNotEmptyUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.javabeanconstraints.test; +package com.baeldung.javaxval.javabeanconstraints.test; import static org.assertj.core.api.Assertions.assertThat; @@ -8,7 +8,7 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.javabeanconstraints.entities.UserNotEmpty; +import com.baeldung.javaxval.javabeanconstraints.entities.UserNotEmpty; import org.junit.BeforeClass; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotNullUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/javabeanconstraints/test/UserNotNullUnitTest.java similarity index 92% rename from javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotNullUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/javabeanconstraints/test/UserNotNullUnitTest.java index a684668ae3..b0df88d72b 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/javabeanconstraints/test/UserNotNullUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/javabeanconstraints/test/UserNotNullUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.javabeanconstraints.test; +package com.baeldung.javaxval.javabeanconstraints.test; import static org.assertj.core.api.Assertions.assertThat; @@ -8,7 +8,7 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.javabeanconstraints.entities.UserNotNull; +import com.baeldung.javaxval.javabeanconstraints.entities.UserNotNull; import org.junit.BeforeClass; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/messageinterpolator/ParameterMessageInterpolaterIntegrationTest.java b/javaxval/src/test/java/com/baeldung/javaxval/messageinterpolator/ParameterMessageInterpolaterIntegrationTest.java similarity index 97% rename from javaxval/src/test/java/org/baeldung/javaxval/messageinterpolator/ParameterMessageInterpolaterIntegrationTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/messageinterpolator/ParameterMessageInterpolaterIntegrationTest.java index 6ecb916ab4..a60550aca5 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/messageinterpolator/ParameterMessageInterpolaterIntegrationTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/messageinterpolator/ParameterMessageInterpolaterIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.messageinterpolator; +package com.baeldung.javaxval.messageinterpolator; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java b/javaxval/src/test/java/com/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java similarity index 92% rename from javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java index 8febdca0ee..d9daf6c4ff 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/methodvalidation/ContainerValidationIntegrationTest.java @@ -1,13 +1,13 @@ -package org.baeldung.javaxval.methodvalidation; +package com.baeldung.javaxval.methodvalidation; import java.time.LocalDate; import java.util.List; import javax.validation.ConstraintViolationException; -import org.baeldung.javaxval.methodvalidation.model.Customer; -import org.baeldung.javaxval.methodvalidation.model.Reservation; -import org.baeldung.javaxval.methodvalidation.model.ReservationManagement; +import com.baeldung.javaxval.methodvalidation.model.Customer; +import com.baeldung.javaxval.methodvalidation.model.Reservation; +import com.baeldung.javaxval.methodvalidation.model.ReservationManagement; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java b/javaxval/src/test/java/com/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java similarity index 97% rename from javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java index 9baeba7189..6f297a7c9c 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/methodvalidation/ValidationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.methodvalidation; +package com.baeldung.javaxval.methodvalidation; import static org.junit.Assert.assertEquals; @@ -13,9 +13,9 @@ import javax.validation.Validation; import javax.validation.ValidatorFactory; import javax.validation.executable.ExecutableValidator; -import org.baeldung.javaxval.methodvalidation.model.Customer; -import org.baeldung.javaxval.methodvalidation.model.Reservation; -import org.baeldung.javaxval.methodvalidation.model.ReservationManagement; +import com.baeldung.javaxval.methodvalidation.model.Customer; +import com.baeldung.javaxval.methodvalidation.model.Reservation; +import com.baeldung.javaxval.methodvalidation.model.ReservationManagement; import org.junit.Before; import org.junit.Test; diff --git a/javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java b/javaxval/src/test/java/com/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java similarity index 98% rename from javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java rename to javaxval/src/test/java/com/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java index df70ca0bce..6b7600d201 100644 --- a/javaxval/src/test/java/org/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java +++ b/javaxval/src/test/java/com/baeldung/javaxval/validationgroup/RegistrationFormUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.javaxval.validationgroup; +package com.baeldung.javaxval.validationgroup; import static org.assertj.core.api.Assertions.assertThat; @@ -8,7 +8,7 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; -import org.baeldung.javaxval.LocaleAwareUnitTest; +import com.baeldung.javaxval.LocaleAwareUnitTest; import org.junit.BeforeClass; import org.junit.Test; diff --git a/jee-7-security/README.md b/jee-7-security/README.md index ced2beec46..0d95d81474 100644 --- a/jee-7-security/README.md +++ b/jee-7-security/README.md @@ -3,4 +3,4 @@ This module contains articles about security in JEE 7. ### Relevant Articles: -- [Securing Java EE with Spring Security](https://www.baeldung.com/java-ee-spring-security) +- [Securing Jakarta EE with Spring Security](https://www.baeldung.com/java-ee-spring-security) diff --git a/jee-7/README.md b/jee-7/README.md index 2c45fe2c67..adaee67d74 100644 --- a/jee-7/README.md +++ b/jee-7/README.md @@ -3,7 +3,7 @@ This module contains articles about JEE 7. ### Relevant Articles: -- [Scheduling in Java EE](https://www.baeldung.com/scheduling-in-java-enterprise-edition) +- [Scheduling in Jakarta EE](https://www.baeldung.com/scheduling-in-java-enterprise-edition) - [JSON Processing in Java EE 7](https://www.baeldung.com/jee7-json) - [Converters, Listeners and Validators in Java EE 7](https://www.baeldung.com/java-ee7-converter-listener-validator) - [Introduction to JAX-WS](https://www.baeldung.com/jax-ws) diff --git a/jee-7/pom.xml b/jee-7/pom.xml index 635d820c2b..a2593e46a5 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -118,7 +118,7 @@ javax.mvc javax.mvc-api - 20160715 + ${mvc.api.version} org.glassfish.ozark @@ -215,7 +215,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -506,6 +506,8 @@ + 1.0.0 + 20160715 1.8 3.0.0 7.0 diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java index ade492b1b9..3babf9b5aa 100644 --- a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java +++ b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java @@ -1,13 +1,17 @@ package com.baeldung.batch.understanding; -import static org.junit.jupiter.api.Assertions.*; -import java.util.Properties; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + import javax.batch.operations.JobOperator; import javax.batch.runtime.BatchRuntime; import javax.batch.runtime.BatchStatus; import javax.batch.runtime.JobExecution; -import org.junit.jupiter.api.Test; +import java.util.Properties; +import static org.junit.jupiter.api.Assertions.assertEquals; + +@Disabled("Should be fixed in BAEL-3812") class SimpleBatchLetUnitTest { @Test public void givenBatchLet_thenBatch_CompleteWithSuccess() throws Exception { diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java index ded31b6345..c53561a0c0 100644 --- a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java +++ b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java @@ -1,21 +1,19 @@ package com.baeldung.batch.understanding; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -import java.util.List; -import java.util.Map; -import java.util.Properties; import javax.batch.operations.JobOperator; import javax.batch.runtime.BatchRuntime; import javax.batch.runtime.BatchStatus; import javax.batch.runtime.JobExecution; -import javax.batch.runtime.Metric.MetricType; import javax.batch.runtime.StepExecution; +import java.util.List; +import java.util.Properties; -import org.junit.jupiter.api.Test; +import static org.junit.Assert.assertEquals; +@Disabled("Should be fixed in BAEL-3812") class SimpleErrorChunkUnitTest { @Test diff --git a/jee-kotlin/README.md b/jee-kotlin/README.md index aa3aa58b4e..e8975a7f62 100644 --- a/jee-kotlin/README.md +++ b/jee-kotlin/README.md @@ -3,4 +3,4 @@ This module contains articles about Java EE with Kotlin. ### Relevant Articles: -- [Java EE Application with Kotlin](https://www.baeldung.com/java-ee-kotlin-app) +- [Jakarta EE Application with Kotlin](https://www.baeldung.com/java-ee-kotlin-app) diff --git a/jee-kotlin/pom.xml b/jee-kotlin/pom.xml index 80c5ea4e22..9191885bd4 100644 --- a/jee-kotlin/pom.xml +++ b/jee-kotlin/pom.xml @@ -253,7 +253,7 @@ org.wildfly.arquillian wildfly-arquillian-container-remote - 2.2.0.Final + ${wildfly.arquillian.version} test @@ -261,6 +261,7 @@ + 2.2.0.Final UTF-8 false 8.0 diff --git a/jhipster/jhipster-microservice/car-app/pom.xml b/jhipster/jhipster-microservice/car-app/pom.xml index 86d94d0a44..c53ea8358e 100644 --- a/jhipster/jhipster-microservice/car-app/pom.xml +++ b/jhipster/jhipster-microservice/car-app/pom.xml @@ -17,6 +17,7 @@ + 1.0.0 -Djava.security.egd=file:/dev/./urandom -Xmx256m 3.6.2 2.0.0 @@ -433,7 +434,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} diff --git a/jhipster/jhipster-microservice/dealer-app/pom.xml b/jhipster/jhipster-microservice/dealer-app/pom.xml index 3051399ae6..a0bcc73e31 100644 --- a/jhipster/jhipster-microservice/dealer-app/pom.xml +++ b/jhipster/jhipster-microservice/dealer-app/pom.xml @@ -92,6 +92,7 @@ 1.4.10.Final 1.1.0.Final v0.21.3 + 1.0.0 @@ -427,7 +428,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} diff --git a/jhipster/jhipster-microservice/gateway-app/pom.xml b/jhipster/jhipster-microservice/gateway-app/pom.xml index 4e2c19ed2d..c6dcbb3f3e 100644 --- a/jhipster/jhipster-microservice/gateway-app/pom.xml +++ b/jhipster/jhipster-microservice/gateway-app/pom.xml @@ -96,6 +96,7 @@ 1.4.10.Final 1.1.0.Final v0.21.3 + 1.0.0 @@ -469,7 +470,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} diff --git a/jhipster/jhipster-monolithic/pom.xml b/jhipster/jhipster-monolithic/pom.xml index 12dead99df..04f790faf5 100644 --- a/jhipster/jhipster-monolithic/pom.xml +++ b/jhipster/jhipster-monolithic/pom.xml @@ -302,7 +302,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -398,8 +398,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - 1.8 - 1.8 + ${source.version} + ${target.version} org.mapstruct @@ -881,6 +881,9 @@ + 1.8 + 1.8 + 1.0.0 -Djava.security.egd=file:/dev/./urandom -Xmx256m 3.6.2 2.0.0 diff --git a/jhipster/jhipster-uaa/gateway/pom.xml b/jhipster/jhipster-uaa/gateway/pom.xml index 0f815bedad..1b85877a9b 100644 --- a/jhipster/jhipster-uaa/gateway/pom.xml +++ b/jhipster/jhipster-uaa/gateway/pom.xml @@ -236,7 +236,7 @@ org.zalando problem-spring-web - 0.24.0-RC.0 + ${spring.web.version} org.springframework.security.oauth @@ -559,7 +559,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -1012,6 +1012,8 @@ + 1.0.0 + 0.24.0-RC.0 3.0.0 1.8 diff --git a/jhipster/jhipster-uaa/quotes/pom.xml b/jhipster/jhipster-uaa/quotes/pom.xml index 81ab23471f..aacc6f8e36 100644 --- a/jhipster/jhipster-uaa/quotes/pom.xml +++ b/jhipster/jhipster-uaa/quotes/pom.xml @@ -232,7 +232,7 @@ org.zalando problem-spring-web - 0.24.0-RC.0 + ${zalando.version} org.springframework.security.oauth @@ -910,5 +910,6 @@ ${project.basedir}/src/test/ + 0.24.0-RC.0 diff --git a/jhipster/jhipster-uaa/uaa/pom.xml b/jhipster/jhipster-uaa/uaa/pom.xml index 2c4dd9d0f0..27a056820d 100644 --- a/jhipster/jhipster-uaa/uaa/pom.xml +++ b/jhipster/jhipster-uaa/uaa/pom.xml @@ -232,7 +232,7 @@ org.zalando problem-spring-web - 0.24.0-RC.0 + ${spring.web.version} org.springframework.security.oauth @@ -543,7 +543,7 @@ org.eclipse.m2e lifecycle-mapping - 1.0.0 + ${lifecycle.mapping.version} @@ -834,6 +834,8 @@ + 1.0.0 + 0.24.0-RC.0 3.0.0 1.8 diff --git a/json-2/README.md b/json-2/README.md new file mode 100644 index 0000000000..e7c3043339 --- /dev/null +++ b/json-2/README.md @@ -0,0 +1,5 @@ +## JSON + +This module contains articles about JSON. + +### Relevant Articles: diff --git a/json-2/pom.xml b/json-2/pom.xml new file mode 100644 index 0000000000..72b3295b2b --- /dev/null +++ b/json-2/pom.xml @@ -0,0 +1,41 @@ + + + com.baeldung + json-2 + 0.0.1-SNAPSHOT + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 + + + + com.jsoniter + jsoniter + ${jsoniter.version} + + + + junit + junit + ${junit.version} + test + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + 0.9.23 + 3.11.1 + + diff --git a/json-2/src/main/java/com/baeldung/jsoniter/model/Name.java b/json-2/src/main/java/com/baeldung/jsoniter/model/Name.java new file mode 100644 index 0000000000..ed5e221235 --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsoniter/model/Name.java @@ -0,0 +1,22 @@ +package com.baeldung.jsoniter.model; + +public class Name { + private String firstName; + private String surname; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getSurname() { + return surname; + } + + public void setSurname(String surname) { + this.surname = surname; + } +} diff --git a/json-2/src/main/java/com/baeldung/jsoniter/model/Student.java b/json-2/src/main/java/com/baeldung/jsoniter/model/Student.java new file mode 100644 index 0000000000..07c73dd18e --- /dev/null +++ b/json-2/src/main/java/com/baeldung/jsoniter/model/Student.java @@ -0,0 +1,26 @@ +package com.baeldung.jsoniter.model; + +import com.jsoniter.annotation.JsonProperty; +import com.jsoniter.fuzzy.MaybeStringIntDecoder; + +public class Student { + @JsonProperty(decoder = MaybeStringIntDecoder.class) + private int id; + private Name name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Name getName() { + return name; + } + + public void setName(Name name) { + this.name = name; + } +} diff --git a/json-2/src/test/java/com/baeldung/jsoniter/JsoniterIntroUnitTest.java b/json-2/src/test/java/com/baeldung/jsoniter/JsoniterIntroUnitTest.java new file mode 100644 index 0000000000..09f82567a2 --- /dev/null +++ b/json-2/src/test/java/com/baeldung/jsoniter/JsoniterIntroUnitTest.java @@ -0,0 +1,85 @@ +package com.baeldung.jsoniter; + +import com.baeldung.jsoniter.model.Name; +import com.baeldung.jsoniter.model.Student; +import com.jsoniter.JsonIterator; +import com.jsoniter.ValueType; +import com.jsoniter.any.Any; + +import org.junit.Test; + +import static com.jsoniter.ValueType.STRING; +import static org.assertj.core.api.Assertions.assertThat; + +public class JsoniterIntroUnitTest { + + @Test + public void whenParsedUsingBindAPI_thenConvertedToJavaObjectCorrectly() { + String input = "{\"id\":1,\"name\":{\"firstName\":\"Joe\",\"surname\":\"Blogg\"}}"; + + Student student = JsonIterator.deserialize(input, Student.class); + + assertThat(student.getId()).isEqualTo(1); + assertThat(student.getName().getFirstName()).isEqualTo("Joe"); + assertThat(student.getName().getSurname()).isEqualTo("Blogg"); + } + + @Test + public void givenTypeInJsonFuzzy_whenFieldIsMaybeDecoded_thenFieldParsedCorrectly() { + String input = "{\"id\":\"1\",\"name\":{\"firstName\":\"Joe\",\"surname\":\"Blogg\"}}"; + + Student student = JsonIterator.deserialize(input, Student.class); + + assertThat(student.getId()).isEqualTo(1); + } + + @Test + public void whenParsedUsingAnyAPI_thenFieldValueCanBeExtractedUsingTheFieldName() { + String input = "{\"id\":1,\"name\":{\"firstName\":\"Joe\",\"surname\":\"Blogg\"}}"; + + Any any = JsonIterator.deserialize(input); + + assertThat(any.toInt("id")).isEqualTo(1); + assertThat(any.toString("name", "firstName")).isEqualTo("Joe"); + assertThat(any.toString("name", "surname")).isEqualTo("Blogg"); + } + + @Test + public void whenParsedUsingAnyAPI_thenFieldValueTypeIsCorrect() { + String input = "{\"id\":1,\"name\":{\"firstName\":\"Joe\",\"surname\":\"Blogg\"}}"; + + Any any = JsonIterator.deserialize(input); + + assertThat(any.get("id").valueType()).isEqualTo(ValueType.NUMBER); + assertThat(any.get("name").valueType()).isEqualTo(ValueType.OBJECT); + assertThat(any.get("error").valueType()).isEqualTo(ValueType.INVALID); + } + + @Test + public void whenParsedUsingIteratorAPI_thenFieldValuesExtractedCorrectly() throws Exception { + Name name = new Name(); + String input = "{ \"firstName\" : \"Joe\", \"surname\" : \"Blogg\" }"; + JsonIterator iterator = JsonIterator.parse(input); + + for (String field = iterator.readObject(); field != null; field = iterator.readObject()) { + switch (field) { + case "firstName": + if (iterator.whatIsNext() == ValueType.STRING) { + name.setFirstName(iterator.readString()); + } + continue; + case "surname": + if (iterator.whatIsNext() == ValueType.STRING) { + name.setSurname(iterator.readString()); + } + continue; + default: + iterator.skip(); + } + } + + assertThat(name.getFirstName()).isEqualTo("Joe"); + assertThat(name.getSurname()).isEqualTo("Blogg"); + } + +} diff --git a/json-2/src/test/resources/Student.json b/json-2/src/test/resources/Student.json new file mode 100644 index 0000000000..7ff3351e8e --- /dev/null +++ b/json-2/src/test/resources/Student.json @@ -0,0 +1 @@ +{"id":1,"name":{"firstName": "Joe", "surname":"Blogg"}} diff --git a/jta/README.md b/jta/README.md index 0351177a0d..202019118d 100644 --- a/jta/README.md +++ b/jta/README.md @@ -3,4 +3,4 @@ This module contains articles about the Java Transaction API (JTA). ### Relevant Articles: -- [Guide to Java EE JTA](https://www.baeldung.com/jee-jta) +- [Guide to Jakarta EE JTA](https://www.baeldung.com/jee-jta) diff --git a/kotlin-libraries-2/README.md b/kotlin-libraries-2/README.md index 4064ef67d8..f725048acd 100644 --- a/kotlin-libraries-2/README.md +++ b/kotlin-libraries-2/README.md @@ -8,4 +8,7 @@ This module contains articles about Kotlin Libraries. - [Introduction to RxKotlin](https://www.baeldung.com/rxkotlin) - [MockK: A Mocking Library for Kotlin](https://www.baeldung.com/kotlin-mockk) - [Kotlin Immutable Collections](https://www.baeldung.com/kotlin-immutable-collections) +- [Dependency Injection for Kotlin with Injekt](https://www.baeldung.com/kotlin-dependency-injection-with-injekt) +- [Fuel HTTP Library with Kotlin](https://www.baeldung.com/kotlin-fuel) +- [Introduction to Kovenant Library for Kotlin](https://www.baeldung.com/kotlin-kovenant) - More articles: [[<-- prev]](/kotlin-libraries) diff --git a/kotlin-libraries-2/pom.xml b/kotlin-libraries-2/pom.xml index 518142403e..254f2c6907 100644 --- a/kotlin-libraries-2/pom.xml +++ b/kotlin-libraries-2/pom.xml @@ -21,7 +21,7 @@ io.reactivex.rxjava2 rxkotlin - 2.3.0 + ${rxkotlin.version} junit @@ -39,6 +39,37 @@ kotlinx-collections-immutable ${kotlinx-collections-immutable.version} + + uy.kohesive.injekt + injekt-core + ${injekt-core.version} + + + com.github.kittinunf.fuel + fuel + ${fuel.version} + + + com.github.kittinunf.fuel + fuel-gson + ${fuel.version} + + + com.github.kittinunf.fuel + fuel-rxjava + ${fuel.version} + + + com.github.kittinunf.fuel + fuel-coroutines + ${fuel.version} + + + nl.komponents.kovenant + kovenant + ${kovenant.version} + pom + io.mockk @@ -49,9 +80,13 @@ + 1.16.1 + 1.15.0 + 3.3.0 27.1-jre 1.9.3 0.1 + 2.3.0 diff --git a/core-kotlin/src/main/kotlin/com/baeldung/fuel/Interceptors.kt b/kotlin-libraries-2/src/main/kotlin/com/baeldung/fuel/Interceptors.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/fuel/Interceptors.kt rename to kotlin-libraries-2/src/main/kotlin/com/baeldung/fuel/Interceptors.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/fuel/Post.kt b/kotlin-libraries-2/src/main/kotlin/com/baeldung/fuel/Post.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/fuel/Post.kt rename to kotlin-libraries-2/src/main/kotlin/com/baeldung/fuel/Post.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/fuel/PostRoutingAPI.kt b/kotlin-libraries-2/src/main/kotlin/com/baeldung/fuel/PostRoutingAPI.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/fuel/PostRoutingAPI.kt rename to kotlin-libraries-2/src/main/kotlin/com/baeldung/fuel/PostRoutingAPI.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/injekt/DelegateInjectionApplication.kt b/kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/DelegateInjectionApplication.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/injekt/DelegateInjectionApplication.kt rename to kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/DelegateInjectionApplication.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/injekt/KeyedApplication.kt b/kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/KeyedApplication.kt similarity index 80% rename from core-kotlin/src/main/kotlin/com/baeldung/injekt/KeyedApplication.kt rename to kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/KeyedApplication.kt index 744459b7fe..4205678981 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/injekt/KeyedApplication.kt +++ b/kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/KeyedApplication.kt @@ -1,8 +1,12 @@ package com.baeldung.injekt import org.slf4j.LoggerFactory -import uy.kohesive.injekt.* -import uy.kohesive.injekt.api.* +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.InjektMain +import uy.kohesive.injekt.api.InjektRegistrar +import uy.kohesive.injekt.api.addPerKeyFactory +import uy.kohesive.injekt.api.addSingletonFactory +import uy.kohesive.injekt.api.get class KeyedApplication { companion object : InjektMain() { diff --git a/core-kotlin/src/main/kotlin/com/baeldung/injekt/ModularApplication.kt b/kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/ModularApplication.kt similarity index 94% rename from core-kotlin/src/main/kotlin/com/baeldung/injekt/ModularApplication.kt rename to kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/ModularApplication.kt index e802f3f6d5..96a0c9556a 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/injekt/ModularApplication.kt +++ b/kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/ModularApplication.kt @@ -1,7 +1,8 @@ package com.baeldung.injekt import org.slf4j.LoggerFactory -import uy.kohesive.injekt.* +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.InjektMain import uy.kohesive.injekt.api.* class ModularApplication { diff --git a/core-kotlin/src/main/kotlin/com/baeldung/injekt/PerThreadApplication.kt b/kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/PerThreadApplication.kt similarity index 84% rename from core-kotlin/src/main/kotlin/com/baeldung/injekt/PerThreadApplication.kt rename to kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/PerThreadApplication.kt index a42f314349..f3167bc223 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/injekt/PerThreadApplication.kt +++ b/kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/PerThreadApplication.kt @@ -1,8 +1,12 @@ package com.baeldung.injekt import org.slf4j.LoggerFactory -import uy.kohesive.injekt.* -import uy.kohesive.injekt.api.* +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.InjektMain +import uy.kohesive.injekt.api.InjektRegistrar +import uy.kohesive.injekt.api.addPerThreadFactory +import uy.kohesive.injekt.api.addSingletonFactory +import uy.kohesive.injekt.api.get import java.util.* import java.util.concurrent.Executors import java.util.concurrent.TimeUnit diff --git a/core-kotlin/src/main/kotlin/com/baeldung/injekt/SimpleApplication.kt b/kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/SimpleApplication.kt similarity index 75% rename from core-kotlin/src/main/kotlin/com/baeldung/injekt/SimpleApplication.kt rename to kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/SimpleApplication.kt index 2b07cd059f..5c2dc28ba5 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/injekt/SimpleApplication.kt +++ b/kotlin-libraries-2/src/main/kotlin/com/baeldung/injekt/SimpleApplication.kt @@ -1,8 +1,12 @@ package com.baeldung.injekt import org.slf4j.LoggerFactory -import uy.kohesive.injekt.* -import uy.kohesive.injekt.api.* +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.InjektMain +import uy.kohesive.injekt.api.InjektRegistrar +import uy.kohesive.injekt.api.addSingleton +import uy.kohesive.injekt.api.addSingletonFactory +import uy.kohesive.injekt.api.get class SimpleApplication { companion object : InjektMain() { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/fuel/FuelHttpUnitTest.kt b/kotlin-libraries-2/src/test/kotlin/com/baeldung/fuel/FuelHttpUnitTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/fuel/FuelHttpUnitTest.kt rename to kotlin-libraries-2/src/test/kotlin/com/baeldung/fuel/FuelHttpUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/KovenantTest.kt b/kotlin-libraries-2/src/test/kotlin/com/baeldung/kovenant/KovenantTest.kt similarity index 99% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/KovenantTest.kt rename to kotlin-libraries-2/src/test/kotlin/com/baeldung/kovenant/KovenantTest.kt index 469118f0f6..046b7380f7 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/KovenantTest.kt +++ b/kotlin-libraries-2/src/test/kotlin/com/baeldung/kovenant/KovenantTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.kovenant import nl.komponents.kovenant.* import nl.komponents.kovenant.Kovenant.deferred @@ -12,6 +12,7 @@ import java.util.* import java.util.concurrent.TimeUnit class KovenantTest { + @Before fun setupTestMode() { Kovenant.testMode { error -> diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/KovenantTimeoutTest.kt b/kotlin-libraries-2/src/test/kotlin/com/baeldung/kovenant/KovenantTimeoutTest.kt similarity index 96% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/KovenantTimeoutTest.kt rename to kotlin-libraries-2/src/test/kotlin/com/baeldung/kovenant/KovenantTimeoutTest.kt index e37d2cc2fa..d98f9c538f 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/KovenantTimeoutTest.kt +++ b/kotlin-libraries-2/src/test/kotlin/com/baeldung/kovenant/KovenantTimeoutTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.kovenant import nl.komponents.kovenant.Promise import nl.komponents.kovenant.any diff --git a/kotlin-libraries/README.md b/kotlin-libraries/README.md index 99a57c8293..570bf9b1e5 100644 --- a/kotlin-libraries/README.md +++ b/kotlin-libraries/README.md @@ -10,7 +10,6 @@ This module contains articles about Kotlin Libraries. - [Writing Specifications with Kotlin and Spek](https://www.baeldung.com/kotlin-spek) - [Processing JSON with Kotlin and Klaxson](https://www.baeldung.com/kotlin-json-klaxson) - [Guide to the Kotlin Exposed Framework](https://www.baeldung.com/kotlin-exposed-persistence) -- [Working with Dates in Kotlin](https://www.baeldung.com/kotlin-dates) - [Introduction to Arrow in Kotlin](https://www.baeldung.com/kotlin-arrow) - [Kotlin with Ktor](https://www.baeldung.com/kotlin-ktor) - [REST API With Kotlin and Kovert](https://www.baeldung.com/kotlin-kovert) diff --git a/kotlin-libraries/pom.xml b/kotlin-libraries/pom.xml index dfd1dc363f..0d6e589377 100644 --- a/kotlin-libraries/pom.xml +++ b/kotlin-libraries/pom.xml @@ -33,19 +33,19 @@ org.jetbrains.spek spek-api - 1.1.5 + ${spek.version} test org.jetbrains.spek spek-subject-extension - 1.1.5 + ${spek.version} test org.jetbrains.spek spek-junit-platform-engine - 1.1.5 + ${spek.version} test @@ -166,6 +166,7 @@ 2.6 2.3.0 0.7.3 + 1.1.5 diff --git a/kotlin-quasar/pom.xml b/kotlin-quasar/pom.xml index a12d27c565..ec37fa8059 100644 --- a/kotlin-quasar/pom.xml +++ b/kotlin-quasar/pom.xml @@ -48,7 +48,7 @@ junit junit - 4.12 + ${junit.version} @@ -103,7 +103,7 @@ maven-dependency-plugin - 3.1.1 + ${dependency.plugin.version} getClasspathFilenames @@ -116,7 +116,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.1 + ${surefire.plugin.version} -Dco.paralleluniverse.fibers.verifyInstrumentation=true -javaagent:${co.paralleluniverse:quasar-core:jar} @@ -125,7 +125,7 @@ org.codehaus.mojo exec-maven-plugin - 1.3.2 + ${exec.plugin.version} target/classes echo @@ -145,6 +145,10 @@ 1.3.31 1.7.21 1.1.7 + 3.1.1 + 2.22.1 + 1.3.2 + 4.12 diff --git a/libraries-2/README.md b/libraries-2/README.md index 95c454edbb..eb45a3e426 100644 --- a/libraries-2/README.md +++ b/libraries-2/README.md @@ -18,7 +18,7 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Key Value Store with Chronicle Map](https://www.baeldung.com/java-chronicle-map) - [Guide to MapDB](https://www.baeldung.com/mapdb) - [A Guide to Apache Mesos](https://www.baeldung.com/apache-mesos) -- [JasperReports with Spring](https://www.baeldung.com/spring-jasper)] +- [JasperReports with Spring](https://www.baeldung.com/spring-jasper) - [Jetty ReactiveStreams HTTP Client](https://www.baeldung.com/jetty-reactivestreams-http-client) - More articles [[<-- prev]](/libraries) diff --git a/libraries-2/src/test/java/com/baeldung/handlebars/BuiltinHelperUnitTest.java b/libraries-2/src/test/java/com/baeldung/handlebars/BuiltinHelperUnitTest.java index 6749f7fe0a..aa29e4c441 100644 --- a/libraries-2/src/test/java/com/baeldung/handlebars/BuiltinHelperUnitTest.java +++ b/libraries-2/src/test/java/com/baeldung/handlebars/BuiltinHelperUnitTest.java @@ -7,6 +7,8 @@ import com.github.jknack.handlebars.Template; import com.github.jknack.handlebars.io.ClassPathTemplateLoader; import com.github.jknack.handlebars.io.TemplateLoader; import java.io.IOException; + +import org.junit.Ignore; import org.junit.Test; /** @@ -18,6 +20,7 @@ public class BuiltinHelperUnitTest { private TemplateLoader templateLoader = new ClassPathTemplateLoader("/handlebars", ".html"); + @Ignore @Test public void whenUsedWith_ThenContextChanges() throws IOException { Handlebars handlebars = new Handlebars(templateLoader); @@ -30,6 +33,7 @@ public class BuiltinHelperUnitTest { assertThat(templateString).isEqualTo("\n

I live in World

\n"); } + @Ignore @Test public void whenUsedWithMustacheStyle_ThenContextChanges() throws IOException { Handlebars handlebars = new Handlebars(templateLoader); @@ -42,6 +46,7 @@ public class BuiltinHelperUnitTest { assertThat(templateString).isEqualTo("\n

I live in World

\n"); } + @Ignore @Test public void whenUsedEach_ThenIterates() throws IOException { Handlebars handlebars = new Handlebars(templateLoader); @@ -58,6 +63,7 @@ public class BuiltinHelperUnitTest { + "\nSpring is my friend.\n"); } + @Ignore @Test public void whenUsedEachMustacheStyle_ThenIterates() throws IOException { Handlebars handlebars = new Handlebars(templateLoader); @@ -74,6 +80,7 @@ public class BuiltinHelperUnitTest { + "\nSpring is my friend.\n"); } + @Ignore @Test public void whenUsedIf_ThenPutsCondition() throws IOException { Handlebars handlebars = new Handlebars(templateLoader); @@ -86,6 +93,7 @@ public class BuiltinHelperUnitTest { assertThat(templateString).isEqualTo("\n

Baeldung is busy.

\n"); } + @Ignore @Test public void whenUsedIfMustacheStyle_ThenPutsCondition() throws IOException { Handlebars handlebars = new Handlebars(templateLoader); diff --git a/libraries-2/src/test/java/com/baeldung/handlebars/ReusingTemplatesUnitTest.java b/libraries-2/src/test/java/com/baeldung/handlebars/ReusingTemplatesUnitTest.java index 36f78f486e..56449f59e4 100644 --- a/libraries-2/src/test/java/com/baeldung/handlebars/ReusingTemplatesUnitTest.java +++ b/libraries-2/src/test/java/com/baeldung/handlebars/ReusingTemplatesUnitTest.java @@ -7,6 +7,8 @@ import com.github.jknack.handlebars.Template; import com.github.jknack.handlebars.io.ClassPathTemplateLoader; import com.github.jknack.handlebars.io.TemplateLoader; import java.io.IOException; + +import org.junit.Ignore; import org.junit.Test; /** @@ -18,6 +20,7 @@ public class ReusingTemplatesUnitTest { private TemplateLoader templateLoader = new ClassPathTemplateLoader("/handlebars", ".html"); + @Ignore @Test public void whenOtherTemplateIsReferenced_ThenCanReuse() throws IOException { Handlebars handlebars = new Handlebars(templateLoader); @@ -30,6 +33,7 @@ public class ReusingTemplatesUnitTest { assertThat(templateString).isEqualTo("

Hi Baeldung!

\n

This is the page Baeldung

"); } + @Ignore @Test public void whenBlockIsDefined_ThenCanOverrideWithPartial() throws IOException { Handlebars handlebars = new Handlebars(templateLoader); diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index c8980fd309..1dbe6b2435 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -8,8 +8,9 @@ com.baeldung - parent-modules - 1.0.0-SNAPSHOT + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 @@ -23,10 +24,75 @@ lombok ${lombok.version}
+ + + org.springframework.boot + spring-boot-starter-web + + + + net.sourceforge.barbecue + barbecue + ${barbecue.version} + + + + net.sf.barcode4j + barcode4j + ${barcode4j.version} + + + + com.google.zxing + core + ${zxing.version} + + + com.google.zxing + javase + ${zxing.version} + + + + com.github.kenglxn.qrgen + javase + ${qrgen.version} + + + com.github.rvesse + airline + ${airline.version} + + + org.cactoos + cactoos + ${cactoos.version} + + + org.cache2k + cache2k-base-bom + ${cache2k.version} + pom +
+ + + jitpack.io + https://jitpack.io + + + 1.78 1.18.6 + 1.5-beta1 + 2.1 + 3.3.0 + 2.6.0 + + 0.43 + 2.7.2 + 1.2.3.Final diff --git a/libraries-3/src/main/java/com/baeldung/airline/CommandLine.java b/libraries-3/src/main/java/com/baeldung/airline/CommandLine.java new file mode 100644 index 0000000000..b4c3fc9b9e --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/airline/CommandLine.java @@ -0,0 +1,17 @@ +package com.baeldung.airline; + +import com.github.rvesse.airline.annotations.Cli; +import com.github.rvesse.airline.help.Help; + +@Cli(name = "baeldung-cli", +description = "Baeldung Airline Tutorial", +defaultCommand = Help.class, +commands = { DatabaseSetupCommand.class, LoggingCommand.class, Help.class }) +public class CommandLine { + + public static void main(String[] args) { + com.github.rvesse.airline.Cli cli = new com.github.rvesse.airline.Cli<>(CommandLine.class); + Runnable cmd = cli.parse(args); + cmd.run(); + } +} diff --git a/libraries-3/src/main/java/com/baeldung/airline/DatabaseSetupCommand.java b/libraries-3/src/main/java/com/baeldung/airline/DatabaseSetupCommand.java new file mode 100644 index 0000000000..bf67fa33b6 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/airline/DatabaseSetupCommand.java @@ -0,0 +1,77 @@ +package com.baeldung.airline; + +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + +import com.github.rvesse.airline.HelpOption; +import com.github.rvesse.airline.annotations.Command; +import com.github.rvesse.airline.annotations.Option; +import com.github.rvesse.airline.annotations.OptionType; +import com.github.rvesse.airline.annotations.restrictions.AllowedRawValues; +import com.github.rvesse.airline.annotations.restrictions.MutuallyExclusiveWith; +import com.github.rvesse.airline.annotations.restrictions.Pattern; +import com.github.rvesse.airline.annotations.restrictions.RequiredOnlyIf; + +@Command(name = "setup-db", description = "Setup our database") +public class DatabaseSetupCommand implements Runnable { + @Inject + private HelpOption help; + + @Option(type = OptionType.COMMAND, + name = {"-d", "--database"}, + description = "Type of RDBMS.", + title = "RDBMS type: mysql|postgresql|mongodb") + @AllowedRawValues(allowedValues = { "mysql", "postgres", "mongodb" }) + protected String rdbmsMode = "mysql"; + + @Option(type = OptionType.COMMAND, + name = {"--rdbms:url", "--url"}, + description = "URL to use for connection to RDBMS.", + title = "RDBMS URL") + @MutuallyExclusiveWith(tag="mode") + @Pattern(pattern="^(http://.*):(d*)(.*)u=(.*)&p=(.*)") + protected String rdbmsUrl = ""; + + @Option(type = OptionType.COMMAND, + name = {"--rdbms:host", "--host"}, + description = "Host to use for connection to RDBMS.", + title = "RDBMS host") + @MutuallyExclusiveWith(tag="mode") + protected String rdbmsHost = ""; + + @RequiredOnlyIf(names={"--rdbms:host", "--host"}) + @Option(type = OptionType.COMMAND, + name = {"--rdbms:user", "-u", "--user"}, + description = "User for login to RDBMS.", + title = "RDBMS user") + protected String rdbmsUser; + + @RequiredOnlyIf(names={"--rdbms:host", "--host"}) + @Option(type = OptionType.COMMAND, + name = {"--rdbms:password", "--password"}, + description = "Password for login to RDBMS.", + title = "RDBMS password") + protected String rdbmsPassword; + + @Option(type = OptionType.COMMAND, + name = {"--driver", "--jars"}, + description = "List of drivers", + title = "--driver --driver ") + protected List jars = new ArrayList<>(); + + @Override + public void run() { + //skipping store our choices... + if (!help.showHelpIfRequested()) { + if(!"".equals(rdbmsHost)) { + System.out.println("Connecting to database host: " + rdbmsHost); + System.out.println("Credential: " + rdbmsUser + " / " + rdbmsPassword); + } else { + System.out.println("Connecting to database url: " + rdbmsUrl); + } + System.out.println(jars.toString()); + } + } +} diff --git a/libraries-3/src/main/java/com/baeldung/airline/LoggingCommand.java b/libraries-3/src/main/java/com/baeldung/airline/LoggingCommand.java new file mode 100644 index 0000000000..4a269f87fd --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/airline/LoggingCommand.java @@ -0,0 +1,24 @@ +package com.baeldung.airline; + +import javax.inject.Inject; + +import com.github.rvesse.airline.HelpOption; +import com.github.rvesse.airline.annotations.Command; +import com.github.rvesse.airline.annotations.Option; + +@Command(name = "setup-log", description = "Setup our log") +public class LoggingCommand implements Runnable { + + @Inject + private HelpOption help; + + @Option(name = { "-v", "--verbose" }, description = "Set log verbosity on/off") + private boolean verbose = false; + + @Override + public void run() { + //skipping store user choice + if (!help.showHelpIfRequested()) + System.out.println("Verbosity: " + verbose); + } +} diff --git a/libraries-3/src/main/java/com/baeldung/barcodes/BarcodesController.java b/libraries-3/src/main/java/com/baeldung/barcodes/BarcodesController.java new file mode 100644 index 0000000000..171d703621 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/barcodes/BarcodesController.java @@ -0,0 +1,99 @@ +package com.baeldung.barcodes; + +import com.baeldung.barcodes.generators.BarbecueBarcodeGenerator; +import com.baeldung.barcodes.generators.Barcode4jBarcodeGenerator; +import com.baeldung.barcodes.generators.QRGenBarcodeGenerator; +import com.baeldung.barcodes.generators.ZxingBarcodeGenerator; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.awt.image.BufferedImage; + +@RestController +@RequestMapping("/barcodes") +public class BarcodesController { + + //Barbecue library + + @GetMapping(value = "/barbecue/upca/{barcode}", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity barbecueUPCABarcode(@PathVariable("barcode") String barcode) throws Exception { + return okResponse(BarbecueBarcodeGenerator.generateUPCABarcodeImage(barcode)); + } + + @GetMapping(value = "/barbecue/ean13/{barcode}", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity barbecueEAN13Barcode(@PathVariable("barcode") String barcode) throws Exception { + return okResponse(BarbecueBarcodeGenerator.generateEAN13BarcodeImage(barcode)); + } + + @PostMapping(value = "/barbecue/code128", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity barbecueCode128Barcode(@RequestBody String barcode) throws Exception { + return okResponse(BarbecueBarcodeGenerator.generateCode128BarcodeImage(barcode)); + } + + @PostMapping(value = "/barbecue/pdf417", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity barbecuePDF417Barcode(@RequestBody String barcode) throws Exception { + return okResponse(BarbecueBarcodeGenerator.generatePDF417BarcodeImage(barcode)); + } + + //Barcode4j library + + @GetMapping(value = "/barcode4j/upca/{barcode}", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity barcode4jUPCABarcode(@PathVariable("barcode") String barcode) { + return okResponse(Barcode4jBarcodeGenerator.generateUPCABarcodeImage(barcode)); + } + + @GetMapping(value = "/barcode4j/ean13/{barcode}", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity barcode4jEAN13Barcode(@PathVariable("barcode") String barcode) { + return okResponse(Barcode4jBarcodeGenerator.generateEAN13BarcodeImage(barcode)); + } + + @PostMapping(value = "/barcode4j/code128", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity barcode4jCode128Barcode(@RequestBody String barcode) { + return okResponse(Barcode4jBarcodeGenerator.generateCode128BarcodeImage(barcode)); + } + + @PostMapping(value = "/barcode4j/pdf417", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity barcode4jPDF417Barcode(@RequestBody String barcode) { + return okResponse(Barcode4jBarcodeGenerator.generatePDF417BarcodeImage(barcode)); + } + + //Zxing library + + @GetMapping(value = "/zxing/upca/{barcode}", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity zxingUPCABarcode(@PathVariable("barcode") String barcode) throws Exception { + return okResponse(ZxingBarcodeGenerator.generateUPCABarcodeImage(barcode)); + } + + @GetMapping(value = "/zxing/ean13/{barcode}", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity zxingEAN13Barcode(@PathVariable("barcode") String barcode) throws Exception { + return okResponse(ZxingBarcodeGenerator.generateEAN13BarcodeImage(barcode)); + } + + @PostMapping(value = "/zxing/code128", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity zxingCode128Barcode(@RequestBody String barcode) throws Exception { + return okResponse(ZxingBarcodeGenerator.generateCode128BarcodeImage(barcode)); + } + + @PostMapping(value = "/zxing/pdf417", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity zxingPDF417Barcode(@RequestBody String barcode) throws Exception { + return okResponse(ZxingBarcodeGenerator.generatePDF417BarcodeImage(barcode)); + } + + @PostMapping(value = "/zxing/qrcode", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity zxingQRCode(@RequestBody String barcode) throws Exception { + return okResponse(ZxingBarcodeGenerator.generateQRCodeImage(barcode)); + } + + //QRGen + + @PostMapping(value = "/qrgen/qrcode", produces = MediaType.IMAGE_PNG_VALUE) + public ResponseEntity qrgenQRCode(@RequestBody String barcode) throws Exception { + return okResponse(QRGenBarcodeGenerator.generateQRCodeImage(barcode)); + } + + private ResponseEntity okResponse(BufferedImage image) { + return new ResponseEntity<>(image, HttpStatus.OK); + } +} diff --git a/libraries-3/src/main/java/com/baeldung/barcodes/SpringBootApp.java b/libraries-3/src/main/java/com/baeldung/barcodes/SpringBootApp.java new file mode 100644 index 0000000000..991b3b11ce --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/barcodes/SpringBootApp.java @@ -0,0 +1,23 @@ +package com.baeldung.barcodes; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.http.converter.BufferedImageHttpMessageConverter; +import org.springframework.http.converter.HttpMessageConverter; + +import java.awt.image.BufferedImage; + +@SpringBootApplication +public class SpringBootApp { + + public static void main(String[] args) { + SpringApplication.run(SpringBootApp.class, args); + } + + @Bean + public HttpMessageConverter createImageHttpMessageConverter() { + return new BufferedImageHttpMessageConverter(); + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/barcodes/generators/BarbecueBarcodeGenerator.java b/libraries-3/src/main/java/com/baeldung/barcodes/generators/BarbecueBarcodeGenerator.java new file mode 100644 index 0000000000..353f824d98 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/barcodes/generators/BarbecueBarcodeGenerator.java @@ -0,0 +1,43 @@ +package com.baeldung.barcodes.generators; + +import net.sourceforge.barbecue.Barcode; +import net.sourceforge.barbecue.BarcodeFactory; +import net.sourceforge.barbecue.BarcodeImageHandler; + +import java.awt.*; +import java.awt.image.BufferedImage; + +public class BarbecueBarcodeGenerator { + + private static final Font BARCODE_TEXT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 14); + + public static BufferedImage generateUPCABarcodeImage(String barcodeText) throws Exception { + Barcode barcode = BarcodeFactory.createUPCA(barcodeText); //checksum is automatically added + barcode.setFont(BARCODE_TEXT_FONT); + barcode.setResolution(400); + + return BarcodeImageHandler.getImage(barcode); + } + + public static BufferedImage generateEAN13BarcodeImage(String barcodeText) throws Exception { + Barcode barcode = BarcodeFactory.createEAN13(barcodeText); //checksum is automatically added + barcode.setFont(BARCODE_TEXT_FONT); + + return BarcodeImageHandler.getImage(barcode); + } + + public static BufferedImage generateCode128BarcodeImage(String barcodeText) throws Exception { + Barcode barcode = BarcodeFactory.createCode128(barcodeText); + barcode.setFont(BARCODE_TEXT_FONT); + + return BarcodeImageHandler.getImage(barcode); + } + + public static BufferedImage generatePDF417BarcodeImage(String barcodeText) throws Exception { + Barcode barcode = BarcodeFactory.createPDF417(barcodeText); + barcode.setFont(BARCODE_TEXT_FONT); + + return BarcodeImageHandler.getImage(barcode); + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/barcodes/generators/Barcode4jBarcodeGenerator.java b/libraries-3/src/main/java/com/baeldung/barcodes/generators/Barcode4jBarcodeGenerator.java new file mode 100644 index 0000000000..a2fee044e5 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/barcodes/generators/Barcode4jBarcodeGenerator.java @@ -0,0 +1,46 @@ +package com.baeldung.barcodes.generators; + +import org.krysalis.barcode4j.impl.code128.Code128Bean; +import org.krysalis.barcode4j.impl.pdf417.PDF417Bean; +import org.krysalis.barcode4j.impl.upcean.EAN13Bean; +import org.krysalis.barcode4j.impl.upcean.UPCABean; +import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider; + +import java.awt.image.BufferedImage; + +public class Barcode4jBarcodeGenerator { + + public static BufferedImage generateUPCABarcodeImage(String barcodeText) { + UPCABean barcodeGenerator = new UPCABean(); + BitmapCanvasProvider canvas = new BitmapCanvasProvider(160, BufferedImage.TYPE_BYTE_BINARY, false, 0); + + barcodeGenerator.generateBarcode(canvas, barcodeText); + return canvas.getBufferedImage(); + } + + public static BufferedImage generateEAN13BarcodeImage(String barcodeText) { + EAN13Bean barcodeGenerator = new EAN13Bean(); + BitmapCanvasProvider canvas = new BitmapCanvasProvider(160, BufferedImage.TYPE_BYTE_BINARY, false, 0); + + barcodeGenerator.generateBarcode(canvas, barcodeText); + return canvas.getBufferedImage(); + } + + public static BufferedImage generateCode128BarcodeImage(String barcodeText) { + Code128Bean barcodeGenerator = new Code128Bean(); + BitmapCanvasProvider canvas = new BitmapCanvasProvider(160, BufferedImage.TYPE_BYTE_BINARY, false, 0); + + barcodeGenerator.generateBarcode(canvas, barcodeText); + return canvas.getBufferedImage(); + } + + public static BufferedImage generatePDF417BarcodeImage(String barcodeText) { + PDF417Bean barcodeGenerator = new PDF417Bean(); + BitmapCanvasProvider canvas = new BitmapCanvasProvider(160, BufferedImage.TYPE_BYTE_BINARY, false, 0); + barcodeGenerator.setColumns(10); + + barcodeGenerator.generateBarcode(canvas, barcodeText); + return canvas.getBufferedImage(); + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/barcodes/generators/QRGenBarcodeGenerator.java b/libraries-3/src/main/java/com/baeldung/barcodes/generators/QRGenBarcodeGenerator.java new file mode 100644 index 0000000000..46d17ac500 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/barcodes/generators/QRGenBarcodeGenerator.java @@ -0,0 +1,21 @@ +package com.baeldung.barcodes.generators; + +import net.glxn.qrgen.javase.QRCode; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; + +public class QRGenBarcodeGenerator { + + public static BufferedImage generateQRCodeImage(String barcodeText) throws Exception { + ByteArrayOutputStream stream = QRCode + .from(barcodeText) + .withSize(250, 250) + .stream(); + ByteArrayInputStream bis = new ByteArrayInputStream(stream.toByteArray()); + + return ImageIO.read(bis); + } +} diff --git a/libraries-3/src/main/java/com/baeldung/barcodes/generators/ZxingBarcodeGenerator.java b/libraries-3/src/main/java/com/baeldung/barcodes/generators/ZxingBarcodeGenerator.java new file mode 100644 index 0000000000..e9aa2975da --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/barcodes/generators/ZxingBarcodeGenerator.java @@ -0,0 +1,51 @@ +package com.baeldung.barcodes.generators; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.oned.Code128Writer; +import com.google.zxing.oned.EAN13Writer; +import com.google.zxing.oned.UPCAWriter; +import com.google.zxing.pdf417.PDF417Writer; +import com.google.zxing.qrcode.QRCodeWriter; + +import java.awt.image.BufferedImage; + +public class ZxingBarcodeGenerator { + + public static BufferedImage generateUPCABarcodeImage(String barcodeText) throws Exception { + UPCAWriter barcodeWriter = new UPCAWriter(); + BitMatrix bitMatrix = barcodeWriter.encode(barcodeText, BarcodeFormat.UPC_A, 300, 150); + + return MatrixToImageWriter.toBufferedImage(bitMatrix); + } + + public static BufferedImage generateEAN13BarcodeImage(String barcodeText) throws Exception { + EAN13Writer barcodeWriter = new EAN13Writer(); + BitMatrix bitMatrix = barcodeWriter.encode(barcodeText, BarcodeFormat.EAN_13, 300, 150); + + return MatrixToImageWriter.toBufferedImage(bitMatrix); + } + + public static BufferedImage generateCode128BarcodeImage(String barcodeText) throws Exception { + Code128Writer barcodeWriter = new Code128Writer(); + BitMatrix bitMatrix = barcodeWriter.encode(barcodeText, BarcodeFormat.CODE_128, 300, 150); + + return MatrixToImageWriter.toBufferedImage(bitMatrix); + } + + public static BufferedImage generatePDF417BarcodeImage(String barcodeText) throws Exception { + PDF417Writer barcodeWriter = new PDF417Writer(); + BitMatrix bitMatrix = barcodeWriter.encode(barcodeText, BarcodeFormat.PDF_417, 700, 700); + + return MatrixToImageWriter.toBufferedImage(bitMatrix); + } + + public static BufferedImage generateQRCodeImage(String barcodeText) throws Exception { + QRCodeWriter barcodeWriter = new QRCodeWriter(); + BitMatrix bitMatrix = barcodeWriter.encode(barcodeText, BarcodeFormat.QR_CODE, 200, 200); + + return MatrixToImageWriter.toBufferedImage(bitMatrix); + } + +} \ No newline at end of file diff --git a/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelper.java b/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelper.java new file mode 100644 index 0000000000..dc984e5f0b --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelper.java @@ -0,0 +1,41 @@ +package com.baeldung.cache2k; + +import java.util.Objects; + +import org.cache2k.Cache; +import org.cache2k.Cache2kBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProductHelper { + + final Logger LOGGER = LoggerFactory.getLogger(ProductHelper.class); + + private Cache cachedDiscounts; + + public ProductHelper() { + cachedDiscounts = Cache2kBuilder.of(String.class, Integer.class) + .name("discount") + .eternal(true) + .entryCapacity(100) + .build(); + + initDiscountCache("Sports", 20); + } + + public void initDiscountCache(String productType, Integer value) { + cachedDiscounts.put(productType, value); + } + + public Integer getDiscount(String productType) { + Integer discount = cachedDiscounts.get(productType); + if (Objects.isNull(discount)) { + LOGGER.info("Discount for {} not found.", productType); + discount = 0; + } else { + LOGGER.info("Discount for {} found.", productType); + } + return discount; + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelperUsingLoader.java b/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelperUsingLoader.java new file mode 100644 index 0000000000..787a78cd36 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelperUsingLoader.java @@ -0,0 +1,41 @@ +package com.baeldung.cache2k; + +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +import org.cache2k.Cache; +import org.cache2k.Cache2kBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProductHelperUsingLoader { + + final Logger LOGGER = LoggerFactory.getLogger(ProductHelperUsingLoader.class); + + private Cache cachedDiscounts; + + public ProductHelperUsingLoader() { + cachedDiscounts = Cache2kBuilder.of(String.class, Integer.class) + .name("discount-loader") + .eternal(false) + .expireAfterWrite(10, TimeUnit.MILLISECONDS) + .entryCapacity(100) + .loader((key) -> { + LOGGER.info("Calculating discount for {}.", key); + return "Sports".equalsIgnoreCase(key) ? 20 : 10; + }) + .build(); + } + + public Integer getDiscount(String productType) { + Integer discount = cachedDiscounts.get(productType); + if (Objects.isNull(discount)) { + LOGGER.info("Discount for {} not found.", productType); + discount = 0; + } else { + LOGGER.info("Discount for {} found.", productType); + } + return discount; + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelperWithEventListener.java b/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelperWithEventListener.java new file mode 100644 index 0000000000..5b9eb28c68 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelperWithEventListener.java @@ -0,0 +1,49 @@ +package com.baeldung.cache2k; + +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +import org.cache2k.Cache; +import org.cache2k.Cache2kBuilder; +import org.cache2k.CacheEntry; +import org.cache2k.event.CacheEntryCreatedListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProductHelperWithEventListener { + + final Logger LOGGER = LoggerFactory.getLogger(ProductHelperWithEventListener.class); + + private Cache cachedDiscounts; + + public ProductHelperWithEventListener() { + cachedDiscounts = Cache2kBuilder.of(String.class, Integer.class) + .name("discount-listener") + .eternal(false) + .expireAfterWrite(10, TimeUnit.MILLISECONDS) + .entryCapacity(100) + .loader((key) -> { + LOGGER.info("Calculating discount for {}.", key); + return "Sports".equalsIgnoreCase(key) ? 20 : 10; + }) + .addListener(new CacheEntryCreatedListener() { + @Override + public void onEntryCreated(Cache cache, CacheEntry entry) { + LOGGER.info("Entry created: [{}, {}].", entry.getKey(), entry.getValue()); + } + }) + .build(); + } + + public Integer getDiscount(String productType) { + Integer discount = cachedDiscounts.get(productType); + if (Objects.isNull(discount)) { + LOGGER.info("Discount for {} not found.", productType); + discount = 0; + } else { + LOGGER.info("Discount for {} found.", productType); + } + return discount; + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelperWithExpiry.java b/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelperWithExpiry.java new file mode 100644 index 0000000000..b0bf8f90de --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cache2k/ProductHelperWithExpiry.java @@ -0,0 +1,43 @@ +package com.baeldung.cache2k; + +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +import org.cache2k.Cache; +import org.cache2k.Cache2kBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProductHelperWithExpiry { + + final Logger LOGGER = LoggerFactory.getLogger(ProductHelperWithExpiry.class); + + private Cache cachedDiscounts; + + public ProductHelperWithExpiry() { + cachedDiscounts = Cache2kBuilder.of(String.class, Integer.class) + .name("discount-expiry") + .eternal(false) + .expireAfterWrite(5, TimeUnit.MILLISECONDS) + .entryCapacity(100) + .build(); + + initDiscountCache("Sports", 20); + } + + public void initDiscountCache(String productType, Integer value) { + cachedDiscounts.put(productType, value); + } + + public Integer getDiscount(String productType) { + Integer discount = cachedDiscounts.get(productType); + if (Objects.isNull(discount)) { + LOGGER.info("Discount for {} not found.", productType); + discount = 0; + } else { + LOGGER.info("Discount for {} found.", productType); + } + return discount; + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java new file mode 100644 index 0000000000..717c63ae63 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosCollectionUtils.java @@ -0,0 +1,28 @@ +package com.baeldung.cactoos; + +import java.util.Collection; +import java.util.List; + +import org.cactoos.collection.Filtered; +import org.cactoos.iterable.IterableOf; +import org.cactoos.list.ListOf; +import org.cactoos.scalar.And; +import org.cactoos.text.FormattedText; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CactoosCollectionUtils { + + final Logger LOGGER = LoggerFactory.getLogger(CactoosCollectionUtils.class); + + public void iterateCollection(List strings) throws Exception { + new And((String input) -> LOGGER.info(new FormattedText("%s\n", input).asString()), strings).value(); + } + + public Collection getFilteredList(List strings) { + Collection filteredStrings = new ListOf<>( + new Filtered<>(string -> string.length() == 5, new IterableOf<>(strings))); + return filteredStrings; + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java new file mode 100644 index 0000000000..3e2903ebf4 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/cactoos/CactoosStringUtils.java @@ -0,0 +1,37 @@ +package com.baeldung.cactoos; + +import java.io.IOException; + +import org.cactoos.text.FormattedText; +import org.cactoos.text.IsBlank; +import org.cactoos.text.Lowered; +import org.cactoos.text.TextOf; +import org.cactoos.text.Upper; + +public class CactoosStringUtils { + + public String createString() throws IOException { + String testString = new TextOf("Test String").asString(); + return testString; + } + + public String createdFormattedString(String stringToFormat) throws IOException { + String formattedString = new FormattedText("Hello %s", stringToFormat).asString(); + return formattedString; + } + + public String toLowerCase(String testString) throws IOException { + String lowerCaseString = new Lowered(new TextOf(testString)).asString(); + return lowerCaseString; + } + + public String toUpperCase(String testString) throws Exception { + String upperCaseString = new Upper(new TextOf(testString)).asString(); + return upperCaseString; + } + + public boolean isBlank(String testString) throws Exception { + return new IsBlank(new TextOf(testString)) != null; + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperUnitTest.java b/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperUnitTest.java new file mode 100644 index 0000000000..69da2591dd --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperUnitTest.java @@ -0,0 +1,17 @@ +package com.baeldung.cache2k; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class ProductHelperUnitTest { + + ProductHelper productHelper = new ProductHelper(); + + @Test + public void whenInvokedGetDiscount_thenGetItFromCache() { + assertTrue(productHelper.getDiscount("Sports") == 20); + assertTrue(productHelper.getDiscount("Electronics") == 0); + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperUsingLoaderUnitTest.java b/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperUsingLoaderUnitTest.java new file mode 100644 index 0000000000..2656e75cab --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperUsingLoaderUnitTest.java @@ -0,0 +1,17 @@ +package com.baeldung.cache2k; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class ProductHelperUsingLoaderUnitTest { + + ProductHelperUsingLoader productHelper = new ProductHelperUsingLoader(); + + @Test + public void whenInvokedGetDiscount_thenPopulateCache() { + assertTrue(productHelper.getDiscount("Sports") == 20); + assertTrue(productHelper.getDiscount("Electronics") == 10); + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperWithEventListenerUnitTest.java b/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperWithEventListenerUnitTest.java new file mode 100644 index 0000000000..7bf08232f4 --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperWithEventListenerUnitTest.java @@ -0,0 +1,16 @@ +package com.baeldung.cache2k; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class ProductHelperWithEventListenerUnitTest { + + ProductHelperWithEventListener productHelper = new ProductHelperWithEventListener(); + + @Test + public void whenEntryAddedInCache_thenEventListenerCalled() { + assertTrue(productHelper.getDiscount("Sports") == 20); + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperWithExpiryUnitTest.java b/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperWithExpiryUnitTest.java new file mode 100644 index 0000000000..65feba2c70 --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cache2k/ProductHelperWithExpiryUnitTest.java @@ -0,0 +1,18 @@ +package com.baeldung.cache2k; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class ProductHelperWithExpiryUnitTest { + + ProductHelperWithExpiry productHelper = new ProductHelperWithExpiry(); + + @Test + public void whenInvokedGetDiscountForExpiredProduct_thenNoDiscount() throws InterruptedException { + assertTrue(productHelper.getDiscount("Sports") == 20); + Thread.sleep(20); + assertTrue(productHelper.getDiscount("Sports") == 0); + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java new file mode 100644 index 0000000000..c6bcbd7df7 --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosCollectionUtilsUnitTest.java @@ -0,0 +1,35 @@ +package com.baeldung.cactoos; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.util.List; +import java.util.ArrayList; + +import org.junit.Test; + +public class CactoosCollectionUtilsUnitTest { + + @Test + public void whenFilteredClassIsCalledWithSpecificArgs_thenCorrespondingFilteredCollectionShouldBeReturned() throws IOException { + + CactoosCollectionUtils obj = new CactoosCollectionUtils(); + + // when + List strings = new ArrayList() { + { + add("Hello"); + add("John"); + add("Smith"); + add("Eric"); + add("Dizzy"); + } + }; + int size = obj.getFilteredList(strings).size(); + + // then + assertEquals(3, size); + + } + +} diff --git a/libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java new file mode 100644 index 0000000000..67dd6d91e4 --- /dev/null +++ b/libraries-3/src/test/java/com/baeldung/cactoos/CactoosStringUtilsUnitTest.java @@ -0,0 +1,54 @@ +package com.baeldung.cactoos; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; + +import org.junit.Test; + +public class CactoosStringUtilsUnitTest { + + @Test + public void whenFormattedTextIsPassedWithArgs_thenFormattedStringIsReturned() throws IOException { + + CactoosStringUtils obj = new CactoosStringUtils(); + + // when + String formattedString = obj.createdFormattedString("John"); + + // then + assertEquals("Hello John", formattedString); + + } + + @Test + public void whenStringIsPassesdToLoweredOrUpperClass_thenCorrespondingStringIsReturned() throws Exception { + + CactoosStringUtils obj = new CactoosStringUtils(); + + // when + String lowerCaseString = obj.toLowerCase("TeSt StrIng"); + String upperCaseString = obj.toUpperCase("TeSt StrIng"); + + // then + assertEquals("test string", lowerCaseString); + assertEquals("TEST STRING", upperCaseString); + + } + + @Test + public void whenEmptyStringIsPassesd_thenIsBlankReturnsTrue() throws Exception { + + CactoosStringUtils obj = new CactoosStringUtils(); + + // when + boolean isBlankEmptyString = obj.isBlank(""); + boolean isBlankNull = obj.isBlank(null); + + // then + assertEquals(true, isBlankEmptyString); + assertEquals(true, isBlankNull); + + } + +} diff --git a/libraries-data-db/pom.xml b/libraries-data-db/pom.xml index 682a6ed185..f028ffe8c3 100644 --- a/libraries-data-db/pom.xml +++ b/libraries-data-db/pom.xml @@ -183,7 +183,7 @@ io.ebean ebean-maven-plugin - 11.11.2 + ${ebean.plugin.version} @@ -202,6 +202,7 @@ + 11.11.2 16.5.1 3.0.0 1.8 diff --git a/libraries-data/pom.xml b/libraries-data/pom.xml index 2086ecb614..1267982c49 100644 --- a/libraries-data/pom.xml +++ b/libraries-data/pom.xml @@ -74,19 +74,19 @@ commons-cli commons-cli - 1.2 + ${commons.cli.version} provided commons-io commons-io - 2.1 + ${commons.io.version} provided commons-httpclient commons-httpclient - 3.0.1 + ${httpclient.version} provided @@ -133,7 +133,7 @@ org.apache.maven.plugins maven-assembly-plugin - 2.3 + ${assembly.plugin.version} src/main/resources/assembly/hadoop-job.xml @@ -158,6 +158,10 @@ + 2.3 + 1.2 + 2.1 + 3.0.1 1.2.2 1.0.0 2.4.0 diff --git a/libraries-http/README.md b/libraries-http/README.md index f5afb2d277..4c27ec1c8d 100644 --- a/libraries-http/README.md +++ b/libraries-http/README.md @@ -12,3 +12,4 @@ This module contains articles about HTTP libraries. - [Introduction to Retrofit](https://www.baeldung.com/retrofit) - [A Guide to Unirest](https://www.baeldung.com/unirest) - [Creating REST Microservices with Javalin](https://www.baeldung.com/javalin-rest-microservices) +- [A Quick Guide to Timeouts in OkHttp](https://www.baeldung.com/okhttp-timeouts) diff --git a/libraries-http/pom.xml b/libraries-http/pom.xml index 6261456486..cbc74ce132 100644 --- a/libraries-http/pom.xml +++ b/libraries-http/pom.xml @@ -71,7 +71,7 @@ com.google.code.gson gson - 2.8.5 + ${gson.version} @@ -116,6 +116,7 @@ + 2.8.5 4.5.3 2.9.8 3.6.2 diff --git a/libraries-io/src/test/java/org/baeldung/java/io/remote/SftpFileTransferLiveTest.java b/libraries-io/src/test/java/com/baeldung/java/io/remote/SftpFileTransferLiveTest.java similarity index 99% rename from libraries-io/src/test/java/org/baeldung/java/io/remote/SftpFileTransferLiveTest.java rename to libraries-io/src/test/java/com/baeldung/java/io/remote/SftpFileTransferLiveTest.java index 192153bc90..5846128082 100644 --- a/libraries-io/src/test/java/org/baeldung/java/io/remote/SftpFileTransferLiveTest.java +++ b/libraries-io/src/test/java/com/baeldung/java/io/remote/SftpFileTransferLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.io.remote; +package com.baeldung.java.io.remote; import java.io.IOException; diff --git a/libraries-security/README.md b/libraries-security/README.md index 819bc866cf..580ebdeab0 100644 --- a/libraries-security/README.md +++ b/libraries-security/README.md @@ -9,4 +9,4 @@ This module contains articles about security libraries. - [Guide to Google Tink](https://www.baeldung.com/google-tink) - [Introduction to BouncyCastle with Java](https://www.baeldung.com/java-bouncy-castle) - [Intro to Jasypt](https://www.baeldung.com/jasypt) -- [Digital Signature in Java](https://www.baeldung.com/java-digital-signature) +- [Digital Signatures in Java](https://www.baeldung.com/java-digital-signature) diff --git a/libraries-testing/pom.xml b/libraries-testing/pom.xml index c84f8dda76..3ffbb291a0 100644 --- a/libraries-testing/pom.xml +++ b/libraries-testing/pom.xml @@ -127,7 +127,7 @@ org.asciidoctor asciidoctor-maven-plugin - 1.5.7.1 + ${asciidoctor.version} @@ -154,7 +154,8 @@ - 1.9.9 + 1.5.7.1 + 1.9.9 1.9.0 1.9.0 1.9.27 diff --git a/libraries/pom.xml b/libraries/pom.xml index 13f91711fd..b5340d1ebb 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -523,7 +523,7 @@ org.apache.maven.plugins maven-shade-plugin - 2.2 + ${shade.plugin.version} package @@ -556,6 +556,7 @@ + 2.2 0.7.0 3.2.7 1.2 diff --git a/linux-bash/functions/src/main/bash/functions.sh b/linux-bash/functions/src/main/bash/functions.sh new file mode 100755 index 0000000000..41ff0ca434 --- /dev/null +++ b/linux-bash/functions/src/main/bash/functions.sh @@ -0,0 +1,208 @@ +#!/bin/bash + +# Subsection 2.1 +simple_function() { + for ((i=0;i<5;++i)) do + echo -n " "$i" "; + done +} + +function simple_function_no_parantheses { + for ((i=0;i<5;++i)) do + echo -n " "$i" "; + done +} + +function simple_for_loop() + for ((i=0;i<5;++i)) do + echo -n " "$i" "; + done + +function simple_comparison() + if [[ "$1" -lt 5 ]]; then + echo "$1 is smaller than 5" + else + echo "$1 is greater than 5" + fi + +# Subsection 2.2 +function simple_inputs() { + echo "This is the first argument [$1]" + echo "This is the second argument [$2]" + echo "Calling function with $# aruments" +} + +# Subsection 2.3 +global_sum=0 +function global_sum_outputs() { + global_sum=$(($1+$2)) +} + +function cs_sum_outputs() { + sum=$(($1+$2)) + echo $sum +} + +# Subsection 2.4 +function arg_ref_sum_outputs() { + declare -n sum_ref=$3 + sum_ref=$(($1+$2)) +} + +# Subsection 3.1 +variable="baeldung" +function variable_scope2() { + echo "Variable inside function variable_scope2: [$variable]" + local variable="ipsum" +} + +function variable_scope() { + local variable="lorem" + echo "Variable inside function variable_scope: [$variable]" + variable_scope2 +} + +# Subsection 3.2 +subshell_sum=0 +function simple_subshell_sum() ( + subshell_sum=$(($1+$2)) + echo "Value of sum in function with global variables: [$subshell_sum]" +) + +function simple_subshell_ref_sum() ( + declare -n sum_ref=$3 + sum_ref=$(($1+$2)) + echo "Value of sum in function with ref arguments: [$sum_ref]" +) + +# Subsection 3.3 +function redirection_in() { + while read input; + do + echo "$input" + done +} < infile + +function redirection_in_ps() { + read + while read -a input; + do + echo "User[${input[2]}]->File[${input[8]}]" + done +} < <(ls -ll /) + +function redirection_out_ps() { + declare -a output=("baeldung" "lorem" "ipsum" "caracg") + for element in "${output[@]}" + do + echo "$element" + done +} > >(grep "g") + +function redirection_out() { + declare -a output=("baeldung" "lorem" "ipsum") + for element in "${output[@]}" + do + echo "$element" + done +} > outfile + +# Subsection 3.4 +function fibonnaci_recursion() { + argument=$1 + if [[ "$argument" -eq 0 ]] || [[ "$argument" -eq 1 ]]; then + echo $argument + else + first=$(fibonnaci_recursion $(($argument-1))) + second=$(fibonnaci_recursion $(($argument-2))) + echo $(( $first + $second )) + fi +} + +# main menu entry point +echo "****Functions samples menu*****" +PS3="Your choice (1,2,3 etc.):" +options=("function_definitions" "function_input_args" "function_outputs" \ + "function_variables" "function_subshells" "function_redirections" \ + "function_recursion" "quit") +select option in "${options[@]}" +do + case $option in + "function_definitions") + echo -e "\n" + echo "**Different ways to define a function**" + echo -e "No function keyword:" + simple_function + echo -e "\nNo function parantheses:" + simple_function_no_parantheses + echo -e "\nOmitting curly braces:" + simple_for_loop + echo -e "\n" + ;; + "function_input_args") + echo -e "\n" + echo "**Passing inputs to a function**" + simple_inputs lorem ipsum + echo -e "\n" + ;; + "function_outputs") + echo -e "\n" + echo "**Getting outputs from a function**" + global_sum_outputs 1 2 + echo -e ">1+2 using global variables: [$global_sum]" + cs_sum=$(cs_sum_outputs 1 2) + echo -e ">1+2 using command substitution: [$cs_sum]" + arg_ref_sum_outputs 1 2 arg_ref_sum + echo -e ">1+2 using argument references: [$arg_ref_sum]" + echo -e "\n" + ;; + "function_variables") + echo -e "\n" + echo "**Overriding variable scopes**" + echo "Global value of variable: [$variable]" + variable_scope + echo -e "\n" + ;; + "function_subshells") + echo -e "\n" + echo "**Running function in subshell**" + echo "Global value of sum: [$subshell_sum]" + simple_subshell_sum 1 2 + echo "Value of sum after subshell function with \ +global variables: [$subshell_sum]" + subshell_sum_arg_ref=0 + simple_subshell_ref_sum 1 2 subshell_sum_arg_ref + echo "Value of sum after subshell function with \ +ref arguments: [$subshell_sum_arg_ref]" + echo -e "\n" + ;; + "function_redirections") + echo -e "\n" + echo "**Function redirections**" + echo -e ">Function input redirection from file:" + redirection_in + echo -e ">Function input redirection from command:" + redirection_in_ps + echo -e ">Function output redirection to file:" + redirection_out + cat outfile + echo -e ">Function output redirection to command:" + red_ps=$(redirection_out_ps) + echo "$red_ps" + echo -e "\n" + ;; + "function_recursion") + echo -e "\n" + echo "**Function recursion**" + fibo_res1=$(fibonnaci_recursion 7) + echo "The 7th Fibonnaci number: [$fibo_res1]" + fibo_res2=$(fibonnaci_recursion 15) + echo "The 15th Fibonnaci number: [$fibo_res2]" + echo -e "\n" + ;; + "quit") + break + ;; + *) echo "Invalid option";; + esac +done \ No newline at end of file diff --git a/linux-bash/functions/src/main/bash/infile b/linux-bash/functions/src/main/bash/infile new file mode 100644 index 0000000000..b1fa680af4 --- /dev/null +++ b/linux-bash/functions/src/main/bash/infile @@ -0,0 +1,3 @@ +Honda Insight 2010 +Honda Element 2006 +Chevrolet Avalanche 2002 diff --git a/linux-bash/read/src/main/bash/file.csv b/linux-bash/read/src/main/bash/file.csv new file mode 100644 index 0000000000..69a50772ab --- /dev/null +++ b/linux-bash/read/src/main/bash/file.csv @@ -0,0 +1 @@ +car,car model,car year,car vin;Mercury,Grand Marquis,2000,2G61S5S33F9986032;Mitsubishi,Truck,1995,SCFFDABE1CG137362;Ford,Mustang,1968,2G4WS55J351278031;Ford,Crown Victoria,1996,4T1BK1EB8EU586249;GMC,Envoy,2004,WVGEF9BP3FD720618; diff --git a/linux-bash/read/src/main/bash/read_inputs.sh b/linux-bash/read/src/main/bash/read_inputs.sh new file mode 100755 index 0000000000..30eb598ac3 --- /dev/null +++ b/linux-bash/read/src/main/bash/read_inputs.sh @@ -0,0 +1,122 @@ +#!/bin/bash + +# section 2.1 +default_read(){ + read input1 input2 input3 + echo "[$input1] [$input2] [$input3]" +} + +# section 2.2 +custom_ifs_no_array(){ + OLDIFS=$IFS + IFS=";" + read input1 input2 input3 + echo "[$input1] [$input2] [$input3]" + # restore default IFS after we're finished so current shell behaves like before + IFS=$OLDIFS +} + +# Section 2.3 +prompt_read_password(){ + prompt="You shall not pass:" + read -p "$prompt" -s input + echo -e "\ninput password [$input]" +} + +array_read(){ + declare -a input_array + text="baeldung is a cool tech site" + read -e -i "$text" -a input_array + for input in ${input_array[@]} + do + echo " word [$input]" + done +} + +# section 3.1 +file_read(){ + exec {file_descriptor}<"./file.csv" + declare -a input_array + delimiter=";" + while IFS="," read -a input_array -d $delimiter -u $file_descriptor + do + echo "${input_array[0]},${input_array[2]}" + done + exec {file_descriptor}>&- +} + +# section 3.2 +command_pipe(){ + ls -ll / | { declare -a input + read + while read -a input; + do + echo "${input[0]} ${input[8]}" + done } +} + +# section 3.3 +timeout_input_read(){ + prompt="You shall not pass:" + read -p "$prompt" -s -r -t 5 input + if [ -z "$input" ]; then + echo -e "\ntimeout occured!" + else + echo -e "\ninput word [$input]" + fi +} + +exactly_n_read(){ + prompt="Reading exactly 11 chars:" + read -p "$prompt" -N 11 -t 5 input1 input2 + echo -e "\ninput word1 [$input1]" + echo "input word2 [$input2]" +} + +# main menu entry point +echo "****Read command samples menu*****" +PS3="Your choice (1,2,3 etc.):" +options=("default_read" "custom_ifs_no_array" "prompt_read_password" \ + "array_read" "file_read" "command_pipe" "timeout_input_read" \ + "exactly_n_read" "quit") +select option in "${options[@]}" +do + case $option in + "default_read") + echo "Enter something separated by spaces" + default_read + ;; + "custom_ifs_no_array") + echo "Enter something separated by ;" + custom_ifs_no_array + ;; + "prompt_read_password") + echo "Enter an invisible password after the prompt" + prompt_read_password + ;; + "array_read") + echo "Enter something else or just return" + array_read + ;; + "file_read") + echo "Reading from one liner csv file" + file_read + ;; + "command_pipe") + echo "Listing files and access rights from /" + command_pipe + ;; + "timeout_input_read") + echo "Enter something in 5 seconds or less" + timeout_input_read + ;; + "exactly_n_read") + echo "Enter at least 11 characters or wait 5 seconds" + exactly_n_read + ;; + "quit") + break + ;; + *) echo "Invalid option";; + esac +done \ No newline at end of file diff --git a/logging-modules/flogger/pom.xml b/logging-modules/flogger/pom.xml index c27e2c8d7a..f553a4a961 100644 --- a/logging-modules/flogger/pom.xml +++ b/logging-modules/flogger/pom.xml @@ -15,26 +15,26 @@ com.google.flogger flogger - 0.4 + ${flogger.version} com.google.flogger flogger-system-backend - 0.4 + ${flogger.version} runtime com.google.flogger flogger-slf4j-backend - 0.4 + ${flogger.version} com.google.flogger flogger-log4j-backend - 0.4 + ${flogger.version} com.sun.jmx @@ -54,13 +54,18 @@ log4j log4j - 1.2.17 + ${log4j.version} log4j apache-log4j-extras - 1.2.17 + ${log4j.version} + + 0.4 + 1.2.17 + + \ No newline at end of file diff --git a/logging-modules/logback/pom.xml b/logging-modules/logback/pom.xml index 6ffc9e1235..ee430949df 100644 --- a/logging-modules/logback/pom.xml +++ b/logging-modules/logback/pom.xml @@ -50,12 +50,25 @@ + + javax.mail + mail + ${javax.mail.version} + + + javax.activation + activation + ${javax.activation.version} + runtime + 1.2.3 0.1.5 3.3.5 + 1.4.7 + 1.1.1 diff --git a/logging-modules/logback/src/main/resources/logback.xml b/logging-modules/logback/src/main/resources/logback.xml index 37ae2adbb0..76ddc2e3ee 100644 --- a/logging-modules/logback/src/main/resources/logback.xml +++ b/logging-modules/logback/src/main/resources/logback.xml @@ -10,9 +10,47 @@ + + OUR-SMTP-HOST-ADDRESS + + EMAIL-RECIPIENT-1 + EMAIL-RECIPIENT-2 + SENDER-EMAIL-ADDRESS + BAELDUNG: %logger{20} - %msg + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n + + + + + OUR-SMTP-HOST-ADDRESS + EMAIL-RECIPIENT + SENDER-EMAIL-ADDRESS + BAELDUNG: %logger{20} - %msg + + + + 5 + + + + + smtp.gmail.com + 587 + true + false + SENDER-EMAIL@gmail.com + GMAIL-ACCT-PASSWORD + EMAIL-RECIPIENT + SENDER-EMAIL@gmail.com + BAELDUNG: %logger{20} - %msg + + + + \ No newline at end of file diff --git a/machine-learning/pom.xml b/machine-learning/pom.xml index 7bc0332012..24162b7b9c 100644 --- a/machine-learning/pom.xml +++ b/machine-learning/pom.xml @@ -19,6 +19,15 @@ 1.7 1.3.50 0.9.1 + 3.1.0 + 3.0.2 + 3.0.2 + 3.8.0 + 2.22.1 + 2.5.2 + 2.8.2 + 3.7.1 + 3.0.0 @@ -63,41 +72,41 @@ maven-clean-plugin - 3.1.0 + ${clean.plugin.version} maven-resources-plugin - 3.0.2 + ${resources.plugin.version} maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} maven-surefire-plugin - 2.22.1 + ${surefire.plugin.version} maven-jar-plugin - 3.0.2 + ${jar.plugin.version} maven-install-plugin - 2.5.2 + ${install.plugin.version} maven-deploy-plugin - 2.8.2 + ${deploy.plugin.version} maven-site-plugin - 3.7.1 + ${site.plugin.version} maven-project-info-reports-plugin - 3.0.0 + ${report.plugin.version} diff --git a/maven-all/compiler-plugin-java-9/pom.xml b/maven-all/compiler-plugin-java-9/pom.xml index 1975e1f7cd..6baadb451c 100644 --- a/maven-all/compiler-plugin-java-9/pom.xml +++ b/maven-all/compiler-plugin-java-9/pom.xml @@ -12,13 +12,19 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 9 - 9 + ${source.version} + ${target.version} + + 3.8.0 + 9 + 9 + + \ No newline at end of file diff --git a/maven-all/maven-custom-plugin/README.md b/maven-all/maven-custom-plugin/README.md new file mode 100644 index 0000000000..55d147c337 --- /dev/null +++ b/maven-all/maven-custom-plugin/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [How to Create a Maven Plugin](https://www.baeldung.com/maven-plugin) diff --git a/maven-all/maven-custom-plugin/usage-example/pom.xml b/maven-all/maven-custom-plugin/usage-example/pom.xml index 542a02b3eb..bd2b16475e 100644 --- a/maven-all/maven-custom-plugin/usage-example/pom.xml +++ b/maven-all/maven-custom-plugin/usage-example/pom.xml @@ -8,16 +8,21 @@ 0.0.1-SNAPSHOT pom + + 3.9 + 4.12 + + org.apache.commons commons-lang3 - 3.9 + ${commons.lang3.version} junit junit - 4.12 + ${junit.version} test diff --git a/maven-all/maven-war-plugin/pom.xml b/maven-all/maven-war-plugin/pom.xml index 233a9f3571..915be306ca 100644 --- a/maven-all/maven-war-plugin/pom.xml +++ b/maven-all/maven-war-plugin/pom.xml @@ -14,7 +14,7 @@ maven-war-plugin - 3.1.0 + ${war.plugin.version} false @@ -26,6 +26,7 @@ false + 3.1.0 \ No newline at end of file diff --git a/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java b/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java index 9b72f40bf1..db636c2308 100644 --- a/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java +++ b/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java @@ -19,8 +19,8 @@ public class MyCustomRule implements EnforcerRule { String groupId = (String) enforcerRuleHelper.evaluate("${project.groupId}"); - if (groupId == null || !groupId.startsWith("org.baeldung")) { - throw new EnforcerRuleException("Project group id does not start with org.baeldung"); + if (groupId == null || !groupId.startsWith("com.baeldung")) { + throw new EnforcerRuleException("Project group id does not start with com.baeldung"); } } diff --git a/maven-all/pom.xml b/maven-all/pom.xml new file mode 100644 index 0000000000..3a79a2a686 --- /dev/null +++ b/maven-all/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + maven-all + 0.0.1-SNAPSHOT + maven-all + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + maven + maven-custom-plugin/counter-maven-plugin + maven-war-plugin + profiles + versions-maven-plugin + + + diff --git a/maven-all/profiles/pom.xml b/maven-all/profiles/pom.xml index 01b191c7d6..4ae6d1ee40 100644 --- a/maven-all/profiles/pom.xml +++ b/maven-all/profiles/pom.xml @@ -73,7 +73,7 @@ org.apache.maven.plugins maven-help-plugin - 3.2.0 + ${help.plugin.version} show-profiles @@ -87,4 +87,8 @@ + + 3.2.0 + + \ No newline at end of file diff --git a/maven-all/versions-maven-plugin/original/pom.xml b/maven-all/versions-maven-plugin/original/pom.xml index c6c1657b25..54140aec9b 100644 --- a/maven-all/versions-maven-plugin/original/pom.xml +++ b/maven-all/versions-maven-plugin/original/pom.xml @@ -46,7 +46,7 @@ org.codehaus.mojo versions-maven-plugin - 2.7 + ${versions.plugin.version} org.apache.commons:commons-collections4 @@ -76,6 +76,7 @@ 4.0 3.0 1.9.1 + 2.7 \ No newline at end of file diff --git a/maven-all/versions-maven-plugin/pom.xml b/maven-all/versions-maven-plugin/pom.xml index 3ce25d16f9..9793f55b28 100644 --- a/maven-all/versions-maven-plugin/pom.xml +++ b/maven-all/versions-maven-plugin/pom.xml @@ -12,19 +12,19 @@ commons-io commons-io - 2.3 + ${commons.io.version} org.apache.commons commons-collections4 - 4.0 + ${commons.collections4.version} org.apache.commons commons-lang3 - 3.0 + ${commons.lang3.version} @@ -36,7 +36,7 @@ commons-beanutils commons-beanutils - 1.9.1 + ${commons.beanutils.version} @@ -45,7 +45,7 @@ org.codehaus.mojo versions-maven-plugin - 2.7 + ${versions.plugin.version} org.apache.commons:commons-collections4 @@ -71,6 +71,11 @@ 1.15 + 2.3 + 2.7 + 1.9.1 + 3.0 + 4.0 \ No newline at end of file diff --git a/maven-archetype/src/main/resources/archetype-resources/pom.xml b/maven-archetype/src/main/resources/archetype-resources/pom.xml index a5c813652d..2a73687e2c 100644 --- a/maven-archetype/src/main/resources/archetype-resources/pom.xml +++ b/maven-archetype/src/main/resources/archetype-resources/pom.xml @@ -14,6 +14,8 @@ ${liberty-plugin-version} 9080 9443 + 2.0 + 2.1 @@ -65,14 +67,14 @@ javax.enterprise cdi-api - 2.0 + ${cdi.api.version} provided javax.ws.rs javax.ws.rs-api - 2.1 + ${rsapi.api.version} provided diff --git a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml b/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml index 42b06bbebd..a4a6575906 100644 --- a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml +++ b/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml @@ -12,23 +12,26 @@ com.baeldung.multimodule-maven-project multimodule-maven-project 1.0 + 1.0 + 1.0 + 1.0 com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version} com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} com.baeldung.userdaomodule userdaomodule - 1.0 + ${userdaomodule.version} diff --git a/maven-java-11/multimodule-maven-project/pom.xml b/maven-java-11/multimodule-maven-project/pom.xml index a79dff93d3..65f5b7a814 100644 --- a/maven-java-11/multimodule-maven-project/pom.xml +++ b/maven-java-11/multimodule-maven-project/pom.xml @@ -26,13 +26,13 @@ junit junit - 4.12 + ${junit.version} test org.assertj assertj-core - 3.12.2 + ${assertj.version} test @@ -44,10 +44,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 11 - 11 + ${source.version} + ${target.version} @@ -56,6 +56,11 @@ UTF-8 + 4.12 + 3.12.2 + 3.8.0 + 11 + 11 diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml b/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml index 3eb5897f8b..cfa59bdc39 100644 --- a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml +++ b/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml @@ -14,16 +14,21 @@ 1.0 + + 1.0 + 1.0 + + com.baeldung.entitymodule entitymodule - 1.0 + ${entitymodule.version}1.0 com.baeldung.daomodule daomodule - 1.0 + ${daomodule.version} junit diff --git a/maven-polyglot/maven-polyglot-json-extension/pom.xml b/maven-polyglot/maven-polyglot-json-extension/pom.xml index 0043bae151..15166046c1 100644 --- a/maven-polyglot/maven-polyglot-json-extension/pom.xml +++ b/maven-polyglot/maven-polyglot-json-extension/pom.xml @@ -34,7 +34,7 @@ org.codehaus.plexus plexus-component-metadata - 1.7.1 + ${plexus.component.version} @@ -48,6 +48,7 @@ 3.5.4 + 1.7.1 \ No newline at end of file diff --git a/maven-polyglot/pom.xml b/maven-polyglot/pom.xml new file mode 100644 index 0000000000..eb4e629a96 --- /dev/null +++ b/maven-polyglot/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + maven-polyglot + 0.0.1-SNAPSHOT + maven-polyglot + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + maven-polyglot-json-extension + + + + diff --git a/micronaut/pom.xml b/micronaut/pom.xml index 13639c11ff..2cb05cc1b9 100644 --- a/micronaut/pom.xml +++ b/micronaut/pom.xml @@ -49,7 +49,7 @@ javax.annotation javax.annotation-api - 1.3.2 + ${annotation.api.version} compile @@ -60,19 +60,19 @@ ch.qos.logback logback-classic - 1.2.3 + ${lombok.version} runtime junit junit - 4.12 + ${junit.version} test io.projectreactor reactor-core - 3.1.6.RELEASE + ${reactor.version} @@ -81,7 +81,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + ${shade.plugin.version} package @@ -102,7 +102,7 @@ org.codehaus.mojo exec-maven-plugin - 1.6.0 + ${exec.plugin.version} java @@ -118,7 +118,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + ${compiler.plugin.version} ${jdk.version} ${jdk.version} @@ -142,6 +142,13 @@ com.baeldung.micronaut.helloworld.server.ServerApplication 1.0.0.RC2 1.8 + 1.3.2 + 1.2.3 + 4.12 + 3.1.6.RELEASE + 3.7.0 + 1.6.0 + 3.1.0 diff --git a/micronaut/src/main/resources/application.yml b/micronaut/src/main/resources/application.yml index 4119026dd6..32daacd4aa 100644 --- a/micronaut/src/main/resources/application.yml +++ b/micronaut/src/main/resources/application.yml @@ -2,4 +2,4 @@ micronaut: application: name: hello-world-server server: - port: 9080 \ No newline at end of file + port: ${random.port} \ No newline at end of file diff --git a/netflix/README.md b/netflix-modules/README.md similarity index 89% rename from netflix/README.md rename to netflix-modules/README.md index 0af07d37a8..4afea527df 100644 --- a/netflix/README.md +++ b/netflix-modules/README.md @@ -1,4 +1,4 @@ -## Netflix +## Netflix Modules This module contains articles about Netflix. diff --git a/netflix/genie/pom.xml b/netflix-modules/genie/pom.xml similarity index 87% rename from netflix/genie/pom.xml rename to netflix-modules/genie/pom.xml index 2288c5338a..2c7c04b26b 100644 --- a/netflix/genie/pom.xml +++ b/netflix-modules/genie/pom.xml @@ -3,14 +3,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 genie - 1.0.0-SNAPSHOT Genie jar Sample project for Netflix Genie com.baeldung - netflix + netflix-modules 1.0.0-SNAPSHOT diff --git a/netflix/genie/src/main/resources/com/baeldung/netflix/genie/docker/docker-compose.yml b/netflix-modules/genie/src/main/resources/com/baeldung/netflix/genie/docker/docker-compose.yml similarity index 100% rename from netflix/genie/src/main/resources/com/baeldung/netflix/genie/docker/docker-compose.yml rename to netflix-modules/genie/src/main/resources/com/baeldung/netflix/genie/docker/docker-compose.yml diff --git a/netflix/genie/src/main/resources/com/baeldung/netflix/genie/docker/init_demo.py b/netflix-modules/genie/src/main/resources/com/baeldung/netflix/genie/docker/init_demo.py similarity index 100% rename from netflix/genie/src/main/resources/com/baeldung/netflix/genie/docker/init_demo.py rename to netflix-modules/genie/src/main/resources/com/baeldung/netflix/genie/docker/init_demo.py diff --git a/netflix/genie/src/main/resources/com/baeldung/netflix/genie/docker/run_spark_submit_job.py b/netflix-modules/genie/src/main/resources/com/baeldung/netflix/genie/docker/run_spark_submit_job.py similarity index 100% rename from netflix/genie/src/main/resources/com/baeldung/netflix/genie/docker/run_spark_submit_job.py rename to netflix-modules/genie/src/main/resources/com/baeldung/netflix/genie/docker/run_spark_submit_job.py diff --git a/netflix/pom.xml b/netflix-modules/pom.xml similarity index 85% rename from netflix/pom.xml rename to netflix-modules/pom.xml index 6cf81cd7ab..9ed22498d8 100644 --- a/netflix/pom.xml +++ b/netflix-modules/pom.xml @@ -2,9 +2,8 @@ 4.0.0 - netflix - 1.0.0-SNAPSHOT - Netflix + netflix-modules + Netflix Modules pom Module for Netflix projects diff --git a/ninja/pom.xml b/ninja/pom.xml new file mode 100644 index 0000000000..afb1d509b8 --- /dev/null +++ b/ninja/pom.xml @@ -0,0 +1,192 @@ + + + 4.0.0 + + ninja + jar + com.baeldung + 1.0.0 + + http://www.ninjaframework.org + + + 6.5.0 + 9.4.18.v20190429 + 3.3.4 + 2.1.3 + 1.4.186 + 3.2 + 1.8 + 1.8 + 1.3.1 + 2.8.2 + 2.2 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${compiler.plugin.version} + + ${source.version} + ${target.version} + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${enforcer.plugin.version} + + + enforce-banned-dependencies + + enforce + + + + + + commons-logging + + + + true + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + + / + + stop + 8889 + 1 + automatic + + + target/classes + + **/* + + + **/*.ftl.html + assets/** + + + + + + ninja.mode + dev + + + + + + + + + org.ninjaframework + ninja-maven-plugin + ${ninja.version} + + + org.apache.maven.plugins + maven-deploy-plugin + ${deploy.plugin.version} + + true + + + + org.apache.maven.plugins + maven-shade-plugin + ${shade.plugin.version} + + true + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + package + + shade + + + + + + ninja.standalone.NinjaJetty + + + + + + + + + + src/main/java + + **/* + + + **/*.java + + + + src/main/resources + + **/* + + + + + + + org.webjars + bootstrap + ${bootstrap.version} + + + org.webjars + jquery + ${jquery.version} + + + com.h2database + h2 + ${h2.version} + + + org.ninjaframework + ninja-standalone + ${ninja.version} + + + org.ninjaframework + ninja-test-utilities + ${ninja.version} + test + + + \ No newline at end of file diff --git a/ninja/src/main/java/META-INF/persistence.xml b/ninja/src/main/java/META-INF/persistence.xml new file mode 100644 index 0000000000..e57cd5ecc0 --- /dev/null +++ b/ninja/src/main/java/META-INF/persistence.xml @@ -0,0 +1,29 @@ + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ninja/src/main/java/assets/css/custom.css b/ninja/src/main/java/assets/css/custom.css new file mode 100644 index 0000000000..41d249d3cb --- /dev/null +++ b/ninja/src/main/java/assets/css/custom.css @@ -0,0 +1,3 @@ +/* Add additional stylesheets below +-------------------------------------------------- */ + diff --git a/ninja/src/main/java/conf/Filters.java b/ninja/src/main/java/conf/Filters.java new file mode 100644 index 0000000000..b201780fa1 --- /dev/null +++ b/ninja/src/main/java/conf/Filters.java @@ -0,0 +1,13 @@ +package conf; + +import java.util.List; +import ninja.Filter; + +public class Filters implements ninja.application.ApplicationFilters { + + @Override + public void addFilters(List> filters) { + // Add your application - wide filters here + // filters.add(MyFilter.class); + } +} diff --git a/ninja/src/main/java/conf/Module.java b/ninja/src/main/java/conf/Module.java new file mode 100644 index 0000000000..f7c03a4b26 --- /dev/null +++ b/ninja/src/main/java/conf/Module.java @@ -0,0 +1,18 @@ +package conf; + +import com.google.inject.AbstractModule; +import com.google.inject.Singleton; + +import services.UserService; +import services.UserServiceImpl; + +@Singleton +public class Module extends AbstractModule { + + protected void configure() { + + bind(UserService.class).to(UserServiceImpl.class); + + } + +} diff --git a/ninja/src/main/java/conf/Routes.java b/ninja/src/main/java/conf/Routes.java new file mode 100644 index 0000000000..a1727d55b0 --- /dev/null +++ b/ninja/src/main/java/conf/Routes.java @@ -0,0 +1,32 @@ +package conf; + +import ninja.AssetsController; +import ninja.Router; +import ninja.application.ApplicationRoutes; +import controllers.ApplicationController; + +public class Routes implements ApplicationRoutes { + + @Override + public void init(Router router) { + + router.GET().route("/index").with(ApplicationController::index); + router.GET().route("/home").with(ApplicationController::home); + router.GET().route("/hello").with(ApplicationController::helloWorld); + router.GET().route("/userJson").with(ApplicationController::userJson); + router.GET().route("/createUser").with(ApplicationController::createUser); + router.GET().route("/flash").with(ApplicationController::showFlashMsg); + + router.GET().route("/users").with(ApplicationController::fetchUsers); + router.POST().route("/users").with(ApplicationController::insertUser); + + //Assets + router.GET().route("/assets/webjars/{fileName: .*}").with(AssetsController::serveWebJars); + router.GET().route("/assets/{fileName: .*}").with(AssetsController::serveStatic); + + //Index + router.GET().route("/.*").with(ApplicationController::index); + + } + +} diff --git a/ninja/src/main/java/conf/application.conf b/ninja/src/main/java/conf/application.conf new file mode 100644 index 0000000000..0ae4c7ec40 --- /dev/null +++ b/ninja/src/main/java/conf/application.conf @@ -0,0 +1,21 @@ +application.name=baeldung ninja dev application +%test.application.name=baeldung ninja test application +%prod.application.name=baeldung ninja application + +application.cookie.prefix=NINJA + +application.languages=fr,en + +application.session.expire_time_in_seconds=3600 +application.session.send_only_if_changed=true +application.session.transferred_over_https_only=false + +ninja.port=8000 +ninja.ssl.port=8001 +application.secret = fxSjSL9Q017BSL7gBnkyo2Prln7uXaXIT35gotXRIED8c46OSa8s4QdoIQdTsEtj + +# h2 jpa configuration +ninja.jpa.persistence_unit_name=dev_unit +db.connection.url=jdbc:h2:./devDb +db.connection.username=sa +db.connection.password= diff --git a/ninja/src/main/java/conf/messages.properties b/ninja/src/main/java/conf/messages.properties new file mode 100644 index 0000000000..3bddfcd8c7 --- /dev/null +++ b/ninja/src/main/java/conf/messages.properties @@ -0,0 +1,2 @@ +header.home=Home! +helloMsg=Hello, welcome to Ninja Framework! \ No newline at end of file diff --git a/ninja/src/main/java/conf/messages_fr.properties b/ninja/src/main/java/conf/messages_fr.properties new file mode 100644 index 0000000000..89264e0cb9 --- /dev/null +++ b/ninja/src/main/java/conf/messages_fr.properties @@ -0,0 +1,2 @@ +header.home=Accueil! +helloMsg=Bonjour, bienvenue dans Ninja Framework! \ No newline at end of file diff --git a/ninja/src/main/java/controllers/ApplicationController.java b/ninja/src/main/java/controllers/ApplicationController.java new file mode 100644 index 0000000000..38dd598694 --- /dev/null +++ b/ninja/src/main/java/controllers/ApplicationController.java @@ -0,0 +1,102 @@ +package controllers; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import javax.inject.Inject; +import javax.persistence.EntityManager; +import javax.persistence.Query; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.google.inject.Provider; +import com.google.inject.Singleton; +import com.google.inject.persist.Transactional; + +import models.User; +import ninja.Context; +import ninja.Result; +import ninja.Results; +import ninja.i18n.Lang; +import ninja.i18n.Messages; +import ninja.jpa.UnitOfWork; +import ninja.session.FlashScope; +import ninja.validation.JSR303Validation; +import ninja.validation.Validation; +import services.UserService; + +@Singleton +public class ApplicationController { + + @Inject + Lang lang; + + @Inject + Messages msg; + + private static Log logger = LogFactory.getLog(ApplicationController.class); + + @Inject + Provider entityManagerProvider; + + @Inject + UserService userService; + + public Result index() { + return Results.html(); + } + + public Result userJson() { + HashMap userMap = userService.getUserMap(); + logger.info(userMap); + return Results.json().render(userMap); + } + + public Result helloWorld(Context context) { + Optional language = Optional.of("fr"); + String helloMsg = msg.get("helloMsg", language).get(); + return Results.text().render(helloMsg); + } + + public Result showFlashMsg(FlashScope flashScope) { + flashScope.success("Success message"); + flashScope.error("Error message"); + return Results.redirect("/home"); + } + + public Result home() { + return Results.html(); + } + + public Result createUser() { + return Results.html(); + } + + @UnitOfWork + public Result fetchUsers() { + EntityManager entityManager = entityManagerProvider.get(); + Query q = entityManager.createQuery("SELECT x FROM User x"); + List users = (List) q.getResultList(); + return Results.json().render(users); + } + + @Transactional + public Result insertUser(FlashScope flashScope, @JSR303Validation User user, Validation validation) { + logger.info("Inserting User : " +user); + + if (validation.getViolations().size() > 0) { + flashScope.error("Validation Error: User can't be created"); + } else { + EntityManager entityManager = entityManagerProvider.get(); + entityManager.persist(user); + entityManager.flush(); + flashScope.success("User '" + user + "' is created successfully"); + } + + return Results.redirect("/home"); + } + +} diff --git a/ninja/src/main/java/ehcache.xml b/ninja/src/main/java/ehcache.xml new file mode 100644 index 0000000000..b401b61a36 --- /dev/null +++ b/ninja/src/main/java/ehcache.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/ninja/src/main/java/logback.xml b/ninja/src/main/java/logback.xml new file mode 100644 index 0000000000..ebdcf56f76 --- /dev/null +++ b/ninja/src/main/java/logback.xml @@ -0,0 +1,33 @@ + + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + diff --git a/ninja/src/main/java/models/User.java b/ninja/src/main/java/models/User.java new file mode 100644 index 0000000000..e021567bca --- /dev/null +++ b/ninja/src/main/java/models/User.java @@ -0,0 +1,25 @@ +package models; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.validation.constraints.NotNull; + +@Entity +public class User { + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + Long id; + + @NotNull + public String firstName; + + public String email; + + public String toString() { + return firstName + " : " + email; + } + +} diff --git a/ninja/src/main/java/services/UserService.java b/ninja/src/main/java/services/UserService.java new file mode 100644 index 0000000000..10d625c66f --- /dev/null +++ b/ninja/src/main/java/services/UserService.java @@ -0,0 +1,9 @@ +package services; + +import java.util.HashMap; + +public interface UserService { + + HashMap getUserMap(); + +} diff --git a/ninja/src/main/java/services/UserServiceImpl.java b/ninja/src/main/java/services/UserServiceImpl.java new file mode 100644 index 0000000000..0f8c2214cf --- /dev/null +++ b/ninja/src/main/java/services/UserServiceImpl.java @@ -0,0 +1,15 @@ +package services; + +import java.util.HashMap; + +public class UserServiceImpl implements UserService { + + @Override + public HashMap getUserMap() { + HashMap userMap = new HashMap<>(); + userMap.put("name", "Norman Lewis"); + userMap.put("email", "norman@email.com"); + return userMap; + } + +} diff --git a/ninja/src/main/java/views/ApplicationController/createUser.ftl.html b/ninja/src/main/java/views/ApplicationController/createUser.ftl.html new file mode 100644 index 0000000000..9156f7dbf2 --- /dev/null +++ b/ninja/src/main/java/views/ApplicationController/createUser.ftl.html @@ -0,0 +1,12 @@ +<#import "../layout/defaultLayout.ftl.html" as layout> +<@layout.myLayout "Create User"> + +
+ + First Name : +
+ Email : +
+ + + \ No newline at end of file diff --git a/ninja/src/main/java/views/ApplicationController/home.ftl.html b/ninja/src/main/java/views/ApplicationController/home.ftl.html new file mode 100644 index 0000000000..10f6612d54 --- /dev/null +++ b/ninja/src/main/java/views/ApplicationController/home.ftl.html @@ -0,0 +1,9 @@ +<#import "../layout/defaultLayout.ftl.html" as layout> +<@layout.myLayout "Home page"> + + +

${i18n("helloMsg")}

+ +User Json + + \ No newline at end of file diff --git a/ninja/src/main/java/views/ApplicationController/index.ftl.html b/ninja/src/main/java/views/ApplicationController/index.ftl.html new file mode 100644 index 0000000000..25d0a31229 --- /dev/null +++ b/ninja/src/main/java/views/ApplicationController/index.ftl.html @@ -0,0 +1,9 @@ + + + Ninja: Index + + +

${i18n("helloMsg")}

+ User Json + + \ No newline at end of file diff --git a/ninja/src/main/java/views/layout/defaultLayout.ftl.html b/ninja/src/main/java/views/layout/defaultLayout.ftl.html new file mode 100644 index 0000000000..a61edd19e6 --- /dev/null +++ b/ninja/src/main/java/views/layout/defaultLayout.ftl.html @@ -0,0 +1,58 @@ +<#macro myLayout title="Layout example"> + + + + + ${title} + + + + + + + + + + + + + + + + + + +
+ + <#include "header.ftl.html"/> + + <#if (flash.error)??> +
+ ${flash.error} +
+ + + <#if (flash.success)??> +
+ ${flash.success} +
+ + + <#nested/> + + <#include "footer.ftl.html"/> + +
+ + + + + \ No newline at end of file diff --git a/ninja/src/main/java/views/layout/footer.ftl.html b/ninja/src/main/java/views/layout/footer.ftl.html new file mode 100644 index 0000000000..0a2cb2721e --- /dev/null +++ b/ninja/src/main/java/views/layout/footer.ftl.html @@ -0,0 +1,5 @@ +
+ + diff --git a/ninja/src/main/java/views/layout/header.ftl.html b/ninja/src/main/java/views/layout/header.ftl.html new file mode 100644 index 0000000000..af79449bf2 --- /dev/null +++ b/ninja/src/main/java/views/layout/header.ftl.html @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/ninja/src/main/java/views/system/403forbidden.ftl.html b/ninja/src/main/java/views/system/403forbidden.ftl.html new file mode 100644 index 0000000000..0f4efd160a --- /dev/null +++ b/ninja/src/main/java/views/system/403forbidden.ftl.html @@ -0,0 +1,18 @@ +<#import "../layout/defaultLayout.ftl.html" as layout> +<@layout.myLayout "Error. Forbidden."> +
+
+
+
+

+ Oops!

+

+ 403 Forbidden

+
+ Sorry, an error has occured. Requested page is forbidden! +
+
+
+
+
+ \ No newline at end of file diff --git a/ninja/src/main/java/views/system/404notFound.ftl.html b/ninja/src/main/java/views/system/404notFound.ftl.html new file mode 100644 index 0000000000..c10e7c3949 --- /dev/null +++ b/ninja/src/main/java/views/system/404notFound.ftl.html @@ -0,0 +1,18 @@ +<#import "../layout/defaultLayout.ftl.html" as layout> +<@layout.myLayout "Error. Not found."> +
+
+
+
+

+ Oops!

+

+ 404 Not Found

+
+ Sorry, an error has occured. Requested page not found! +
+
+
+
+
+ \ No newline at end of file diff --git a/ninja/src/main/webapp/WEB-INF/web.xml b/ninja/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..fe4b2c95bf --- /dev/null +++ b/ninja/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + ninja + + + ninja.servlet.NinjaServletListener + + + + guiceFilter + com.google.inject.servlet.GuiceFilter + + + guiceFilter + /* + + + diff --git a/ninja/src/test/java/controllers/ApiControllerDocTesterTest.java b/ninja/src/test/java/controllers/ApiControllerDocTesterTest.java new file mode 100644 index 0000000000..d5f4f1811c --- /dev/null +++ b/ninja/src/test/java/controllers/ApiControllerDocTesterTest.java @@ -0,0 +1,27 @@ +package controllers; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; +import org.doctester.testbrowser.Request; +import org.doctester.testbrowser.Response; +import org.junit.Test; +import ninja.NinjaDocTester; + +public class ApiControllerDocTesterTest extends NinjaDocTester { + + String URL_INDEX = "/"; + String URL_HELLO = "/hello"; + + @Test + public void testGetIndex() { + Response response = makeRequest(Request.GET().url(testServerUrl().path(URL_INDEX))); + assertThat(response.payload, containsString("Hello, welcome to Ninja Framework!")); + } + + @Test + public void testGetHello() { + Response response = makeRequest(Request.GET().url(testServerUrl().path(URL_HELLO))); + assertThat(response.payload, containsString("Bonjour, bienvenue dans Ninja Framework!")); + } + +} diff --git a/ninja/src/test/java/controllers/ApiControllerMockUnitTest.java b/ninja/src/test/java/controllers/ApiControllerMockUnitTest.java new file mode 100644 index 0000000000..cb53965678 --- /dev/null +++ b/ninja/src/test/java/controllers/ApiControllerMockUnitTest.java @@ -0,0 +1,32 @@ +package controllers; + +import static org.junit.Assert.assertEquals; +import javax.inject.Inject; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import ninja.NinjaRunner; +import ninja.Result; +import services.UserService; + +@RunWith(NinjaRunner.class) +public class ApiControllerMockUnitTest { + + @Inject private UserService userService; + + ApplicationController applicationController; + + @Before + public void setupTest() { + applicationController = new ApplicationController(); + applicationController.userService = userService; + } + + @Test + public void testThatGetUserJson() { + Result result = applicationController.userJson(); + System.out.println(result.getRenderable()); + assertEquals(userService.getUserMap().toString(), result.getRenderable().toString()); + } + +} diff --git a/oauth2-framework-impl/README.md b/oauth2-framework-impl/README.md index ea9686b451..ae28c1b511 100644 --- a/oauth2-framework-impl/README.md +++ b/oauth2-framework-impl/README.md @@ -4,4 +4,4 @@ This module contains articles about the implementation of OAuth2 with Java EE. ### Relevant Articles -- [Implementing The OAuth 2.0 Authorization Framework Using Java EE](https://www.baeldung.com/java-ee-oauth2-implementation) +- [Implementing The OAuth 2.0 Authorization Framework Using Jakarta EE](https://www.baeldung.com/java-ee-oauth2-implementation) diff --git a/open-liberty/pom.xml b/open-liberty/pom.xml new file mode 100644 index 0000000000..d6588ce49a --- /dev/null +++ b/open-liberty/pom.xml @@ -0,0 +1,130 @@ + + + 4.0.0 + + com.baeldung + open-liberty + 1.0-SNAPSHOT + war + + + + jakarta.platform + jakarta.jakartaee-web-api + ${version.jakarta.jakartaee-web-api} + provided + + + org.eclipse.microprofile + microprofile + ${version.microprofile} + pom + provided + + + org.apache.derby + derby + ${version.derby} + + + + + junit + junit + ${version.junit} + test + + + org.eclipse + yasson + ${version.yasson} + test + + + org.apache.cxf + cxf-rt-rs-client + ${version.cxf-rt-rs-client} + test + + + org.glassfish + javax.json + ${version.javax.json} + test + + + org.apache.cxf + cxf-rt-rs-mp-client + ${version.cxf-rt-rs-mp-client} + test + + + + + ${project.artifactId} + + + + io.openliberty.tools + liberty-maven-plugin + ${version.liberty-maven-plugin} + + + org.apache.maven.plugins + maven-dependency-plugin + ${version.maven-dependency-plugin} + + + copy-derby-dependency + package + + copy-dependencies + + + derby + ${project.build.directory}/liberty/wlp/usr/shared/resources/ + + ${testServerHttpPort} + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${version.maven-war-plugin} + + + + + + + 1.8 + 1.8 + UTF-8 + UTF-8 + false + + + 8.0.0 + 3.2 + 10.14.2.0 + 3.1 + 2.10 + 3.2.3 + 4.12 + 1.0.5 + 3.2.6 + 1.0.4 + 3.3.1 + + + openliberty + 9080 + 9443 + 7070 + + \ No newline at end of file diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/person/dao/PersonDao.java b/open-liberty/src/main/java/com/baeldung/openliberty/person/dao/PersonDao.java new file mode 100644 index 0000000000..e2d408d8b0 --- /dev/null +++ b/open-liberty/src/main/java/com/baeldung/openliberty/person/dao/PersonDao.java @@ -0,0 +1,24 @@ +package com.baeldung.openliberty.person.dao; + +import javax.enterprise.context.RequestScoped; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +import com.baeldung.openliberty.person.model.Person; + +@RequestScoped +public class PersonDao { + + @PersistenceContext(name = "jpa-unit") + private EntityManager em; + + public Person createPerson(Person person) { + em.persist(person); + return person; + } + + public Person readPerson(int personId) { + return em.find(Person.class, personId); + } + +} \ No newline at end of file diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/person/model/Person.java b/open-liberty/src/main/java/com/baeldung/openliberty/person/model/Person.java new file mode 100644 index 0000000000..79e8c16911 --- /dev/null +++ b/open-liberty/src/main/java/com/baeldung/openliberty/person/model/Person.java @@ -0,0 +1,58 @@ +package com.baeldung.openliberty.person.model; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; + +@Entity +public class Person { + + @GeneratedValue(strategy = GenerationType.AUTO) + @Id + private int id; + + private String username; + private String email; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Person(int id, @NotBlank String username, @Email String email) { + super(); + this.id = id; + this.username = username; + this.email = email; + } + + public Person() { + super(); + } + + public String toString() { + return this.id + ":" +this.username; + } +} diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/person/resource/PersonResource.java b/open-liberty/src/main/java/com/baeldung/openliberty/person/resource/PersonResource.java new file mode 100644 index 0000000000..0fb86860b8 --- /dev/null +++ b/open-liberty/src/main/java/com/baeldung/openliberty/person/resource/PersonResource.java @@ -0,0 +1,52 @@ +package com.baeldung.openliberty.person.resource; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.baeldung.openliberty.person.dao.PersonDao; +import com.baeldung.openliberty.person.model.Person; + +@RequestScoped +@Path("persons") +public class PersonResource { + + @Inject + private PersonDao personDao; + + @GET + @Produces(MediaType.APPLICATION_JSON) + public List getAllPersons() { + return Arrays.asList(new Person(1, "normanlewis", "normanlewis@email.com")); + } + + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Transactional + public Response addPerson(Person person) { + personDao.createPerson(person); + String respMessage = "Person #" + person.getId() + " created successfully."; + return Response.status(Response.Status.CREATED).entity(respMessage).build(); + } + + @GET + @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) + @Transactional + public Person getPerson(@PathParam("id") int id) { + Person person = personDao.readPerson(id); + return person; + } +} diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/rest/ApiApplication.java b/open-liberty/src/main/java/com/baeldung/openliberty/rest/ApiApplication.java new file mode 100644 index 0000000000..176eaccaed --- /dev/null +++ b/open-liberty/src/main/java/com/baeldung/openliberty/rest/ApiApplication.java @@ -0,0 +1,9 @@ +package com.baeldung.openliberty.rest; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("/api") +public class ApiApplication extends Application { + +} diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/rest/consumes/RestConsumer.java b/open-liberty/src/main/java/com/baeldung/openliberty/rest/consumes/RestConsumer.java new file mode 100644 index 0000000000..8073c408dd --- /dev/null +++ b/open-liberty/src/main/java/com/baeldung/openliberty/rest/consumes/RestConsumer.java @@ -0,0 +1,18 @@ +package com.baeldung.openliberty.rest.consumes; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.core.Response; + +public class RestConsumer { + + public static String consumeWithJsonb(String targetUrl) { + Client client = ClientBuilder.newClient(); + Response response = client.target(targetUrl).request().get(); + String result = response.readEntity(String.class); + response.close(); + client.close(); + return result; + } + +} diff --git a/open-liberty/src/main/java/com/baeldung/openliberty/servlet/AppServlet.java b/open-liberty/src/main/java/com/baeldung/openliberty/servlet/AppServlet.java new file mode 100644 index 0000000000..d8c8d159c4 --- /dev/null +++ b/open-liberty/src/main/java/com/baeldung/openliberty/servlet/AppServlet.java @@ -0,0 +1,27 @@ +package com.baeldung.openliberty.servlet; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@WebServlet(urlPatterns="/app") +public class AppServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String htmlOutput = "

Hello! Welcome to Open Liberty

"; + response.getWriter().append(htmlOutput); + } + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } +} \ No newline at end of file diff --git a/open-liberty/src/main/liberty/config/server.xml b/open-liberty/src/main/liberty/config/server.xml new file mode 100644 index 0000000000..bc99905058 --- /dev/null +++ b/open-liberty/src/main/liberty/config/server.xml @@ -0,0 +1,28 @@ + + + mpHealth-2.0 + servlet-4.0 + jaxrs-2.1 + jsonp-1.1 + jsonb-1.0 + cdi-2.0 + jpa-2.2 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/open-liberty/src/main/resources/META-INF/persistence.xml b/open-liberty/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..ca8ad1a5c9 --- /dev/null +++ b/open-liberty/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,14 @@ + + + + jdbc/jpadatasource + + + + + + \ No newline at end of file diff --git a/open-liberty/src/test/java/com/baeldung/openliberty/RestClientTest.java b/open-liberty/src/test/java/com/baeldung/openliberty/RestClientTest.java new file mode 100644 index 0000000000..4978483ca0 --- /dev/null +++ b/open-liberty/src/test/java/com/baeldung/openliberty/RestClientTest.java @@ -0,0 +1,40 @@ +package com.baeldung.openliberty; + +import static org.junit.Assert.assertEquals; + +import javax.json.bind.JsonbBuilder; + +import org.junit.BeforeClass; +import org.junit.Test; + +import com.baeldung.openliberty.person.model.Person; +import com.baeldung.openliberty.rest.consumes.RestConsumer; + +public class RestClientTest { + + private static String BASE_URL; + + private final String API_PERSON = "api/persons"; + + @BeforeClass + public static void oneTimeSetup() { + BASE_URL = "http://localhost:9080/"; + } + + @Test + public void testSuite() { + //run the test only when liberty server is started + //this.whenConsumeWithJsonb_thenGetPerson(); + } + + public void whenConsumeWithJsonb_thenGetPerson() { + String url = BASE_URL + API_PERSON + "/1"; + String result = RestConsumer.consumeWithJsonb(url); + + Person person = JsonbBuilder.create().fromJson(result, Person.class); + assertEquals(1, person.getId()); + assertEquals("normanlewis", person.getUsername()); + assertEquals("normanlewis@email.com", person.getEmail()); + } + +} diff --git a/osgi/pom.xml b/osgi/pom.xml index ed708e8004..afc980c8bd 100644 --- a/osgi/pom.xml +++ b/osgi/pom.xml @@ -11,7 +11,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - .. diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index 881a0f1d67..43911a26ad 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -79,7 +79,7 @@ 3.3.0 1.0.22.RELEASE - 2.1.9.RELEASE + 2.2.2.RELEASE diff --git a/parent-java/pom.xml b/parent-java/pom.xml index 47965fc36d..e4ec2255c6 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -27,11 +27,22 @@ commons-io ${commons.io.version} + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + 23.0 2.6 + 1.19 diff --git a/parent-kotlin/pom.xml b/parent-kotlin/pom.xml index a180343378..abc871ca91 100644 --- a/parent-kotlin/pom.xml +++ b/parent-kotlin/pom.xml @@ -16,7 +16,7 @@ jcenter - http://jcenter.bintray.com + https://jcenter.bintray.com kotlin-ktor @@ -45,7 +45,7 @@ org.springframework.boot spring-boot-dependencies - 2.2.0.M4 + ${boot.dependencies.version} pom import @@ -215,6 +215,7 @@ 0.9.5 3.12.0 1.3.2 + 2.2.0.M4 diff --git a/parent-spring-5/pom.xml b/parent-spring-5/pom.xml index 9260f88de5..85a4645aa7 100644 --- a/parent-spring-5/pom.xml +++ b/parent-spring-5/pom.xml @@ -30,8 +30,8 @@ - 5.1.9.RELEASE - 5.1.6.RELEASE + 5.2.2.RELEASE + 5.2.1.RELEASE \ No newline at end of file diff --git a/patterns/design-patterns-architectural/pom.xml b/patterns/design-patterns-architectural/pom.xml index 81cc55aa21..d1945a1d0a 100644 --- a/patterns/design-patterns-architectural/pom.xml +++ b/patterns/design-patterns-architectural/pom.xml @@ -11,7 +11,6 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. @@ -22,11 +21,6 @@ test - - javax - javaee-api - ${javaee.version} - org.hibernate hibernate-core @@ -41,11 +35,7 @@ - UTF-8 - 1.8 - 1.8 3.9.1 - 8.0 5.2.16.Final 6.0.6 diff --git a/patterns/design-patterns-behavioral-2/pom.xml b/patterns/design-patterns-behavioral-2/pom.xml index 4cbe6e32b9..3a6d21353e 100644 --- a/patterns/design-patterns-behavioral-2/pom.xml +++ b/patterns/design-patterns-behavioral-2/pom.xml @@ -11,7 +11,6 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. @@ -24,9 +23,6 @@ - UTF-8 - 1.8 - 1.8 3.12.2 diff --git a/patterns/design-patterns-behavioral/pom.xml b/patterns/design-patterns-behavioral/pom.xml index c4ae00435e..aceaabf582 100644 --- a/patterns/design-patterns-behavioral/pom.xml +++ b/patterns/design-patterns-behavioral/pom.xml @@ -11,7 +11,6 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. @@ -41,9 +40,6 @@ - UTF-8 - 1.8 - 1.8 16.0.2 3.9.1 diff --git a/patterns/design-patterns-cloud/pom.xml b/patterns/design-patterns-cloud/pom.xml index 51f6a42f76..34defb7eac 100644 --- a/patterns/design-patterns-cloud/pom.xml +++ b/patterns/design-patterns-cloud/pom.xml @@ -9,47 +9,4 @@ design-patterns-cloud pom - - - junit - junit - ${junit.version} - test - - - org.mockito - mockito-core - ${mockito-core.version} - test - - - io.github.resilience4j - resilience4j-retry - ${resilience4j.version} - test - - - org.slf4j - slf4j-api - ${slf4j.version} - test - - - org.slf4j - slf4j-simple - ${slf4j.version} - test - - - - - UTF-8 - 1.8 - 1.8 - 4.12 - 2.27.0 - 1.7.26 - 0.16.0 - - diff --git a/patterns/design-patterns-creational/pom.xml b/patterns/design-patterns-creational/pom.xml index aa20c1c085..7c2742ade4 100644 --- a/patterns/design-patterns-creational/pom.xml +++ b/patterns/design-patterns-creational/pom.xml @@ -11,7 +11,6 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. @@ -36,10 +35,6 @@ - UTF-8 - 1.8 - 1.8 - 2.4.1 3.0.2 3.9.1 diff --git a/patterns/design-patterns-functional/pom.xml b/patterns/design-patterns-functional/pom.xml index ec37ad1e8d..e5166dc61e 100644 --- a/patterns/design-patterns-functional/pom.xml +++ b/patterns/design-patterns-functional/pom.xml @@ -11,13 +11,6 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. - - UTF-8 - 1.8 - 1.8 - - diff --git a/patterns/design-patterns-structural/pom.xml b/patterns/design-patterns-structural/pom.xml index 97e0b9b38b..c37b6845be 100644 --- a/patterns/design-patterns-structural/pom.xml +++ b/patterns/design-patterns-structural/pom.xml @@ -11,7 +11,6 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. @@ -22,10 +21,4 @@ - - UTF-8 - 1.8 - 1.8 - - diff --git a/patterns/dip/pom.xml b/patterns/dip/pom.xml index 37c980f2e3..7217c4fdcc 100644 --- a/patterns/dip/pom.xml +++ b/patterns/dip/pom.xml @@ -12,16 +12,9 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. - - junit - junit - ${junit.version} - test - org.assertj assertj-core @@ -31,9 +24,6 @@ - UTF-8 - 11 - 11 3.12.1 diff --git a/patterns/front-controller/pom.xml b/patterns/front-controller/pom.xml index 1de3b82fcd..dc10250946 100644 --- a/patterns/front-controller/pom.xml +++ b/patterns/front-controller/pom.xml @@ -10,7 +10,6 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. diff --git a/patterns/intercepting-filter/pom.xml b/patterns/intercepting-filter/pom.xml index 435c1e13cf..7f2f57b5e1 100644 --- a/patterns/intercepting-filter/pom.xml +++ b/patterns/intercepting-filter/pom.xml @@ -10,7 +10,6 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. @@ -27,15 +26,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${java.version} - ${java.version} - - org.apache.maven.plugins maven-war-plugin diff --git a/patterns/pom.xml b/patterns/pom.xml index 8a510769a9..4c17055231 100644 --- a/patterns/pom.xml +++ b/patterns/pom.xml @@ -10,21 +10,20 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - .. - front-controller - intercepting-filter design-patterns-architectural design-patterns-behavioral design-patterns-behavioral-2 + design-patterns-cloud design-patterns-creational design-patterns-functional design-patterns-structural - solid dip - design-patterns-cloud + front-controller + intercepting-filter + solid diff --git a/patterns/solid/pom.xml b/patterns/solid/pom.xml index 1b0e35339d..ad76ea89fd 100644 --- a/patterns/solid/pom.xml +++ b/patterns/solid/pom.xml @@ -11,7 +11,6 @@ com.baeldung patterns 1.0.0-SNAPSHOT - .. diff --git a/performance-tests/pom.xml b/performance-tests/pom.xml index 94588c99d4..c8cebd8a11 100644 --- a/performance-tests/pom.xml +++ b/performance-tests/pom.xml @@ -38,7 +38,7 @@ org.mapstruct mapstruct-processor - 1.2.0.Final + ${mapstruct-jdk8.version} provided @@ -93,6 +93,15 @@ Name of the benchmark Uber-JAR to generate. --> benchmarks + 3.1 + 2.2 + 2.5.1 + 2.4 + 2.9.1 + 2.6 + 3.3 + 2.2.1 + 2.17 @@ -100,7 +109,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 + ${compiler.plugin.version} ${javac.target} ${javac.target} @@ -117,7 +126,7 @@ org.apache.maven.plugins maven-shade-plugin - 2.2 + ${shade.plugin.version} package @@ -162,31 +171,31 @@ maven-install-plugin - 2.5.1 + ${install.version} maven-jar-plugin - 2.4 + ${jar.plugin.version} maven-javadoc-plugin - 2.9.1 + ${javadoc.plugin.version} maven-resources-plugin - 2.6 + ${resources.plugin.version} maven-site-plugin - 3.3 + ${site.plugin.version} maven-source-plugin - 2.2.1 + ${source.plugin.version} maven-surefire-plugin - 2.17 + ${surefire.plugin.version} diff --git a/performance-tests/src/main/java/com/baeldung/performancetests/MappingFrameworksPerformance.java b/performance-tests/src/main/java/com/baeldung/performancetests/MappingFrameworksPerformance.java index 1c9e4c5dc4..66251eb078 100644 --- a/performance-tests/src/main/java/com/baeldung/performancetests/MappingFrameworksPerformance.java +++ b/performance-tests/src/main/java/com/baeldung/performancetests/MappingFrameworksPerformance.java @@ -1,4 +1,4 @@ -package com.baeldung.performancetests.benchmark; +package com.baeldung.performancetests; import com.baeldung.performancetests.dozer.DozerConverter; import com.baeldung.performancetests.jmapper.JMapperConverter; diff --git a/persistence-modules/activejdbc/pom.xml b/persistence-modules/activejdbc/pom.xml index 47643cd639..84ce1c2b48 100644 --- a/persistence-modules/activejdbc/pom.xml +++ b/persistence-modules/activejdbc/pom.xml @@ -10,9 +10,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -41,16 +40,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${java.version} - ${java.version} - UTF-8 - - org.javalite activejdbc-instrumentation diff --git a/persistence-modules/apache-cayenne/pom.xml b/persistence-modules/apache-cayenne/pom.xml index 7c94c5ba39..d728e18b33 100644 --- a/persistence-modules/apache-cayenne/pom.xml +++ b/persistence-modules/apache-cayenne/pom.xml @@ -10,9 +10,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/core-java-persistence/pom.xml b/persistence-modules/core-java-persistence/pom.xml index 80c4053743..1224523ac7 100644 --- a/persistence-modules/core-java-persistence/pom.xml +++ b/persistence-modules/core-java-persistence/pom.xml @@ -10,9 +10,8 @@ com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java + persistence-modules + 1.0.0-SNAPSHOT @@ -60,19 +59,8 @@ - - core-java-persistence - - - src/main/resources - true - - - - 42.2.5.jre7 - 8.0.15 3.10.0 2.4.0 3.2.0 diff --git a/persistence-modules/deltaspike/pom.xml b/persistence-modules/deltaspike/pom.xml index 141412654f..871bacd18b 100644 --- a/persistence-modules/deltaspike/pom.xml +++ b/persistence-modules/deltaspike/pom.xml @@ -11,9 +11,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/elasticsearch/pom.xml b/persistence-modules/elasticsearch/pom.xml index 878dd5847b..654d43d622 100644 --- a/persistence-modules/elasticsearch/pom.xml +++ b/persistence-modules/elasticsearch/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/hbase/pom.xml b/persistence-modules/hbase/pom.xml index 9403239fb2..f54f2d8985 100644 --- a/persistence-modules/hbase/pom.xml +++ b/persistence-modules/hbase/pom.xml @@ -7,9 +7,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/hibernate-mapping/pom.xml b/persistence-modules/hibernate-mapping/pom.xml index a0a2a047e3..ac7952fa2b 100644 --- a/persistence-modules/hibernate-mapping/pom.xml +++ b/persistence-modules/hibernate-mapping/pom.xml @@ -4,14 +4,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 hibernate-mapping - 1.0.0-SNAPSHOT hibernate-mapping com.baeldung persistence-modules 1.0.0-SNAPSHOT - .. @@ -55,21 +53,11 @@ - - hibernate-mapping - - - src/main/resources - true - - - - 5.3.10.Final 3.8.0 6.0.16.Final - 3.0.1-b11 + 3.0.1-b11 1.0.3 1.3 diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Customer.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Customer.java index 5997602205..5589601da8 100644 --- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Customer.java +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Customer.java @@ -1,4 +1,4 @@ -package com.baeldung.fetchMode; +package com.baeldung.hibernate.fetchMode; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Order.java index c031972830..aa9c517321 100644 --- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Order.java +++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Order.java @@ -1,4 +1,4 @@ -package com.baeldung.fetchMode; +package com.baeldung.hibernate.fetchMode; import javax.persistence.*; diff --git a/persistence-modules/hibernate-ogm/pom.xml b/persistence-modules/hibernate-ogm/pom.xml index bb15881788..8f42c28eee 100644 --- a/persistence-modules/hibernate-ogm/pom.xml +++ b/persistence-modules/hibernate-ogm/pom.xml @@ -8,9 +8,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -33,12 +32,6 @@ ${narayana-jta.version} - - junit - junit - ${junit.version} - test - org.easytesting fest-assert @@ -47,16 +40,6 @@ - - hibernate-ogm - - - src/main/resources - true - - - - 5.4.0.Final 1.4 diff --git a/persistence-modules/hibernate5-2/README.md b/persistence-modules/hibernate5-2/README.md index 0b6be27410..d409f99a3a 100644 --- a/persistence-modules/hibernate5-2/README.md +++ b/persistence-modules/hibernate5-2/README.md @@ -5,4 +5,6 @@ This module contains articles about Hibernate 5. ### Relevant Articles: - [Hibernate Error “Not all named parameters have been set”](https://www.baeldung.com/hibernate-error-named-parameters-not-set) - [FetchMode in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-fetchmode) -- [[<-- Prev]](/hibernate5) \ No newline at end of file +- [JPA/Hibernate Persistence Context](https://www.baeldung.com/jpa-hibernate-persistence-context) +- [FetchMode in Hibernate](https://www.baeldung.com/hibernate-fetchmode) +- [[<-- Prev]](/hibernate5) diff --git a/persistence-modules/hibernate5-2/pom.xml b/persistence-modules/hibernate5-2/pom.xml index dfee4bb81e..15d42b3244 100644 --- a/persistence-modules/hibernate5-2/pom.xml +++ b/persistence-modules/hibernate5-2/pom.xml @@ -10,16 +10,15 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ org.hibernate hibernate-core - 5.4.7.Final + ${hibernate-core.version} org.springframework.boot @@ -51,19 +50,25 @@ com.h2database h2 - 1.4.200 + ${h2.version} org.apache.commons commons-lang3 - 3.8.1 + ${commons.lang3.version} + 5.4.7.Final + 1.4.200 + 3.8.1 true 2.1.7.RELEASE + 5.4.7.Final + 1.4.200 + 3.8.1 diff --git a/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernatelogging/HibernateLoggingIntegrationTest.java b/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernate/logging/HibernateLoggingIntegrationTest.java similarity index 97% rename from persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernatelogging/HibernateLoggingIntegrationTest.java rename to persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernate/logging/HibernateLoggingIntegrationTest.java index 8ec722671d..f609c75834 100644 --- a/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernatelogging/HibernateLoggingIntegrationTest.java +++ b/persistence-modules/hibernate5-2/src/test/java/com/baeldung/hibernate/logging/HibernateLoggingIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.hibernatelogging; +package com.baeldung.hibernate.logging; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; diff --git a/persistence-modules/hibernate5/pom.xml b/persistence-modules/hibernate5/pom.xml index ec06136f9c..ffeff5ee4a 100644 --- a/persistence-modules/hibernate5/pom.xml +++ b/persistence-modules/hibernate5/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -41,11 +40,6 @@ geodb ${geodb.version} - - org.hibernate - hibernate-c3p0 - ${hibernate.version} - mysql mysql-connector-java @@ -66,44 +60,14 @@ jackson-databind ${jackson.version} - - net.bytebuddy - byte-buddy - ${byte-buddy.version} - - - org.hibernate - hibernate-jpamodelgen - ${hibernate.version} - - - org.openjdk.jmh - jmh-core - ${openjdk-jmh.version} - org.openjdk.jmh jmh-generator-annprocess ${openjdk-jmh.version} - - javax.xml.bind - jaxb-api - ${jaxb-api.version} - - - hibernate5 - - - src/test/resources - true - - - - geodb-repo @@ -119,8 +83,6 @@ 3.8.0 1.21 0.9 - 1.9.5 - 2.3.0 diff --git a/persistence-modules/influxdb/pom.xml b/persistence-modules/influxdb/pom.xml index 7531ad8217..23ae64dca1 100644 --- a/persistence-modules/influxdb/pom.xml +++ b/persistence-modules/influxdb/pom.xml @@ -10,9 +10,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/java-cassandra/pom.xml b/persistence-modules/java-cassandra/pom.xml index 6628a393fa..54879fb321 100644 --- a/persistence-modules/java-cassandra/pom.xml +++ b/persistence-modules/java-cassandra/pom.xml @@ -3,14 +3,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 java-cassandra - 1.0.0-SNAPSHOT java-cassandra com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java + persistence-modules + 1.0.0-SNAPSHOT @@ -40,26 +38,13 @@ java-driver-query-builder ${datastax-cassandra.version} - - - io.netty - netty-handler - ${io-netty.version} - - - - java-cassandra - - 3.1.2 3.1.1.0 4.1.0 - 4.1.34.Final - 18.0 diff --git a/persistence-modules/java-cockroachdb/pom.xml b/persistence-modules/java-cockroachdb/pom.xml index 750cbfce4c..e8c6365ca3 100644 --- a/persistence-modules/java-cockroachdb/pom.xml +++ b/persistence-modules/java-cockroachdb/pom.xml @@ -8,9 +8,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/java-jdbi/pom.xml b/persistence-modules/java-jdbi/pom.xml index 0d978dc164..eb0de45593 100644 --- a/persistence-modules/java-jdbi/pom.xml +++ b/persistence-modules/java-jdbi/pom.xml @@ -8,9 +8,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/java-jpa-2/pom.xml b/persistence-modules/java-jpa-2/pom.xml index cc9e69fcaa..f79f6f1633 100644 --- a/persistence-modules/java-jpa-2/pom.xml +++ b/persistence-modules/java-jpa-2/pom.xml @@ -7,9 +7,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../pom.xml @@ -63,7 +62,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + ${maven-compiler-plugin.version} -proc:none @@ -71,7 +70,7 @@ org.bsc.maven maven-processor-plugin - 3.3.3 + ${maven-processor-plugin.version} process @@ -91,7 +90,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.0.0 + ${build-helper-maven-plugin.version} add-source @@ -116,6 +115,9 @@ 42.2.5 2.2 3.11.1 + 3.5.1 + 3.3.3 + 3.0.0 \ No newline at end of file diff --git a/persistence-modules/java-jpa/pom.xml b/persistence-modules/java-jpa/pom.xml index a979cf7e65..762c541d96 100644 --- a/persistence-modules/java-jpa/pom.xml +++ b/persistence-modules/java-jpa/pom.xml @@ -8,9 +8,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../pom.xml diff --git a/persistence-modules/java-mongodb/pom.xml b/persistence-modules/java-mongodb/pom.xml index 1e59bd9064..d62240927a 100644 --- a/persistence-modules/java-mongodb/pom.xml +++ b/persistence-modules/java-mongodb/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -35,8 +34,6 @@ - 1.8 - 1.8 3.10.1 1.11 1.5.3 diff --git a/persistence-modules/java-mongodb/src/test/java/com/baeldung/aggregation/AggregationLiveTest.java b/persistence-modules/java-mongodb/src/test/java/com/baeldung/aggregation/AggregationLiveTest.java new file mode 100644 index 0000000000..b3f01be566 --- /dev/null +++ b/persistence-modules/java-mongodb/src/test/java/com/baeldung/aggregation/AggregationLiveTest.java @@ -0,0 +1,111 @@ +package com.baeldung.aggregation; + +import static com.mongodb.client.model.Aggregates.count; +import static com.mongodb.client.model.Aggregates.group; +import static com.mongodb.client.model.Aggregates.limit; +import static com.mongodb.client.model.Aggregates.match; +import static com.mongodb.client.model.Aggregates.out; +import static com.mongodb.client.model.Aggregates.project; +import static com.mongodb.client.model.Aggregates.sort; +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Arrays; + +import org.bson.Document; +import org.bson.conversions.Bson; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.MongoDatabase; +import com.mongodb.client.model.Accumulators; +import com.mongodb.client.model.Filters; +import com.mongodb.client.model.Projections; +import com.mongodb.client.model.Sorts; + +public class AggregationLiveTest { + + private static final String DATABASE = "world"; + private static final String COLLECTION = "countries"; + private static final String DATASET_JSON = "/countrydata.json"; + private static MongoClient mongoClient; + private static MongoDatabase database; + private static MongoCollection collection; + + @BeforeClass + public static void setUpDB() throws IOException { + mongoClient = MongoClients.create(); + database = mongoClient.getDatabase(DATABASE); + collection = database.getCollection(COLLECTION); + + collection.drop(); + + InputStream is = AggregationLiveTest.class.getResourceAsStream(DATASET_JSON); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + reader.lines() + .forEach(line -> collection.insertOne(Document.parse(line))); + reader.close(); + } + + @Test + public void givenCountryCollection_whenNAFTACountriesCounted_thenThree() { + Document naftaCountries = collection.aggregate(Arrays.asList(match(Filters.eq("regionalBlocs.acronym", "NAFTA")), count())) + .first(); + + assertEquals(3, naftaCountries.get("count")); + } + + @Test + public void givenCountryCollection_whenAreaSortedDescending_thenSuccess() { + + collection.aggregate(Arrays.asList(sort(Sorts.descending("area")), limit(7), out("largest_seven"))) + .toCollection(); + + MongoCollection largestSeven = database.getCollection("largest_seven"); + + assertEquals(7, largestSeven.countDocuments()); + + Document usa = largestSeven.find(Filters.eq("alpha3Code", "USA")) + .first(); + + assertNotNull(usa); + } + + @Test + public void givenCountryCollection_whenCountedRegionWise_thenMaxInAfrica() { + Document maxCountriedRegion = collection.aggregate(Arrays.asList(group("$region", Accumulators.sum("tally", 1)), sort(Sorts.descending("tally")))) + .first(); + assertTrue(maxCountriedRegion.containsValue("Africa")); + } + + @Test + public void givenCountryCollection_whenNeighborsCalculated_thenMaxIsFifteenInChina() { + Bson borderingCountriesCollection = project(Projections.fields(Projections.excludeId(), Projections.include("name"), Projections.computed("borderingCountries", Projections.computed("$size", "$borders")))); + + int maxValue = collection.aggregate(Arrays.asList(borderingCountriesCollection, group(null, Accumulators.max("max", "$borderingCountries")))) + .first() + .getInteger("max"); + + assertEquals(15, maxValue); + + Document maxNeighboredCountry = collection.aggregate(Arrays.asList(borderingCountriesCollection, match(Filters.eq("borderingCountries", maxValue)))) + .first(); + assertTrue(maxNeighboredCountry.containsValue("China")); + + } + + @AfterClass + public static void cleanUp() { + mongoClient.close(); + } + +} diff --git a/persistence-modules/java-mongodb/src/test/resources/countrydata.json b/persistence-modules/java-mongodb/src/test/resources/countrydata.json new file mode 100644 index 0000000000..81213c31e7 --- /dev/null +++ b/persistence-modules/java-mongodb/src/test/resources/countrydata.json @@ -0,0 +1,250 @@ +{"name":"Afghanistan","topLevelDomain":[".af"],"alpha2Code":"AF","alpha3Code":"AFG","callingCodes":["93"],"capital":"Kabul","altSpellings":["AF","Afġānistān"],"region":"Asia","subregion":"Southern Asia","population":27657145,"latlng":[33.0,65.0],"demonym":"Afghan","area":652230.0,"gini":27.8,"timezones":["UTC+04:30"],"borders":["IRN","PAK","TKM","UZB","TJK","CHN"],"nativeName":"افغانستان","numericCode":"004","currencies":[{"code":"AFN","name":"Afghan afghani","symbol":"؋"}],"languages":[{"iso639_1":"ps","iso639_2":"pus","name":"Pashto","nativeName":"پښتو"},{"iso639_1":"uz","iso639_2":"uzb","name":"Uzbek","nativeName":"Oʻzbek"},{"iso639_1":"tk","iso639_2":"tuk","name":"Turkmen","nativeName":"Türkmen"}],"translations":{"de":"Afghanistan","es":"Afganistán","fr":"Afghanistan","ja":"アフガニスタン","it":"Afghanistan","br":"Afeganistão","pt":"Afeganistão","nl":"Afghanistan","hr":"Afganistan","fa":"افغانستان"},"flag":"https://restcountries.eu/data/afg.svg","regionalBlocs":[{"acronym":"SAARC","name":"South Asian Association for Regional Cooperation","otherAcronyms":[],"otherNames":[]}],"cioc":"AFG"} +{"name":"Åland Islands","topLevelDomain":[".ax"],"alpha2Code":"AX","alpha3Code":"ALA","callingCodes":["358"],"capital":"Mariehamn","altSpellings":["AX","Aaland","Aland","Ahvenanmaa"],"region":"Europe","subregion":"Northern Europe","population":28875,"latlng":[60.116667,19.9],"demonym":"Ålandish","area":1580.0,"gini":null,"timezones":["UTC+02:00"],"borders":[],"nativeName":"Åland","numericCode":"248","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"sv","iso639_2":"swe","name":"Swedish","nativeName":"svenska"}],"translations":{"de":"Åland","es":"Alandia","fr":"Åland","ja":"オーランド諸島","it":"Isole Aland","br":"Ilhas de Aland","pt":"Ilhas de Aland","nl":"Ålandeilanden","hr":"Ålandski otoci","fa":"جزایر الند"},"flag":"https://restcountries.eu/data/ala.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":""} +{"name":"Albania","topLevelDomain":[".al"],"alpha2Code":"AL","alpha3Code":"ALB","callingCodes":["355"],"capital":"Tirana","altSpellings":["AL","Shqipëri","Shqipëria","Shqipnia"],"region":"Europe","subregion":"Southern Europe","population":2886026,"latlng":[41.0,20.0],"demonym":"Albanian","area":28748.0,"gini":34.5,"timezones":["UTC+01:00"],"borders":["MNE","GRC","MKD","KOS"],"nativeName":"Shqipëria","numericCode":"008","currencies":[{"code":"ALL","name":"Albanian lek","symbol":"L"}],"languages":[{"iso639_1":"sq","iso639_2":"sqi","name":"Albanian","nativeName":"Shqip"}],"translations":{"de":"Albanien","es":"Albania","fr":"Albanie","ja":"アルバニア","it":"Albania","br":"Albânia","pt":"Albânia","nl":"Albanië","hr":"Albanija","fa":"آلبانی"},"flag":"https://restcountries.eu/data/alb.svg","regionalBlocs":[{"acronym":"CEFTA","name":"Central European Free Trade Agreement","otherAcronyms":[],"otherNames":[]}],"cioc":"ALB"} +{"name":"Algeria","topLevelDomain":[".dz"],"alpha2Code":"DZ","alpha3Code":"DZA","callingCodes":["213"],"capital":"Algiers","altSpellings":["DZ","Dzayer","Algérie"],"region":"Africa","subregion":"Northern Africa","population":40400000,"latlng":[28.0,3.0],"demonym":"Algerian","area":2381741.0,"gini":35.3,"timezones":["UTC+01:00"],"borders":["TUN","LBY","NER","ESH","MRT","MLI","MAR"],"nativeName":"الجزائر","numericCode":"012","currencies":[{"code":"DZD","name":"Algerian dinar","symbol":"د.ج"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Algerien","es":"Argelia","fr":"Algérie","ja":"アルジェリア","it":"Algeria","br":"Argélia","pt":"Argélia","nl":"Algerije","hr":"Alžir","fa":"الجزایر"},"flag":"https://restcountries.eu/data/dza.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"ALG"} +{"name":"American Samoa","topLevelDomain":[".as"],"alpha2Code":"AS","alpha3Code":"ASM","callingCodes":["1684"],"capital":"Pago Pago","altSpellings":["AS","Amerika Sāmoa","Amelika Sāmoa","Sāmoa Amelika"],"region":"Oceania","subregion":"Polynesia","population":57100,"latlng":[-14.33333333,-170.0],"demonym":"American Samoan","area":199.0,"gini":null,"timezones":["UTC-11:00"],"borders":[],"nativeName":"American Samoa","numericCode":"016","currencies":[{"code":"USD","name":"United State Dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"sm","iso639_2":"smo","name":"Samoan","nativeName":"gagana fa'a Samoa"}],"translations":{"de":"Amerikanisch-Samoa","es":"Samoa Americana","fr":"Samoa américaines","ja":"アメリカ領サモア","it":"Samoa Americane","br":"Samoa Americana","pt":"Samoa Americana","nl":"Amerikaans Samoa","hr":"Američka Samoa","fa":"ساموآی آمریکا"},"flag":"https://restcountries.eu/data/asm.svg","regionalBlocs":[],"cioc":"ASA"} +{"name":"Andorra","topLevelDomain":[".ad"],"alpha2Code":"AD","alpha3Code":"AND","callingCodes":["376"],"capital":"Andorra la Vella","altSpellings":["AD","Principality of Andorra","Principat d'Andorra"],"region":"Europe","subregion":"Southern Europe","population":78014,"latlng":[42.5,1.5],"demonym":"Andorran","area":468.0,"gini":null,"timezones":["UTC+01:00"],"borders":["FRA","ESP"],"nativeName":"Andorra","numericCode":"020","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"ca","iso639_2":"cat","name":"Catalan","nativeName":"català"}],"translations":{"de":"Andorra","es":"Andorra","fr":"Andorre","ja":"アンドラ","it":"Andorra","br":"Andorra","pt":"Andorra","nl":"Andorra","hr":"Andora","fa":"آندورا"},"flag":"https://restcountries.eu/data/and.svg","regionalBlocs":[],"cioc":"AND"} +{"name":"Angola","topLevelDomain":[".ao"],"alpha2Code":"AO","alpha3Code":"AGO","callingCodes":["244"],"capital":"Luanda","altSpellings":["AO","República de Angola","ʁɛpublika de an'ɡɔla"],"region":"Africa","subregion":"Middle Africa","population":25868000,"latlng":[-12.5,18.5],"demonym":"Angolan","area":1246700.0,"gini":58.6,"timezones":["UTC+01:00"],"borders":["COG","COD","ZMB","NAM"],"nativeName":"Angola","numericCode":"024","currencies":[{"code":"AOA","name":"Angolan kwanza","symbol":"Kz"}],"languages":[{"iso639_1":"pt","iso639_2":"por","name":"Portuguese","nativeName":"Português"}],"translations":{"de":"Angola","es":"Angola","fr":"Angola","ja":"アンゴラ","it":"Angola","br":"Angola","pt":"Angola","nl":"Angola","hr":"Angola","fa":"آنگولا"},"flag":"https://restcountries.eu/data/ago.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"ANG"} +{"name":"Anguilla","topLevelDomain":[".ai"],"alpha2Code":"AI","alpha3Code":"AIA","callingCodes":["1264"],"capital":"The Valley","altSpellings":["AI"],"region":"Americas","subregion":"Caribbean","population":13452,"latlng":[18.25,-63.16666666],"demonym":"Anguillian","area":91.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Anguilla","numericCode":"660","currencies":[{"code":"XCD","name":"East Caribbean dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Anguilla","es":"Anguilla","fr":"Anguilla","ja":"アンギラ","it":"Anguilla","br":"Anguila","pt":"Anguila","nl":"Anguilla","hr":"Angvila","fa":"آنگویلا"},"flag":"https://restcountries.eu/data/aia.svg","regionalBlocs":[],"cioc":""} +{"name":"Antarctica","topLevelDomain":[".aq"],"alpha2Code":"AQ","alpha3Code":"ATA","callingCodes":["672"],"capital":"","altSpellings":[],"region":"Polar","subregion":"","population":1000,"latlng":[-74.65,4.48],"demonym":"","area":1.4E7,"gini":null,"timezones":["UTC-03:00","UTC+03:00","UTC+05:00","UTC+06:00","UTC+07:00","UTC+08:00","UTC+10:00","UTC+12:00"],"borders":[],"nativeName":"Antarctica","numericCode":"010","currencies":[{"code":"AUD","name":"Australian dollar","symbol":"$"},{"code":"GBP","name":"British pound","symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"ru","iso639_2":"rus","name":"Russian","nativeName":"Русский"}],"translations":{"de":"Antarktika","es":"Antártida","fr":"Antarctique","ja":"南極大陸","it":"Antartide","br":"Antártida","pt":"Antárctida","nl":"Antarctica","hr":"Antarktika","fa":"جنوبگان"},"flag":"https://restcountries.eu/data/ata.svg","regionalBlocs":[],"cioc":""} +{"name":"Antigua and Barbuda","topLevelDomain":[".ag"],"alpha2Code":"AG","alpha3Code":"ATG","callingCodes":["1268"],"capital":"Saint John's","altSpellings":["AG"],"region":"Americas","subregion":"Caribbean","population":86295,"latlng":[17.05,-61.8],"demonym":"Antiguan, Barbudan","area":442.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Antigua and Barbuda","numericCode":"028","currencies":[{"code":"XCD","name":"East Caribbean dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Antigua und Barbuda","es":"Antigua y Barbuda","fr":"Antigua-et-Barbuda","ja":"アンティグア・バーブーダ","it":"Antigua e Barbuda","br":"Antígua e Barbuda","pt":"Antígua e Barbuda","nl":"Antigua en Barbuda","hr":"Antigva i Barbuda","fa":"آنتیگوا و باربودا"},"flag":"https://restcountries.eu/data/atg.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"ANT"} +{"name":"Argentina","topLevelDomain":[".ar"],"alpha2Code":"AR","alpha3Code":"ARG","callingCodes":["54"],"capital":"Buenos Aires","altSpellings":["AR","Argentine Republic","República Argentina"],"region":"Americas","subregion":"South America","population":43590400,"latlng":[-34.0,-64.0],"demonym":"Argentinean","area":2780400.0,"gini":44.5,"timezones":["UTC-03:00"],"borders":["BOL","BRA","CHL","PRY","URY"],"nativeName":"Argentina","numericCode":"032","currencies":[{"code":"ARS","name":"Argentine peso","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"},{"iso639_1":"gn","iso639_2":"grn","name":"Guaraní","nativeName":"Avañe'ẽ"}],"translations":{"de":"Argentinien","es":"Argentina","fr":"Argentine","ja":"アルゼンチン","it":"Argentina","br":"Argentina","pt":"Argentina","nl":"Argentinië","hr":"Argentina","fa":"آرژانتین"},"flag":"https://restcountries.eu/data/arg.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"ARG"} +{"name":"Armenia","topLevelDomain":[".am"],"alpha2Code":"AM","alpha3Code":"ARM","callingCodes":["374"],"capital":"Yerevan","altSpellings":["AM","Hayastan","Republic of Armenia","Հայաստանի Հանրապետություն"],"region":"Asia","subregion":"Western Asia","population":2994400,"latlng":[40.0,45.0],"demonym":"Armenian","area":29743.0,"gini":30.9,"timezones":["UTC+04:00"],"borders":["AZE","GEO","IRN","TUR"],"nativeName":"Հայաստան","numericCode":"051","currencies":[{"code":"AMD","name":"Armenian dram","symbol":null}],"languages":[{"iso639_1":"hy","iso639_2":"hye","name":"Armenian","nativeName":"Հայերեն"},{"iso639_1":"ru","iso639_2":"rus","name":"Russian","nativeName":"Русский"}],"translations":{"de":"Armenien","es":"Armenia","fr":"Arménie","ja":"アルメニア","it":"Armenia","br":"Armênia","pt":"Arménia","nl":"Armenië","hr":"Armenija","fa":"ارمنستان"},"flag":"https://restcountries.eu/data/arm.svg","regionalBlocs":[{"acronym":"EEU","name":"Eurasian Economic Union","otherAcronyms":["EAEU"],"otherNames":[]}],"cioc":"ARM"} +{"name":"Aruba","topLevelDomain":[".aw"],"alpha2Code":"AW","alpha3Code":"ABW","callingCodes":["297"],"capital":"Oranjestad","altSpellings":["AW"],"region":"Americas","subregion":"Caribbean","population":107394,"latlng":[12.5,-69.96666666],"demonym":"Aruban","area":180.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Aruba","numericCode":"533","currencies":[{"code":"AWG","name":"Aruban florin","symbol":"ƒ"}],"languages":[{"iso639_1":"nl","iso639_2":"nld","name":"Dutch","nativeName":"Nederlands"},{"iso639_1":"pa","iso639_2":"pan","name":"(Eastern) Punjabi","nativeName":"ਪੰਜਾਬੀ"}],"translations":{"de":"Aruba","es":"Aruba","fr":"Aruba","ja":"アルバ","it":"Aruba","br":"Aruba","pt":"Aruba","nl":"Aruba","hr":"Aruba","fa":"آروبا"},"flag":"https://restcountries.eu/data/abw.svg","regionalBlocs":[],"cioc":"ARU"} +{"name":"Australia","topLevelDomain":[".au"],"alpha2Code":"AU","alpha3Code":"AUS","callingCodes":["61"],"capital":"Canberra","altSpellings":["AU"],"region":"Oceania","subregion":"Australia and New Zealand","population":24117360,"latlng":[-27.0,133.0],"demonym":"Australian","area":7692024.0,"gini":30.5,"timezones":["UTC+05:00","UTC+06:30","UTC+07:00","UTC+08:00","UTC+09:30","UTC+10:00","UTC+10:30","UTC+11:30"],"borders":[],"nativeName":"Australia","numericCode":"036","currencies":[{"code":"AUD","name":"Australian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Australien","es":"Australia","fr":"Australie","ja":"オーストラリア","it":"Australia","br":"Austrália","pt":"Austrália","nl":"Australië","hr":"Australija","fa":"استرالیا"},"flag":"https://restcountries.eu/data/aus.svg","regionalBlocs":[],"cioc":"AUS"} +{"name":"Austria","topLevelDomain":[".at"],"alpha2Code":"AT","alpha3Code":"AUT","callingCodes":["43"],"capital":"Vienna","altSpellings":["AT","Österreich","Osterreich","Oesterreich"],"region":"Europe","subregion":"Western Europe","population":8725931,"latlng":[47.33333333,13.33333333],"demonym":"Austrian","area":83871.0,"gini":26.0,"timezones":["UTC+01:00"],"borders":["CZE","DEU","HUN","ITA","LIE","SVK","SVN","CHE"],"nativeName":"Österreich","numericCode":"040","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"de","iso639_2":"deu","name":"German","nativeName":"Deutsch"}],"translations":{"de":"Österreich","es":"Austria","fr":"Autriche","ja":"オーストリア","it":"Austria","br":"áustria","pt":"áustria","nl":"Oostenrijk","hr":"Austrija","fa":"اتریش"},"flag":"https://restcountries.eu/data/aut.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"AUT"} +{"name":"Azerbaijan","topLevelDomain":[".az"],"alpha2Code":"AZ","alpha3Code":"AZE","callingCodes":["994"],"capital":"Baku","altSpellings":["AZ","Republic of Azerbaijan","Azərbaycan Respublikası"],"region":"Asia","subregion":"Western Asia","population":9730500,"latlng":[40.5,47.5],"demonym":"Azerbaijani","area":86600.0,"gini":33.7,"timezones":["UTC+04:00"],"borders":["ARM","GEO","IRN","RUS","TUR"],"nativeName":"Azərbaycan","numericCode":"031","currencies":[{"code":"AZN","name":"Azerbaijani manat","symbol":null}],"languages":[{"iso639_1":"az","iso639_2":"aze","name":"Azerbaijani","nativeName":"azərbaycan dili"}],"translations":{"de":"Aserbaidschan","es":"Azerbaiyán","fr":"Azerbaïdjan","ja":"アゼルバイジャン","it":"Azerbaijan","br":"Azerbaijão","pt":"Azerbaijão","nl":"Azerbeidzjan","hr":"Azerbajdžan","fa":"آذربایجان"},"flag":"https://restcountries.eu/data/aze.svg","regionalBlocs":[],"cioc":"AZE"} +{"name":"Bahamas","topLevelDomain":[".bs"],"alpha2Code":"BS","alpha3Code":"BHS","callingCodes":["1242"],"capital":"Nassau","altSpellings":["BS","Commonwealth of the Bahamas"],"region":"Americas","subregion":"Caribbean","population":378040,"latlng":[24.25,-76.0],"demonym":"Bahamian","area":13943.0,"gini":null,"timezones":["UTC-05:00"],"borders":[],"nativeName":"Bahamas","numericCode":"044","currencies":[{"code":"BSD","name":"Bahamian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Bahamas","es":"Bahamas","fr":"Bahamas","ja":"バハマ","it":"Bahamas","br":"Bahamas","pt":"Baamas","nl":"Bahama’s","hr":"Bahami","fa":"باهاما"},"flag":"https://restcountries.eu/data/bhs.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"BAH"} +{"name":"Bahrain","topLevelDomain":[".bh"],"alpha2Code":"BH","alpha3Code":"BHR","callingCodes":["973"],"capital":"Manama","altSpellings":["BH","Kingdom of Bahrain","Mamlakat al-Baḥrayn"],"region":"Asia","subregion":"Western Asia","population":1404900,"latlng":[26.0,50.55],"demonym":"Bahraini","area":765.0,"gini":null,"timezones":["UTC+03:00"],"borders":[],"nativeName":"‏البحرين","numericCode":"048","currencies":[{"code":"BHD","name":"Bahraini dinar","symbol":".د.ب"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Bahrain","es":"Bahrein","fr":"Bahreïn","ja":"バーレーン","it":"Bahrein","br":"Bahrein","pt":"Barém","nl":"Bahrein","hr":"Bahrein","fa":"بحرین"},"flag":"https://restcountries.eu/data/bhr.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"BRN"} +{"name":"Bangladesh","topLevelDomain":[".bd"],"alpha2Code":"BD","alpha3Code":"BGD","callingCodes":["880"],"capital":"Dhaka","altSpellings":["BD","People's Republic of Bangladesh","Gônôprôjatôntri Bangladesh"],"region":"Asia","subregion":"Southern Asia","population":161006790,"latlng":[24.0,90.0],"demonym":"Bangladeshi","area":147570.0,"gini":32.1,"timezones":["UTC+06:00"],"borders":["MMR","IND"],"nativeName":"Bangladesh","numericCode":"050","currencies":[{"code":"BDT","name":"Bangladeshi taka","symbol":"৳"}],"languages":[{"iso639_1":"bn","iso639_2":"ben","name":"Bengali","nativeName":"বাংলা"}],"translations":{"de":"Bangladesch","es":"Bangladesh","fr":"Bangladesh","ja":"バングラデシュ","it":"Bangladesh","br":"Bangladesh","pt":"Bangladeche","nl":"Bangladesh","hr":"Bangladeš","fa":"بنگلادش"},"flag":"https://restcountries.eu/data/bgd.svg","regionalBlocs":[{"acronym":"SAARC","name":"South Asian Association for Regional Cooperation","otherAcronyms":[],"otherNames":[]}],"cioc":"BAN"} +{"name":"Barbados","topLevelDomain":[".bb"],"alpha2Code":"BB","alpha3Code":"BRB","callingCodes":["1246"],"capital":"Bridgetown","altSpellings":["BB"],"region":"Americas","subregion":"Caribbean","population":285000,"latlng":[13.16666666,-59.53333333],"demonym":"Barbadian","area":430.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Barbados","numericCode":"052","currencies":[{"code":"BBD","name":"Barbadian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Barbados","es":"Barbados","fr":"Barbade","ja":"バルバドス","it":"Barbados","br":"Barbados","pt":"Barbados","nl":"Barbados","hr":"Barbados","fa":"باربادوس"},"flag":"https://restcountries.eu/data/brb.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"BAR"} +{"name":"Belarus","topLevelDomain":[".by"],"alpha2Code":"BY","alpha3Code":"BLR","callingCodes":["375"],"capital":"Minsk","altSpellings":["BY","Bielaruś","Republic of Belarus","Белоруссия","Республика Беларусь","Belorussiya","Respublika Belarus’"],"region":"Europe","subregion":"Eastern Europe","population":9498700,"latlng":[53.0,28.0],"demonym":"Belarusian","area":207600.0,"gini":26.5,"timezones":["UTC+03:00"],"borders":["LVA","LTU","POL","RUS","UKR"],"nativeName":"Белару́сь","numericCode":"112","currencies":[{"code":"BYN","name":"New Belarusian ruble","symbol":"Br"},{"code":"BYR","name":"Old Belarusian ruble","symbol":"Br"}],"languages":[{"iso639_1":"be","iso639_2":"bel","name":"Belarusian","nativeName":"беларуская мова"},{"iso639_1":"ru","iso639_2":"rus","name":"Russian","nativeName":"Русский"}],"translations":{"de":"Weißrussland","es":"Bielorrusia","fr":"Biélorussie","ja":"ベラルーシ","it":"Bielorussia","br":"Bielorrússia","pt":"Bielorrússia","nl":"Wit-Rusland","hr":"Bjelorusija","fa":"بلاروس"},"flag":"https://restcountries.eu/data/blr.svg","regionalBlocs":[{"acronym":"EEU","name":"Eurasian Economic Union","otherAcronyms":["EAEU"],"otherNames":[]}],"cioc":"BLR"} +{"name":"Belgium","topLevelDomain":[".be"],"alpha2Code":"BE","alpha3Code":"BEL","callingCodes":["32"],"capital":"Brussels","altSpellings":["BE","België","Belgie","Belgien","Belgique","Kingdom of Belgium","Koninkrijk België","Royaume de Belgique","Königreich Belgien"],"region":"Europe","subregion":"Western Europe","population":11319511,"latlng":[50.83333333,4.0],"demonym":"Belgian","area":30528.0,"gini":33.0,"timezones":["UTC+01:00"],"borders":["FRA","DEU","LUX","NLD"],"nativeName":"België","numericCode":"056","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"nl","iso639_2":"nld","name":"Dutch","nativeName":"Nederlands"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"de","iso639_2":"deu","name":"German","nativeName":"Deutsch"}],"translations":{"de":"Belgien","es":"Bélgica","fr":"Belgique","ja":"ベルギー","it":"Belgio","br":"Bélgica","pt":"Bélgica","nl":"België","hr":"Belgija","fa":"بلژیک"},"flag":"https://restcountries.eu/data/bel.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"BEL"} +{"name":"Belize","topLevelDomain":[".bz"],"alpha2Code":"BZ","alpha3Code":"BLZ","callingCodes":["501"],"capital":"Belmopan","altSpellings":["BZ"],"region":"Americas","subregion":"Central America","population":370300,"latlng":[17.25,-88.75],"demonym":"Belizean","area":22966.0,"gini":53.1,"timezones":["UTC-06:00"],"borders":["GTM","MEX"],"nativeName":"Belize","numericCode":"084","currencies":[{"code":"BZD","name":"Belize dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Belize","es":"Belice","fr":"Belize","ja":"ベリーズ","it":"Belize","br":"Belize","pt":"Belize","nl":"Belize","hr":"Belize","fa":"بلیز"},"flag":"https://restcountries.eu/data/blz.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]},{"acronym":"CAIS","name":"Central American Integration System","otherAcronyms":["SICA"],"otherNames":["Sistema de la Integración Centroamericana,"]}],"cioc":"BIZ"} +{"name":"Benin","topLevelDomain":[".bj"],"alpha2Code":"BJ","alpha3Code":"BEN","callingCodes":["229"],"capital":"Porto-Novo","altSpellings":["BJ","Republic of Benin","République du Bénin"],"region":"Africa","subregion":"Western Africa","population":10653654,"latlng":[9.5,2.25],"demonym":"Beninese","area":112622.0,"gini":38.6,"timezones":["UTC+01:00"],"borders":["BFA","NER","NGA","TGO"],"nativeName":"Bénin","numericCode":"204","currencies":[{"code":"XOF","name":"West African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Benin","es":"Benín","fr":"Bénin","ja":"ベナン","it":"Benin","br":"Benin","pt":"Benim","nl":"Benin","hr":"Benin","fa":"بنین"},"flag":"https://restcountries.eu/data/ben.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"BEN"} +{"name":"Bermuda","topLevelDomain":[".bm"],"alpha2Code":"BM","alpha3Code":"BMU","callingCodes":["1441"],"capital":"Hamilton","altSpellings":["BM","The Islands of Bermuda","The Bermudas","Somers Isles"],"region":"Americas","subregion":"Northern America","population":61954,"latlng":[32.33333333,-64.75],"demonym":"Bermudian","area":54.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Bermuda","numericCode":"060","currencies":[{"code":"BMD","name":"Bermudian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Bermuda","es":"Bermudas","fr":"Bermudes","ja":"バミューダ","it":"Bermuda","br":"Bermudas","pt":"Bermudas","nl":"Bermuda","hr":"Bermudi","fa":"برمودا"},"flag":"https://restcountries.eu/data/bmu.svg","regionalBlocs":[],"cioc":"BER"} +{"name":"Bhutan","topLevelDomain":[".bt"],"alpha2Code":"BT","alpha3Code":"BTN","callingCodes":["975"],"capital":"Thimphu","altSpellings":["BT","Kingdom of Bhutan"],"region":"Asia","subregion":"Southern Asia","population":775620,"latlng":[27.5,90.5],"demonym":"Bhutanese","area":38394.0,"gini":38.1,"timezones":["UTC+06:00"],"borders":["CHN","IND"],"nativeName":"ʼbrug-yul","numericCode":"064","currencies":[{"code":"BTN","name":"Bhutanese ngultrum","symbol":"Nu."},{"code":"INR","name":"Indian rupee","symbol":"₹"}],"languages":[{"iso639_1":"dz","iso639_2":"dzo","name":"Dzongkha","nativeName":"རྫོང་ཁ"}],"translations":{"de":"Bhutan","es":"Bután","fr":"Bhoutan","ja":"ブータン","it":"Bhutan","br":"Butão","pt":"Butão","nl":"Bhutan","hr":"Butan","fa":"بوتان"},"flag":"https://restcountries.eu/data/btn.svg","regionalBlocs":[{"acronym":"SAARC","name":"South Asian Association for Regional Cooperation","otherAcronyms":[],"otherNames":[]}],"cioc":"BHU"} +{"name":"Bolivia (Plurinational State of)","topLevelDomain":[".bo"],"alpha2Code":"BO","alpha3Code":"BOL","callingCodes":["591"],"capital":"Sucre","altSpellings":["BO","Buliwya","Wuliwya","Plurinational State of Bolivia","Estado Plurinacional de Bolivia","Buliwya Mamallaqta","Wuliwya Suyu","Tetã Volívia"],"region":"Americas","subregion":"South America","population":10985059,"latlng":[-17.0,-65.0],"demonym":"Bolivian","area":1098581.0,"gini":56.3,"timezones":["UTC-04:00"],"borders":["ARG","BRA","CHL","PRY","PER"],"nativeName":"Bolivia","numericCode":"068","currencies":[{"code":"BOB","name":"Bolivian boliviano","symbol":"Bs."}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"},{"iso639_1":"ay","iso639_2":"aym","name":"Aymara","nativeName":"aymar aru"},{"iso639_1":"qu","iso639_2":"que","name":"Quechua","nativeName":"Runa Simi"}],"translations":{"de":"Bolivien","es":"Bolivia","fr":"Bolivie","ja":"ボリビア多民族国","it":"Bolivia","br":"Bolívia","pt":"Bolívia","nl":"Bolivia","hr":"Bolivija","fa":"بولیوی"},"flag":"https://restcountries.eu/data/bol.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"BOL"} +{"name":"Bonaire, Sint Eustatius and Saba","topLevelDomain":[".an",".nl"],"alpha2Code":"BQ","alpha3Code":"BES","callingCodes":["5997"],"capital":"Kralendijk","altSpellings":["BQ","Boneiru"],"region":"Americas","subregion":"Caribbean","population":17408,"latlng":[12.15,-68.266667],"demonym":"Dutch","area":294.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Bonaire","numericCode":"535","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"nl","iso639_2":"nld","name":"Dutch","nativeName":"Nederlands"}],"translations":{"de":"Bonaire, Sint Eustatius und Saba","es":null,"fr":"Bonaire, Saint-Eustache et Saba","ja":null,"it":"Bonaire, Saint-Eustache e Saba","br":"Bonaire","pt":"Bonaire","nl":null,"hr":null,"fa":"بونیر"},"flag":"https://restcountries.eu/data/bes.svg","regionalBlocs":[],"cioc":null} +{"name":"Bosnia and Herzegovina","topLevelDomain":[".ba"],"alpha2Code":"BA","alpha3Code":"BIH","callingCodes":["387"],"capital":"Sarajevo","altSpellings":["BA","Bosnia-Herzegovina","Босна и Херцеговина"],"region":"Europe","subregion":"Southern Europe","population":3531159,"latlng":[44.0,18.0],"demonym":"Bosnian, Herzegovinian","area":51209.0,"gini":36.2,"timezones":["UTC+01:00"],"borders":["HRV","MNE","SRB"],"nativeName":"Bosna i Hercegovina","numericCode":"070","currencies":[{"code":"BAM","name":"Bosnia and Herzegovina convertible mark","symbol":null}],"languages":[{"iso639_1":"bs","iso639_2":"bos","name":"Bosnian","nativeName":"bosanski jezik"},{"iso639_1":"hr","iso639_2":"hrv","name":"Croatian","nativeName":"hrvatski jezik"},{"iso639_1":"sr","iso639_2":"srp","name":"Serbian","nativeName":"српски језик"}],"translations":{"de":"Bosnien und Herzegowina","es":"Bosnia y Herzegovina","fr":"Bosnie-Herzégovine","ja":"ボスニア・ヘルツェゴビナ","it":"Bosnia ed Erzegovina","br":"Bósnia e Herzegovina","pt":"Bósnia e Herzegovina","nl":"Bosnië en Herzegovina","hr":"Bosna i Hercegovina","fa":"بوسنی و هرزگوین"},"flag":"https://restcountries.eu/data/bih.svg","regionalBlocs":[{"acronym":"CEFTA","name":"Central European Free Trade Agreement","otherAcronyms":[],"otherNames":[]}],"cioc":"BIH"} +{"name":"Botswana","topLevelDomain":[".bw"],"alpha2Code":"BW","alpha3Code":"BWA","callingCodes":["267"],"capital":"Gaborone","altSpellings":["BW","Republic of Botswana","Lefatshe la Botswana"],"region":"Africa","subregion":"Southern Africa","population":2141206,"latlng":[-22.0,24.0],"demonym":"Motswana","area":582000.0,"gini":61.0,"timezones":["UTC+02:00"],"borders":["NAM","ZAF","ZMB","ZWE"],"nativeName":"Botswana","numericCode":"072","currencies":[{"code":"BWP","name":"Botswana pula","symbol":"P"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"tn","iso639_2":"tsn","name":"Tswana","nativeName":"Setswana"}],"translations":{"de":"Botswana","es":"Botswana","fr":"Botswana","ja":"ボツワナ","it":"Botswana","br":"Botsuana","pt":"Botsuana","nl":"Botswana","hr":"Bocvana","fa":"بوتسوانا"},"flag":"https://restcountries.eu/data/bwa.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"BOT"} +{"name":"Bouvet Island","topLevelDomain":[".bv"],"alpha2Code":"BV","alpha3Code":"BVT","callingCodes":[""],"capital":"","altSpellings":["BV","Bouvetøya","Bouvet-øya"],"region":"","subregion":"","population":0,"latlng":[-54.43333333,3.4],"demonym":"","area":49.0,"gini":null,"timezones":["UTC+01:00"],"borders":[],"nativeName":"Bouvetøya","numericCode":"074","currencies":[{"code":"NOK","name":"Norwegian krone","symbol":"kr"}],"languages":[{"iso639_1":"no","iso639_2":"nor","name":"Norwegian","nativeName":"Norsk"},{"iso639_1":"nb","iso639_2":"nob","name":"Norwegian Bokmål","nativeName":"Norsk bokmål"},{"iso639_1":"nn","iso639_2":"nno","name":"Norwegian Nynorsk","nativeName":"Norsk nynorsk"}],"translations":{"de":"Bouvetinsel","es":"Isla Bouvet","fr":"Île Bouvet","ja":"ブーベ島","it":"Isola Bouvet","br":"Ilha Bouvet","pt":"Ilha Bouvet","nl":"Bouveteiland","hr":"Otok Bouvet","fa":"جزیره بووه"},"flag":"https://restcountries.eu/data/bvt.svg","regionalBlocs":[],"cioc":""} +{"name":"Brazil","topLevelDomain":[".br"],"alpha2Code":"BR","alpha3Code":"BRA","callingCodes":["55"],"capital":"Brasília","altSpellings":["BR","Brasil","Federative Republic of Brazil","República Federativa do Brasil"],"region":"Americas","subregion":"South America","population":206135893,"latlng":[-10.0,-55.0],"demonym":"Brazilian","area":8515767.0,"gini":54.7,"timezones":["UTC-05:00","UTC-04:00","UTC-03:00","UTC-02:00"],"borders":["ARG","BOL","COL","GUF","GUY","PRY","PER","SUR","URY","VEN"],"nativeName":"Brasil","numericCode":"076","currencies":[{"code":"BRL","name":"Brazilian real","symbol":"R$"}],"languages":[{"iso639_1":"pt","iso639_2":"por","name":"Portuguese","nativeName":"Português"}],"translations":{"de":"Brasilien","es":"Brasil","fr":"Brésil","ja":"ブラジル","it":"Brasile","br":"Brasil","pt":"Brasil","nl":"Brazilië","hr":"Brazil","fa":"برزیل"},"flag":"https://restcountries.eu/data/bra.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"BRA"} +{"name":"British Indian Ocean Territory","topLevelDomain":[".io"],"alpha2Code":"IO","alpha3Code":"IOT","callingCodes":["246"],"capital":"Diego Garcia","altSpellings":["IO"],"region":"Africa","subregion":"Eastern Africa","population":3000,"latlng":[-6.0,71.5],"demonym":"Indian","area":60.0,"gini":null,"timezones":["UTC+06:00"],"borders":[],"nativeName":"British Indian Ocean Territory","numericCode":"086","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Britisches Territorium im Indischen Ozean","es":"Territorio Británico del Océano Índico","fr":"Territoire britannique de l'océan Indien","ja":"イギリス領インド洋地域","it":"Territorio britannico dell'oceano indiano","br":"Território Britânico do Oceano íÍdico","pt":"Território Britânico do Oceano Índico","nl":"Britse Gebieden in de Indische Oceaan","hr":"Britanski Indijskooceanski teritorij","fa":"قلمرو بریتانیا در اقیانوس هند"},"flag":"https://restcountries.eu/data/iot.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":""} +{"name":"United States Minor Outlying Islands","topLevelDomain":[".us"],"alpha2Code":"UM","alpha3Code":"UMI","callingCodes":[""],"capital":"","altSpellings":["UM"],"region":"Americas","subregion":"Northern America","population":300,"latlng":[],"demonym":"American","area":null,"gini":null,"timezones":["UTC-11:00","UTC-10:00","UTC+12:00"],"borders":[],"nativeName":"United States Minor Outlying Islands","numericCode":"581","currencies":[{"code":"USD","name":"United States Dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Kleinere Inselbesitzungen der Vereinigten Staaten","es":"Islas Ultramarinas Menores de Estados Unidos","fr":"Îles mineures éloignées des États-Unis","ja":"合衆国領有小離島","it":"Isole minori esterne degli Stati Uniti d'America","br":"Ilhas Menores Distantes dos Estados Unidos","pt":"Ilhas Menores Distantes dos Estados Unidos","nl":"Kleine afgelegen eilanden van de Verenigde Staten","hr":"Mali udaljeni otoci SAD-a","fa":"جزایر کوچک حاشیه‌ای ایالات متحده آمریکا"},"flag":"https://restcountries.eu/data/umi.svg","regionalBlocs":[],"cioc":""} +{"name":"Virgin Islands (British)","topLevelDomain":[".vg"],"alpha2Code":"VG","alpha3Code":"VGB","callingCodes":["1284"],"capital":"Road Town","altSpellings":["VG"],"region":"Americas","subregion":"Caribbean","population":28514,"latlng":[18.431383,-64.62305],"demonym":"Virgin Islander","area":151.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"British Virgin Islands","numericCode":"092","currencies":[{"code":null,"name":"[D]","symbol":"$"},{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Britische Jungferninseln","es":"Islas Vírgenes del Reino Unido","fr":"Îles Vierges britanniques","ja":"イギリス領ヴァージン諸島","it":"Isole Vergini Britanniche","br":"Ilhas Virgens Britânicas","pt":"Ilhas Virgens Britânicas","nl":"Britse Maagdeneilanden","hr":"Britanski Djevičanski Otoci","fa":"جزایر ویرجین بریتانیا"},"flag":"https://restcountries.eu/data/vgb.svg","regionalBlocs":[],"cioc":"IVB"} +{"name":"Virgin Islands (U.S.)","topLevelDomain":[".vi"],"alpha2Code":"VI","alpha3Code":"VIR","callingCodes":["1 340"],"capital":"Charlotte Amalie","altSpellings":["VI","USVI","American Virgin Islands","U.S. Virgin Islands"],"region":"Americas","subregion":"Caribbean","population":114743,"latlng":[18.34,-64.93],"demonym":"Virgin Islander","area":346.36,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Virgin Islands of the United States","numericCode":"850","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Amerikanische Jungferninseln","es":"Islas Vírgenes de los Estados Unidos","fr":"Îles Vierges des États-Unis","ja":"アメリカ領ヴァージン諸島","it":"Isole Vergini americane","br":"Ilhas Virgens Americanas","pt":"Ilhas Virgens Americanas","nl":"Verenigde Staten Maagdeneilanden","hr":null,"fa":"جزایر ویرجین آمریکا"},"flag":"https://restcountries.eu/data/vir.svg","regionalBlocs":[],"cioc":"ISV"} +{"name":"Brunei Darussalam","topLevelDomain":[".bn"],"alpha2Code":"BN","alpha3Code":"BRN","callingCodes":["673"],"capital":"Bandar Seri Begawan","altSpellings":["BN","Nation of Brunei"," the Abode of Peace"],"region":"Asia","subregion":"South-Eastern Asia","population":411900,"latlng":[4.5,114.66666666],"demonym":"Bruneian","area":5765.0,"gini":null,"timezones":["UTC+08:00"],"borders":["MYS"],"nativeName":"Negara Brunei Darussalam","numericCode":"096","currencies":[{"code":"BND","name":"Brunei dollar","symbol":"$"},{"code":"SGD","name":"Singapore dollar","symbol":"$"}],"languages":[{"iso639_1":"ms","iso639_2":"msa","name":"Malay","nativeName":"bahasa Melayu"}],"translations":{"de":"Brunei","es":"Brunei","fr":"Brunei","ja":"ブルネイ・ダルサラーム","it":"Brunei","br":"Brunei","pt":"Brunei","nl":"Brunei","hr":"Brunej","fa":"برونئی"},"flag":"https://restcountries.eu/data/brn.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"BRU"} +{"name":"Bulgaria","topLevelDomain":[".bg"],"alpha2Code":"BG","alpha3Code":"BGR","callingCodes":["359"],"capital":"Sofia","altSpellings":["BG","Republic of Bulgaria","Република България"],"region":"Europe","subregion":"Eastern Europe","population":7153784,"latlng":[43.0,25.0],"demonym":"Bulgarian","area":110879.0,"gini":28.2,"timezones":["UTC+02:00"],"borders":["GRC","MKD","ROU","SRB","TUR"],"nativeName":"България","numericCode":"100","currencies":[{"code":"BGN","name":"Bulgarian lev","symbol":"лв"}],"languages":[{"iso639_1":"bg","iso639_2":"bul","name":"Bulgarian","nativeName":"български език"}],"translations":{"de":"Bulgarien","es":"Bulgaria","fr":"Bulgarie","ja":"ブルガリア","it":"Bulgaria","br":"Bulgária","pt":"Bulgária","nl":"Bulgarije","hr":"Bugarska","fa":"بلغارستان"},"flag":"https://restcountries.eu/data/bgr.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"BUL"} +{"name":"Burkina Faso","topLevelDomain":[".bf"],"alpha2Code":"BF","alpha3Code":"BFA","callingCodes":["226"],"capital":"Ouagadougou","altSpellings":["BF"],"region":"Africa","subregion":"Western Africa","population":19034397,"latlng":[13.0,-2.0],"demonym":"Burkinabe","area":272967.0,"gini":39.8,"timezones":["UTC"],"borders":["BEN","CIV","GHA","MLI","NER","TGO"],"nativeName":"Burkina Faso","numericCode":"854","currencies":[{"code":"XOF","name":"West African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"ff","iso639_2":"ful","name":"Fula","nativeName":"Fulfulde"}],"translations":{"de":"Burkina Faso","es":"Burkina Faso","fr":"Burkina Faso","ja":"ブルキナファソ","it":"Burkina Faso","br":"Burkina Faso","pt":"Burquina Faso","nl":"Burkina Faso","hr":"Burkina Faso","fa":"بورکینافاسو"},"flag":"https://restcountries.eu/data/bfa.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"BUR"} +{"name":"Burundi","topLevelDomain":[".bi"],"alpha2Code":"BI","alpha3Code":"BDI","callingCodes":["257"],"capital":"Bujumbura","altSpellings":["BI","Republic of Burundi","Republika y'Uburundi","République du Burundi"],"region":"Africa","subregion":"Eastern Africa","population":10114505,"latlng":[-3.5,30.0],"demonym":"Burundian","area":27834.0,"gini":33.3,"timezones":["UTC+02:00"],"borders":["COD","RWA","TZA"],"nativeName":"Burundi","numericCode":"108","currencies":[{"code":"BIF","name":"Burundian franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"rn","iso639_2":"run","name":"Kirundi","nativeName":"Ikirundi"}],"translations":{"de":"Burundi","es":"Burundi","fr":"Burundi","ja":"ブルンジ","it":"Burundi","br":"Burundi","pt":"Burúndi","nl":"Burundi","hr":"Burundi","fa":"بوروندی"},"flag":"https://restcountries.eu/data/bdi.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"BDI"} +{"name":"Cambodia","topLevelDomain":[".kh"],"alpha2Code":"KH","alpha3Code":"KHM","callingCodes":["855"],"capital":"Phnom Penh","altSpellings":["KH","Kingdom of Cambodia"],"region":"Asia","subregion":"South-Eastern Asia","population":15626444,"latlng":[13.0,105.0],"demonym":"Cambodian","area":181035.0,"gini":37.9,"timezones":["UTC+07:00"],"borders":["LAO","THA","VNM"],"nativeName":"Kâmpŭchéa","numericCode":"116","currencies":[{"code":"KHR","name":"Cambodian riel","symbol":"៛"},{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"km","iso639_2":"khm","name":"Khmer","nativeName":"ខ្មែរ"}],"translations":{"de":"Kambodscha","es":"Camboya","fr":"Cambodge","ja":"カンボジア","it":"Cambogia","br":"Camboja","pt":"Camboja","nl":"Cambodja","hr":"Kambodža","fa":"کامبوج"},"flag":"https://restcountries.eu/data/khm.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"CAM"} +{"name":"Cameroon","topLevelDomain":[".cm"],"alpha2Code":"CM","alpha3Code":"CMR","callingCodes":["237"],"capital":"Yaoundé","altSpellings":["CM","Republic of Cameroon","République du Cameroun"],"region":"Africa","subregion":"Middle Africa","population":22709892,"latlng":[6.0,12.0],"demonym":"Cameroonian","area":475442.0,"gini":38.9,"timezones":["UTC+01:00"],"borders":["CAF","TCD","COG","GNQ","GAB","NGA"],"nativeName":"Cameroon","numericCode":"120","currencies":[{"code":"XAF","name":"Central African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Kamerun","es":"Camerún","fr":"Cameroun","ja":"カメルーン","it":"Camerun","br":"Camarões","pt":"Camarões","nl":"Kameroen","hr":"Kamerun","fa":"کامرون"},"flag":"https://restcountries.eu/data/cmr.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"CMR"} +{"name":"Canada","topLevelDomain":[".ca"],"alpha2Code":"CA","alpha3Code":"CAN","callingCodes":["1"],"capital":"Ottawa","altSpellings":["CA"],"region":"Americas","subregion":"Northern America","population":36155487,"latlng":[60.0,-95.0],"demonym":"Canadian","area":9984670.0,"gini":32.6,"timezones":["UTC-08:00","UTC-07:00","UTC-06:00","UTC-05:00","UTC-04:00","UTC-03:30"],"borders":["USA"],"nativeName":"Canada","numericCode":"124","currencies":[{"code":"CAD","name":"Canadian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Kanada","es":"Canadá","fr":"Canada","ja":"カナダ","it":"Canada","br":"Canadá","pt":"Canadá","nl":"Canada","hr":"Kanada","fa":"کانادا"},"flag":"https://restcountries.eu/data/can.svg","regionalBlocs":[{"acronym":"NAFTA","name":"North American Free Trade Agreement","otherAcronyms":[],"otherNames":["Tratado de Libre Comercio de América del Norte","Accord de Libre-échange Nord-Américain"]}],"cioc":"CAN"} +{"name":"Cabo Verde","topLevelDomain":[".cv"],"alpha2Code":"CV","alpha3Code":"CPV","callingCodes":["238"],"capital":"Praia","altSpellings":["CV","Republic of Cabo Verde","República de Cabo Verde"],"region":"Africa","subregion":"Western Africa","population":531239,"latlng":[16.0,-24.0],"demonym":"Cape Verdian","area":4033.0,"gini":50.5,"timezones":["UTC-01:00"],"borders":[],"nativeName":"Cabo Verde","numericCode":"132","currencies":[{"code":"CVE","name":"Cape Verdean escudo","symbol":"Esc"}],"languages":[{"iso639_1":"pt","iso639_2":"por","name":"Portuguese","nativeName":"Português"}],"translations":{"de":"Kap Verde","es":"Cabo Verde","fr":"Cap Vert","ja":"カーボベルデ","it":"Capo Verde","br":"Cabo Verde","pt":"Cabo Verde","nl":"Kaapverdië","hr":"Zelenortska Republika","fa":"کیپ ورد"},"flag":"https://restcountries.eu/data/cpv.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"CPV"} +{"name":"Cayman Islands","topLevelDomain":[".ky"],"alpha2Code":"KY","alpha3Code":"CYM","callingCodes":["1345"],"capital":"George Town","altSpellings":["KY"],"region":"Americas","subregion":"Caribbean","population":58238,"latlng":[19.5,-80.5],"demonym":"Caymanian","area":264.0,"gini":null,"timezones":["UTC-05:00"],"borders":[],"nativeName":"Cayman Islands","numericCode":"136","currencies":[{"code":"KYD","name":"Cayman Islands dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Kaimaninseln","es":"Islas Caimán","fr":"Îles Caïmans","ja":"ケイマン諸島","it":"Isole Cayman","br":"Ilhas Cayman","pt":"Ilhas Caimão","nl":"Caymaneilanden","hr":"Kajmanski otoci","fa":"جزایر کیمن"},"flag":"https://restcountries.eu/data/cym.svg","regionalBlocs":[],"cioc":"CAY"} +{"name":"Central African Republic","topLevelDomain":[".cf"],"alpha2Code":"CF","alpha3Code":"CAF","callingCodes":["236"],"capital":"Bangui","altSpellings":["CF","Central African Republic","République centrafricaine"],"region":"Africa","subregion":"Middle Africa","population":4998000,"latlng":[7.0,21.0],"demonym":"Central African","area":622984.0,"gini":56.3,"timezones":["UTC+01:00"],"borders":["CMR","TCD","COD","COG","SSD","SDN"],"nativeName":"Ködörösêse tî Bêafrîka","numericCode":"140","currencies":[{"code":"XAF","name":"Central African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"sg","iso639_2":"sag","name":"Sango","nativeName":"yângâ tî sängö"}],"translations":{"de":"Zentralafrikanische Republik","es":"República Centroafricana","fr":"République centrafricaine","ja":"中央アフリカ共和国","it":"Repubblica Centrafricana","br":"República Centro-Africana","pt":"República Centro-Africana","nl":"Centraal-Afrikaanse Republiek","hr":"Srednjoafrička Republika","fa":"جمهوری آفریقای مرکزی"},"flag":"https://restcountries.eu/data/caf.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"CAF"} +{"name":"Chad","topLevelDomain":[".td"],"alpha2Code":"TD","alpha3Code":"TCD","callingCodes":["235"],"capital":"N'Djamena","altSpellings":["TD","Tchad","Republic of Chad","République du Tchad"],"region":"Africa","subregion":"Middle Africa","population":14497000,"latlng":[15.0,19.0],"demonym":"Chadian","area":1284000.0,"gini":39.8,"timezones":["UTC+01:00"],"borders":["CMR","CAF","LBY","NER","NGA","SSD"],"nativeName":"Tchad","numericCode":"148","currencies":[{"code":"XAF","name":"Central African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Tschad","es":"Chad","fr":"Tchad","ja":"チャド","it":"Ciad","br":"Chade","pt":"Chade","nl":"Tsjaad","hr":"Čad","fa":"چاد"},"flag":"https://restcountries.eu/data/tcd.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"CHA"} +{"name":"Chile","topLevelDomain":[".cl"],"alpha2Code":"CL","alpha3Code":"CHL","callingCodes":["56"],"capital":"Santiago","altSpellings":["CL","Republic of Chile","República de Chile"],"region":"Americas","subregion":"South America","population":18191900,"latlng":[-30.0,-71.0],"demonym":"Chilean","area":756102.0,"gini":52.1,"timezones":["UTC-06:00","UTC-04:00"],"borders":["ARG","BOL","PER"],"nativeName":"Chile","numericCode":"152","currencies":[{"code":"CLP","name":"Chilean peso","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Chile","es":"Chile","fr":"Chili","ja":"チリ","it":"Cile","br":"Chile","pt":"Chile","nl":"Chili","hr":"Čile","fa":"شیلی"},"flag":"https://restcountries.eu/data/chl.svg","regionalBlocs":[{"acronym":"PA","name":"Pacific Alliance","otherAcronyms":[],"otherNames":["Alianza del Pacífico"]},{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"CHI"} +{"name":"China","topLevelDomain":[".cn"],"alpha2Code":"CN","alpha3Code":"CHN","callingCodes":["86"],"capital":"Beijing","altSpellings":["CN","Zhōngguó","Zhongguo","Zhonghua","People's Republic of China","中华人民共和国","Zhōnghuá Rénmín Gònghéguó"],"region":"Asia","subregion":"Eastern Asia","population":1377422166,"latlng":[35.0,105.0],"demonym":"Chinese","area":9640011.0,"gini":47.0,"timezones":["UTC+08:00"],"borders":["AFG","BTN","MMR","HKG","IND","KAZ","PRK","KGZ","LAO","MAC","MNG","PAK","RUS","TJK","VNM"],"nativeName":"中国","numericCode":"156","currencies":[{"code":"CNY","name":"Chinese yuan","symbol":"¥"}],"languages":[{"iso639_1":"zh","iso639_2":"zho","name":"Chinese","nativeName":"中文 (Zhōngwén)"}],"translations":{"de":"China","es":"China","fr":"Chine","ja":"中国","it":"Cina","br":"China","pt":"China","nl":"China","hr":"Kina","fa":"چین"},"flag":"https://restcountries.eu/data/chn.svg","regionalBlocs":[],"cioc":"CHN"} +{"name":"Christmas Island","topLevelDomain":[".cx"],"alpha2Code":"CX","alpha3Code":"CXR","callingCodes":["61"],"capital":"Flying Fish Cove","altSpellings":["CX","Territory of Christmas Island"],"region":"Oceania","subregion":"Australia and New Zealand","population":2072,"latlng":[-10.5,105.66666666],"demonym":"Christmas Island","area":135.0,"gini":null,"timezones":["UTC+07:00"],"borders":[],"nativeName":"Christmas Island","numericCode":"162","currencies":[{"code":"AUD","name":"Australian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Weihnachtsinsel","es":"Isla de Navidad","fr":"Île Christmas","ja":"クリスマス島","it":"Isola di Natale","br":"Ilha Christmas","pt":"Ilha do Natal","nl":"Christmaseiland","hr":"Božićni otok","fa":"جزیره کریسمس"},"flag":"https://restcountries.eu/data/cxr.svg","regionalBlocs":[],"cioc":""} +{"name":"Cocos (Keeling) Islands","topLevelDomain":[".cc"],"alpha2Code":"CC","alpha3Code":"CCK","callingCodes":["61"],"capital":"West Island","altSpellings":["CC","Territory of the Cocos (Keeling) Islands","Keeling Islands"],"region":"Oceania","subregion":"Australia and New Zealand","population":550,"latlng":[-12.5,96.83333333],"demonym":"Cocos Islander","area":14.0,"gini":null,"timezones":["UTC+06:30"],"borders":[],"nativeName":"Cocos (Keeling) Islands","numericCode":"166","currencies":[{"code":"AUD","name":"Australian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Kokosinseln","es":"Islas Cocos o Islas Keeling","fr":"Îles Cocos","ja":"ココス(キーリング)諸島","it":"Isole Cocos e Keeling","br":"Ilhas Cocos","pt":"Ilhas dos Cocos","nl":"Cocoseilanden","hr":"Kokosovi Otoci","fa":"جزایر کوکوس"},"flag":"https://restcountries.eu/data/cck.svg","regionalBlocs":[],"cioc":""} +{"name":"Colombia","topLevelDomain":[".co"],"alpha2Code":"CO","alpha3Code":"COL","callingCodes":["57"],"capital":"Bogotá","altSpellings":["CO","Republic of Colombia","República de Colombia"],"region":"Americas","subregion":"South America","population":48759958,"latlng":[4.0,-72.0],"demonym":"Colombian","area":1141748.0,"gini":55.9,"timezones":["UTC-05:00"],"borders":["BRA","ECU","PAN","PER","VEN"],"nativeName":"Colombia","numericCode":"170","currencies":[{"code":"COP","name":"Colombian peso","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Kolumbien","es":"Colombia","fr":"Colombie","ja":"コロンビア","it":"Colombia","br":"Colômbia","pt":"Colômbia","nl":"Colombia","hr":"Kolumbija","fa":"کلمبیا"},"flag":"https://restcountries.eu/data/col.svg","regionalBlocs":[{"acronym":"PA","name":"Pacific Alliance","otherAcronyms":[],"otherNames":["Alianza del Pacífico"]},{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"COL"} +{"name":"Comoros","topLevelDomain":[".km"],"alpha2Code":"KM","alpha3Code":"COM","callingCodes":["269"],"capital":"Moroni","altSpellings":["KM","Union of the Comoros","Union des Comores","Udzima wa Komori","al-Ittiḥād al-Qumurī"],"region":"Africa","subregion":"Eastern Africa","population":806153,"latlng":[-12.16666666,44.25],"demonym":"Comoran","area":1862.0,"gini":64.3,"timezones":["UTC+03:00"],"borders":[],"nativeName":"Komori","numericCode":"174","currencies":[{"code":"KMF","name":"Comorian franc","symbol":"Fr"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Union der Komoren","es":"Comoras","fr":"Comores","ja":"コモロ","it":"Comore","br":"Comores","pt":"Comores","nl":"Comoren","hr":"Komori","fa":"کومور"},"flag":"https://restcountries.eu/data/com.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"COM"} +{"name":"Congo","topLevelDomain":[".cg"],"alpha2Code":"CG","alpha3Code":"COG","callingCodes":["242"],"capital":"Brazzaville","altSpellings":["CG","Congo-Brazzaville"],"region":"Africa","subregion":"Middle Africa","population":4741000,"latlng":[-1.0,15.0],"demonym":"Congolese","area":342000.0,"gini":47.3,"timezones":["UTC+01:00"],"borders":["AGO","CMR","CAF","COD","GAB"],"nativeName":"République du Congo","numericCode":"178","currencies":[{"code":"XAF","name":"Central African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"ln","iso639_2":"lin","name":"Lingala","nativeName":"Lingála"}],"translations":{"de":"Kongo","es":"Congo","fr":"Congo","ja":"コンゴ共和国","it":"Congo","br":"Congo","pt":"Congo","nl":"Congo [Republiek]","hr":"Kongo","fa":"کنگو"},"flag":"https://restcountries.eu/data/cog.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"CGO"} +{"name":"Congo (Democratic Republic of the)","topLevelDomain":[".cd"],"alpha2Code":"CD","alpha3Code":"COD","callingCodes":["243"],"capital":"Kinshasa","altSpellings":["CD","DR Congo","Congo-Kinshasa","DRC"],"region":"Africa","subregion":"Middle Africa","population":85026000,"latlng":[0.0,25.0],"demonym":"Congolese","area":2344858.0,"gini":null,"timezones":["UTC+01:00","UTC+02:00"],"borders":["AGO","BDI","CAF","COG","RWA","SSD","TZA","UGA","ZMB"],"nativeName":"République démocratique du Congo","numericCode":"180","currencies":[{"code":"CDF","name":"Congolese franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"ln","iso639_2":"lin","name":"Lingala","nativeName":"Lingála"},{"iso639_1":"kg","iso639_2":"kon","name":"Kongo","nativeName":"Kikongo"},{"iso639_1":"sw","iso639_2":"swa","name":"Swahili","nativeName":"Kiswahili"},{"iso639_1":"lu","iso639_2":"lub","name":"Luba-Katanga","nativeName":"Tshiluba"}],"translations":{"de":"Kongo (Dem. Rep.)","es":"Congo (Rep. Dem.)","fr":"Congo (Rép. dém.)","ja":"コンゴ民主共和国","it":"Congo (Rep. Dem.)","br":"RD Congo","pt":"RD Congo","nl":"Congo [DRC]","hr":"Kongo, Demokratska Republika","fa":"جمهوری کنگو"},"flag":"https://restcountries.eu/data/cod.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"COD"} +{"name":"Cook Islands","topLevelDomain":[".ck"],"alpha2Code":"CK","alpha3Code":"COK","callingCodes":["682"],"capital":"Avarua","altSpellings":["CK","Kūki 'Āirani"],"region":"Oceania","subregion":"Polynesia","population":18100,"latlng":[-21.23333333,-159.76666666],"demonym":"Cook Islander","area":236.0,"gini":null,"timezones":["UTC-10:00"],"borders":[],"nativeName":"Cook Islands","numericCode":"184","currencies":[{"code":"NZD","name":"New Zealand dollar","symbol":"$"},{"code":"CKD","name":"Cook Islands dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Cookinseln","es":"Islas Cook","fr":"Îles Cook","ja":"クック諸島","it":"Isole Cook","br":"Ilhas Cook","pt":"Ilhas Cook","nl":"Cookeilanden","hr":"Cookovo Otočje","fa":"جزایر کوک"},"flag":"https://restcountries.eu/data/cok.svg","regionalBlocs":[],"cioc":"COK"} +{"name":"Costa Rica","topLevelDomain":[".cr"],"alpha2Code":"CR","alpha3Code":"CRI","callingCodes":["506"],"capital":"San José","altSpellings":["CR","Republic of Costa Rica","República de Costa Rica"],"region":"Americas","subregion":"Central America","population":4890379,"latlng":[10.0,-84.0],"demonym":"Costa Rican","area":51100.0,"gini":50.7,"timezones":["UTC-06:00"],"borders":["NIC","PAN"],"nativeName":"Costa Rica","numericCode":"188","currencies":[{"code":"CRC","name":"Costa Rican colón","symbol":"₡"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Costa Rica","es":"Costa Rica","fr":"Costa Rica","ja":"コスタリカ","it":"Costa Rica","br":"Costa Rica","pt":"Costa Rica","nl":"Costa Rica","hr":"Kostarika","fa":"کاستاریکا"},"flag":"https://restcountries.eu/data/cri.svg","regionalBlocs":[{"acronym":"CAIS","name":"Central American Integration System","otherAcronyms":["SICA"],"otherNames":["Sistema de la Integración Centroamericana,"]}],"cioc":"CRC"} +{"name":"Croatia","topLevelDomain":[".hr"],"alpha2Code":"HR","alpha3Code":"HRV","callingCodes":["385"],"capital":"Zagreb","altSpellings":["HR","Hrvatska","Republic of Croatia","Republika Hrvatska"],"region":"Europe","subregion":"Southern Europe","population":4190669,"latlng":[45.16666666,15.5],"demonym":"Croatian","area":56594.0,"gini":33.7,"timezones":["UTC+01:00"],"borders":["BIH","HUN","MNE","SRB","SVN"],"nativeName":"Hrvatska","numericCode":"191","currencies":[{"code":"HRK","name":"Croatian kuna","symbol":"kn"}],"languages":[{"iso639_1":"hr","iso639_2":"hrv","name":"Croatian","nativeName":"hrvatski jezik"}],"translations":{"de":"Kroatien","es":"Croacia","fr":"Croatie","ja":"クロアチア","it":"Croazia","br":"Croácia","pt":"Croácia","nl":"Kroatië","hr":"Hrvatska","fa":"کرواسی"},"flag":"https://restcountries.eu/data/hrv.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"CRO"} +{"name":"Cuba","topLevelDomain":[".cu"],"alpha2Code":"CU","alpha3Code":"CUB","callingCodes":["53"],"capital":"Havana","altSpellings":["CU","Republic of Cuba","República de Cuba"],"region":"Americas","subregion":"Caribbean","population":11239004,"latlng":[21.5,-80.0],"demonym":"Cuban","area":109884.0,"gini":null,"timezones":["UTC-05:00"],"borders":[],"nativeName":"Cuba","numericCode":"192","currencies":[{"code":"CUC","name":"Cuban convertible peso","symbol":"$"},{"code":"CUP","name":"Cuban peso","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Kuba","es":"Cuba","fr":"Cuba","ja":"キューバ","it":"Cuba","br":"Cuba","pt":"Cuba","nl":"Cuba","hr":"Kuba","fa":"کوبا"},"flag":"https://restcountries.eu/data/cub.svg","regionalBlocs":[],"cioc":"CUB"} +{"name":"Curaçao","topLevelDomain":[".cw"],"alpha2Code":"CW","alpha3Code":"CUW","callingCodes":["599"],"capital":"Willemstad","altSpellings":["CW","Curacao","Kòrsou","Country of Curaçao","Land Curaçao","Pais Kòrsou"],"region":"Americas","subregion":"Caribbean","population":154843,"latlng":[12.116667,-68.933333],"demonym":"Dutch","area":444.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Curaçao","numericCode":"531","currencies":[{"code":"ANG","name":"Netherlands Antillean guilder","symbol":"ƒ"}],"languages":[{"iso639_1":"nl","iso639_2":"nld","name":"Dutch","nativeName":"Nederlands"},{"iso639_1":"pa","iso639_2":"pan","name":"(Eastern) Punjabi","nativeName":"ਪੰਜਾਬੀ"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Curaçao","es":null,"fr":"Curaçao","ja":null,"it":"Curaçao","br":"Curaçao","pt":"Curaçao","nl":"Curaçao","hr":null,"fa":"کوراسائو"},"flag":"https://restcountries.eu/data/cuw.svg","regionalBlocs":[],"cioc":""} +{"name":"Cyprus","topLevelDomain":[".cy"],"alpha2Code":"CY","alpha3Code":"CYP","callingCodes":["357"],"capital":"Nicosia","altSpellings":["CY","Kýpros","Kıbrıs","Republic of Cyprus","Κυπριακή Δημοκρατία","Kıbrıs Cumhuriyeti"],"region":"Europe","subregion":"Southern Europe","population":847000,"latlng":[35.0,33.0],"demonym":"Cypriot","area":9251.0,"gini":null,"timezones":["UTC+02:00"],"borders":["GBR"],"nativeName":"Κύπρος","numericCode":"196","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"el","iso639_2":"ell","name":"Greek (modern)","nativeName":"ελληνικά"},{"iso639_1":"tr","iso639_2":"tur","name":"Turkish","nativeName":"Türkçe"},{"iso639_1":"hy","iso639_2":"hye","name":"Armenian","nativeName":"Հայերեն"}],"translations":{"de":"Zypern","es":"Chipre","fr":"Chypre","ja":"キプロス","it":"Cipro","br":"Chipre","pt":"Chipre","nl":"Cyprus","hr":"Cipar","fa":"قبرس"},"flag":"https://restcountries.eu/data/cyp.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"CYP"} +{"name":"Czech Republic","topLevelDomain":[".cz"],"alpha2Code":"CZ","alpha3Code":"CZE","callingCodes":["420"],"capital":"Prague","altSpellings":["CZ","Česká republika","Česko"],"region":"Europe","subregion":"Eastern Europe","population":10558524,"latlng":[49.75,15.5],"demonym":"Czech","area":78865.0,"gini":26.0,"timezones":["UTC+01:00"],"borders":["AUT","DEU","POL","SVK"],"nativeName":"Česká republika","numericCode":"203","currencies":[{"code":"CZK","name":"Czech koruna","symbol":"Kč"}],"languages":[{"iso639_1":"cs","iso639_2":"ces","name":"Czech","nativeName":"čeština"},{"iso639_1":"sk","iso639_2":"slk","name":"Slovak","nativeName":"slovenčina"}],"translations":{"de":"Tschechische Republik","es":"República Checa","fr":"République tchèque","ja":"チェコ","it":"Repubblica Ceca","br":"República Tcheca","pt":"República Checa","nl":"Tsjechië","hr":"Češka","fa":"جمهوری چک"},"flag":"https://restcountries.eu/data/cze.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"CZE"} +{"name":"Denmark","topLevelDomain":[".dk"],"alpha2Code":"DK","alpha3Code":"DNK","callingCodes":["45"],"capital":"Copenhagen","altSpellings":["DK","Danmark","Kingdom of Denmark","Kongeriget Danmark"],"region":"Europe","subregion":"Northern Europe","population":5717014,"latlng":[56.0,10.0],"demonym":"Danish","area":43094.0,"gini":24.0,"timezones":["UTC-04:00","UTC-03:00","UTC-01:00","UTC","UTC+01:00"],"borders":["DEU"],"nativeName":"Danmark","numericCode":"208","currencies":[{"code":"DKK","name":"Danish krone","symbol":"kr"}],"languages":[{"iso639_1":"da","iso639_2":"dan","name":"Danish","nativeName":"dansk"}],"translations":{"de":"Dänemark","es":"Dinamarca","fr":"Danemark","ja":"デンマーク","it":"Danimarca","br":"Dinamarca","pt":"Dinamarca","nl":"Denemarken","hr":"Danska","fa":"دانمارک"},"flag":"https://restcountries.eu/data/dnk.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"DEN"} +{"name":"Djibouti","topLevelDomain":[".dj"],"alpha2Code":"DJ","alpha3Code":"DJI","callingCodes":["253"],"capital":"Djibouti","altSpellings":["DJ","Jabuuti","Gabuuti","Republic of Djibouti","République de Djibouti","Gabuutih Ummuuno","Jamhuuriyadda Jabuuti"],"region":"Africa","subregion":"Eastern Africa","population":900000,"latlng":[11.5,43.0],"demonym":"Djibouti","area":23200.0,"gini":40.0,"timezones":["UTC+03:00"],"borders":["ERI","ETH","SOM"],"nativeName":"Djibouti","numericCode":"262","currencies":[{"code":"DJF","name":"Djiboutian franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Dschibuti","es":"Yibuti","fr":"Djibouti","ja":"ジブチ","it":"Gibuti","br":"Djibuti","pt":"Djibuti","nl":"Djibouti","hr":"Džibuti","fa":"جیبوتی"},"flag":"https://restcountries.eu/data/dji.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"DJI"} +{"name":"Dominica","topLevelDomain":[".dm"],"alpha2Code":"DM","alpha3Code":"DMA","callingCodes":["1767"],"capital":"Roseau","altSpellings":["DM","Dominique","Wai‘tu kubuli","Commonwealth of Dominica"],"region":"Americas","subregion":"Caribbean","population":71293,"latlng":[15.41666666,-61.33333333],"demonym":"Dominican","area":751.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Dominica","numericCode":"212","currencies":[{"code":"XCD","name":"East Caribbean dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Dominica","es":"Dominica","fr":"Dominique","ja":"ドミニカ国","it":"Dominica","br":"Dominica","pt":"Dominica","nl":"Dominica","hr":"Dominika","fa":"دومینیکا"},"flag":"https://restcountries.eu/data/dma.svg","regionalBlocs":[],"cioc":"DMA"} +{"name":"Dominican Republic","topLevelDomain":[".do"],"alpha2Code":"DO","alpha3Code":"DOM","callingCodes":["1809","1829","1849"],"capital":"Santo Domingo","altSpellings":["DO"],"region":"Americas","subregion":"Caribbean","population":10075045,"latlng":[19.0,-70.66666666],"demonym":"Dominican","area":48671.0,"gini":47.2,"timezones":["UTC-04:00"],"borders":["HTI"],"nativeName":"República Dominicana","numericCode":"214","currencies":[{"code":"DOP","name":"Dominican peso","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Dominikanische Republik","es":"República Dominicana","fr":"République dominicaine","ja":"ドミニカ共和国","it":"Repubblica Dominicana","br":"República Dominicana","pt":"República Dominicana","nl":"Dominicaanse Republiek","hr":"Dominikanska Republika","fa":"جمهوری دومینیکن"},"flag":"https://restcountries.eu/data/dom.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]},{"acronym":"CAIS","name":"Central American Integration System","otherAcronyms":["SICA"],"otherNames":["Sistema de la Integración Centroamericana,"]}],"cioc":"DOM"} +{"name":"Ecuador","topLevelDomain":[".ec"],"alpha2Code":"EC","alpha3Code":"ECU","callingCodes":["593"],"capital":"Quito","altSpellings":["EC","Republic of Ecuador","República del Ecuador"],"region":"Americas","subregion":"South America","population":16545799,"latlng":[-2.0,-77.5],"demonym":"Ecuadorean","area":276841.0,"gini":49.3,"timezones":["UTC-06:00","UTC-05:00"],"borders":["COL","PER"],"nativeName":"Ecuador","numericCode":"218","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Ecuador","es":"Ecuador","fr":"Équateur","ja":"エクアドル","it":"Ecuador","br":"Equador","pt":"Equador","nl":"Ecuador","hr":"Ekvador","fa":"اکوادور"},"flag":"https://restcountries.eu/data/ecu.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"ECU"} +{"name":"Egypt","topLevelDomain":[".eg"],"alpha2Code":"EG","alpha3Code":"EGY","callingCodes":["20"],"capital":"Cairo","altSpellings":["EG","Arab Republic of Egypt"],"region":"Africa","subregion":"Northern Africa","population":91290000,"latlng":[27.0,30.0],"demonym":"Egyptian","area":1002450.0,"gini":30.8,"timezones":["UTC+02:00"],"borders":["ISR","LBY","SDN"],"nativeName":"مصر‎","numericCode":"818","currencies":[{"code":"EGP","name":"Egyptian pound","symbol":"£"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Ägypten","es":"Egipto","fr":"Égypte","ja":"エジプト","it":"Egitto","br":"Egito","pt":"Egipto","nl":"Egypte","hr":"Egipat","fa":"مصر"},"flag":"https://restcountries.eu/data/egy.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"EGY"} +{"name":"El Salvador","topLevelDomain":[".sv"],"alpha2Code":"SV","alpha3Code":"SLV","callingCodes":["503"],"capital":"San Salvador","altSpellings":["SV","Republic of El Salvador","República de El Salvador"],"region":"Americas","subregion":"Central America","population":6520675,"latlng":[13.83333333,-88.91666666],"demonym":"Salvadoran","area":21041.0,"gini":48.3,"timezones":["UTC-06:00"],"borders":["GTM","HND"],"nativeName":"El Salvador","numericCode":"222","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"El Salvador","es":"El Salvador","fr":"Salvador","ja":"エルサルバドル","it":"El Salvador","br":"El Salvador","pt":"El Salvador","nl":"El Salvador","hr":"Salvador","fa":"السالوادور"},"flag":"https://restcountries.eu/data/slv.svg","regionalBlocs":[{"acronym":"CAIS","name":"Central American Integration System","otherAcronyms":["SICA"],"otherNames":["Sistema de la Integración Centroamericana,"]}],"cioc":"ESA"} +{"name":"Equatorial Guinea","topLevelDomain":[".gq"],"alpha2Code":"GQ","alpha3Code":"GNQ","callingCodes":["240"],"capital":"Malabo","altSpellings":["GQ","Republic of Equatorial Guinea","República de Guinea Ecuatorial","République de Guinée équatoriale","República da Guiné Equatorial"],"region":"Africa","subregion":"Middle Africa","population":1222442,"latlng":[2.0,10.0],"demonym":"Equatorial Guinean","area":28051.0,"gini":null,"timezones":["UTC+01:00"],"borders":["CMR","GAB"],"nativeName":"Guinea Ecuatorial","numericCode":"226","currencies":[{"code":"XAF","name":"Central African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Äquatorial-Guinea","es":"Guinea Ecuatorial","fr":"Guinée-Équatoriale","ja":"赤道ギニア","it":"Guinea Equatoriale","br":"Guiné Equatorial","pt":"Guiné Equatorial","nl":"Equatoriaal-Guinea","hr":"Ekvatorijalna Gvineja","fa":"گینه استوایی"},"flag":"https://restcountries.eu/data/gnq.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"GEQ"} +{"name":"Eritrea","topLevelDomain":[".er"],"alpha2Code":"ER","alpha3Code":"ERI","callingCodes":["291"],"capital":"Asmara","altSpellings":["ER","State of Eritrea","ሃገረ ኤርትራ","Dawlat Iritriyá","ʾErtrā","Iritriyā",""],"region":"Africa","subregion":"Eastern Africa","population":5352000,"latlng":[15.0,39.0],"demonym":"Eritrean","area":117600.0,"gini":null,"timezones":["UTC+03:00"],"borders":["DJI","ETH","SDN"],"nativeName":"ኤርትራ","numericCode":"232","currencies":[{"code":"ERN","name":"Eritrean nakfa","symbol":"Nfk"}],"languages":[{"iso639_1":"ti","iso639_2":"tir","name":"Tigrinya","nativeName":"ትግርኛ"},{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Eritrea","es":"Eritrea","fr":"Érythrée","ja":"エリトリア","it":"Eritrea","br":"Eritreia","pt":"Eritreia","nl":"Eritrea","hr":"Eritreja","fa":"اریتره"},"flag":"https://restcountries.eu/data/eri.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"ERI"} +{"name":"Estonia","topLevelDomain":[".ee"],"alpha2Code":"EE","alpha3Code":"EST","callingCodes":["372"],"capital":"Tallinn","altSpellings":["EE","Eesti","Republic of Estonia","Eesti Vabariik"],"region":"Europe","subregion":"Northern Europe","population":1315944,"latlng":[59.0,26.0],"demonym":"Estonian","area":45227.0,"gini":36.0,"timezones":["UTC+02:00"],"borders":["LVA","RUS"],"nativeName":"Eesti","numericCode":"233","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"et","iso639_2":"est","name":"Estonian","nativeName":"eesti"}],"translations":{"de":"Estland","es":"Estonia","fr":"Estonie","ja":"エストニア","it":"Estonia","br":"Estônia","pt":"Estónia","nl":"Estland","hr":"Estonija","fa":"استونی"},"flag":"https://restcountries.eu/data/est.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"EST"} +{"name":"Ethiopia","topLevelDomain":[".et"],"alpha2Code":"ET","alpha3Code":"ETH","callingCodes":["251"],"capital":"Addis Ababa","altSpellings":["ET","ʾĪtyōṗṗyā","Federal Democratic Republic of Ethiopia","የኢትዮጵያ ፌዴራላዊ ዲሞክራሲያዊ ሪፐብሊክ"],"region":"Africa","subregion":"Eastern Africa","population":92206005,"latlng":[8.0,38.0],"demonym":"Ethiopian","area":1104300.0,"gini":29.8,"timezones":["UTC+03:00"],"borders":["DJI","ERI","KEN","SOM","SSD","SDN"],"nativeName":"ኢትዮጵያ","numericCode":"231","currencies":[{"code":"ETB","name":"Ethiopian birr","symbol":"Br"}],"languages":[{"iso639_1":"am","iso639_2":"amh","name":"Amharic","nativeName":"አማርኛ"}],"translations":{"de":"Äthiopien","es":"Etiopía","fr":"Éthiopie","ja":"エチオピア","it":"Etiopia","br":"Etiópia","pt":"Etiópia","nl":"Ethiopië","hr":"Etiopija","fa":"اتیوپی"},"flag":"https://restcountries.eu/data/eth.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"ETH"} +{"name":"Falkland Islands (Malvinas)","topLevelDomain":[".fk"],"alpha2Code":"FK","alpha3Code":"FLK","callingCodes":["500"],"capital":"Stanley","altSpellings":["FK","Islas Malvinas"],"region":"Americas","subregion":"South America","population":2563,"latlng":[-51.75,-59.0],"demonym":"Falkland Islander","area":12173.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Falkland Islands","numericCode":"238","currencies":[{"code":"FKP","name":"Falkland Islands pound","symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Falklandinseln","es":"Islas Malvinas","fr":"Îles Malouines","ja":"フォークランド(マルビナス)諸島","it":"Isole Falkland o Isole Malvine","br":"Ilhas Malvinas","pt":"Ilhas Falkland","nl":"Falklandeilanden [Islas Malvinas]","hr":"Falklandski Otoci","fa":"جزایر فالکلند"},"flag":"https://restcountries.eu/data/flk.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":""} +{"name":"Faroe Islands","topLevelDomain":[".fo"],"alpha2Code":"FO","alpha3Code":"FRO","callingCodes":["298"],"capital":"Tórshavn","altSpellings":["FO","Føroyar","Færøerne"],"region":"Europe","subregion":"Northern Europe","population":49376,"latlng":[62.0,-7.0],"demonym":"Faroese","area":1393.0,"gini":null,"timezones":["UTC+00:00"],"borders":[],"nativeName":"Føroyar","numericCode":"234","currencies":[{"code":"DKK","name":"Danish krone","symbol":"kr"},{"code":"(none)","name":"Faroese króna","symbol":"kr"}],"languages":[{"iso639_1":"fo","iso639_2":"fao","name":"Faroese","nativeName":"føroyskt"}],"translations":{"de":"Färöer-Inseln","es":"Islas Faroe","fr":"Îles Féroé","ja":"フェロー諸島","it":"Isole Far Oer","br":"Ilhas Faroé","pt":"Ilhas Faroé","nl":"Faeröer","hr":"Farski Otoci","fa":"جزایر فارو"},"flag":"https://restcountries.eu/data/fro.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":""} +{"name":"Fiji","topLevelDomain":[".fj"],"alpha2Code":"FJ","alpha3Code":"FJI","callingCodes":["679"],"capital":"Suva","altSpellings":["FJ","Viti","Republic of Fiji","Matanitu ko Viti","Fijī Gaṇarājya"],"region":"Oceania","subregion":"Melanesia","population":867000,"latlng":[-18.0,175.0],"demonym":"Fijian","area":18272.0,"gini":42.8,"timezones":["UTC+12:00"],"borders":[],"nativeName":"Fiji","numericCode":"242","currencies":[{"code":"FJD","name":"Fijian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"fj","iso639_2":"fij","name":"Fijian","nativeName":"vosa Vakaviti"},{"iso639_1":"hi","iso639_2":"hin","name":"Hindi","nativeName":"हिन्दी"},{"iso639_1":"ur","iso639_2":"urd","name":"Urdu","nativeName":"اردو"}],"translations":{"de":"Fidschi","es":"Fiyi","fr":"Fidji","ja":"フィジー","it":"Figi","br":"Fiji","pt":"Fiji","nl":"Fiji","hr":"Fiđi","fa":"فیجی"},"flag":"https://restcountries.eu/data/fji.svg","regionalBlocs":[],"cioc":"FIJ"} +{"name":"Finland","topLevelDomain":[".fi"],"alpha2Code":"FI","alpha3Code":"FIN","callingCodes":["358"],"capital":"Helsinki","altSpellings":["FI","Suomi","Republic of Finland","Suomen tasavalta","Republiken Finland"],"region":"Europe","subregion":"Northern Europe","population":5491817,"latlng":[64.0,26.0],"demonym":"Finnish","area":338424.0,"gini":26.9,"timezones":["UTC+02:00"],"borders":["NOR","SWE","RUS"],"nativeName":"Suomi","numericCode":"246","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fi","iso639_2":"fin","name":"Finnish","nativeName":"suomi"},{"iso639_1":"sv","iso639_2":"swe","name":"Swedish","nativeName":"svenska"}],"translations":{"de":"Finnland","es":"Finlandia","fr":"Finlande","ja":"フィンランド","it":"Finlandia","br":"Finlândia","pt":"Finlândia","nl":"Finland","hr":"Finska","fa":"فنلاند"},"flag":"https://restcountries.eu/data/fin.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"FIN"} +{"name":"France","topLevelDomain":[".fr"],"alpha2Code":"FR","alpha3Code":"FRA","callingCodes":["33"],"capital":"Paris","altSpellings":["FR","French Republic","République française"],"region":"Europe","subregion":"Western Europe","population":66710000,"latlng":[46.0,2.0],"demonym":"French","area":640679.0,"gini":32.7,"timezones":["UTC-10:00","UTC-09:30","UTC-09:00","UTC-08:00","UTC-04:00","UTC-03:00","UTC+01:00","UTC+03:00","UTC+04:00","UTC+05:00","UTC+11:00","UTC+12:00"],"borders":["AND","BEL","DEU","ITA","LUX","MCO","ESP","CHE"],"nativeName":"France","numericCode":"250","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Frankreich","es":"Francia","fr":"France","ja":"フランス","it":"Francia","br":"França","pt":"França","nl":"Frankrijk","hr":"Francuska","fa":"فرانسه"},"flag":"https://restcountries.eu/data/fra.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"FRA"} +{"name":"French Guiana","topLevelDomain":[".gf"],"alpha2Code":"GF","alpha3Code":"GUF","callingCodes":["594"],"capital":"Cayenne","altSpellings":["GF","Guiana","Guyane"],"region":"Americas","subregion":"South America","population":254541,"latlng":[4.0,-53.0],"demonym":"","area":null,"gini":null,"timezones":["UTC-03:00"],"borders":["BRA","SUR"],"nativeName":"Guyane française","numericCode":"254","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Französisch Guyana","es":"Guayana Francesa","fr":"Guayane","ja":"フランス領ギアナ","it":"Guyana francese","br":"Guiana Francesa","pt":"Guiana Francesa","nl":"Frans-Guyana","hr":"Francuska Gvajana","fa":"گویان فرانسه"},"flag":"https://restcountries.eu/data/guf.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]},{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":""} +{"name":"French Polynesia","topLevelDomain":[".pf"],"alpha2Code":"PF","alpha3Code":"PYF","callingCodes":["689"],"capital":"Papeetē","altSpellings":["PF","Polynésie française","French Polynesia","Pōrīnetia Farāni"],"region":"Oceania","subregion":"Polynesia","population":271800,"latlng":[-15.0,-140.0],"demonym":"French Polynesian","area":4167.0,"gini":null,"timezones":["UTC-10:00","UTC-09:30","UTC-09:00"],"borders":[],"nativeName":"Polynésie française","numericCode":"258","currencies":[{"code":"XPF","name":"CFP franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Französisch-Polynesien","es":"Polinesia Francesa","fr":"Polynésie française","ja":"フランス領ポリネシア","it":"Polinesia Francese","br":"Polinésia Francesa","pt":"Polinésia Francesa","nl":"Frans-Polynesië","hr":"Francuska Polinezija","fa":"پلی‌نزی فرانسه"},"flag":"https://restcountries.eu/data/pyf.svg","regionalBlocs":[],"cioc":""} +{"name":"French Southern Territories","topLevelDomain":[".tf"],"alpha2Code":"TF","alpha3Code":"ATF","callingCodes":[""],"capital":"Port-aux-Français","altSpellings":["TF"],"region":"Africa","subregion":"Southern Africa","population":140,"latlng":[-49.25,69.167],"demonym":"French","area":7747.0,"gini":null,"timezones":["UTC+05:00"],"borders":[],"nativeName":"Territoire des Terres australes et antarctiques françaises","numericCode":"260","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Französische Süd- und Antarktisgebiete","es":"Tierras Australes y Antárticas Francesas","fr":"Terres australes et antarctiques françaises","ja":"フランス領南方・南極地域","it":"Territori Francesi del Sud","br":"Terras Austrais e Antárticas Francesas","pt":"Terras Austrais e Antárticas Francesas","nl":"Franse Gebieden in de zuidelijke Indische Oceaan","hr":"Francuski južni i antarktički teritoriji","fa":"سرزمین‌های جنوبی و جنوبگانی فرانسه"},"flag":"https://restcountries.eu/data/atf.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":""} +{"name":"Gabon","topLevelDomain":[".ga"],"alpha2Code":"GA","alpha3Code":"GAB","callingCodes":["241"],"capital":"Libreville","altSpellings":["GA","Gabonese Republic","République Gabonaise"],"region":"Africa","subregion":"Middle Africa","population":1802278,"latlng":[-1.0,11.75],"demonym":"Gabonese","area":267668.0,"gini":41.5,"timezones":["UTC+01:00"],"borders":["CMR","COG","GNQ"],"nativeName":"Gabon","numericCode":"266","currencies":[{"code":"XAF","name":"Central African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Gabun","es":"Gabón","fr":"Gabon","ja":"ガボン","it":"Gabon","br":"Gabão","pt":"Gabão","nl":"Gabon","hr":"Gabon","fa":"گابن"},"flag":"https://restcountries.eu/data/gab.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"GAB"} +{"name":"Gambia","topLevelDomain":[".gm"],"alpha2Code":"GM","alpha3Code":"GMB","callingCodes":["220"],"capital":"Banjul","altSpellings":["GM","Republic of the Gambia"],"region":"Africa","subregion":"Western Africa","population":1882450,"latlng":[13.46666666,-16.56666666],"demonym":"Gambian","area":11295.0,"gini":null,"timezones":["UTC+00:00"],"borders":["SEN"],"nativeName":"Gambia","numericCode":"270","currencies":[{"code":"GMD","name":"Gambian dalasi","symbol":"D"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Gambia","es":"Gambia","fr":"Gambie","ja":"ガンビア","it":"Gambia","br":"Gâmbia","pt":"Gâmbia","nl":"Gambia","hr":"Gambija","fa":"گامبیا"},"flag":"https://restcountries.eu/data/gmb.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"GAM"} +{"name":"Georgia","topLevelDomain":[".ge"],"alpha2Code":"GE","alpha3Code":"GEO","callingCodes":["995"],"capital":"Tbilisi","altSpellings":["GE","Sakartvelo"],"region":"Asia","subregion":"Western Asia","population":3720400,"latlng":[42.0,43.5],"demonym":"Georgian","area":69700.0,"gini":41.3,"timezones":["UTC-05:00"],"borders":["ARM","AZE","RUS","TUR"],"nativeName":"საქართველო","numericCode":"268","currencies":[{"code":"GEL","name":"Georgian Lari","symbol":"ლ"}],"languages":[{"iso639_1":"ka","iso639_2":"kat","name":"Georgian","nativeName":"ქართული"}],"translations":{"de":"Georgien","es":"Georgia","fr":"Géorgie","ja":"グルジア","it":"Georgia","br":"Geórgia","pt":"Geórgia","nl":"Georgië","hr":"Gruzija","fa":"گرجستان"},"flag":"https://restcountries.eu/data/geo.svg","regionalBlocs":[],"cioc":"GEO"} +{"name":"Germany","topLevelDomain":[".de"],"alpha2Code":"DE","alpha3Code":"DEU","callingCodes":["49"],"capital":"Berlin","altSpellings":["DE","Federal Republic of Germany","Bundesrepublik Deutschland"],"region":"Europe","subregion":"Western Europe","population":81770900,"latlng":[51.0,9.0],"demonym":"German","area":357114.0,"gini":28.3,"timezones":["UTC+01:00"],"borders":["AUT","BEL","CZE","DNK","FRA","LUX","NLD","POL","CHE"],"nativeName":"Deutschland","numericCode":"276","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"de","iso639_2":"deu","name":"German","nativeName":"Deutsch"}],"translations":{"de":"Deutschland","es":"Alemania","fr":"Allemagne","ja":"ドイツ","it":"Germania","br":"Alemanha","pt":"Alemanha","nl":"Duitsland","hr":"Njemačka","fa":"آلمان"},"flag":"https://restcountries.eu/data/deu.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"GER"} +{"name":"Ghana","topLevelDomain":[".gh"],"alpha2Code":"GH","alpha3Code":"GHA","callingCodes":["233"],"capital":"Accra","altSpellings":["GH"],"region":"Africa","subregion":"Western Africa","population":27670174,"latlng":[8.0,-2.0],"demonym":"Ghanaian","area":238533.0,"gini":42.8,"timezones":["UTC"],"borders":["BFA","CIV","TGO"],"nativeName":"Ghana","numericCode":"288","currencies":[{"code":"GHS","name":"Ghanaian cedi","symbol":"₵"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Ghana","es":"Ghana","fr":"Ghana","ja":"ガーナ","it":"Ghana","br":"Gana","pt":"Gana","nl":"Ghana","hr":"Gana","fa":"غنا"},"flag":"https://restcountries.eu/data/gha.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"GHA"} +{"name":"Gibraltar","topLevelDomain":[".gi"],"alpha2Code":"GI","alpha3Code":"GIB","callingCodes":["350"],"capital":"Gibraltar","altSpellings":["GI"],"region":"Europe","subregion":"Southern Europe","population":33140,"latlng":[36.13333333,-5.35],"demonym":"Gibraltar","area":6.0,"gini":null,"timezones":["UTC+01:00"],"borders":["ESP"],"nativeName":"Gibraltar","numericCode":"292","currencies":[{"code":"GIP","name":"Gibraltar pound","symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Gibraltar","es":"Gibraltar","fr":"Gibraltar","ja":"ジブラルタル","it":"Gibilterra","br":"Gibraltar","pt":"Gibraltar","nl":"Gibraltar","hr":"Gibraltar","fa":"جبل‌طارق"},"flag":"https://restcountries.eu/data/gib.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":""} +{"name":"Greece","topLevelDomain":[".gr"],"alpha2Code":"GR","alpha3Code":"GRC","callingCodes":["30"],"capital":"Athens","altSpellings":["GR","Elláda","Hellenic Republic","Ελληνική Δημοκρατία"],"region":"Europe","subregion":"Southern Europe","population":10858018,"latlng":[39.0,22.0],"demonym":"Greek","area":131990.0,"gini":34.3,"timezones":["UTC+02:00"],"borders":["ALB","BGR","TUR","MKD"],"nativeName":"Ελλάδα","numericCode":"300","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"el","iso639_2":"ell","name":"Greek (modern)","nativeName":"ελληνικά"}],"translations":{"de":"Griechenland","es":"Grecia","fr":"Grèce","ja":"ギリシャ","it":"Grecia","br":"Grécia","pt":"Grécia","nl":"Griekenland","hr":"Grčka","fa":"یونان"},"flag":"https://restcountries.eu/data/grc.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"GRE"} +{"name":"Greenland","topLevelDomain":[".gl"],"alpha2Code":"GL","alpha3Code":"GRL","callingCodes":["299"],"capital":"Nuuk","altSpellings":["GL","Grønland"],"region":"Americas","subregion":"Northern America","population":55847,"latlng":[72.0,-40.0],"demonym":"Greenlandic","area":2166086.0,"gini":null,"timezones":["UTC-04:00","UTC-03:00","UTC-01:00","UTC+00:00"],"borders":[],"nativeName":"Kalaallit Nunaat","numericCode":"304","currencies":[{"code":"DKK","name":"Danish krone","symbol":"kr"}],"languages":[{"iso639_1":"kl","iso639_2":"kal","name":"Kalaallisut","nativeName":"kalaallisut"}],"translations":{"de":"Grönland","es":"Groenlandia","fr":"Groenland","ja":"グリーンランド","it":"Groenlandia","br":"Groelândia","pt":"Gronelândia","nl":"Groenland","hr":"Grenland","fa":"گرینلند"},"flag":"https://restcountries.eu/data/grl.svg","regionalBlocs":[],"cioc":""} +{"name":"Grenada","topLevelDomain":[".gd"],"alpha2Code":"GD","alpha3Code":"GRD","callingCodes":["1473"],"capital":"St. George's","altSpellings":["GD"],"region":"Americas","subregion":"Caribbean","population":103328,"latlng":[12.11666666,-61.66666666],"demonym":"Grenadian","area":344.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Grenada","numericCode":"308","currencies":[{"code":"XCD","name":"East Caribbean dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Grenada","es":"Grenada","fr":"Grenade","ja":"グレナダ","it":"Grenada","br":"Granada","pt":"Granada","nl":"Grenada","hr":"Grenada","fa":"گرنادا"},"flag":"https://restcountries.eu/data/grd.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"GRN"} +{"name":"Guadeloupe","topLevelDomain":[".gp"],"alpha2Code":"GP","alpha3Code":"GLP","callingCodes":["590"],"capital":"Basse-Terre","altSpellings":["GP","Gwadloup"],"region":"Americas","subregion":"Caribbean","population":400132,"latlng":[16.25,-61.583333],"demonym":"Guadeloupian","area":null,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Guadeloupe","numericCode":"312","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Guadeloupe","es":"Guadalupe","fr":"Guadeloupe","ja":"グアドループ","it":"Guadeloupa","br":"Guadalupe","pt":"Guadalupe","nl":"Guadeloupe","hr":"Gvadalupa","fa":"جزیره گوادلوپ"},"flag":"https://restcountries.eu/data/glp.svg","regionalBlocs":[],"cioc":""} +{"name":"Guam","topLevelDomain":[".gu"],"alpha2Code":"GU","alpha3Code":"GUM","callingCodes":["1671"],"capital":"Hagåtña","altSpellings":["GU","Guåhån"],"region":"Oceania","subregion":"Micronesia","population":184200,"latlng":[13.46666666,144.78333333],"demonym":"Guamanian","area":549.0,"gini":null,"timezones":["UTC+10:00"],"borders":[],"nativeName":"Guam","numericCode":"316","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"ch","iso639_2":"cha","name":"Chamorro","nativeName":"Chamoru"},{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Guam","es":"Guam","fr":"Guam","ja":"グアム","it":"Guam","br":"Guam","pt":"Guame","nl":"Guam","hr":"Guam","fa":"گوام"},"flag":"https://restcountries.eu/data/gum.svg","regionalBlocs":[],"cioc":"GUM"} +{"name":"Guatemala","topLevelDomain":[".gt"],"alpha2Code":"GT","alpha3Code":"GTM","callingCodes":["502"],"capital":"Guatemala City","altSpellings":["GT"],"region":"Americas","subregion":"Central America","population":16176133,"latlng":[15.5,-90.25],"demonym":"Guatemalan","area":108889.0,"gini":55.9,"timezones":["UTC-06:00"],"borders":["BLZ","SLV","HND","MEX"],"nativeName":"Guatemala","numericCode":"320","currencies":[{"code":"GTQ","name":"Guatemalan quetzal","symbol":"Q"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Guatemala","es":"Guatemala","fr":"Guatemala","ja":"グアテマラ","it":"Guatemala","br":"Guatemala","pt":"Guatemala","nl":"Guatemala","hr":"Gvatemala","fa":"گواتمالا"},"flag":"https://restcountries.eu/data/gtm.svg","regionalBlocs":[{"acronym":"CAIS","name":"Central American Integration System","otherAcronyms":["SICA"],"otherNames":["Sistema de la Integración Centroamericana,"]}],"cioc":"GUA"} +{"name":"Guernsey","topLevelDomain":[".gg"],"alpha2Code":"GG","alpha3Code":"GGY","callingCodes":["44"],"capital":"St. Peter Port","altSpellings":["GG","Bailiwick of Guernsey","Bailliage de Guernesey"],"region":"Europe","subregion":"Northern Europe","population":62999,"latlng":[49.46666666,-2.58333333],"demonym":"Channel Islander","area":78.0,"gini":null,"timezones":["UTC+00:00"],"borders":[],"nativeName":"Guernsey","numericCode":"831","currencies":[{"code":"GBP","name":"British pound","symbol":"£"},{"code":"(none)","name":"Guernsey pound","symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Guernsey","es":"Guernsey","fr":"Guernesey","ja":"ガーンジー","it":"Guernsey","br":"Guernsey","pt":"Guernsey","nl":"Guernsey","hr":"Guernsey","fa":"گرنزی"},"flag":"https://restcountries.eu/data/ggy.svg","regionalBlocs":[],"cioc":""} +{"name":"Guinea","topLevelDomain":[".gn"],"alpha2Code":"GN","alpha3Code":"GIN","callingCodes":["224"],"capital":"Conakry","altSpellings":["GN","Republic of Guinea","République de Guinée"],"region":"Africa","subregion":"Western Africa","population":12947000,"latlng":[11.0,-10.0],"demonym":"Guinean","area":245857.0,"gini":39.4,"timezones":["UTC"],"borders":["CIV","GNB","LBR","MLI","SEN","SLE"],"nativeName":"Guinée","numericCode":"324","currencies":[{"code":"GNF","name":"Guinean franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"ff","iso639_2":"ful","name":"Fula","nativeName":"Fulfulde"}],"translations":{"de":"Guinea","es":"Guinea","fr":"Guinée","ja":"ギニア","it":"Guinea","br":"Guiné","pt":"Guiné","nl":"Guinee","hr":"Gvineja","fa":"گینه"},"flag":"https://restcountries.eu/data/gin.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"GUI"} +{"name":"Guinea-Bissau","topLevelDomain":[".gw"],"alpha2Code":"GW","alpha3Code":"GNB","callingCodes":["245"],"capital":"Bissau","altSpellings":["GW","Republic of Guinea-Bissau","República da Guiné-Bissau"],"region":"Africa","subregion":"Western Africa","population":1547777,"latlng":[12.0,-15.0],"demonym":"Guinea-Bissauan","area":36125.0,"gini":35.5,"timezones":["UTC"],"borders":["GIN","SEN"],"nativeName":"Guiné-Bissau","numericCode":"624","currencies":[{"code":"XOF","name":"West African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"pt","iso639_2":"por","name":"Portuguese","nativeName":"Português"}],"translations":{"de":"Guinea-Bissau","es":"Guinea-Bisáu","fr":"Guinée-Bissau","ja":"ギニアビサウ","it":"Guinea-Bissau","br":"Guiné-Bissau","pt":"Guiné-Bissau","nl":"Guinee-Bissau","hr":"Gvineja Bisau","fa":"گینه بیسائو"},"flag":"https://restcountries.eu/data/gnb.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"GBS"} +{"name":"Guyana","topLevelDomain":[".gy"],"alpha2Code":"GY","alpha3Code":"GUY","callingCodes":["592"],"capital":"Georgetown","altSpellings":["GY","Co-operative Republic of Guyana"],"region":"Americas","subregion":"South America","population":746900,"latlng":[5.0,-59.0],"demonym":"Guyanese","area":214969.0,"gini":44.5,"timezones":["UTC-04:00"],"borders":["BRA","SUR","VEN"],"nativeName":"Guyana","numericCode":"328","currencies":[{"code":"GYD","name":"Guyanese dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Guyana","es":"Guyana","fr":"Guyane","ja":"ガイアナ","it":"Guyana","br":"Guiana","pt":"Guiana","nl":"Guyana","hr":"Gvajana","fa":"گویان"},"flag":"https://restcountries.eu/data/guy.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]},{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"GUY"} +{"name":"Haiti","topLevelDomain":[".ht"],"alpha2Code":"HT","alpha3Code":"HTI","callingCodes":["509"],"capital":"Port-au-Prince","altSpellings":["HT","Republic of Haiti","République d'Haïti","Repiblik Ayiti"],"region":"Americas","subregion":"Caribbean","population":11078033,"latlng":[19.0,-72.41666666],"demonym":"Haitian","area":27750.0,"gini":59.2,"timezones":["UTC-05:00"],"borders":["DOM"],"nativeName":"Haïti","numericCode":"332","currencies":[{"code":"HTG","name":"Haitian gourde","symbol":"G"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"ht","iso639_2":"hat","name":"Haitian","nativeName":"Kreyòl ayisyen"}],"translations":{"de":"Haiti","es":"Haiti","fr":"Haïti","ja":"ハイチ","it":"Haiti","br":"Haiti","pt":"Haiti","nl":"Haïti","hr":"Haiti","fa":"هائیتی"},"flag":"https://restcountries.eu/data/hti.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"HAI"} +{"name":"Heard Island and McDonald Islands","topLevelDomain":[".hm",".aq"],"alpha2Code":"HM","alpha3Code":"HMD","callingCodes":[""],"capital":"","altSpellings":["HM"],"region":"","subregion":"","population":0,"latlng":[-53.1,72.51666666],"demonym":"Heard and McDonald Islander","area":412.0,"gini":null,"timezones":["UTC+05:00"],"borders":[],"nativeName":"Heard Island and McDonald Islands","numericCode":"334","currencies":[{"code":"AUD","name":"Australian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Heard und die McDonaldinseln","es":"Islas Heard y McDonald","fr":"Îles Heard-et-MacDonald","ja":"ハード島とマクドナルド諸島","it":"Isole Heard e McDonald","br":"Ilha Heard e Ilhas McDonald","pt":"Ilha Heard e Ilhas McDonald","nl":"Heard- en McDonaldeilanden","hr":"Otok Heard i otočje McDonald","fa":"جزیره هرد و جزایر مک‌دونالد"},"flag":"https://restcountries.eu/data/hmd.svg","regionalBlocs":[],"cioc":""} +{"name":"Holy See","topLevelDomain":[".va"],"alpha2Code":"VA","alpha3Code":"VAT","callingCodes":["379"],"capital":"Rome","altSpellings":["Sancta Sedes","Vatican","The Vatican"],"region":"Europe","subregion":"Southern Europe","population":451,"latlng":[41.9,12.45],"demonym":"","area":0.44,"gini":null,"timezones":["UTC+01:00"],"borders":["ITA"],"nativeName":"Sancta Sedes","numericCode":"336","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"la","iso639_2":"lat","name":"Latin","nativeName":"latine"},{"iso639_1":"it","iso639_2":"ita","name":"Italian","nativeName":"Italiano"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"de","iso639_2":"deu","name":"German","nativeName":"Deutsch"}],"translations":{"de":"Heiliger Stuhl","es":"Santa Sede","fr":"voir Saint","ja":"聖座","it":"Santa Sede","br":"Vaticano","pt":"Vaticano","nl":"Heilige Stoel","hr":"Sveta Stolica","fa":"سریر مقدس"},"flag":"https://restcountries.eu/data/vat.svg","regionalBlocs":[],"cioc":""} +{"name":"Honduras","topLevelDomain":[".hn"],"alpha2Code":"HN","alpha3Code":"HND","callingCodes":["504"],"capital":"Tegucigalpa","altSpellings":["HN","Republic of Honduras","República de Honduras"],"region":"Americas","subregion":"Central America","population":8576532,"latlng":[15.0,-86.5],"demonym":"Honduran","area":112492.0,"gini":57.0,"timezones":["UTC-06:00"],"borders":["GTM","SLV","NIC"],"nativeName":"Honduras","numericCode":"340","currencies":[{"code":"HNL","name":"Honduran lempira","symbol":"L"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Honduras","es":"Honduras","fr":"Honduras","ja":"ホンジュラス","it":"Honduras","br":"Honduras","pt":"Honduras","nl":"Honduras","hr":"Honduras","fa":"هندوراس"},"flag":"https://restcountries.eu/data/hnd.svg","regionalBlocs":[{"acronym":"CAIS","name":"Central American Integration System","otherAcronyms":["SICA"],"otherNames":["Sistema de la Integración Centroamericana,"]}],"cioc":"HON"} +{"name":"Hong Kong","topLevelDomain":[".hk"],"alpha2Code":"HK","alpha3Code":"HKG","callingCodes":["852"],"capital":"City of Victoria","altSpellings":["HK","香港"],"region":"Asia","subregion":"Eastern Asia","population":7324300,"latlng":[22.25,114.16666666],"demonym":"Chinese","area":1104.0,"gini":53.3,"timezones":["UTC+08:00"],"borders":["CHN"],"nativeName":"香港","numericCode":"344","currencies":[{"code":"HKD","name":"Hong Kong dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"zh","iso639_2":"zho","name":"Chinese","nativeName":"中文 (Zhōngwén)"}],"translations":{"de":"Hong Kong","es":"Hong Kong","fr":"Hong Kong","ja":"香港","it":"Hong Kong","br":"Hong Kong","pt":"Hong Kong","nl":"Hongkong","hr":"Hong Kong","fa":"هنگ‌کنگ"},"flag":"https://restcountries.eu/data/hkg.svg","regionalBlocs":[],"cioc":"HKG"} +{"name":"Hungary","topLevelDomain":[".hu"],"alpha2Code":"HU","alpha3Code":"HUN","callingCodes":["36"],"capital":"Budapest","altSpellings":["HU"],"region":"Europe","subregion":"Eastern Europe","population":9823000,"latlng":[47.0,20.0],"demonym":"Hungarian","area":93028.0,"gini":31.2,"timezones":["UTC+01:00"],"borders":["AUT","HRV","ROU","SRB","SVK","SVN","UKR"],"nativeName":"Magyarország","numericCode":"348","currencies":[{"code":"HUF","name":"Hungarian forint","symbol":"Ft"}],"languages":[{"iso639_1":"hu","iso639_2":"hun","name":"Hungarian","nativeName":"magyar"}],"translations":{"de":"Ungarn","es":"Hungría","fr":"Hongrie","ja":"ハンガリー","it":"Ungheria","br":"Hungria","pt":"Hungria","nl":"Hongarije","hr":"Mađarska","fa":"مجارستان"},"flag":"https://restcountries.eu/data/hun.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"HUN"} +{"name":"Iceland","topLevelDomain":[".is"],"alpha2Code":"IS","alpha3Code":"ISL","callingCodes":["354"],"capital":"Reykjavík","altSpellings":["IS","Island","Republic of Iceland","Lýðveldið Ísland"],"region":"Europe","subregion":"Northern Europe","population":334300,"latlng":[65.0,-18.0],"demonym":"Icelander","area":103000.0,"gini":null,"timezones":["UTC"],"borders":[],"nativeName":"Ísland","numericCode":"352","currencies":[{"code":"ISK","name":"Icelandic króna","symbol":"kr"}],"languages":[{"iso639_1":"is","iso639_2":"isl","name":"Icelandic","nativeName":"Íslenska"}],"translations":{"de":"Island","es":"Islandia","fr":"Islande","ja":"アイスランド","it":"Islanda","br":"Islândia","pt":"Islândia","nl":"IJsland","hr":"Island","fa":"ایسلند"},"flag":"https://restcountries.eu/data/isl.svg","regionalBlocs":[{"acronym":"EFTA","name":"European Free Trade Association","otherAcronyms":[],"otherNames":[]}],"cioc":"ISL"} +{"name":"India","topLevelDomain":[".in"],"alpha2Code":"IN","alpha3Code":"IND","callingCodes":["91"],"capital":"New Delhi","altSpellings":["IN","Bhārat","Republic of India","Bharat Ganrajya"],"region":"Asia","subregion":"Southern Asia","population":1295210000,"latlng":[20.0,77.0],"demonym":"Indian","area":3287590.0,"gini":33.4,"timezones":["UTC+05:30"],"borders":["AFG","BGD","BTN","MMR","CHN","NPL","PAK","LKA"],"nativeName":"भारत","numericCode":"356","currencies":[{"code":"INR","name":"Indian rupee","symbol":"₹"}],"languages":[{"iso639_1":"hi","iso639_2":"hin","name":"Hindi","nativeName":"हिन्दी"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Indien","es":"India","fr":"Inde","ja":"インド","it":"India","br":"Índia","pt":"Índia","nl":"India","hr":"Indija","fa":"هند"},"flag":"https://restcountries.eu/data/ind.svg","regionalBlocs":[{"acronym":"SAARC","name":"South Asian Association for Regional Cooperation","otherAcronyms":[],"otherNames":[]}],"cioc":"IND"} +{"name":"Indonesia","topLevelDomain":[".id"],"alpha2Code":"ID","alpha3Code":"IDN","callingCodes":["62"],"capital":"Jakarta","altSpellings":["ID","Republic of Indonesia","Republik Indonesia"],"region":"Asia","subregion":"South-Eastern Asia","population":258705000,"latlng":[-5.0,120.0],"demonym":"Indonesian","area":1904569.0,"gini":34.0,"timezones":["UTC+07:00","UTC+08:00","UTC+09:00"],"borders":["TLS","MYS","PNG"],"nativeName":"Indonesia","numericCode":"360","currencies":[{"code":"IDR","name":"Indonesian rupiah","symbol":"Rp"}],"languages":[{"iso639_1":"id","iso639_2":"ind","name":"Indonesian","nativeName":"Bahasa Indonesia"}],"translations":{"de":"Indonesien","es":"Indonesia","fr":"Indonésie","ja":"インドネシア","it":"Indonesia","br":"Indonésia","pt":"Indonésia","nl":"Indonesië","hr":"Indonezija","fa":"اندونزی"},"flag":"https://restcountries.eu/data/idn.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"INA"} +{"name":"Côte d'Ivoire","topLevelDomain":[".ci"],"alpha2Code":"CI","alpha3Code":"CIV","callingCodes":["225"],"capital":"Yamoussoukro","altSpellings":["CI","Ivory Coast","Republic of Côte d'Ivoire","République de Côte d'Ivoire"],"region":"Africa","subregion":"Western Africa","population":22671331,"latlng":[8.0,-5.0],"demonym":"Ivorian","area":322463.0,"gini":41.5,"timezones":["UTC"],"borders":["BFA","GHA","GIN","LBR","MLI"],"nativeName":"Côte d'Ivoire","numericCode":"384","currencies":[{"code":"XOF","name":"West African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Elfenbeinküste","es":"Costa de Marfil","fr":"Côte d'Ivoire","ja":"コートジボワール","it":"Costa D'Avorio","br":"Costa do Marfim","pt":"Costa do Marfim","nl":"Ivoorkust","hr":"Obala Bjelokosti","fa":"ساحل عاج"},"flag":"https://restcountries.eu/data/civ.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"CIV"} +{"name":"Iran (Islamic Republic of)","topLevelDomain":[".ir"],"alpha2Code":"IR","alpha3Code":"IRN","callingCodes":["98"],"capital":"Tehran","altSpellings":["IR","Islamic Republic of Iran","Jomhuri-ye Eslāmi-ye Irān"],"region":"Asia","subregion":"Southern Asia","population":79369900,"latlng":[32.0,53.0],"demonym":"Iranian","area":1648195.0,"gini":38.3,"timezones":["UTC+03:30"],"borders":["AFG","ARM","AZE","IRQ","PAK","TUR","TKM"],"nativeName":"ایران","numericCode":"364","currencies":[{"code":"IRR","name":"Iranian rial","symbol":"﷼"}],"languages":[{"iso639_1":"fa","iso639_2":"fas","name":"Persian (Farsi)","nativeName":"فارسی"}],"translations":{"de":"Iran","es":"Iran","fr":"Iran","ja":"イラン・イスラム共和国","it":null,"br":"Irã","pt":"Irão","nl":"Iran","hr":"Iran","fa":"ایران"},"flag":"https://restcountries.eu/data/irn.svg","regionalBlocs":[],"cioc":"IRI"} +{"name":"Iraq","topLevelDomain":[".iq"],"alpha2Code":"IQ","alpha3Code":"IRQ","callingCodes":["964"],"capital":"Baghdad","altSpellings":["IQ","Republic of Iraq","Jumhūriyyat al-‘Irāq"],"region":"Asia","subregion":"Western Asia","population":37883543,"latlng":[33.0,44.0],"demonym":"Iraqi","area":438317.0,"gini":30.9,"timezones":["UTC+03:00"],"borders":["IRN","JOR","KWT","SAU","SYR","TUR"],"nativeName":"العراق","numericCode":"368","currencies":[{"code":"IQD","name":"Iraqi dinar","symbol":"ع.د"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"},{"iso639_1":"ku","iso639_2":"kur","name":"Kurdish","nativeName":"Kurdî"}],"translations":{"de":"Irak","es":"Irak","fr":"Irak","ja":"イラク","it":"Iraq","br":"Iraque","pt":"Iraque","nl":"Irak","hr":"Irak","fa":"عراق"},"flag":"https://restcountries.eu/data/irq.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"IRQ"} +{"name":"Ireland","topLevelDomain":[".ie"],"alpha2Code":"IE","alpha3Code":"IRL","callingCodes":["353"],"capital":"Dublin","altSpellings":["IE","Éire","Republic of Ireland","Poblacht na hÉireann"],"region":"Europe","subregion":"Northern Europe","population":6378000,"latlng":[53.0,-8.0],"demonym":"Irish","area":70273.0,"gini":34.3,"timezones":["UTC"],"borders":["GBR"],"nativeName":"Éire","numericCode":"372","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"ga","iso639_2":"gle","name":"Irish","nativeName":"Gaeilge"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Irland","es":"Irlanda","fr":"Irlande","ja":"アイルランド","it":"Irlanda","br":"Irlanda","pt":"Irlanda","nl":"Ierland","hr":"Irska","fa":"ایرلند"},"flag":"https://restcountries.eu/data/irl.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"IRL"} +{"name":"Isle of Man","topLevelDomain":[".im"],"alpha2Code":"IM","alpha3Code":"IMN","callingCodes":["44"],"capital":"Douglas","altSpellings":["IM","Ellan Vannin","Mann","Mannin"],"region":"Europe","subregion":"Northern Europe","population":84497,"latlng":[54.25,-4.5],"demonym":"Manx","area":572.0,"gini":null,"timezones":["UTC+00:00"],"borders":[],"nativeName":"Isle of Man","numericCode":"833","currencies":[{"code":"GBP","name":"British pound","symbol":"£"},{"code":"IMP[G]","name":"Manx pound","symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"gv","iso639_2":"glv","name":"Manx","nativeName":"Gaelg"}],"translations":{"de":"Insel Man","es":"Isla de Man","fr":"Île de Man","ja":"マン島","it":"Isola di Man","br":"Ilha de Man","pt":"Ilha de Man","nl":"Isle of Man","hr":"Otok Man","fa":"جزیره من"},"flag":"https://restcountries.eu/data/imn.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":""} +{"name":"Israel","topLevelDomain":[".il"],"alpha2Code":"IL","alpha3Code":"ISR","callingCodes":["972"],"capital":"Jerusalem","altSpellings":["IL","State of Israel","Medīnat Yisrā'el"],"region":"Asia","subregion":"Western Asia","population":8527400,"latlng":[31.5,34.75],"demonym":"Israeli","area":20770.0,"gini":39.2,"timezones":["UTC+02:00"],"borders":["EGY","JOR","LBN","SYR"],"nativeName":"יִשְׂרָאֵל","numericCode":"376","currencies":[{"code":"ILS","name":"Israeli new shekel","symbol":"₪"}],"languages":[{"iso639_1":"he","iso639_2":"heb","name":"Hebrew (modern)","nativeName":"עברית"},{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Israel","es":"Israel","fr":"Israël","ja":"イスラエル","it":"Israele","br":"Israel","pt":"Israel","nl":"Israël","hr":"Izrael","fa":"اسرائیل"},"flag":"https://restcountries.eu/data/isr.svg","regionalBlocs":[],"cioc":"ISR"} +{"name":"Italy","topLevelDomain":[".it"],"alpha2Code":"IT","alpha3Code":"ITA","callingCodes":["39"],"capital":"Rome","altSpellings":["IT","Italian Republic","Repubblica italiana"],"region":"Europe","subregion":"Southern Europe","population":60665551,"latlng":[42.83333333,12.83333333],"demonym":"Italian","area":301336.0,"gini":36.0,"timezones":["UTC+01:00"],"borders":["AUT","FRA","SMR","SVN","CHE","VAT"],"nativeName":"Italia","numericCode":"380","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"it","iso639_2":"ita","name":"Italian","nativeName":"Italiano"}],"translations":{"de":"Italien","es":"Italia","fr":"Italie","ja":"イタリア","it":"Italia","br":"Itália","pt":"Itália","nl":"Italië","hr":"Italija","fa":"ایتالیا"},"flag":"https://restcountries.eu/data/ita.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"ITA"} +{"name":"Jamaica","topLevelDomain":[".jm"],"alpha2Code":"JM","alpha3Code":"JAM","callingCodes":["1876"],"capital":"Kingston","altSpellings":["JM"],"region":"Americas","subregion":"Caribbean","population":2723246,"latlng":[18.25,-77.5],"demonym":"Jamaican","area":10991.0,"gini":45.5,"timezones":["UTC-05:00"],"borders":[],"nativeName":"Jamaica","numericCode":"388","currencies":[{"code":"JMD","name":"Jamaican dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Jamaika","es":"Jamaica","fr":"Jamaïque","ja":"ジャマイカ","it":"Giamaica","br":"Jamaica","pt":"Jamaica","nl":"Jamaica","hr":"Jamajka","fa":"جامائیکا"},"flag":"https://restcountries.eu/data/jam.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"JAM"} +{"name":"Japan","topLevelDomain":[".jp"],"alpha2Code":"JP","alpha3Code":"JPN","callingCodes":["81"],"capital":"Tokyo","altSpellings":["JP","Nippon","Nihon"],"region":"Asia","subregion":"Eastern Asia","population":126960000,"latlng":[36.0,138.0],"demonym":"Japanese","area":377930.0,"gini":38.1,"timezones":["UTC+09:00"],"borders":[],"nativeName":"日本","numericCode":"392","currencies":[{"code":"JPY","name":"Japanese yen","symbol":"¥"}],"languages":[{"iso639_1":"ja","iso639_2":"jpn","name":"Japanese","nativeName":"日本語 (にほんご)"}],"translations":{"de":"Japan","es":"Japón","fr":"Japon","ja":"日本","it":"Giappone","br":"Japão","pt":"Japão","nl":"Japan","hr":"Japan","fa":"ژاپن"},"flag":"https://restcountries.eu/data/jpn.svg","regionalBlocs":[],"cioc":"JPN"} +{"name":"Jersey","topLevelDomain":[".je"],"alpha2Code":"JE","alpha3Code":"JEY","callingCodes":["44"],"capital":"Saint Helier","altSpellings":["JE","Bailiwick of Jersey","Bailliage de Jersey","Bailliage dé Jèrri"],"region":"Europe","subregion":"Northern Europe","population":100800,"latlng":[49.25,-2.16666666],"demonym":"Channel Islander","area":116.0,"gini":null,"timezones":["UTC+01:00"],"borders":[],"nativeName":"Jersey","numericCode":"832","currencies":[{"code":"GBP","name":"British pound","symbol":"£"},{"code":"JEP[G]","name":"Jersey pound","symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Jersey","es":"Jersey","fr":"Jersey","ja":"ジャージー","it":"Isola di Jersey","br":"Jersey","pt":"Jersey","nl":"Jersey","hr":"Jersey","fa":"جرزی"},"flag":"https://restcountries.eu/data/jey.svg","regionalBlocs":[],"cioc":""} +{"name":"Jordan","topLevelDomain":[".jo"],"alpha2Code":"JO","alpha3Code":"JOR","callingCodes":["962"],"capital":"Amman","altSpellings":["JO","Hashemite Kingdom of Jordan","al-Mamlakah al-Urdunīyah al-Hāshimīyah"],"region":"Asia","subregion":"Western Asia","population":9531712,"latlng":[31.0,36.0],"demonym":"Jordanian","area":89342.0,"gini":35.4,"timezones":["UTC+03:00"],"borders":["IRQ","ISR","SAU","SYR"],"nativeName":"الأردن","numericCode":"400","currencies":[{"code":"JOD","name":"Jordanian dinar","symbol":"د.ا"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Jordanien","es":"Jordania","fr":"Jordanie","ja":"ヨルダン","it":"Giordania","br":"Jordânia","pt":"Jordânia","nl":"Jordanië","hr":"Jordan","fa":"اردن"},"flag":"https://restcountries.eu/data/jor.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"JOR"} +{"name":"Kazakhstan","topLevelDomain":[".kz",".қаз"],"alpha2Code":"KZ","alpha3Code":"KAZ","callingCodes":["76","77"],"capital":"Astana","altSpellings":["KZ","Qazaqstan","Казахстан","Republic of Kazakhstan","Қазақстан Республикасы","Qazaqstan Respublïkası","Республика Казахстан","Respublika Kazakhstan"],"region":"Asia","subregion":"Central Asia","population":17753200,"latlng":[48.0,68.0],"demonym":"Kazakhstani","area":2724900.0,"gini":29.0,"timezones":["UTC+05:00","UTC+06:00"],"borders":["CHN","KGZ","RUS","TKM","UZB"],"nativeName":"Қазақстан","numericCode":"398","currencies":[{"code":"KZT","name":"Kazakhstani tenge","symbol":null}],"languages":[{"iso639_1":"kk","iso639_2":"kaz","name":"Kazakh","nativeName":"қазақ тілі"},{"iso639_1":"ru","iso639_2":"rus","name":"Russian","nativeName":"Русский"}],"translations":{"de":"Kasachstan","es":"Kazajistán","fr":"Kazakhstan","ja":"カザフスタン","it":"Kazakistan","br":"Cazaquistão","pt":"Cazaquistão","nl":"Kazachstan","hr":"Kazahstan","fa":"قزاقستان"},"flag":"https://restcountries.eu/data/kaz.svg","regionalBlocs":[{"acronym":"EEU","name":"Eurasian Economic Union","otherAcronyms":["EAEU"],"otherNames":[]}],"cioc":"KAZ"} +{"name":"Kenya","topLevelDomain":[".ke"],"alpha2Code":"KE","alpha3Code":"KEN","callingCodes":["254"],"capital":"Nairobi","altSpellings":["KE","Republic of Kenya","Jamhuri ya Kenya"],"region":"Africa","subregion":"Eastern Africa","population":47251000,"latlng":[1.0,38.0],"demonym":"Kenyan","area":580367.0,"gini":47.7,"timezones":["UTC+03:00"],"borders":["ETH","SOM","SSD","TZA","UGA"],"nativeName":"Kenya","numericCode":"404","currencies":[{"code":"KES","name":"Kenyan shilling","symbol":"Sh"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"sw","iso639_2":"swa","name":"Swahili","nativeName":"Kiswahili"}],"translations":{"de":"Kenia","es":"Kenia","fr":"Kenya","ja":"ケニア","it":"Kenya","br":"Quênia","pt":"Quénia","nl":"Kenia","hr":"Kenija","fa":"کنیا"},"flag":"https://restcountries.eu/data/ken.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"KEN"} +{"name":"Kiribati","topLevelDomain":[".ki"],"alpha2Code":"KI","alpha3Code":"KIR","callingCodes":["686"],"capital":"South Tarawa","altSpellings":["KI","Republic of Kiribati","Ribaberiki Kiribati"],"region":"Oceania","subregion":"Micronesia","population":113400,"latlng":[1.41666666,173.0],"demonym":"I-Kiribati","area":811.0,"gini":null,"timezones":["UTC+12:00","UTC+13:00","UTC+14:00"],"borders":[],"nativeName":"Kiribati","numericCode":"296","currencies":[{"code":"AUD","name":"Australian dollar","symbol":"$"},{"code":"(none)","name":"Kiribati dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Kiribati","es":"Kiribati","fr":"Kiribati","ja":"キリバス","it":"Kiribati","br":"Kiribati","pt":"Quiribáti","nl":"Kiribati","hr":"Kiribati","fa":"کیریباتی"},"flag":"https://restcountries.eu/data/kir.svg","regionalBlocs":[],"cioc":"KIR"} +{"name":"Kuwait","topLevelDomain":[".kw"],"alpha2Code":"KW","alpha3Code":"KWT","callingCodes":["965"],"capital":"Kuwait City","altSpellings":["KW","State of Kuwait","Dawlat al-Kuwait"],"region":"Asia","subregion":"Western Asia","population":4183658,"latlng":[29.5,45.75],"demonym":"Kuwaiti","area":17818.0,"gini":null,"timezones":["UTC+03:00"],"borders":["IRN","SAU"],"nativeName":"الكويت","numericCode":"414","currencies":[{"code":"KWD","name":"Kuwaiti dinar","symbol":"د.ك"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Kuwait","es":"Kuwait","fr":"Koweït","ja":"クウェート","it":"Kuwait","br":"Kuwait","pt":"Kuwait","nl":"Koeweit","hr":"Kuvajt","fa":"کویت"},"flag":"https://restcountries.eu/data/kwt.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"KUW"} +{"name":"Kyrgyzstan","topLevelDomain":[".kg"],"alpha2Code":"KG","alpha3Code":"KGZ","callingCodes":["996"],"capital":"Bishkek","altSpellings":["KG","Киргизия","Kyrgyz Republic","Кыргыз Республикасы","Kyrgyz Respublikasy"],"region":"Asia","subregion":"Central Asia","population":6047800,"latlng":[41.0,75.0],"demonym":"Kirghiz","area":199951.0,"gini":36.2,"timezones":["UTC+06:00"],"borders":["CHN","KAZ","TJK","UZB"],"nativeName":"Кыргызстан","numericCode":"417","currencies":[{"code":"KGS","name":"Kyrgyzstani som","symbol":"с"}],"languages":[{"iso639_1":"ky","iso639_2":"kir","name":"Kyrgyz","nativeName":"Кыргызча"},{"iso639_1":"ru","iso639_2":"rus","name":"Russian","nativeName":"Русский"}],"translations":{"de":"Kirgisistan","es":"Kirguizistán","fr":"Kirghizistan","ja":"キルギス","it":"Kirghizistan","br":"Quirguistão","pt":"Quirguizistão","nl":"Kirgizië","hr":"Kirgistan","fa":"قرقیزستان"},"flag":"https://restcountries.eu/data/kgz.svg","regionalBlocs":[{"acronym":"EEU","name":"Eurasian Economic Union","otherAcronyms":["EAEU"],"otherNames":[]}],"cioc":"KGZ"} +{"name":"Lao People's Democratic Republic","topLevelDomain":[".la"],"alpha2Code":"LA","alpha3Code":"LAO","callingCodes":["856"],"capital":"Vientiane","altSpellings":["LA","Lao","Laos","Lao People's Democratic Republic","Sathalanalat Paxathipatai Paxaxon Lao"],"region":"Asia","subregion":"South-Eastern Asia","population":6492400,"latlng":[18.0,105.0],"demonym":"Laotian","area":236800.0,"gini":36.7,"timezones":["UTC+07:00"],"borders":["MMR","KHM","CHN","THA","VNM"],"nativeName":"ສປປລາວ","numericCode":"418","currencies":[{"code":"LAK","name":"Lao kip","symbol":"₭"}],"languages":[{"iso639_1":"lo","iso639_2":"lao","name":"Lao","nativeName":"ພາສາລາວ"}],"translations":{"de":"Laos","es":"Laos","fr":"Laos","ja":"ラオス人民民主共和国","it":"Laos","br":"Laos","pt":"Laos","nl":"Laos","hr":"Laos","fa":"لائوس"},"flag":"https://restcountries.eu/data/lao.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"LAO"} +{"name":"Latvia","topLevelDomain":[".lv"],"alpha2Code":"LV","alpha3Code":"LVA","callingCodes":["371"],"capital":"Riga","altSpellings":["LV","Republic of Latvia","Latvijas Republika"],"region":"Europe","subregion":"Northern Europe","population":1961600,"latlng":[57.0,25.0],"demonym":"Latvian","area":64559.0,"gini":36.6,"timezones":["UTC+02:00"],"borders":["BLR","EST","LTU","RUS"],"nativeName":"Latvija","numericCode":"428","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"lv","iso639_2":"lav","name":"Latvian","nativeName":"latviešu valoda"}],"translations":{"de":"Lettland","es":"Letonia","fr":"Lettonie","ja":"ラトビア","it":"Lettonia","br":"Letônia","pt":"Letónia","nl":"Letland","hr":"Latvija","fa":"لتونی"},"flag":"https://restcountries.eu/data/lva.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"LAT"} +{"name":"Lebanon","topLevelDomain":[".lb"],"alpha2Code":"LB","alpha3Code":"LBN","callingCodes":["961"],"capital":"Beirut","altSpellings":["LB","Lebanese Republic","Al-Jumhūrīyah Al-Libnānīyah"],"region":"Asia","subregion":"Western Asia","population":5988000,"latlng":[33.83333333,35.83333333],"demonym":"Lebanese","area":10452.0,"gini":null,"timezones":["UTC+02:00"],"borders":["ISR","SYR"],"nativeName":"لبنان","numericCode":"422","currencies":[{"code":"LBP","name":"Lebanese pound","symbol":"ل.ل"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Libanon","es":"Líbano","fr":"Liban","ja":"レバノン","it":"Libano","br":"Líbano","pt":"Líbano","nl":"Libanon","hr":"Libanon","fa":"لبنان"},"flag":"https://restcountries.eu/data/lbn.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"LIB"} +{"name":"Lesotho","topLevelDomain":[".ls"],"alpha2Code":"LS","alpha3Code":"LSO","callingCodes":["266"],"capital":"Maseru","altSpellings":["LS","Kingdom of Lesotho","Muso oa Lesotho"],"region":"Africa","subregion":"Southern Africa","population":1894194,"latlng":[-29.5,28.5],"demonym":"Mosotho","area":30355.0,"gini":52.5,"timezones":["UTC+02:00"],"borders":["ZAF"],"nativeName":"Lesotho","numericCode":"426","currencies":[{"code":"LSL","name":"Lesotho loti","symbol":"L"},{"code":"ZAR","name":"South African rand","symbol":"R"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"st","iso639_2":"sot","name":"Southern Sotho","nativeName":"Sesotho"}],"translations":{"de":"Lesotho","es":"Lesotho","fr":"Lesotho","ja":"レソト","it":"Lesotho","br":"Lesoto","pt":"Lesoto","nl":"Lesotho","hr":"Lesoto","fa":"لسوتو"},"flag":"https://restcountries.eu/data/lso.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"LES"} +{"name":"Liberia","topLevelDomain":[".lr"],"alpha2Code":"LR","alpha3Code":"LBR","callingCodes":["231"],"capital":"Monrovia","altSpellings":["LR","Republic of Liberia"],"region":"Africa","subregion":"Western Africa","population":4615000,"latlng":[6.5,-9.5],"demonym":"Liberian","area":111369.0,"gini":38.2,"timezones":["UTC"],"borders":["GIN","CIV","SLE"],"nativeName":"Liberia","numericCode":"430","currencies":[{"code":"LRD","name":"Liberian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Liberia","es":"Liberia","fr":"Liberia","ja":"リベリア","it":"Liberia","br":"Libéria","pt":"Libéria","nl":"Liberia","hr":"Liberija","fa":"لیبریا"},"flag":"https://restcountries.eu/data/lbr.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"LBR"} +{"name":"Libya","topLevelDomain":[".ly"],"alpha2Code":"LY","alpha3Code":"LBY","callingCodes":["218"],"capital":"Tripoli","altSpellings":["LY","State of Libya","Dawlat Libya"],"region":"Africa","subregion":"Northern Africa","population":6385000,"latlng":[25.0,17.0],"demonym":"Libyan","area":1759540.0,"gini":null,"timezones":["UTC+01:00"],"borders":["DZA","TCD","EGY","NER","SDN","TUN"],"nativeName":"‏ليبيا","numericCode":"434","currencies":[{"code":"LYD","name":"Libyan dinar","symbol":"ل.د"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Libyen","es":"Libia","fr":"Libye","ja":"リビア","it":"Libia","br":"Líbia","pt":"Líbia","nl":"Libië","hr":"Libija","fa":"لیبی"},"flag":"https://restcountries.eu/data/lby.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"LBA"} +{"name":"Liechtenstein","topLevelDomain":[".li"],"alpha2Code":"LI","alpha3Code":"LIE","callingCodes":["423"],"capital":"Vaduz","altSpellings":["LI","Principality of Liechtenstein","Fürstentum Liechtenstein"],"region":"Europe","subregion":"Western Europe","population":37623,"latlng":[47.26666666,9.53333333],"demonym":"Liechtensteiner","area":160.0,"gini":null,"timezones":["UTC+01:00"],"borders":["AUT","CHE"],"nativeName":"Liechtenstein","numericCode":"438","currencies":[{"code":"CHF","name":"Swiss franc","symbol":"Fr"}],"languages":[{"iso639_1":"de","iso639_2":"deu","name":"German","nativeName":"Deutsch"}],"translations":{"de":"Liechtenstein","es":"Liechtenstein","fr":"Liechtenstein","ja":"リヒテンシュタイン","it":"Liechtenstein","br":"Liechtenstein","pt":"Listenstaine","nl":"Liechtenstein","hr":"Lihtenštajn","fa":"لیختن‌اشتاین"},"flag":"https://restcountries.eu/data/lie.svg","regionalBlocs":[{"acronym":"EFTA","name":"European Free Trade Association","otherAcronyms":[],"otherNames":[]}],"cioc":"LIE"} +{"name":"Lithuania","topLevelDomain":[".lt"],"alpha2Code":"LT","alpha3Code":"LTU","callingCodes":["370"],"capital":"Vilnius","altSpellings":["LT","Republic of Lithuania","Lietuvos Respublika"],"region":"Europe","subregion":"Northern Europe","population":2872294,"latlng":[56.0,24.0],"demonym":"Lithuanian","area":65300.0,"gini":37.6,"timezones":["UTC+02:00"],"borders":["BLR","LVA","POL","RUS"],"nativeName":"Lietuva","numericCode":"440","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"lt","iso639_2":"lit","name":"Lithuanian","nativeName":"lietuvių kalba"}],"translations":{"de":"Litauen","es":"Lituania","fr":"Lituanie","ja":"リトアニア","it":"Lituania","br":"Lituânia","pt":"Lituânia","nl":"Litouwen","hr":"Litva","fa":"لیتوانی"},"flag":"https://restcountries.eu/data/ltu.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"LTU"} +{"name":"Luxembourg","topLevelDomain":[".lu"],"alpha2Code":"LU","alpha3Code":"LUX","callingCodes":["352"],"capital":"Luxembourg","altSpellings":["LU","Grand Duchy of Luxembourg","Grand-Duché de Luxembourg","Großherzogtum Luxemburg","Groussherzogtum Lëtzebuerg"],"region":"Europe","subregion":"Western Europe","population":576200,"latlng":[49.75,6.16666666],"demonym":"Luxembourger","area":2586.0,"gini":30.8,"timezones":["UTC+01:00"],"borders":["BEL","FRA","DEU"],"nativeName":"Luxembourg","numericCode":"442","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"de","iso639_2":"deu","name":"German","nativeName":"Deutsch"},{"iso639_1":"lb","iso639_2":"ltz","name":"Luxembourgish","nativeName":"Lëtzebuergesch"}],"translations":{"de":"Luxemburg","es":"Luxemburgo","fr":"Luxembourg","ja":"ルクセンブルク","it":"Lussemburgo","br":"Luxemburgo","pt":"Luxemburgo","nl":"Luxemburg","hr":"Luksemburg","fa":"لوکزامبورگ"},"flag":"https://restcountries.eu/data/lux.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"LUX"} +{"name":"Macao","topLevelDomain":[".mo"],"alpha2Code":"MO","alpha3Code":"MAC","callingCodes":["853"],"capital":"","altSpellings":["MO","澳门","Macao Special Administrative Region of the People's Republic of China","中華人民共和國澳門特別行政區","Região Administrativa Especial de Macau da República Popular da China"],"region":"Asia","subregion":"Eastern Asia","population":649100,"latlng":[22.16666666,113.55],"demonym":"Chinese","area":30.0,"gini":null,"timezones":["UTC+08:00"],"borders":["CHN"],"nativeName":"澳門","numericCode":"446","currencies":[{"code":"MOP","name":"Macanese pataca","symbol":"P"}],"languages":[{"iso639_1":"zh","iso639_2":"zho","name":"Chinese","nativeName":"中文 (Zhōngwén)"},{"iso639_1":"pt","iso639_2":"por","name":"Portuguese","nativeName":"Português"}],"translations":{"de":"Macao","es":"Macao","fr":"Macao","ja":"マカオ","it":"Macao","br":"Macau","pt":"Macau","nl":"Macao","hr":"Makao","fa":"مکائو"},"flag":"https://restcountries.eu/data/mac.svg","regionalBlocs":[],"cioc":""} +{"name":"Macedonia (the former Yugoslav Republic of)","topLevelDomain":[".mk"],"alpha2Code":"MK","alpha3Code":"MKD","callingCodes":["389"],"capital":"Skopje","altSpellings":["MK","Republic of Macedonia","Република Македонија"],"region":"Europe","subregion":"Southern Europe","population":2058539,"latlng":[41.83333333,22.0],"demonym":"Macedonian","area":25713.0,"gini":43.2,"timezones":["UTC+01:00"],"borders":["ALB","BGR","GRC","KOS","SRB"],"nativeName":"Македонија","numericCode":"807","currencies":[{"code":"MKD","name":"Macedonian denar","symbol":"ден"}],"languages":[{"iso639_1":"mk","iso639_2":"mkd","name":"Macedonian","nativeName":"македонски јазик"}],"translations":{"de":"Mazedonien","es":"Macedonia","fr":"Macédoine","ja":"マケドニア旧ユーゴスラビア共和国","it":"Macedonia","br":"Macedônia","pt":"Macedónia","nl":"Macedonië","hr":"Makedonija","fa":""},"flag":"https://restcountries.eu/data/mkd.svg","regionalBlocs":[{"acronym":"CEFTA","name":"Central European Free Trade Agreement","otherAcronyms":[],"otherNames":[]}],"cioc":"MKD"} +{"name":"Madagascar","topLevelDomain":[".mg"],"alpha2Code":"MG","alpha3Code":"MDG","callingCodes":["261"],"capital":"Antananarivo","altSpellings":["MG","Republic of Madagascar","Repoblikan'i Madagasikara","République de Madagascar"],"region":"Africa","subregion":"Eastern Africa","population":22434363,"latlng":[-20.0,47.0],"demonym":"Malagasy","area":587041.0,"gini":44.1,"timezones":["UTC+03:00"],"borders":[],"nativeName":"Madagasikara","numericCode":"450","currencies":[{"code":"MGA","name":"Malagasy ariary","symbol":"Ar"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"mg","iso639_2":"mlg","name":"Malagasy","nativeName":"fiteny malagasy"}],"translations":{"de":"Madagaskar","es":"Madagascar","fr":"Madagascar","ja":"マダガスカル","it":"Madagascar","br":"Madagascar","pt":"Madagáscar","nl":"Madagaskar","hr":"Madagaskar","fa":"ماداگاسکار"},"flag":"https://restcountries.eu/data/mdg.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"MAD"} +{"name":"Malawi","topLevelDomain":[".mw"],"alpha2Code":"MW","alpha3Code":"MWI","callingCodes":["265"],"capital":"Lilongwe","altSpellings":["MW","Republic of Malawi"],"region":"Africa","subregion":"Eastern Africa","population":16832910,"latlng":[-13.5,34.0],"demonym":"Malawian","area":118484.0,"gini":39.0,"timezones":["UTC+02:00"],"borders":["MOZ","TZA","ZMB"],"nativeName":"Malawi","numericCode":"454","currencies":[{"code":"MWK","name":"Malawian kwacha","symbol":"MK"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"ny","iso639_2":"nya","name":"Chichewa","nativeName":"chiCheŵa"}],"translations":{"de":"Malawi","es":"Malawi","fr":"Malawi","ja":"マラウイ","it":"Malawi","br":"Malawi","pt":"Malávi","nl":"Malawi","hr":"Malavi","fa":"مالاوی"},"flag":"https://restcountries.eu/data/mwi.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"MAW"} +{"name":"Malaysia","topLevelDomain":[".my"],"alpha2Code":"MY","alpha3Code":"MYS","callingCodes":["60"],"capital":"Kuala Lumpur","altSpellings":["MY"],"region":"Asia","subregion":"South-Eastern Asia","population":31405416,"latlng":[2.5,112.5],"demonym":"Malaysian","area":330803.0,"gini":46.2,"timezones":["UTC+08:00"],"borders":["BRN","IDN","THA"],"nativeName":"Malaysia","numericCode":"458","currencies":[{"code":"MYR","name":"Malaysian ringgit","symbol":"RM"}],"languages":[{"iso639_1":null,"iso639_2":"zsm","name":"Malaysian","nativeName":"بهاس مليسيا"}],"translations":{"de":"Malaysia","es":"Malasia","fr":"Malaisie","ja":"マレーシア","it":"Malesia","br":"Malásia","pt":"Malásia","nl":"Maleisië","hr":"Malezija","fa":"مالزی"},"flag":"https://restcountries.eu/data/mys.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"MAS"} +{"name":"Maldives","topLevelDomain":[".mv"],"alpha2Code":"MV","alpha3Code":"MDV","callingCodes":["960"],"capital":"Malé","altSpellings":["MV","Maldive Islands","Republic of the Maldives","Dhivehi Raajjeyge Jumhooriyya"],"region":"Asia","subregion":"Southern Asia","population":344023,"latlng":[3.25,73.0],"demonym":"Maldivan","area":300.0,"gini":37.4,"timezones":["UTC+05:00"],"borders":[],"nativeName":"Maldives","numericCode":"462","currencies":[{"code":"MVR","name":"Maldivian rufiyaa","symbol":".ރ"}],"languages":[{"iso639_1":"dv","iso639_2":"div","name":"Divehi","nativeName":"ދިވެހި"}],"translations":{"de":"Malediven","es":"Maldivas","fr":"Maldives","ja":"モルディブ","it":"Maldive","br":"Maldivas","pt":"Maldivas","nl":"Maldiven","hr":"Maldivi","fa":"مالدیو"},"flag":"https://restcountries.eu/data/mdv.svg","regionalBlocs":[{"acronym":"SAARC","name":"South Asian Association for Regional Cooperation","otherAcronyms":[],"otherNames":[]}],"cioc":"MDV"} +{"name":"Mali","topLevelDomain":[".ml"],"alpha2Code":"ML","alpha3Code":"MLI","callingCodes":["223"],"capital":"Bamako","altSpellings":["ML","Republic of Mali","République du Mali"],"region":"Africa","subregion":"Western Africa","population":18135000,"latlng":[17.0,-4.0],"demonym":"Malian","area":1240192.0,"gini":33.0,"timezones":["UTC"],"borders":["DZA","BFA","GIN","CIV","MRT","NER","SEN"],"nativeName":"Mali","numericCode":"466","currencies":[{"code":"XOF","name":"West African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Mali","es":"Mali","fr":"Mali","ja":"マリ","it":"Mali","br":"Mali","pt":"Mali","nl":"Mali","hr":"Mali","fa":"مالی"},"flag":"https://restcountries.eu/data/mli.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"MLI"} +{"name":"Malta","topLevelDomain":[".mt"],"alpha2Code":"MT","alpha3Code":"MLT","callingCodes":["356"],"capital":"Valletta","altSpellings":["MT","Republic of Malta","Repubblika ta' Malta"],"region":"Europe","subregion":"Southern Europe","population":425384,"latlng":[35.83333333,14.58333333],"demonym":"Maltese","area":316.0,"gini":null,"timezones":["UTC+01:00"],"borders":[],"nativeName":"Malta","numericCode":"470","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"mt","iso639_2":"mlt","name":"Maltese","nativeName":"Malti"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Malta","es":"Malta","fr":"Malte","ja":"マルタ","it":"Malta","br":"Malta","pt":"Malta","nl":"Malta","hr":"Malta","fa":"مالت"},"flag":"https://restcountries.eu/data/mlt.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"MLT"} +{"name":"Marshall Islands","topLevelDomain":[".mh"],"alpha2Code":"MH","alpha3Code":"MHL","callingCodes":["692"],"capital":"Majuro","altSpellings":["MH","Republic of the Marshall Islands","Aolepān Aorōkin M̧ajeļ"],"region":"Oceania","subregion":"Micronesia","population":54880,"latlng":[9.0,168.0],"demonym":"Marshallese","area":181.0,"gini":null,"timezones":["UTC+12:00"],"borders":[],"nativeName":"M̧ajeļ","numericCode":"584","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"mh","iso639_2":"mah","name":"Marshallese","nativeName":"Kajin M̧ajeļ"}],"translations":{"de":"Marshallinseln","es":"Islas Marshall","fr":"Îles Marshall","ja":"マーシャル諸島","it":"Isole Marshall","br":"Ilhas Marshall","pt":"Ilhas Marshall","nl":"Marshalleilanden","hr":"Maršalovi Otoci","fa":"جزایر مارشال"},"flag":"https://restcountries.eu/data/mhl.svg","regionalBlocs":[],"cioc":"MHL"} +{"name":"Martinique","topLevelDomain":[".mq"],"alpha2Code":"MQ","alpha3Code":"MTQ","callingCodes":["596"],"capital":"Fort-de-France","altSpellings":["MQ"],"region":"Americas","subregion":"Caribbean","population":378243,"latlng":[14.666667,-61.0],"demonym":"French","area":null,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Martinique","numericCode":"474","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Martinique","es":"Martinica","fr":"Martinique","ja":"マルティニーク","it":"Martinica","br":"Martinica","pt":"Martinica","nl":"Martinique","hr":"Martinique","fa":"مونتسرات"},"flag":"https://restcountries.eu/data/mtq.svg","regionalBlocs":[],"cioc":""} +{"name":"Mauritania","topLevelDomain":[".mr"],"alpha2Code":"MR","alpha3Code":"MRT","callingCodes":["222"],"capital":"Nouakchott","altSpellings":["MR","Islamic Republic of Mauritania","al-Jumhūriyyah al-ʾIslāmiyyah al-Mūrītāniyyah"],"region":"Africa","subregion":"Western Africa","population":3718678,"latlng":[20.0,-12.0],"demonym":"Mauritanian","area":1030700.0,"gini":40.5,"timezones":["UTC"],"borders":["DZA","MLI","SEN","ESH"],"nativeName":"موريتانيا","numericCode":"478","currencies":[{"code":"MRO","name":"Mauritanian ouguiya","symbol":"UM"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Mauretanien","es":"Mauritania","fr":"Mauritanie","ja":"モーリタニア","it":"Mauritania","br":"Mauritânia","pt":"Mauritânia","nl":"Mauritanië","hr":"Mauritanija","fa":"موریتانی"},"flag":"https://restcountries.eu/data/mrt.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"MTN"} +{"name":"Mauritius","topLevelDomain":[".mu"],"alpha2Code":"MU","alpha3Code":"MUS","callingCodes":["230"],"capital":"Port Louis","altSpellings":["MU","Republic of Mauritius","République de Maurice"],"region":"Africa","subregion":"Eastern Africa","population":1262879,"latlng":[-20.28333333,57.55],"demonym":"Mauritian","area":2040.0,"gini":null,"timezones":["UTC+04:00"],"borders":[],"nativeName":"Maurice","numericCode":"480","currencies":[{"code":"MUR","name":"Mauritian rupee","symbol":"₨"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Mauritius","es":"Mauricio","fr":"Île Maurice","ja":"モーリシャス","it":"Mauritius","br":"Maurício","pt":"Maurícia","nl":"Mauritius","hr":"Mauricijus","fa":"موریس"},"flag":"https://restcountries.eu/data/mus.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"MRI"} +{"name":"Mayotte","topLevelDomain":[".yt"],"alpha2Code":"YT","alpha3Code":"MYT","callingCodes":["262"],"capital":"Mamoudzou","altSpellings":["YT","Department of Mayotte","Département de Mayotte"],"region":"Africa","subregion":"Eastern Africa","population":226915,"latlng":[-12.83333333,45.16666666],"demonym":"French","area":null,"gini":null,"timezones":["UTC+03:00"],"borders":[],"nativeName":"Mayotte","numericCode":"175","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Mayotte","es":"Mayotte","fr":"Mayotte","ja":"マヨット","it":"Mayotte","br":"Mayotte","pt":"Mayotte","nl":"Mayotte","hr":"Mayotte","fa":"مایوت"},"flag":"https://restcountries.eu/data/myt.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":""} +{"name":"Mexico","topLevelDomain":[".mx"],"alpha2Code":"MX","alpha3Code":"MEX","callingCodes":["52"],"capital":"Mexico City","altSpellings":["MX","Mexicanos","United Mexican States","Estados Unidos Mexicanos"],"region":"Americas","subregion":"Central America","population":122273473,"latlng":[23.0,-102.0],"demonym":"Mexican","area":1964375.0,"gini":47.0,"timezones":["UTC-08:00","UTC-07:00","UTC-06:00"],"borders":["BLZ","GTM","USA"],"nativeName":"México","numericCode":"484","currencies":[{"code":"MXN","name":"Mexican peso","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Mexiko","es":"México","fr":"Mexique","ja":"メキシコ","it":"Messico","br":"México","pt":"México","nl":"Mexico","hr":"Meksiko","fa":"مکزیک"},"flag":"https://restcountries.eu/data/mex.svg","regionalBlocs":[{"acronym":"PA","name":"Pacific Alliance","otherAcronyms":[],"otherNames":["Alianza del Pacífico"]},{"acronym":"NAFTA","name":"North American Free Trade Agreement","otherAcronyms":[],"otherNames":["Tratado de Libre Comercio de América del Norte","Accord de Libre-échange Nord-Américain"]}],"cioc":"MEX"} +{"name":"Micronesia (Federated States of)","topLevelDomain":[".fm"],"alpha2Code":"FM","alpha3Code":"FSM","callingCodes":["691"],"capital":"Palikir","altSpellings":["FM","Federated States of Micronesia"],"region":"Oceania","subregion":"Micronesia","population":102800,"latlng":[6.91666666,158.25],"demonym":"Micronesian","area":702.0,"gini":null,"timezones":["UTC+10:00","UTC+11"],"borders":[],"nativeName":"Micronesia","numericCode":"583","currencies":[{"code":null,"name":"[D]","symbol":"$"},{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Mikronesien","es":"Micronesia","fr":"Micronésie","ja":"ミクロネシア連邦","it":"Micronesia","br":"Micronésia","pt":"Micronésia","nl":"Micronesië","hr":"Mikronezija","fa":"ایالات فدرال میکرونزی"},"flag":"https://restcountries.eu/data/fsm.svg","regionalBlocs":[],"cioc":"FSM"} +{"name":"Moldova (Republic of)","topLevelDomain":[".md"],"alpha2Code":"MD","alpha3Code":"MDA","callingCodes":["373"],"capital":"Chișinău","altSpellings":["MD","Republic of Moldova","Republica Moldova"],"region":"Europe","subregion":"Eastern Europe","population":3553100,"latlng":[47.0,29.0],"demonym":"Moldovan","area":33846.0,"gini":33.0,"timezones":["UTC+02:00"],"borders":["ROU","UKR"],"nativeName":"Moldova","numericCode":"498","currencies":[{"code":"MDL","name":"Moldovan leu","symbol":"L"}],"languages":[{"iso639_1":"ro","iso639_2":"ron","name":"Romanian","nativeName":"Română"}],"translations":{"de":"Moldawie","es":"Moldavia","fr":"Moldavie","ja":"モルドバ共和国","it":"Moldavia","br":"Moldávia","pt":"Moldávia","nl":"Moldavië","hr":"Moldova","fa":"مولداوی"},"flag":"https://restcountries.eu/data/mda.svg","regionalBlocs":[{"acronym":"CEFTA","name":"Central European Free Trade Agreement","otherAcronyms":[],"otherNames":[]}],"cioc":"MDA"} +{"name":"Monaco","topLevelDomain":[".mc"],"alpha2Code":"MC","alpha3Code":"MCO","callingCodes":["377"],"capital":"Monaco","altSpellings":["MC","Principality of Monaco","Principauté de Monaco"],"region":"Europe","subregion":"Western Europe","population":38400,"latlng":[43.73333333,7.4],"demonym":"Monegasque","area":2.02,"gini":null,"timezones":["UTC+01:00"],"borders":["FRA"],"nativeName":"Monaco","numericCode":"492","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Monaco","es":"Mónaco","fr":"Monaco","ja":"モナコ","it":"Principato di Monaco","br":"Mônaco","pt":"Mónaco","nl":"Monaco","hr":"Monako","fa":"موناکو"},"flag":"https://restcountries.eu/data/mco.svg","regionalBlocs":[],"cioc":"MON"} +{"name":"Mongolia","topLevelDomain":[".mn"],"alpha2Code":"MN","alpha3Code":"MNG","callingCodes":["976"],"capital":"Ulan Bator","altSpellings":["MN"],"region":"Asia","subregion":"Eastern Asia","population":3093100,"latlng":[46.0,105.0],"demonym":"Mongolian","area":1564110.0,"gini":36.5,"timezones":["UTC+07:00","UTC+08:00"],"borders":["CHN","RUS"],"nativeName":"Монгол улс","numericCode":"496","currencies":[{"code":"MNT","name":"Mongolian tögrög","symbol":"₮"}],"languages":[{"iso639_1":"mn","iso639_2":"mon","name":"Mongolian","nativeName":"Монгол хэл"}],"translations":{"de":"Mongolei","es":"Mongolia","fr":"Mongolie","ja":"モンゴル","it":"Mongolia","br":"Mongólia","pt":"Mongólia","nl":"Mongolië","hr":"Mongolija","fa":"مغولستان"},"flag":"https://restcountries.eu/data/mng.svg","regionalBlocs":[],"cioc":"MGL"} +{"name":"Montenegro","topLevelDomain":[".me"],"alpha2Code":"ME","alpha3Code":"MNE","callingCodes":["382"],"capital":"Podgorica","altSpellings":["ME","Crna Gora"],"region":"Europe","subregion":"Southern Europe","population":621810,"latlng":[42.5,19.3],"demonym":"Montenegrin","area":13812.0,"gini":30.0,"timezones":["UTC+01:00"],"borders":["ALB","BIH","HRV","KOS","SRB"],"nativeName":"Црна Гора","numericCode":"499","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"sr","iso639_2":"srp","name":"Serbian","nativeName":"српски језик"},{"iso639_1":"bs","iso639_2":"bos","name":"Bosnian","nativeName":"bosanski jezik"},{"iso639_1":"sq","iso639_2":"sqi","name":"Albanian","nativeName":"Shqip"},{"iso639_1":"hr","iso639_2":"hrv","name":"Croatian","nativeName":"hrvatski jezik"}],"translations":{"de":"Montenegro","es":"Montenegro","fr":"Monténégro","ja":"モンテネグロ","it":"Montenegro","br":"Montenegro","pt":"Montenegro","nl":"Montenegro","hr":"Crna Gora","fa":"مونته‌نگرو"},"flag":"https://restcountries.eu/data/mne.svg","regionalBlocs":[{"acronym":"CEFTA","name":"Central European Free Trade Agreement","otherAcronyms":[],"otherNames":[]}],"cioc":"MNE"} +{"name":"Montserrat","topLevelDomain":[".ms"],"alpha2Code":"MS","alpha3Code":"MSR","callingCodes":["1664"],"capital":"Plymouth","altSpellings":["MS"],"region":"Americas","subregion":"Caribbean","population":4922,"latlng":[16.75,-62.2],"demonym":"Montserratian","area":102.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Montserrat","numericCode":"500","currencies":[{"code":"XCD","name":"East Caribbean dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Montserrat","es":"Montserrat","fr":"Montserrat","ja":"モントセラト","it":"Montserrat","br":"Montserrat","pt":"Monserrate","nl":"Montserrat","hr":"Montserrat","fa":"مایوت"},"flag":"https://restcountries.eu/data/msr.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":""} +{"name":"Morocco","topLevelDomain":[".ma"],"alpha2Code":"MA","alpha3Code":"MAR","callingCodes":["212"],"capital":"Rabat","altSpellings":["MA","Kingdom of Morocco","Al-Mamlakah al-Maġribiyah"],"region":"Africa","subregion":"Northern Africa","population":33337529,"latlng":[32.0,-5.0],"demonym":"Moroccan","area":446550.0,"gini":40.9,"timezones":["UTC"],"borders":["DZA","ESH","ESP"],"nativeName":"المغرب","numericCode":"504","currencies":[{"code":"MAD","name":"Moroccan dirham","symbol":"د.م."}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Marokko","es":"Marruecos","fr":"Maroc","ja":"モロッコ","it":"Marocco","br":"Marrocos","pt":"Marrocos","nl":"Marokko","hr":"Maroko","fa":"مراکش"},"flag":"https://restcountries.eu/data/mar.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"MAR"} +{"name":"Mozambique","topLevelDomain":[".mz"],"alpha2Code":"MZ","alpha3Code":"MOZ","callingCodes":["258"],"capital":"Maputo","altSpellings":["MZ","Republic of Mozambique","República de Moçambique"],"region":"Africa","subregion":"Eastern Africa","population":26423700,"latlng":[-18.25,35.0],"demonym":"Mozambican","area":801590.0,"gini":45.7,"timezones":["UTC+02:00"],"borders":["MWI","ZAF","SWZ","TZA","ZMB","ZWE"],"nativeName":"Moçambique","numericCode":"508","currencies":[{"code":"MZN","name":"Mozambican metical","symbol":"MT"}],"languages":[{"iso639_1":"pt","iso639_2":"por","name":"Portuguese","nativeName":"Português"}],"translations":{"de":"Mosambik","es":"Mozambique","fr":"Mozambique","ja":"モザンビーク","it":"Mozambico","br":"Moçambique","pt":"Moçambique","nl":"Mozambique","hr":"Mozambik","fa":"موزامبیک"},"flag":"https://restcountries.eu/data/moz.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"MOZ"} +{"name":"Myanmar","topLevelDomain":[".mm"],"alpha2Code":"MM","alpha3Code":"MMR","callingCodes":["95"],"capital":"Naypyidaw","altSpellings":["MM","Burma","Republic of the Union of Myanmar","Pyidaunzu Thanmăda Myăma Nainngandaw"],"region":"Asia","subregion":"South-Eastern Asia","population":51419420,"latlng":[22.0,98.0],"demonym":"Burmese","area":676578.0,"gini":null,"timezones":["UTC+06:30"],"borders":["BGD","CHN","IND","LAO","THA"],"nativeName":"Myanma","numericCode":"104","currencies":[{"code":"MMK","name":"Burmese kyat","symbol":"Ks"}],"languages":[{"iso639_1":"my","iso639_2":"mya","name":"Burmese","nativeName":"ဗမာစာ"}],"translations":{"de":"Myanmar","es":"Myanmar","fr":"Myanmar","ja":"ミャンマー","it":"Birmania","br":"Myanmar","pt":"Myanmar","nl":"Myanmar","hr":"Mijanmar","fa":"میانمار"},"flag":"https://restcountries.eu/data/mmr.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"MYA"} +{"name":"Namibia","topLevelDomain":[".na"],"alpha2Code":"NA","alpha3Code":"NAM","callingCodes":["264"],"capital":"Windhoek","altSpellings":["NA","Namibië","Republic of Namibia"],"region":"Africa","subregion":"Southern Africa","population":2324388,"latlng":[-22.0,17.0],"demonym":"Namibian","area":825615.0,"gini":63.9,"timezones":["UTC+01:00"],"borders":["AGO","BWA","ZAF","ZMB"],"nativeName":"Namibia","numericCode":"516","currencies":[{"code":"NAD","name":"Namibian dollar","symbol":"$"},{"code":"ZAR","name":"South African rand","symbol":"R"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"af","iso639_2":"afr","name":"Afrikaans","nativeName":"Afrikaans"}],"translations":{"de":"Namibia","es":"Namibia","fr":"Namibie","ja":"ナミビア","it":"Namibia","br":"Namíbia","pt":"Namíbia","nl":"Namibië","hr":"Namibija","fa":"نامیبیا"},"flag":"https://restcountries.eu/data/nam.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"NAM"} +{"name":"Nauru","topLevelDomain":[".nr"],"alpha2Code":"NR","alpha3Code":"NRU","callingCodes":["674"],"capital":"Yaren","altSpellings":["NR","Naoero","Pleasant Island","Republic of Nauru","Ripublik Naoero"],"region":"Oceania","subregion":"Micronesia","population":10084,"latlng":[-0.53333333,166.91666666],"demonym":"Nauruan","area":21.0,"gini":null,"timezones":["UTC+12:00"],"borders":[],"nativeName":"Nauru","numericCode":"520","currencies":[{"code":"AUD","name":"Australian dollar","symbol":"$"},{"code":"(none)","name":null,"symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"na","iso639_2":"nau","name":"Nauruan","nativeName":"Dorerin Naoero"}],"translations":{"de":"Nauru","es":"Nauru","fr":"Nauru","ja":"ナウル","it":"Nauru","br":"Nauru","pt":"Nauru","nl":"Nauru","hr":"Nauru","fa":"نائورو"},"flag":"https://restcountries.eu/data/nru.svg","regionalBlocs":[],"cioc":"NRU"} +{"name":"Nepal","topLevelDomain":[".np"],"alpha2Code":"NP","alpha3Code":"NPL","callingCodes":["977"],"capital":"Kathmandu","altSpellings":["NP","Federal Democratic Republic of Nepal","Loktāntrik Ganatantra Nepāl"],"region":"Asia","subregion":"Southern Asia","population":28431500,"latlng":[28.0,84.0],"demonym":"Nepalese","area":147181.0,"gini":32.8,"timezones":["UTC+05:45"],"borders":["CHN","IND"],"nativeName":"नेपाल","numericCode":"524","currencies":[{"code":"NPR","name":"Nepalese rupee","symbol":"₨"}],"languages":[{"iso639_1":"ne","iso639_2":"nep","name":"Nepali","nativeName":"नेपाली"}],"translations":{"de":"Népal","es":"Nepal","fr":"Népal","ja":"ネパール","it":"Nepal","br":"Nepal","pt":"Nepal","nl":"Nepal","hr":"Nepal","fa":"نپال"},"flag":"https://restcountries.eu/data/npl.svg","regionalBlocs":[{"acronym":"SAARC","name":"South Asian Association for Regional Cooperation","otherAcronyms":[],"otherNames":[]}],"cioc":"NEP"} +{"name":"Netherlands","topLevelDomain":[".nl"],"alpha2Code":"NL","alpha3Code":"NLD","callingCodes":["31"],"capital":"Amsterdam","altSpellings":["NL","Holland","Nederland"],"region":"Europe","subregion":"Western Europe","population":17019800,"latlng":[52.5,5.75],"demonym":"Dutch","area":41850.0,"gini":30.9,"timezones":["UTC-04:00","UTC+01:00"],"borders":["BEL","DEU"],"nativeName":"Nederland","numericCode":"528","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"nl","iso639_2":"nld","name":"Dutch","nativeName":"Nederlands"}],"translations":{"de":"Niederlande","es":"Países Bajos","fr":"Pays-Bas","ja":"オランダ","it":"Paesi Bassi","br":"Holanda","pt":"Países Baixos","nl":"Nederland","hr":"Nizozemska","fa":"پادشاهی هلند"},"flag":"https://restcountries.eu/data/nld.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"NED"} +{"name":"New Caledonia","topLevelDomain":[".nc"],"alpha2Code":"NC","alpha3Code":"NCL","callingCodes":["687"],"capital":"Nouméa","altSpellings":["NC"],"region":"Oceania","subregion":"Melanesia","population":268767,"latlng":[-21.5,165.5],"demonym":"New Caledonian","area":18575.0,"gini":null,"timezones":["UTC+11:00"],"borders":[],"nativeName":"Nouvelle-Calédonie","numericCode":"540","currencies":[{"code":"XPF","name":"CFP franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Neukaledonien","es":"Nueva Caledonia","fr":"Nouvelle-Calédonie","ja":"ニューカレドニア","it":"Nuova Caledonia","br":"Nova Caledônia","pt":"Nova Caledónia","nl":"Nieuw-Caledonië","hr":"Nova Kaledonija","fa":"کالدونیای جدید"},"flag":"https://restcountries.eu/data/ncl.svg","regionalBlocs":[],"cioc":""} +{"name":"New Zealand","topLevelDomain":[".nz"],"alpha2Code":"NZ","alpha3Code":"NZL","callingCodes":["64"],"capital":"Wellington","altSpellings":["NZ","Aotearoa"],"region":"Oceania","subregion":"Australia and New Zealand","population":4697854,"latlng":[-41.0,174.0],"demonym":"New Zealander","area":270467.0,"gini":36.2,"timezones":["UTC-11:00","UTC-10:00","UTC+12:00","UTC+12:45","UTC+13:00"],"borders":[],"nativeName":"New Zealand","numericCode":"554","currencies":[{"code":"NZD","name":"New Zealand dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"mi","iso639_2":"mri","name":"Māori","nativeName":"te reo Māori"}],"translations":{"de":"Neuseeland","es":"Nueva Zelanda","fr":"Nouvelle-Zélande","ja":"ニュージーランド","it":"Nuova Zelanda","br":"Nova Zelândia","pt":"Nova Zelândia","nl":"Nieuw-Zeeland","hr":"Novi Zeland","fa":"نیوزیلند"},"flag":"https://restcountries.eu/data/nzl.svg","regionalBlocs":[],"cioc":"NZL"} +{"name":"Nicaragua","topLevelDomain":[".ni"],"alpha2Code":"NI","alpha3Code":"NIC","callingCodes":["505"],"capital":"Managua","altSpellings":["NI","Republic of Nicaragua","República de Nicaragua"],"region":"Americas","subregion":"Central America","population":6262703,"latlng":[13.0,-85.0],"demonym":"Nicaraguan","area":130373.0,"gini":40.5,"timezones":["UTC-06:00"],"borders":["CRI","HND"],"nativeName":"Nicaragua","numericCode":"558","currencies":[{"code":"NIO","name":"Nicaraguan córdoba","symbol":"C$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Nicaragua","es":"Nicaragua","fr":"Nicaragua","ja":"ニカラグア","it":"Nicaragua","br":"Nicarágua","pt":"Nicarágua","nl":"Nicaragua","hr":"Nikaragva","fa":"نیکاراگوئه"},"flag":"https://restcountries.eu/data/nic.svg","regionalBlocs":[{"acronym":"CAIS","name":"Central American Integration System","otherAcronyms":["SICA"],"otherNames":["Sistema de la Integración Centroamericana,"]}],"cioc":"NCA"} +{"name":"Niger","topLevelDomain":[".ne"],"alpha2Code":"NE","alpha3Code":"NER","callingCodes":["227"],"capital":"Niamey","altSpellings":["NE","Nijar","Republic of Niger","République du Niger"],"region":"Africa","subregion":"Western Africa","population":20715000,"latlng":[16.0,8.0],"demonym":"Nigerien","area":1267000.0,"gini":34.6,"timezones":["UTC+01:00"],"borders":["DZA","BEN","BFA","TCD","LBY","MLI","NGA"],"nativeName":"Niger","numericCode":"562","currencies":[{"code":"XOF","name":"West African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Niger","es":"Níger","fr":"Niger","ja":"ニジェール","it":"Niger","br":"Níger","pt":"Níger","nl":"Niger","hr":"Niger","fa":"نیجر"},"flag":"https://restcountries.eu/data/ner.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"NIG"} +{"name":"Nigeria","topLevelDomain":[".ng"],"alpha2Code":"NG","alpha3Code":"NGA","callingCodes":["234"],"capital":"Abuja","altSpellings":["NG","Nijeriya","Naíjíríà","Federal Republic of Nigeria"],"region":"Africa","subregion":"Western Africa","population":186988000,"latlng":[10.0,8.0],"demonym":"Nigerian","area":923768.0,"gini":48.8,"timezones":["UTC+01:00"],"borders":["BEN","CMR","TCD","NER"],"nativeName":"Nigeria","numericCode":"566","currencies":[{"code":"NGN","name":"Nigerian naira","symbol":"₦"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Nigeria","es":"Nigeria","fr":"Nigéria","ja":"ナイジェリア","it":"Nigeria","br":"Nigéria","pt":"Nigéria","nl":"Nigeria","hr":"Nigerija","fa":"نیجریه"},"flag":"https://restcountries.eu/data/nga.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"NGR"} +{"name":"Niue","topLevelDomain":[".nu"],"alpha2Code":"NU","alpha3Code":"NIU","callingCodes":["683"],"capital":"Alofi","altSpellings":["NU"],"region":"Oceania","subregion":"Polynesia","population":1470,"latlng":[-19.03333333,-169.86666666],"demonym":"Niuean","area":260.0,"gini":null,"timezones":["UTC-11:00"],"borders":[],"nativeName":"Niuē","numericCode":"570","currencies":[{"code":"NZD","name":"New Zealand dollar","symbol":"$"},{"code":"(none)","name":"Niue dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Niue","es":"Niue","fr":"Niue","ja":"ニウエ","it":"Niue","br":"Niue","pt":"Niue","nl":"Niue","hr":"Niue","fa":"نیووی"},"flag":"https://restcountries.eu/data/niu.svg","regionalBlocs":[],"cioc":""} +{"name":"Norfolk Island","topLevelDomain":[".nf"],"alpha2Code":"NF","alpha3Code":"NFK","callingCodes":["672"],"capital":"Kingston","altSpellings":["NF","Territory of Norfolk Island","Teratri of Norf'k Ailen"],"region":"Oceania","subregion":"Australia and New Zealand","population":2302,"latlng":[-29.03333333,167.95],"demonym":"Norfolk Islander","area":36.0,"gini":null,"timezones":["UTC+11:30"],"borders":[],"nativeName":"Norfolk Island","numericCode":"574","currencies":[{"code":"AUD","name":"Australian dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Norfolkinsel","es":"Isla de Norfolk","fr":"Île de Norfolk","ja":"ノーフォーク島","it":"Isola Norfolk","br":"Ilha Norfolk","pt":"Ilha Norfolk","nl":"Norfolkeiland","hr":"Otok Norfolk","fa":"جزیره نورفک"},"flag":"https://restcountries.eu/data/nfk.svg","regionalBlocs":[],"cioc":""} +{"name":"Korea (Democratic People's Republic of)","topLevelDomain":[".kp"],"alpha2Code":"KP","alpha3Code":"PRK","callingCodes":["850"],"capital":"Pyongyang","altSpellings":["KP","Democratic People's Republic of Korea","조선민주주의인민공화국","Chosŏn Minjujuŭi Inmin Konghwaguk"],"region":"Asia","subregion":"Eastern Asia","population":25281000,"latlng":[40.0,127.0],"demonym":"North Korean","area":120538.0,"gini":null,"timezones":["UTC+09:00"],"borders":["CHN","KOR","RUS"],"nativeName":"북한","numericCode":"408","currencies":[{"code":"KPW","name":"North Korean won","symbol":"₩"}],"languages":[{"iso639_1":"ko","iso639_2":"kor","name":"Korean","nativeName":"한국어"}],"translations":{"de":"Nordkorea","es":"Corea del Norte","fr":"Corée du Nord","ja":"朝鮮民主主義人民共和国","it":"Corea del Nord","br":"Coreia do Norte","pt":"Coreia do Norte","nl":"Noord-Korea","hr":"Sjeverna Koreja","fa":"کره جنوبی"},"flag":"https://restcountries.eu/data/prk.svg","regionalBlocs":[],"cioc":"PRK"} +{"name":"Northern Mariana Islands","topLevelDomain":[".mp"],"alpha2Code":"MP","alpha3Code":"MNP","callingCodes":["1670"],"capital":"Saipan","altSpellings":["MP","Commonwealth of the Northern Mariana Islands","Sankattan Siha Na Islas Mariånas"],"region":"Oceania","subregion":"Micronesia","population":56940,"latlng":[15.2,145.75],"demonym":"American","area":464.0,"gini":null,"timezones":["UTC+10:00"],"borders":[],"nativeName":"Northern Mariana Islands","numericCode":"580","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"ch","iso639_2":"cha","name":"Chamorro","nativeName":"Chamoru"}],"translations":{"de":"Nördliche Marianen","es":"Islas Marianas del Norte","fr":"Îles Mariannes du Nord","ja":"北マリアナ諸島","it":"Isole Marianne Settentrionali","br":"Ilhas Marianas","pt":"Ilhas Marianas","nl":"Noordelijke Marianeneilanden","hr":"Sjevernomarijanski otoci","fa":"جزایر ماریانای شمالی"},"flag":"https://restcountries.eu/data/mnp.svg","regionalBlocs":[],"cioc":""} +{"name":"Norway","topLevelDomain":[".no"],"alpha2Code":"NO","alpha3Code":"NOR","callingCodes":["47"],"capital":"Oslo","altSpellings":["NO","Norge","Noreg","Kingdom of Norway","Kongeriket Norge","Kongeriket Noreg"],"region":"Europe","subregion":"Northern Europe","population":5223256,"latlng":[62.0,10.0],"demonym":"Norwegian","area":323802.0,"gini":25.8,"timezones":["UTC+01:00"],"borders":["FIN","SWE","RUS"],"nativeName":"Norge","numericCode":"578","currencies":[{"code":"NOK","name":"Norwegian krone","symbol":"kr"}],"languages":[{"iso639_1":"no","iso639_2":"nor","name":"Norwegian","nativeName":"Norsk"},{"iso639_1":"nb","iso639_2":"nob","name":"Norwegian Bokmål","nativeName":"Norsk bokmål"},{"iso639_1":"nn","iso639_2":"nno","name":"Norwegian Nynorsk","nativeName":"Norsk nynorsk"}],"translations":{"de":"Norwegen","es":"Noruega","fr":"Norvège","ja":"ノルウェー","it":"Norvegia","br":"Noruega","pt":"Noruega","nl":"Noorwegen","hr":"Norveška","fa":"نروژ"},"flag":"https://restcountries.eu/data/nor.svg","regionalBlocs":[{"acronym":"EFTA","name":"European Free Trade Association","otherAcronyms":[],"otherNames":[]}],"cioc":"NOR"} +{"name":"Oman","topLevelDomain":[".om"],"alpha2Code":"OM","alpha3Code":"OMN","callingCodes":["968"],"capital":"Muscat","altSpellings":["OM","Sultanate of Oman","Salṭanat ʻUmān"],"region":"Asia","subregion":"Western Asia","population":4420133,"latlng":[21.0,57.0],"demonym":"Omani","area":309500.0,"gini":null,"timezones":["UTC+04:00"],"borders":["SAU","ARE","YEM"],"nativeName":"عمان","numericCode":"512","currencies":[{"code":"OMR","name":"Omani rial","symbol":"ر.ع."}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Oman","es":"Omán","fr":"Oman","ja":"オマーン","it":"oman","br":"Omã","pt":"Omã","nl":"Oman","hr":"Oman","fa":"عمان"},"flag":"https://restcountries.eu/data/omn.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"OMA"} +{"name":"Pakistan","topLevelDomain":[".pk"],"alpha2Code":"PK","alpha3Code":"PAK","callingCodes":["92"],"capital":"Islamabad","altSpellings":["PK","Pākistān","Islamic Republic of Pakistan","Islāmī Jumhūriya'eh Pākistān"],"region":"Asia","subregion":"Southern Asia","population":194125062,"latlng":[30.0,70.0],"demonym":"Pakistani","area":881912.0,"gini":30.0,"timezones":["UTC+05:00"],"borders":["AFG","CHN","IND","IRN"],"nativeName":"Pakistan","numericCode":"586","currencies":[{"code":"PKR","name":"Pakistani rupee","symbol":"₨"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"ur","iso639_2":"urd","name":"Urdu","nativeName":"اردو"}],"translations":{"de":"Pakistan","es":"Pakistán","fr":"Pakistan","ja":"パキスタン","it":"Pakistan","br":"Paquistão","pt":"Paquistão","nl":"Pakistan","hr":"Pakistan","fa":"پاکستان"},"flag":"https://restcountries.eu/data/pak.svg","regionalBlocs":[{"acronym":"SAARC","name":"South Asian Association for Regional Cooperation","otherAcronyms":[],"otherNames":[]}],"cioc":"PAK"} +{"name":"Palau","topLevelDomain":[".pw"],"alpha2Code":"PW","alpha3Code":"PLW","callingCodes":["680"],"capital":"Ngerulmud","altSpellings":["PW","Republic of Palau","Beluu er a Belau"],"region":"Oceania","subregion":"Micronesia","population":17950,"latlng":[7.5,134.5],"demonym":"Palauan","area":459.0,"gini":null,"timezones":["UTC+09:00"],"borders":[],"nativeName":"Palau","numericCode":"585","currencies":[{"code":"(none)","name":"[E]","symbol":"$"},{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Palau","es":"Palau","fr":"Palaos","ja":"パラオ","it":"Palau","br":"Palau","pt":"Palau","nl":"Palau","hr":"Palau","fa":"پالائو"},"flag":"https://restcountries.eu/data/plw.svg","regionalBlocs":[],"cioc":"PLW"} +{"name":"Palestine, State of","topLevelDomain":[".ps"],"alpha2Code":"PS","alpha3Code":"PSE","callingCodes":["970"],"capital":"Ramallah","altSpellings":["PS","State of Palestine","Dawlat Filasṭin"],"region":"Asia","subregion":"Western Asia","population":4682467,"latlng":[31.9,35.2],"demonym":"Palestinian","area":null,"gini":35.5,"timezones":["UTC+02:00"],"borders":["ISR","EGY","JOR"],"nativeName":"فلسطين","numericCode":"275","currencies":[{"code":"ILS","name":"Israeli new sheqel","symbol":"₪"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Palästina","es":"Palestina","fr":"Palestine","ja":"パレスチナ","it":"Palestina","br":"Palestina","pt":"Palestina","nl":"Palestijnse gebieden","hr":"Palestina","fa":"فلسطین"},"flag":"https://restcountries.eu/data/pse.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"PLE"} +{"name":"Panama","topLevelDomain":[".pa"],"alpha2Code":"PA","alpha3Code":"PAN","callingCodes":["507"],"capital":"Panama City","altSpellings":["PA","Republic of Panama","República de Panamá"],"region":"Americas","subregion":"Central America","population":3814672,"latlng":[9.0,-80.0],"demonym":"Panamanian","area":75417.0,"gini":51.9,"timezones":["UTC-05:00"],"borders":["COL","CRI"],"nativeName":"Panamá","numericCode":"591","currencies":[{"code":"PAB","name":"Panamanian balboa","symbol":"B/."},{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Panama","es":"Panamá","fr":"Panama","ja":"パナマ","it":"Panama","br":"Panamá","pt":"Panamá","nl":"Panama","hr":"Panama","fa":"پاناما"},"flag":"https://restcountries.eu/data/pan.svg","regionalBlocs":[{"acronym":"CAIS","name":"Central American Integration System","otherAcronyms":["SICA"],"otherNames":["Sistema de la Integración Centroamericana,"]}],"cioc":"PAN"} +{"name":"Papua New Guinea","topLevelDomain":[".pg"],"alpha2Code":"PG","alpha3Code":"PNG","callingCodes":["675"],"capital":"Port Moresby","altSpellings":["PG","Independent State of Papua New Guinea","Independen Stet bilong Papua Niugini"],"region":"Oceania","subregion":"Melanesia","population":8083700,"latlng":[-6.0,147.0],"demonym":"Papua New Guinean","area":462840.0,"gini":50.9,"timezones":["UTC+10:00"],"borders":["IDN"],"nativeName":"Papua Niugini","numericCode":"598","currencies":[{"code":"PGK","name":"Papua New Guinean kina","symbol":"K"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Papua-Neuguinea","es":"Papúa Nueva Guinea","fr":"Papouasie-Nouvelle-Guinée","ja":"パプアニューギニア","it":"Papua Nuova Guinea","br":"Papua Nova Guiné","pt":"Papua Nova Guiné","nl":"Papoea-Nieuw-Guinea","hr":"Papua Nova Gvineja","fa":"پاپوآ گینه نو"},"flag":"https://restcountries.eu/data/png.svg","regionalBlocs":[],"cioc":"PNG"} +{"name":"Paraguay","topLevelDomain":[".py"],"alpha2Code":"PY","alpha3Code":"PRY","callingCodes":["595"],"capital":"Asunción","altSpellings":["PY","Republic of Paraguay","República del Paraguay","Tetã Paraguái"],"region":"Americas","subregion":"South America","population":6854536,"latlng":[-23.0,-58.0],"demonym":"Paraguayan","area":406752.0,"gini":52.4,"timezones":["UTC-04:00"],"borders":["ARG","BOL","BRA"],"nativeName":"Paraguay","numericCode":"600","currencies":[{"code":"PYG","name":"Paraguayan guaraní","symbol":"₲"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"},{"iso639_1":"gn","iso639_2":"grn","name":"Guaraní","nativeName":"Avañe'ẽ"}],"translations":{"de":"Paraguay","es":"Paraguay","fr":"Paraguay","ja":"パラグアイ","it":"Paraguay","br":"Paraguai","pt":"Paraguai","nl":"Paraguay","hr":"Paragvaj","fa":"پاراگوئه"},"flag":"https://restcountries.eu/data/pry.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"PAR"} +{"name":"Peru","topLevelDomain":[".pe"],"alpha2Code":"PE","alpha3Code":"PER","callingCodes":["51"],"capital":"Lima","altSpellings":["PE","Republic of Peru"," República del Perú"],"region":"Americas","subregion":"South America","population":31488700,"latlng":[-10.0,-76.0],"demonym":"Peruvian","area":1285216.0,"gini":48.1,"timezones":["UTC-05:00"],"borders":["BOL","BRA","CHL","COL","ECU"],"nativeName":"Perú","numericCode":"604","currencies":[{"code":"PEN","name":"Peruvian sol","symbol":"S/."}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Peru","es":"Perú","fr":"Pérou","ja":"ペルー","it":"Perù","br":"Peru","pt":"Peru","nl":"Peru","hr":"Peru","fa":"پرو"},"flag":"https://restcountries.eu/data/per.svg","regionalBlocs":[{"acronym":"PA","name":"Pacific Alliance","otherAcronyms":[],"otherNames":["Alianza del Pacífico"]},{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"PER"} +{"name":"Philippines","topLevelDomain":[".ph"],"alpha2Code":"PH","alpha3Code":"PHL","callingCodes":["63"],"capital":"Manila","altSpellings":["PH","Republic of the Philippines","Repúblika ng Pilipinas"],"region":"Asia","subregion":"South-Eastern Asia","population":103279800,"latlng":[13.0,122.0],"demonym":"Filipino","area":342353.0,"gini":43.0,"timezones":["UTC+08:00"],"borders":[],"nativeName":"Pilipinas","numericCode":"608","currencies":[{"code":"PHP","name":"Philippine peso","symbol":"₱"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Philippinen","es":"Filipinas","fr":"Philippines","ja":"フィリピン","it":"Filippine","br":"Filipinas","pt":"Filipinas","nl":"Filipijnen","hr":"Filipini","fa":"جزایر الندفیلیپین"},"flag":"https://restcountries.eu/data/phl.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"PHI"} +{"name":"Pitcairn","topLevelDomain":[".pn"],"alpha2Code":"PN","alpha3Code":"PCN","callingCodes":["64"],"capital":"Adamstown","altSpellings":["PN","Pitcairn Henderson Ducie and Oeno Islands"],"region":"Oceania","subregion":"Polynesia","population":56,"latlng":[-25.06666666,-130.1],"demonym":"Pitcairn Islander","area":47.0,"gini":null,"timezones":["UTC-08:00"],"borders":[],"nativeName":"Pitcairn Islands","numericCode":"612","currencies":[{"code":"NZD","name":"New Zealand dollar","symbol":"$"},{"code":null,"name":"Pitcairn Islands dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Pitcairn","es":"Islas Pitcairn","fr":"Îles Pitcairn","ja":"ピトケアン","it":"Isole Pitcairn","br":"Ilhas Pitcairn","pt":"Ilhas Picárnia","nl":"Pitcairneilanden","hr":"Pitcairnovo otočje","fa":"پیتکرن"},"flag":"https://restcountries.eu/data/pcn.svg","regionalBlocs":[],"cioc":""} +{"name":"Poland","topLevelDomain":[".pl"],"alpha2Code":"PL","alpha3Code":"POL","callingCodes":["48"],"capital":"Warsaw","altSpellings":["PL","Republic of Poland","Rzeczpospolita Polska"],"region":"Europe","subregion":"Eastern Europe","population":38437239,"latlng":[52.0,20.0],"demonym":"Polish","area":312679.0,"gini":34.1,"timezones":["UTC+01:00"],"borders":["BLR","CZE","DEU","LTU","RUS","SVK","UKR"],"nativeName":"Polska","numericCode":"616","currencies":[{"code":"PLN","name":"Polish złoty","symbol":"zł"}],"languages":[{"iso639_1":"pl","iso639_2":"pol","name":"Polish","nativeName":"język polski"}],"translations":{"de":"Polen","es":"Polonia","fr":"Pologne","ja":"ポーランド","it":"Polonia","br":"Polônia","pt":"Polónia","nl":"Polen","hr":"Poljska","fa":"لهستان"},"flag":"https://restcountries.eu/data/pol.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"POL"} +{"name":"Portugal","topLevelDomain":[".pt"],"alpha2Code":"PT","alpha3Code":"PRT","callingCodes":["351"],"capital":"Lisbon","altSpellings":["PT","Portuguesa","Portuguese Republic","República Portuguesa"],"region":"Europe","subregion":"Southern Europe","population":10374822,"latlng":[39.5,-8.0],"demonym":"Portuguese","area":92090.0,"gini":38.5,"timezones":["UTC-01:00","UTC"],"borders":["ESP"],"nativeName":"Portugal","numericCode":"620","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"pt","iso639_2":"por","name":"Portuguese","nativeName":"Português"}],"translations":{"de":"Portugal","es":"Portugal","fr":"Portugal","ja":"ポルトガル","it":"Portogallo","br":"Portugal","pt":"Portugal","nl":"Portugal","hr":"Portugal","fa":"پرتغال"},"flag":"https://restcountries.eu/data/prt.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"POR"} +{"name":"Puerto Rico","topLevelDomain":[".pr"],"alpha2Code":"PR","alpha3Code":"PRI","callingCodes":["1787","1939"],"capital":"San Juan","altSpellings":["PR","Commonwealth of Puerto Rico","Estado Libre Asociado de Puerto Rico"],"region":"Americas","subregion":"Caribbean","population":3474182,"latlng":[18.25,-66.5],"demonym":"Puerto Rican","area":8870.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Puerto Rico","numericCode":"630","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Puerto Rico","es":"Puerto Rico","fr":"Porto Rico","ja":"プエルトリコ","it":"Porto Rico","br":"Porto Rico","pt":"Porto Rico","nl":"Puerto Rico","hr":"Portoriko","fa":"پورتو ریکو"},"flag":"https://restcountries.eu/data/pri.svg","regionalBlocs":[],"cioc":"PUR"} +{"name":"Qatar","topLevelDomain":[".qa"],"alpha2Code":"QA","alpha3Code":"QAT","callingCodes":["974"],"capital":"Doha","altSpellings":["QA","State of Qatar","Dawlat Qaṭar"],"region":"Asia","subregion":"Western Asia","population":2587564,"latlng":[25.5,51.25],"demonym":"Qatari","area":11586.0,"gini":41.1,"timezones":["UTC+03:00"],"borders":["SAU"],"nativeName":"قطر","numericCode":"634","currencies":[{"code":"QAR","name":"Qatari riyal","symbol":"ر.ق"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Katar","es":"Catar","fr":"Qatar","ja":"カタール","it":"Qatar","br":"Catar","pt":"Catar","nl":"Qatar","hr":"Katar","fa":"قطر"},"flag":"https://restcountries.eu/data/qat.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"QAT"} +{"name":"Republic of Kosovo","topLevelDomain":[""],"alpha2Code":"XK","alpha3Code":"KOS","callingCodes":["383"],"capital":"Pristina","altSpellings":["XK","Република Косово"],"region":"Europe","subregion":"Eastern Europe","population":1733842,"latlng":[42.666667,21.166667],"demonym":"Kosovar","area":10908.0,"gini":null,"timezones":["UTC+01:00"],"borders":["ALB","MKD","MNE","SRB"],"nativeName":"Republika e Kosovës","numericCode":null,"currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"sq","iso639_2":"sqi","name":"Albanian","nativeName":"Shqip"},{"iso639_1":"sr","iso639_2":"srp","name":"Serbian","nativeName":"српски језик"}],"translations":{"de":null,"es":"Kosovo","fr":null,"ja":null,"it":null,"br":"Kosovo","pt":"Kosovo","nl":null,"hr":"Kosovo","fa":"کوزوو"},"flag":"https://restcountries.eu/data/kos.svg","regionalBlocs":[{"acronym":"CEFTA","name":"Central European Free Trade Agreement","otherAcronyms":[],"otherNames":[]}],"cioc":null} +{"name":"Réunion","topLevelDomain":[".re"],"alpha2Code":"RE","alpha3Code":"REU","callingCodes":["262"],"capital":"Saint-Denis","altSpellings":["RE","Reunion"],"region":"Africa","subregion":"Eastern Africa","population":840974,"latlng":[-21.15,55.5],"demonym":"French","area":null,"gini":null,"timezones":["UTC+04:00"],"borders":[],"nativeName":"La Réunion","numericCode":"638","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Réunion","es":"Reunión","fr":"Réunion","ja":"レユニオン","it":"Riunione","br":"Reunião","pt":"Reunião","nl":"Réunion","hr":"Réunion","fa":"رئونیون"},"flag":"https://restcountries.eu/data/reu.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":""} +{"name":"Romania","topLevelDomain":[".ro"],"alpha2Code":"RO","alpha3Code":"ROU","callingCodes":["40"],"capital":"Bucharest","altSpellings":["RO","Rumania","Roumania","România"],"region":"Europe","subregion":"Eastern Europe","population":19861408,"latlng":[46.0,25.0],"demonym":"Romanian","area":238391.0,"gini":30.0,"timezones":["UTC+02:00"],"borders":["BGR","HUN","MDA","SRB","UKR"],"nativeName":"România","numericCode":"642","currencies":[{"code":"RON","name":"Romanian leu","symbol":"lei"}],"languages":[{"iso639_1":"ro","iso639_2":"ron","name":"Romanian","nativeName":"Română"}],"translations":{"de":"Rumänien","es":"Rumania","fr":"Roumanie","ja":"ルーマニア","it":"Romania","br":"Romênia","pt":"Roménia","nl":"Roemenië","hr":"Rumunjska","fa":"رومانی"},"flag":"https://restcountries.eu/data/rou.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"ROU"} +{"name":"Russian Federation","topLevelDomain":[".ru"],"alpha2Code":"RU","alpha3Code":"RUS","callingCodes":["7"],"capital":"Moscow","altSpellings":["RU","Rossiya","Russian Federation","Российская Федерация","Rossiyskaya Federatsiya"],"region":"Europe","subregion":"Eastern Europe","population":146599183,"latlng":[60.0,100.0],"demonym":"Russian","area":1.7124442E7,"gini":40.1,"timezones":["UTC+03:00","UTC+04:00","UTC+06:00","UTC+07:00","UTC+08:00","UTC+09:00","UTC+10:00","UTC+11:00","UTC+12:00"],"borders":["AZE","BLR","CHN","EST","FIN","GEO","KAZ","PRK","LVA","LTU","MNG","NOR","POL","UKR"],"nativeName":"Россия","numericCode":"643","currencies":[{"code":"RUB","name":"Russian ruble","symbol":"₽"}],"languages":[{"iso639_1":"ru","iso639_2":"rus","name":"Russian","nativeName":"Русский"}],"translations":{"de":"Russland","es":"Rusia","fr":"Russie","ja":"ロシア連邦","it":"Russia","br":"Rússia","pt":"Rússia","nl":"Rusland","hr":"Rusija","fa":"روسیه"},"flag":"https://restcountries.eu/data/rus.svg","regionalBlocs":[{"acronym":"EEU","name":"Eurasian Economic Union","otherAcronyms":["EAEU"],"otherNames":[]}],"cioc":"RUS"} +{"name":"Rwanda","topLevelDomain":[".rw"],"alpha2Code":"RW","alpha3Code":"RWA","callingCodes":["250"],"capital":"Kigali","altSpellings":["RW","Republic of Rwanda","Repubulika y'u Rwanda","République du Rwanda"],"region":"Africa","subregion":"Eastern Africa","population":11553188,"latlng":[-2.0,30.0],"demonym":"Rwandan","area":26338.0,"gini":50.8,"timezones":["UTC+02:00"],"borders":["BDI","COD","TZA","UGA"],"nativeName":"Rwanda","numericCode":"646","currencies":[{"code":"RWF","name":"Rwandan franc","symbol":"Fr"}],"languages":[{"iso639_1":"rw","iso639_2":"kin","name":"Kinyarwanda","nativeName":"Ikinyarwanda"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Ruanda","es":"Ruanda","fr":"Rwanda","ja":"ルワンダ","it":"Ruanda","br":"Ruanda","pt":"Ruanda","nl":"Rwanda","hr":"Ruanda","fa":"رواندا"},"flag":"https://restcountries.eu/data/rwa.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"RWA"} +{"name":"Saint Barthélemy","topLevelDomain":[".bl"],"alpha2Code":"BL","alpha3Code":"BLM","callingCodes":["590"],"capital":"Gustavia","altSpellings":["BL","St. Barthelemy","Collectivity of Saint Barthélemy","Collectivité de Saint-Barthélemy"],"region":"Americas","subregion":"Caribbean","population":9417,"latlng":[18.5,-63.41666666],"demonym":"Saint Barthélemy Islander","area":21.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Saint-Barthélemy","numericCode":"652","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Saint-Barthélemy","es":"San Bartolomé","fr":"Saint-Barthélemy","ja":"サン・バルテルミー","it":"Antille Francesi","br":"São Bartolomeu","pt":"São Bartolomeu","nl":"Saint Barthélemy","hr":"Saint Barthélemy","fa":"سن-بارتلمی"},"flag":"https://restcountries.eu/data/blm.svg","regionalBlocs":[],"cioc":""} +{"name":"Saint Helena, Ascension and Tristan da Cunha","topLevelDomain":[".sh"],"alpha2Code":"SH","alpha3Code":"SHN","callingCodes":["290"],"capital":"Jamestown","altSpellings":["SH"],"region":"Africa","subregion":"Western Africa","population":4255,"latlng":[-15.95,-5.7],"demonym":"Saint Helenian","area":null,"gini":null,"timezones":["UTC+00:00"],"borders":[],"nativeName":"Saint Helena","numericCode":"654","currencies":[{"code":"SHP","name":"Saint Helena pound","symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Sankt Helena","es":"Santa Helena","fr":"Sainte-Hélène","ja":"セントヘレナ・アセンションおよびトリスタンダクーニャ","it":"Sant'Elena","br":"Santa Helena","pt":"Santa Helena","nl":"Sint-Helena","hr":"Sveta Helena","fa":"سنت هلنا، اسنشن و تریستان دا کونا"},"flag":"https://restcountries.eu/data/shn.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":null} +{"name":"Saint Kitts and Nevis","topLevelDomain":[".kn"],"alpha2Code":"KN","alpha3Code":"KNA","callingCodes":["1869"],"capital":"Basseterre","altSpellings":["KN","Federation of Saint Christopher and Nevis"],"region":"Americas","subregion":"Caribbean","population":46204,"latlng":[17.33333333,-62.75],"demonym":"Kittian and Nevisian","area":261.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Saint Kitts and Nevis","numericCode":"659","currencies":[{"code":"XCD","name":"East Caribbean dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"St. Kitts und Nevis","es":"San Cristóbal y Nieves","fr":"Saint-Christophe-et-Niévès","ja":"セントクリストファー・ネイビス","it":"Saint Kitts e Nevis","br":"São Cristóvão e Neves","pt":"São Cristóvão e Neves","nl":"Saint Kitts en Nevis","hr":"Sveti Kristof i Nevis","fa":"سنت کیتس و نویس"},"flag":"https://restcountries.eu/data/kna.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"SKN"} +{"name":"Saint Lucia","topLevelDomain":[".lc"],"alpha2Code":"LC","alpha3Code":"LCA","callingCodes":["1758"],"capital":"Castries","altSpellings":["LC"],"region":"Americas","subregion":"Caribbean","population":186000,"latlng":[13.88333333,-60.96666666],"demonym":"Saint Lucian","area":616.0,"gini":42.6,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Saint Lucia","numericCode":"662","currencies":[{"code":"XCD","name":"East Caribbean dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Saint Lucia","es":"Santa Lucía","fr":"Saint-Lucie","ja":"セントルシア","it":"Santa Lucia","br":"Santa Lúcia","pt":"Santa Lúcia","nl":"Saint Lucia","hr":"Sveta Lucija","fa":"سنت لوسیا"},"flag":"https://restcountries.eu/data/lca.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"LCA"} +{"name":"Saint Martin (French part)","topLevelDomain":[".mf",".fr",".gp"],"alpha2Code":"MF","alpha3Code":"MAF","callingCodes":["590"],"capital":"Marigot","altSpellings":["MF","Collectivity of Saint Martin","Collectivité de Saint-Martin"],"region":"Americas","subregion":"Caribbean","population":36979,"latlng":[18.08333333,-63.95],"demonym":"Saint Martin Islander","area":53.0,"gini":null,"timezones":["UTC-04:00"],"borders":["SXM","NLD"],"nativeName":"Saint-Martin","numericCode":"663","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"nl","iso639_2":"nld","name":"Dutch","nativeName":"Nederlands"}],"translations":{"de":"Saint Martin","es":"Saint Martin","fr":"Saint-Martin","ja":"サン・マルタン(フランス領)","it":"Saint Martin","br":"Saint Martin","pt":"Ilha São Martinho","nl":"Saint-Martin","hr":"Sveti Martin","fa":"سینت مارتن"},"flag":"https://restcountries.eu/data/maf.svg","regionalBlocs":[],"cioc":""} +{"name":"Saint Pierre and Miquelon","topLevelDomain":[".pm"],"alpha2Code":"PM","alpha3Code":"SPM","callingCodes":["508"],"capital":"Saint-Pierre","altSpellings":["PM","Collectivité territoriale de Saint-Pierre-et-Miquelon"],"region":"Americas","subregion":"Northern America","population":6069,"latlng":[46.83333333,-56.33333333],"demonym":"French","area":242.0,"gini":null,"timezones":["UTC-03:00"],"borders":[],"nativeName":"Saint-Pierre-et-Miquelon","numericCode":"666","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Saint-Pierre und Miquelon","es":"San Pedro y Miquelón","fr":"Saint-Pierre-et-Miquelon","ja":"サンピエール島・ミクロン島","it":"Saint-Pierre e Miquelon","br":"Saint-Pierre e Miquelon","pt":"São Pedro e Miquelon","nl":"Saint Pierre en Miquelon","hr":"Sveti Petar i Mikelon","fa":"سن پیر و میکلن"},"flag":"https://restcountries.eu/data/spm.svg","regionalBlocs":[],"cioc":""} +{"name":"Saint Vincent and the Grenadines","topLevelDomain":[".vc"],"alpha2Code":"VC","alpha3Code":"VCT","callingCodes":["1784"],"capital":"Kingstown","altSpellings":["VC"],"region":"Americas","subregion":"Caribbean","population":109991,"latlng":[13.25,-61.2],"demonym":"Saint Vincentian","area":389.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Saint Vincent and the Grenadines","numericCode":"670","currencies":[{"code":"XCD","name":"East Caribbean dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Saint Vincent und die Grenadinen","es":"San Vicente y Granadinas","fr":"Saint-Vincent-et-les-Grenadines","ja":"セントビンセントおよびグレナディーン諸島","it":"Saint Vincent e Grenadine","br":"São Vicente e Granadinas","pt":"São Vicente e Granadinas","nl":"Saint Vincent en de Grenadines","hr":"Sveti Vincent i Grenadini","fa":"سنت وینسنت و گرنادین‌ها"},"flag":"https://restcountries.eu/data/vct.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"VIN"} +{"name":"Samoa","topLevelDomain":[".ws"],"alpha2Code":"WS","alpha3Code":"WSM","callingCodes":["685"],"capital":"Apia","altSpellings":["WS","Independent State of Samoa","Malo Saʻoloto Tutoʻatasi o Sāmoa"],"region":"Oceania","subregion":"Polynesia","population":194899,"latlng":[-13.58333333,-172.33333333],"demonym":"Samoan","area":2842.0,"gini":null,"timezones":["UTC+13:00"],"borders":[],"nativeName":"Samoa","numericCode":"882","currencies":[{"code":"WST","name":"Samoan tālā","symbol":"T"}],"languages":[{"iso639_1":"sm","iso639_2":"smo","name":"Samoan","nativeName":"gagana fa'a Samoa"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Samoa","es":"Samoa","fr":"Samoa","ja":"サモア","it":"Samoa","br":"Samoa","pt":"Samoa","nl":"Samoa","hr":"Samoa","fa":"ساموآ"},"flag":"https://restcountries.eu/data/wsm.svg","regionalBlocs":[],"cioc":"SAM"} +{"name":"San Marino","topLevelDomain":[".sm"],"alpha2Code":"SM","alpha3Code":"SMR","callingCodes":["378"],"capital":"City of San Marino","altSpellings":["SM","Republic of San Marino","Repubblica di San Marino"],"region":"Europe","subregion":"Southern Europe","population":33005,"latlng":[43.76666666,12.41666666],"demonym":"Sammarinese","area":61.0,"gini":null,"timezones":["UTC+01:00"],"borders":["ITA"],"nativeName":"San Marino","numericCode":"674","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"it","iso639_2":"ita","name":"Italian","nativeName":"Italiano"}],"translations":{"de":"San Marino","es":"San Marino","fr":"Saint-Marin","ja":"サンマリノ","it":"San Marino","br":"San Marino","pt":"São Marinho","nl":"San Marino","hr":"San Marino","fa":"سان مارینو"},"flag":"https://restcountries.eu/data/smr.svg","regionalBlocs":[],"cioc":"SMR"} +{"name":"Sao Tome and Principe","topLevelDomain":[".st"],"alpha2Code":"ST","alpha3Code":"STP","callingCodes":["239"],"capital":"São Tomé","altSpellings":["ST","Democratic Republic of São Tomé and Príncipe","República Democrática de São Tomé e Príncipe"],"region":"Africa","subregion":"Middle Africa","population":187356,"latlng":[1.0,7.0],"demonym":"Sao Tomean","area":964.0,"gini":50.8,"timezones":["UTC"],"borders":[],"nativeName":"São Tomé e Príncipe","numericCode":"678","currencies":[{"code":"STD","name":"São Tomé and Príncipe dobra","symbol":"Db"}],"languages":[{"iso639_1":"pt","iso639_2":"por","name":"Portuguese","nativeName":"Português"}],"translations":{"de":"São Tomé und Príncipe","es":"Santo Tomé y Príncipe","fr":"Sao Tomé-et-Principe","ja":"サントメ・プリンシペ","it":"São Tomé e Príncipe","br":"São Tomé e Príncipe","pt":"São Tomé e Príncipe","nl":"Sao Tomé en Principe","hr":"Sveti Toma i Princip","fa":"کواترو دو فرویرو"},"flag":"https://restcountries.eu/data/stp.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"STP"} +{"name":"Saudi Arabia","topLevelDomain":[".sa"],"alpha2Code":"SA","alpha3Code":"SAU","callingCodes":["966"],"capital":"Riyadh","altSpellings":["SA","Kingdom of Saudi Arabia","Al-Mamlakah al-‘Arabiyyah as-Su‘ūdiyyah"],"region":"Asia","subregion":"Western Asia","population":32248200,"latlng":[25.0,45.0],"demonym":"Saudi Arabian","area":2149690.0,"gini":null,"timezones":["UTC+03:00"],"borders":["IRQ","JOR","KWT","OMN","QAT","ARE","YEM"],"nativeName":"العربية السعودية","numericCode":"682","currencies":[{"code":"SAR","name":"Saudi riyal","symbol":"ر.س"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Saudi-Arabien","es":"Arabia Saudí","fr":"Arabie Saoudite","ja":"サウジアラビア","it":"Arabia Saudita","br":"Arábia Saudita","pt":"Arábia Saudita","nl":"Saoedi-Arabië","hr":"Saudijska Arabija","fa":"عربستان سعودی"},"flag":"https://restcountries.eu/data/sau.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"KSA"} +{"name":"Senegal","topLevelDomain":[".sn"],"alpha2Code":"SN","alpha3Code":"SEN","callingCodes":["221"],"capital":"Dakar","altSpellings":["SN","Republic of Senegal","République du Sénégal"],"region":"Africa","subregion":"Western Africa","population":14799859,"latlng":[14.0,-14.0],"demonym":"Senegalese","area":196722.0,"gini":39.2,"timezones":["UTC"],"borders":["GMB","GIN","GNB","MLI","MRT"],"nativeName":"Sénégal","numericCode":"686","currencies":[{"code":"XOF","name":"West African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Senegal","es":"Senegal","fr":"Sénégal","ja":"セネガル","it":"Senegal","br":"Senegal","pt":"Senegal","nl":"Senegal","hr":"Senegal","fa":"سنگال"},"flag":"https://restcountries.eu/data/sen.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"SEN"} +{"name":"Serbia","topLevelDomain":[".rs"],"alpha2Code":"RS","alpha3Code":"SRB","callingCodes":["381"],"capital":"Belgrade","altSpellings":["RS","Srbija","Republic of Serbia","Република Србија","Republika Srbija"],"region":"Europe","subregion":"Southern Europe","population":7076372,"latlng":[44.0,21.0],"demonym":"Serbian","area":88361.0,"gini":27.8,"timezones":["UTC+01:00"],"borders":["BIH","BGR","HRV","HUN","KOS","MKD","MNE","ROU"],"nativeName":"Србија","numericCode":"688","currencies":[{"code":"RSD","name":"Serbian dinar","symbol":"дин."}],"languages":[{"iso639_1":"sr","iso639_2":"srp","name":"Serbian","nativeName":"српски језик"}],"translations":{"de":"Serbien","es":"Serbia","fr":"Serbie","ja":"セルビア","it":"Serbia","br":"Sérvia","pt":"Sérvia","nl":"Servië","hr":"Srbija","fa":"صربستان"},"flag":"https://restcountries.eu/data/srb.svg","regionalBlocs":[{"acronym":"CEFTA","name":"Central European Free Trade Agreement","otherAcronyms":[],"otherNames":[]}],"cioc":"SRB"} +{"name":"Seychelles","topLevelDomain":[".sc"],"alpha2Code":"SC","alpha3Code":"SYC","callingCodes":["248"],"capital":"Victoria","altSpellings":["SC","Republic of Seychelles","Repiblik Sesel","République des Seychelles"],"region":"Africa","subregion":"Eastern Africa","population":91400,"latlng":[-4.58333333,55.66666666],"demonym":"Seychellois","area":452.0,"gini":65.8,"timezones":["UTC+04:00"],"borders":[],"nativeName":"Seychelles","numericCode":"690","currencies":[{"code":"SCR","name":"Seychellois rupee","symbol":"₨"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Seychellen","es":"Seychelles","fr":"Seychelles","ja":"セーシェル","it":"Seychelles","br":"Seicheles","pt":"Seicheles","nl":"Seychellen","hr":"Sejšeli","fa":"سیشل"},"flag":"https://restcountries.eu/data/syc.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"SEY"} +{"name":"Sierra Leone","topLevelDomain":[".sl"],"alpha2Code":"SL","alpha3Code":"SLE","callingCodes":["232"],"capital":"Freetown","altSpellings":["SL","Republic of Sierra Leone"],"region":"Africa","subregion":"Western Africa","population":7075641,"latlng":[8.5,-11.5],"demonym":"Sierra Leonean","area":71740.0,"gini":42.5,"timezones":["UTC"],"borders":["GIN","LBR"],"nativeName":"Sierra Leone","numericCode":"694","currencies":[{"code":"SLL","name":"Sierra Leonean leone","symbol":"Le"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Sierra Leone","es":"Sierra Leone","fr":"Sierra Leone","ja":"シエラレオネ","it":"Sierra Leone","br":"Serra Leoa","pt":"Serra Leoa","nl":"Sierra Leone","hr":"Sijera Leone","fa":"سیرالئون"},"flag":"https://restcountries.eu/data/sle.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"SLE"} +{"name":"Singapore","topLevelDomain":[".sg"],"alpha2Code":"SG","alpha3Code":"SGP","callingCodes":["65"],"capital":"Singapore","altSpellings":["SG","Singapura","Republik Singapura","新加坡共和国"],"region":"Asia","subregion":"South-Eastern Asia","population":5535000,"latlng":[1.36666666,103.8],"demonym":"Singaporean","area":710.0,"gini":48.1,"timezones":["UTC+08:00"],"borders":[],"nativeName":"Singapore","numericCode":"702","currencies":[{"code":"BND","name":"Brunei dollar","symbol":"$"},{"code":"SGD","name":"Singapore dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"ms","iso639_2":"msa","name":"Malay","nativeName":"bahasa Melayu"},{"iso639_1":"ta","iso639_2":"tam","name":"Tamil","nativeName":"தமிழ்"},{"iso639_1":"zh","iso639_2":"zho","name":"Chinese","nativeName":"中文 (Zhōngwén)"}],"translations":{"de":"Singapur","es":"Singapur","fr":"Singapour","ja":"シンガポール","it":"Singapore","br":"Singapura","pt":"Singapura","nl":"Singapore","hr":"Singapur","fa":"سنگاپور"},"flag":"https://restcountries.eu/data/sgp.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"SIN"} +{"name":"Sint Maarten (Dutch part)","topLevelDomain":[".sx"],"alpha2Code":"SX","alpha3Code":"SXM","callingCodes":["1721"],"capital":"Philipsburg","altSpellings":["SX"],"region":"Americas","subregion":"Caribbean","population":38247,"latlng":[18.033333,-63.05],"demonym":"Dutch","area":34.0,"gini":null,"timezones":["UTC-04:00"],"borders":["MAF"],"nativeName":"Sint Maarten","numericCode":"534","currencies":[{"code":"ANG","name":"Netherlands Antillean guilder","symbol":"ƒ"}],"languages":[{"iso639_1":"nl","iso639_2":"nld","name":"Dutch","nativeName":"Nederlands"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Sint Maarten (niederl. Teil)","es":null,"fr":"Saint Martin (partie néerlandaise)","ja":null,"it":"Saint Martin (parte olandese)","br":"Sint Maarten","pt":"São Martinho","nl":"Sint Maarten","hr":null,"fa":"سینت مارتن"},"flag":"https://restcountries.eu/data/sxm.svg","regionalBlocs":[],"cioc":""} +{"name":"Slovakia","topLevelDomain":[".sk"],"alpha2Code":"SK","alpha3Code":"SVK","callingCodes":["421"],"capital":"Bratislava","altSpellings":["SK","Slovak Republic","Slovenská republika"],"region":"Europe","subregion":"Eastern Europe","population":5426252,"latlng":[48.66666666,19.5],"demonym":"Slovak","area":49037.0,"gini":26.0,"timezones":["UTC+01:00"],"borders":["AUT","CZE","HUN","POL","UKR"],"nativeName":"Slovensko","numericCode":"703","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"sk","iso639_2":"slk","name":"Slovak","nativeName":"slovenčina"}],"translations":{"de":"Slowakei","es":"República Eslovaca","fr":"Slovaquie","ja":"スロバキア","it":"Slovacchia","br":"Eslováquia","pt":"Eslováquia","nl":"Slowakije","hr":"Slovačka","fa":"اسلواکی"},"flag":"https://restcountries.eu/data/svk.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"SVK"} +{"name":"Slovenia","topLevelDomain":[".si"],"alpha2Code":"SI","alpha3Code":"SVN","callingCodes":["386"],"capital":"Ljubljana","altSpellings":["SI","Republic of Slovenia","Republika Slovenija"],"region":"Europe","subregion":"Southern Europe","population":2064188,"latlng":[46.11666666,14.81666666],"demonym":"Slovene","area":20273.0,"gini":31.2,"timezones":["UTC+01:00"],"borders":["AUT","HRV","ITA","HUN"],"nativeName":"Slovenija","numericCode":"705","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"sl","iso639_2":"slv","name":"Slovene","nativeName":"slovenski jezik"}],"translations":{"de":"Slowenien","es":"Eslovenia","fr":"Slovénie","ja":"スロベニア","it":"Slovenia","br":"Eslovênia","pt":"Eslovénia","nl":"Slovenië","hr":"Slovenija","fa":"اسلوونی"},"flag":"https://restcountries.eu/data/svn.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"SLO"} +{"name":"Solomon Islands","topLevelDomain":[".sb"],"alpha2Code":"SB","alpha3Code":"SLB","callingCodes":["677"],"capital":"Honiara","altSpellings":["SB"],"region":"Oceania","subregion":"Melanesia","population":642000,"latlng":[-8.0,159.0],"demonym":"Solomon Islander","area":28896.0,"gini":null,"timezones":["UTC+11:00"],"borders":[],"nativeName":"Solomon Islands","numericCode":"090","currencies":[{"code":"SBD","name":"Solomon Islands dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Salomonen","es":"Islas Salomón","fr":"Îles Salomon","ja":"ソロモン諸島","it":"Isole Salomone","br":"Ilhas Salomão","pt":"Ilhas Salomão","nl":"Salomonseilanden","hr":"Solomonski Otoci","fa":"جزایر سلیمان"},"flag":"https://restcountries.eu/data/slb.svg","regionalBlocs":[],"cioc":"SOL"} +{"name":"Somalia","topLevelDomain":[".so"],"alpha2Code":"SO","alpha3Code":"SOM","callingCodes":["252"],"capital":"Mogadishu","altSpellings":["SO","aṣ-Ṣūmāl","Federal Republic of Somalia","Jamhuuriyadda Federaalka Soomaaliya","Jumhūriyyat aṣ-Ṣūmāl al-Fiderāliyya"],"region":"Africa","subregion":"Eastern Africa","population":11079000,"latlng":[10.0,49.0],"demonym":"Somali","area":637657.0,"gini":null,"timezones":["UTC+03:00"],"borders":["DJI","ETH","KEN"],"nativeName":"Soomaaliya","numericCode":"706","currencies":[{"code":"SOS","name":"Somali shilling","symbol":"Sh"}],"languages":[{"iso639_1":"so","iso639_2":"som","name":"Somali","nativeName":"Soomaaliga"},{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Somalia","es":"Somalia","fr":"Somalie","ja":"ソマリア","it":"Somalia","br":"Somália","pt":"Somália","nl":"Somalië","hr":"Somalija","fa":"سومالی"},"flag":"https://restcountries.eu/data/som.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"SOM"} +{"name":"South Africa","topLevelDomain":[".za"],"alpha2Code":"ZA","alpha3Code":"ZAF","callingCodes":["27"],"capital":"Pretoria","altSpellings":["ZA","RSA","Suid-Afrika","Republic of South Africa"],"region":"Africa","subregion":"Southern Africa","population":55653654,"latlng":[-29.0,24.0],"demonym":"South African","area":1221037.0,"gini":63.1,"timezones":["UTC+02:00"],"borders":["BWA","LSO","MOZ","NAM","SWZ","ZWE"],"nativeName":"South Africa","numericCode":"710","currencies":[{"code":"ZAR","name":"South African rand","symbol":"R"}],"languages":[{"iso639_1":"af","iso639_2":"afr","name":"Afrikaans","nativeName":"Afrikaans"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"nr","iso639_2":"nbl","name":"Southern Ndebele","nativeName":"isiNdebele"},{"iso639_1":"st","iso639_2":"sot","name":"Southern Sotho","nativeName":"Sesotho"},{"iso639_1":"ss","iso639_2":"ssw","name":"Swati","nativeName":"SiSwati"},{"iso639_1":"tn","iso639_2":"tsn","name":"Tswana","nativeName":"Setswana"},{"iso639_1":"ts","iso639_2":"tso","name":"Tsonga","nativeName":"Xitsonga"},{"iso639_1":"ve","iso639_2":"ven","name":"Venda","nativeName":"Tshivenḓa"},{"iso639_1":"xh","iso639_2":"xho","name":"Xhosa","nativeName":"isiXhosa"},{"iso639_1":"zu","iso639_2":"zul","name":"Zulu","nativeName":"isiZulu"}],"translations":{"de":"Republik Südafrika","es":"República de Sudáfrica","fr":"Afrique du Sud","ja":"南アフリカ","it":"Sud Africa","br":"República Sul-Africana","pt":"República Sul-Africana","nl":"Zuid-Afrika","hr":"Južnoafrička Republika","fa":"آفریقای جنوبی"},"flag":"https://restcountries.eu/data/zaf.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"RSA"} +{"name":"South Georgia and the South Sandwich Islands","topLevelDomain":[".gs"],"alpha2Code":"GS","alpha3Code":"SGS","callingCodes":["500"],"capital":"King Edward Point","altSpellings":["GS","South Georgia and the South Sandwich Islands"],"region":"Americas","subregion":"South America","population":30,"latlng":[-54.5,-37.0],"demonym":"South Georgia and the South Sandwich Islander","area":null,"gini":null,"timezones":["UTC-02:00"],"borders":[],"nativeName":"South Georgia","numericCode":"239","currencies":[{"code":"GBP","name":"British pound","symbol":"£"},{"code":"(none)","name":null,"symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Südgeorgien und die Südlichen Sandwichinseln","es":"Islas Georgias del Sur y Sandwich del Sur","fr":"Géorgie du Sud-et-les Îles Sandwich du Sud","ja":"サウスジョージア・サウスサンドウィッチ諸島","it":"Georgia del Sud e Isole Sandwich Meridionali","br":"Ilhas Geórgias do Sul e Sandwich do Sul","pt":"Ilhas Geórgia do Sul e Sanduíche do Sul","nl":"Zuid-Georgia en Zuidelijke Sandwicheilanden","hr":"Južna Georgija i otočje Južni Sandwich","fa":"جزایر جورجیای جنوبی و ساندویچ جنوبی"},"flag":"https://restcountries.eu/data/sgs.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":""} +{"name":"Korea (Republic of)","topLevelDomain":[".kr"],"alpha2Code":"KR","alpha3Code":"KOR","callingCodes":["82"],"capital":"Seoul","altSpellings":["KR","Republic of Korea"],"region":"Asia","subregion":"Eastern Asia","population":50801405,"latlng":[37.0,127.5],"demonym":"South Korean","area":100210.0,"gini":31.3,"timezones":["UTC+09:00"],"borders":["PRK"],"nativeName":"대한민국","numericCode":"410","currencies":[{"code":"KRW","name":"South Korean won","symbol":"₩"}],"languages":[{"iso639_1":"ko","iso639_2":"kor","name":"Korean","nativeName":"한국어"}],"translations":{"de":"Südkorea","es":"Corea del Sur","fr":"Corée du Sud","ja":"大韓民国","it":"Corea del Sud","br":"Coreia do Sul","pt":"Coreia do Sul","nl":"Zuid-Korea","hr":"Južna Koreja","fa":"کره شمالی"},"flag":"https://restcountries.eu/data/kor.svg","regionalBlocs":[],"cioc":"KOR"} +{"name":"South Sudan","topLevelDomain":[".ss"],"alpha2Code":"SS","alpha3Code":"SSD","callingCodes":["211"],"capital":"Juba","altSpellings":["SS"],"region":"Africa","subregion":"Middle Africa","population":12131000,"latlng":[7.0,30.0],"demonym":"South Sudanese","area":619745.0,"gini":45.5,"timezones":["UTC+03:00"],"borders":["CAF","COD","ETH","KEN","SDN","UGA"],"nativeName":"South Sudan","numericCode":"728","currencies":[{"code":"SSP","name":"South Sudanese pound","symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Südsudan","es":"Sudán del Sur","fr":"Soudan du Sud","ja":"南スーダン","it":"Sudan del sud","br":"Sudão do Sul","pt":"Sudão do Sul","nl":"Zuid-Soedan","hr":"Južni Sudan","fa":"سودان جنوبی"},"flag":"https://restcountries.eu/data/ssd.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":""} +{"name":"Spain","topLevelDomain":[".es"],"alpha2Code":"ES","alpha3Code":"ESP","callingCodes":["34"],"capital":"Madrid","altSpellings":["ES","Kingdom of Spain","Reino de España"],"region":"Europe","subregion":"Southern Europe","population":46438422,"latlng":[40.0,-4.0],"demonym":"Spanish","area":505992.0,"gini":34.7,"timezones":["UTC","UTC+01:00"],"borders":["AND","FRA","GIB","PRT","MAR"],"nativeName":"España","numericCode":"724","currencies":[{"code":"EUR","name":"Euro","symbol":"€"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Spanien","es":"España","fr":"Espagne","ja":"スペイン","it":"Spagna","br":"Espanha","pt":"Espanha","nl":"Spanje","hr":"Španjolska","fa":"اسپانیا"},"flag":"https://restcountries.eu/data/esp.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"ESP"} +{"name":"Sri Lanka","topLevelDomain":[".lk"],"alpha2Code":"LK","alpha3Code":"LKA","callingCodes":["94"],"capital":"Colombo","altSpellings":["LK","ilaṅkai","Democratic Socialist Republic of Sri Lanka"],"region":"Asia","subregion":"Southern Asia","population":20966000,"latlng":[7.0,81.0],"demonym":"Sri Lankan","area":65610.0,"gini":40.3,"timezones":["UTC+05:30"],"borders":["IND"],"nativeName":"śrī laṃkāva","numericCode":"144","currencies":[{"code":"LKR","name":"Sri Lankan rupee","symbol":"Rs"}],"languages":[{"iso639_1":"si","iso639_2":"sin","name":"Sinhalese","nativeName":"සිංහල"},{"iso639_1":"ta","iso639_2":"tam","name":"Tamil","nativeName":"தமிழ்"}],"translations":{"de":"Sri Lanka","es":"Sri Lanka","fr":"Sri Lanka","ja":"スリランカ","it":"Sri Lanka","br":"Sri Lanka","pt":"Sri Lanka","nl":"Sri Lanka","hr":"Šri Lanka","fa":"سری‌لانکا"},"flag":"https://restcountries.eu/data/lka.svg","regionalBlocs":[{"acronym":"SAARC","name":"South Asian Association for Regional Cooperation","otherAcronyms":[],"otherNames":[]}],"cioc":"SRI"} +{"name":"Sudan","topLevelDomain":[".sd"],"alpha2Code":"SD","alpha3Code":"SDN","callingCodes":["249"],"capital":"Khartoum","altSpellings":["SD","Republic of the Sudan","Jumhūrīyat as-Sūdān"],"region":"Africa","subregion":"Northern Africa","population":39598700,"latlng":[15.0,30.0],"demonym":"Sudanese","area":1886068.0,"gini":35.3,"timezones":["UTC+03:00"],"borders":["CAF","TCD","EGY","ERI","ETH","LBY","SSD"],"nativeName":"السودان","numericCode":"729","currencies":[{"code":"SDG","name":"Sudanese pound","symbol":"ج.س."}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Sudan","es":"Sudán","fr":"Soudan","ja":"スーダン","it":"Sudan","br":"Sudão","pt":"Sudão","nl":"Soedan","hr":"Sudan","fa":"سودان"},"flag":"https://restcountries.eu/data/sdn.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"SUD"} +{"name":"Suriname","topLevelDomain":[".sr"],"alpha2Code":"SR","alpha3Code":"SUR","callingCodes":["597"],"capital":"Paramaribo","altSpellings":["SR","Sarnam","Sranangron","Republic of Suriname","Republiek Suriname"],"region":"Americas","subregion":"South America","population":541638,"latlng":[4.0,-56.0],"demonym":"Surinamer","area":163820.0,"gini":52.9,"timezones":["UTC-03:00"],"borders":["BRA","GUF","FRA","GUY"],"nativeName":"Suriname","numericCode":"740","currencies":[{"code":"SRD","name":"Surinamese dollar","symbol":"$"}],"languages":[{"iso639_1":"nl","iso639_2":"nld","name":"Dutch","nativeName":"Nederlands"}],"translations":{"de":"Suriname","es":"Surinam","fr":"Surinam","ja":"スリナム","it":"Suriname","br":"Suriname","pt":"Suriname","nl":"Suriname","hr":"Surinam","fa":"سورینام"},"flag":"https://restcountries.eu/data/sur.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]},{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"SUR"} +{"name":"Svalbard and Jan Mayen","topLevelDomain":[".sj"],"alpha2Code":"SJ","alpha3Code":"SJM","callingCodes":["4779"],"capital":"Longyearbyen","altSpellings":["SJ","Svalbard and Jan Mayen Islands"],"region":"Europe","subregion":"Northern Europe","population":2562,"latlng":[78.0,20.0],"demonym":"Norwegian","area":null,"gini":null,"timezones":["UTC+01:00"],"borders":[],"nativeName":"Svalbard og Jan Mayen","numericCode":"744","currencies":[{"code":"NOK","name":"Norwegian krone","symbol":"kr"}],"languages":[{"iso639_1":"no","iso639_2":"nor","name":"Norwegian","nativeName":"Norsk"}],"translations":{"de":"Svalbard und Jan Mayen","es":"Islas Svalbard y Jan Mayen","fr":"Svalbard et Jan Mayen","ja":"スヴァールバル諸島およびヤンマイエン島","it":"Svalbard e Jan Mayen","br":"Svalbard","pt":"Svalbard","nl":"Svalbard en Jan Mayen","hr":"Svalbard i Jan Mayen","fa":"سوالبارد و یان ماین"},"flag":"https://restcountries.eu/data/sjm.svg","regionalBlocs":[],"cioc":""} +{"name":"Swaziland","topLevelDomain":[".sz"],"alpha2Code":"SZ","alpha3Code":"SWZ","callingCodes":["268"],"capital":"Lobamba","altSpellings":["SZ","weSwatini","Swatini","Ngwane","Kingdom of Swaziland","Umbuso waseSwatini"],"region":"Africa","subregion":"Southern Africa","population":1132657,"latlng":[-26.5,31.5],"demonym":"Swazi","area":17364.0,"gini":51.5,"timezones":["UTC+02:00"],"borders":["MOZ","ZAF"],"nativeName":"Swaziland","numericCode":"748","currencies":[{"code":"SZL","name":"Swazi lilangeni","symbol":"L"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"ss","iso639_2":"ssw","name":"Swati","nativeName":"SiSwati"}],"translations":{"de":"Swasiland","es":"Suazilandia","fr":"Swaziland","ja":"スワジランド","it":"Swaziland","br":"Suazilândia","pt":"Suazilândia","nl":"Swaziland","hr":"Svazi","fa":"سوازیلند"},"flag":"https://restcountries.eu/data/swz.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"SWZ"} +{"name":"Sweden","topLevelDomain":[".se"],"alpha2Code":"SE","alpha3Code":"SWE","callingCodes":["46"],"capital":"Stockholm","altSpellings":["SE","Kingdom of Sweden","Konungariket Sverige"],"region":"Europe","subregion":"Northern Europe","population":9894888,"latlng":[62.0,15.0],"demonym":"Swedish","area":450295.0,"gini":25.0,"timezones":["UTC+01:00"],"borders":["FIN","NOR"],"nativeName":"Sverige","numericCode":"752","currencies":[{"code":"SEK","name":"Swedish krona","symbol":"kr"}],"languages":[{"iso639_1":"sv","iso639_2":"swe","name":"Swedish","nativeName":"svenska"}],"translations":{"de":"Schweden","es":"Suecia","fr":"Suède","ja":"スウェーデン","it":"Svezia","br":"Suécia","pt":"Suécia","nl":"Zweden","hr":"Švedska","fa":"سوئد"},"flag":"https://restcountries.eu/data/swe.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"SWE"} +{"name":"Switzerland","topLevelDomain":[".ch"],"alpha2Code":"CH","alpha3Code":"CHE","callingCodes":["41"],"capital":"Bern","altSpellings":["CH","Swiss Confederation","Schweiz","Suisse","Svizzera","Svizra"],"region":"Europe","subregion":"Western Europe","population":8341600,"latlng":[47.0,8.0],"demonym":"Swiss","area":41284.0,"gini":33.7,"timezones":["UTC+01:00"],"borders":["AUT","FRA","ITA","LIE","DEU"],"nativeName":"Schweiz","numericCode":"756","currencies":[{"code":"CHF","name":"Swiss franc","symbol":"Fr"}],"languages":[{"iso639_1":"de","iso639_2":"deu","name":"German","nativeName":"Deutsch"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"},{"iso639_1":"it","iso639_2":"ita","name":"Italian","nativeName":"Italiano"}],"translations":{"de":"Schweiz","es":"Suiza","fr":"Suisse","ja":"スイス","it":"Svizzera","br":"Suíça","pt":"Suíça","nl":"Zwitserland","hr":"Švicarska","fa":"سوئیس"},"flag":"https://restcountries.eu/data/che.svg","regionalBlocs":[{"acronym":"EFTA","name":"European Free Trade Association","otherAcronyms":[],"otherNames":[]}],"cioc":"SUI"} +{"name":"Syrian Arab Republic","topLevelDomain":[".sy"],"alpha2Code":"SY","alpha3Code":"SYR","callingCodes":["963"],"capital":"Damascus","altSpellings":["SY","Syrian Arab Republic","Al-Jumhūrīyah Al-ʻArabīyah As-Sūrīyah"],"region":"Asia","subregion":"Western Asia","population":18564000,"latlng":[35.0,38.0],"demonym":"Syrian","area":185180.0,"gini":35.8,"timezones":["UTC+02:00"],"borders":["IRQ","ISR","JOR","LBN","TUR"],"nativeName":"سوريا","numericCode":"760","currencies":[{"code":"SYP","name":"Syrian pound","symbol":"£"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Syrien","es":"Siria","fr":"Syrie","ja":"シリア・アラブ共和国","it":"Siria","br":"Síria","pt":"Síria","nl":"Syrië","hr":"Sirija","fa":"سوریه"},"flag":"https://restcountries.eu/data/syr.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"SYR"} +{"name":"Taiwan","topLevelDomain":[".tw"],"alpha2Code":"TW","alpha3Code":"TWN","callingCodes":["886"],"capital":"Taipei","altSpellings":["TW","Táiwān","Republic of China","中華民國","Zhōnghuá Mínguó"],"region":"Asia","subregion":"Eastern Asia","population":23503349,"latlng":[23.5,121.0],"demonym":"Taiwanese","area":36193.0,"gini":null,"timezones":["UTC+08:00"],"borders":[],"nativeName":"臺灣","numericCode":"158","currencies":[{"code":"TWD","name":"New Taiwan dollar","symbol":"$"}],"languages":[{"iso639_1":"zh","iso639_2":"zho","name":"Chinese","nativeName":"中文 (Zhōngwén)"}],"translations":{"de":"Taiwan","es":"Taiwán","fr":"Taïwan","ja":"台湾(中華民国)","it":"Taiwan","br":"Taiwan","pt":"Taiwan","nl":"Taiwan","hr":"Tajvan","fa":"تایوان"},"flag":"https://restcountries.eu/data/twn.svg","regionalBlocs":[],"cioc":"TPE"} +{"name":"Tajikistan","topLevelDomain":[".tj"],"alpha2Code":"TJ","alpha3Code":"TJK","callingCodes":["992"],"capital":"Dushanbe","altSpellings":["TJ","Toçikiston","Republic of Tajikistan","Ҷумҳурии Тоҷикистон","Çumhuriyi Toçikiston"],"region":"Asia","subregion":"Central Asia","population":8593600,"latlng":[39.0,71.0],"demonym":"Tadzhik","area":143100.0,"gini":30.8,"timezones":["UTC+05:00"],"borders":["AFG","CHN","KGZ","UZB"],"nativeName":"Тоҷикистон","numericCode":"762","currencies":[{"code":"TJS","name":"Tajikistani somoni","symbol":"ЅМ"}],"languages":[{"iso639_1":"tg","iso639_2":"tgk","name":"Tajik","nativeName":"тоҷикӣ"},{"iso639_1":"ru","iso639_2":"rus","name":"Russian","nativeName":"Русский"}],"translations":{"de":"Tadschikistan","es":"Tayikistán","fr":"Tadjikistan","ja":"タジキスタン","it":"Tagikistan","br":"Tajiquistão","pt":"Tajiquistão","nl":"Tadzjikistan","hr":"Tađikistan","fa":"تاجیکستان"},"flag":"https://restcountries.eu/data/tjk.svg","regionalBlocs":[],"cioc":"TJK"} +{"name":"Tanzania, United Republic of","topLevelDomain":[".tz"],"alpha2Code":"TZ","alpha3Code":"TZA","callingCodes":["255"],"capital":"Dodoma","altSpellings":["TZ","United Republic of Tanzania","Jamhuri ya Muungano wa Tanzania"],"region":"Africa","subregion":"Eastern Africa","population":55155000,"latlng":[-6.0,35.0],"demonym":"Tanzanian","area":945087.0,"gini":37.6,"timezones":["UTC+03:00"],"borders":["BDI","COD","KEN","MWI","MOZ","RWA","UGA","ZMB"],"nativeName":"Tanzania","numericCode":"834","currencies":[{"code":"TZS","name":"Tanzanian shilling","symbol":"Sh"}],"languages":[{"iso639_1":"sw","iso639_2":"swa","name":"Swahili","nativeName":"Kiswahili"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Tansania","es":"Tanzania","fr":"Tanzanie","ja":"タンザニア","it":"Tanzania","br":"Tanzânia","pt":"Tanzânia","nl":"Tanzania","hr":"Tanzanija","fa":"تانزانیا"},"flag":"https://restcountries.eu/data/tza.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"TAN"} +{"name":"Thailand","topLevelDomain":[".th"],"alpha2Code":"TH","alpha3Code":"THA","callingCodes":["66"],"capital":"Bangkok","altSpellings":["TH","Prathet","Thai","Kingdom of Thailand","ราชอาณาจักรไทย","Ratcha Anachak Thai"],"region":"Asia","subregion":"South-Eastern Asia","population":65327652,"latlng":[15.0,100.0],"demonym":"Thai","area":513120.0,"gini":40.0,"timezones":["UTC+07:00"],"borders":["MMR","KHM","LAO","MYS"],"nativeName":"ประเทศไทย","numericCode":"764","currencies":[{"code":"THB","name":"Thai baht","symbol":"฿"}],"languages":[{"iso639_1":"th","iso639_2":"tha","name":"Thai","nativeName":"ไทย"}],"translations":{"de":"Thailand","es":"Tailandia","fr":"Thaïlande","ja":"タイ","it":"Tailandia","br":"Tailândia","pt":"Tailândia","nl":"Thailand","hr":"Tajland","fa":"تایلند"},"flag":"https://restcountries.eu/data/tha.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"THA"} +{"name":"Timor-Leste","topLevelDomain":[".tl"],"alpha2Code":"TL","alpha3Code":"TLS","callingCodes":["670"],"capital":"Dili","altSpellings":["TL","East Timor","Democratic Republic of Timor-Leste","República Democrática de Timor-Leste","Repúblika Demokrátika Timór-Leste"],"region":"Asia","subregion":"South-Eastern Asia","population":1167242,"latlng":[-8.83333333,125.91666666],"demonym":"East Timorese","area":14874.0,"gini":31.9,"timezones":["UTC+09:00"],"borders":["IDN"],"nativeName":"Timor-Leste","numericCode":"626","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"},{"code":null,"name":null,"symbol":null}],"languages":[{"iso639_1":"pt","iso639_2":"por","name":"Portuguese","nativeName":"Português"}],"translations":{"de":"Timor-Leste","es":"Timor Oriental","fr":"Timor oriental","ja":"東ティモール","it":"Timor Est","br":"Timor Leste","pt":"Timor Leste","nl":"Oost-Timor","hr":"Istočni Timor","fa":"تیمور شرقی"},"flag":"https://restcountries.eu/data/tls.svg","regionalBlocs":[],"cioc":"TLS"} +{"name":"Togo","topLevelDomain":[".tg"],"alpha2Code":"TG","alpha3Code":"TGO","callingCodes":["228"],"capital":"Lomé","altSpellings":["TG","Togolese","Togolese Republic","République Togolaise"],"region":"Africa","subregion":"Western Africa","population":7143000,"latlng":[8.0,1.16666666],"demonym":"Togolese","area":56785.0,"gini":34.4,"timezones":["UTC"],"borders":["BEN","BFA","GHA"],"nativeName":"Togo","numericCode":"768","currencies":[{"code":"XOF","name":"West African CFA franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Togo","es":"Togo","fr":"Togo","ja":"トーゴ","it":"Togo","br":"Togo","pt":"Togo","nl":"Togo","hr":"Togo","fa":"توگو"},"flag":"https://restcountries.eu/data/tgo.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"TOG"} +{"name":"Tokelau","topLevelDomain":[".tk"],"alpha2Code":"TK","alpha3Code":"TKL","callingCodes":["690"],"capital":"Fakaofo","altSpellings":["TK"],"region":"Oceania","subregion":"Polynesia","population":1411,"latlng":[-9.0,-172.0],"demonym":"Tokelauan","area":12.0,"gini":null,"timezones":["UTC+13:00"],"borders":[],"nativeName":"Tokelau","numericCode":"772","currencies":[{"code":"NZD","name":"New Zealand dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Tokelau","es":"Islas Tokelau","fr":"Tokelau","ja":"トケラウ","it":"Isole Tokelau","br":"Tokelau","pt":"Toquelau","nl":"Tokelau","hr":"Tokelau","fa":"توکلائو"},"flag":"https://restcountries.eu/data/tkl.svg","regionalBlocs":[],"cioc":""} +{"name":"Tonga","topLevelDomain":[".to"],"alpha2Code":"TO","alpha3Code":"TON","callingCodes":["676"],"capital":"Nuku'alofa","altSpellings":["TO"],"region":"Oceania","subregion":"Polynesia","population":103252,"latlng":[-20.0,-175.0],"demonym":"Tongan","area":747.0,"gini":null,"timezones":["UTC+13:00"],"borders":[],"nativeName":"Tonga","numericCode":"776","currencies":[{"code":"TOP","name":"Tongan paʻanga","symbol":"T$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"to","iso639_2":"ton","name":"Tonga (Tonga Islands)","nativeName":"faka Tonga"}],"translations":{"de":"Tonga","es":"Tonga","fr":"Tonga","ja":"トンガ","it":"Tonga","br":"Tonga","pt":"Tonga","nl":"Tonga","hr":"Tonga","fa":"تونگا"},"flag":"https://restcountries.eu/data/ton.svg","regionalBlocs":[],"cioc":"TGA"} +{"name":"Trinidad and Tobago","topLevelDomain":[".tt"],"alpha2Code":"TT","alpha3Code":"TTO","callingCodes":["1868"],"capital":"Port of Spain","altSpellings":["TT","Republic of Trinidad and Tobago"],"region":"Americas","subregion":"Caribbean","population":1349667,"latlng":[11.0,-61.0],"demonym":"Trinidadian","area":5130.0,"gini":40.3,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Trinidad and Tobago","numericCode":"780","currencies":[{"code":"TTD","name":"Trinidad and Tobago dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Trinidad und Tobago","es":"Trinidad y Tobago","fr":"Trinité et Tobago","ja":"トリニダード・トバゴ","it":"Trinidad e Tobago","br":"Trinidad e Tobago","pt":"Trindade e Tobago","nl":"Trinidad en Tobago","hr":"Trinidad i Tobago","fa":"ترینیداد و توباگو"},"flag":"https://restcountries.eu/data/tto.svg","regionalBlocs":[{"acronym":"CARICOM","name":"Caribbean Community","otherAcronyms":[],"otherNames":["Comunidad del Caribe","Communauté Caribéenne","Caribische Gemeenschap"]}],"cioc":"TTO"} +{"name":"Tunisia","topLevelDomain":[".tn"],"alpha2Code":"TN","alpha3Code":"TUN","callingCodes":["216"],"capital":"Tunis","altSpellings":["TN","Republic of Tunisia","al-Jumhūriyyah at-Tūnisiyyah"],"region":"Africa","subregion":"Northern Africa","population":11154400,"latlng":[34.0,9.0],"demonym":"Tunisian","area":163610.0,"gini":41.4,"timezones":["UTC+01:00"],"borders":["DZA","LBY"],"nativeName":"تونس","numericCode":"788","currencies":[{"code":"TND","name":"Tunisian dinar","symbol":"د.ت"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Tunesien","es":"Túnez","fr":"Tunisie","ja":"チュニジア","it":"Tunisia","br":"Tunísia","pt":"Tunísia","nl":"Tunesië","hr":"Tunis","fa":"تونس"},"flag":"https://restcountries.eu/data/tun.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]},{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"TUN"} +{"name":"Turkey","topLevelDomain":[".tr"],"alpha2Code":"TR","alpha3Code":"TUR","callingCodes":["90"],"capital":"Ankara","altSpellings":["TR","Turkiye","Republic of Turkey","Türkiye Cumhuriyeti"],"region":"Asia","subregion":"Western Asia","population":78741053,"latlng":[39.0,35.0],"demonym":"Turkish","area":783562.0,"gini":39.0,"timezones":["UTC+03:00"],"borders":["ARM","AZE","BGR","GEO","GRC","IRN","IRQ","SYR"],"nativeName":"Türkiye","numericCode":"792","currencies":[{"code":"TRY","name":"Turkish lira","symbol":null}],"languages":[{"iso639_1":"tr","iso639_2":"tur","name":"Turkish","nativeName":"Türkçe"}],"translations":{"de":"Türkei","es":"Turquía","fr":"Turquie","ja":"トルコ","it":"Turchia","br":"Turquia","pt":"Turquia","nl":"Turkije","hr":"Turska","fa":"ترکیه"},"flag":"https://restcountries.eu/data/tur.svg","regionalBlocs":[],"cioc":"TUR"} +{"name":"Turkmenistan","topLevelDomain":[".tm"],"alpha2Code":"TM","alpha3Code":"TKM","callingCodes":["993"],"capital":"Ashgabat","altSpellings":["TM"],"region":"Asia","subregion":"Central Asia","population":4751120,"latlng":[40.0,60.0],"demonym":"Turkmen","area":488100.0,"gini":40.8,"timezones":["UTC+05:00"],"borders":["AFG","IRN","KAZ","UZB"],"nativeName":"Türkmenistan","numericCode":"795","currencies":[{"code":"TMT","name":"Turkmenistan manat","symbol":"m"}],"languages":[{"iso639_1":"tk","iso639_2":"tuk","name":"Turkmen","nativeName":"Türkmen"},{"iso639_1":"ru","iso639_2":"rus","name":"Russian","nativeName":"Русский"}],"translations":{"de":"Turkmenistan","es":"Turkmenistán","fr":"Turkménistan","ja":"トルクメニスタン","it":"Turkmenistan","br":"Turcomenistão","pt":"Turquemenistão","nl":"Turkmenistan","hr":"Turkmenistan","fa":"ترکمنستان"},"flag":"https://restcountries.eu/data/tkm.svg","regionalBlocs":[],"cioc":"TKM"} +{"name":"Turks and Caicos Islands","topLevelDomain":[".tc"],"alpha2Code":"TC","alpha3Code":"TCA","callingCodes":["1649"],"capital":"Cockburn Town","altSpellings":["TC"],"region":"Americas","subregion":"Caribbean","population":31458,"latlng":[21.75,-71.58333333],"demonym":"Turks and Caicos Islander","area":948.0,"gini":null,"timezones":["UTC-04:00"],"borders":[],"nativeName":"Turks and Caicos Islands","numericCode":"796","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Turks- und Caicosinseln","es":"Islas Turks y Caicos","fr":"Îles Turques-et-Caïques","ja":"タークス・カイコス諸島","it":"Isole Turks e Caicos","br":"Ilhas Turcas e Caicos","pt":"Ilhas Turcas e Caicos","nl":"Turks- en Caicoseilanden","hr":"Otoci Turks i Caicos","fa":"جزایر تورکس و کایکوس"},"flag":"https://restcountries.eu/data/tca.svg","regionalBlocs":[],"cioc":""} +{"name":"Tuvalu","topLevelDomain":[".tv"],"alpha2Code":"TV","alpha3Code":"TUV","callingCodes":["688"],"capital":"Funafuti","altSpellings":["TV"],"region":"Oceania","subregion":"Polynesia","population":10640,"latlng":[-8.0,178.0],"demonym":"Tuvaluan","area":26.0,"gini":null,"timezones":["UTC+12:00"],"borders":[],"nativeName":"Tuvalu","numericCode":"798","currencies":[{"code":"AUD","name":"Australian dollar","symbol":"$"},{"code":"TVD[G]","name":"Tuvaluan dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Tuvalu","es":"Tuvalu","fr":"Tuvalu","ja":"ツバル","it":"Tuvalu","br":"Tuvalu","pt":"Tuvalu","nl":"Tuvalu","hr":"Tuvalu","fa":"تووالو"},"flag":"https://restcountries.eu/data/tuv.svg","regionalBlocs":[],"cioc":"TUV"} +{"name":"Uganda","topLevelDomain":[".ug"],"alpha2Code":"UG","alpha3Code":"UGA","callingCodes":["256"],"capital":"Kampala","altSpellings":["UG","Republic of Uganda","Jamhuri ya Uganda"],"region":"Africa","subregion":"Eastern Africa","population":33860700,"latlng":[1.0,32.0],"demonym":"Ugandan","area":241550.0,"gini":44.3,"timezones":["UTC+03:00"],"borders":["COD","KEN","RWA","SSD","TZA"],"nativeName":"Uganda","numericCode":"800","currencies":[{"code":"UGX","name":"Ugandan shilling","symbol":"Sh"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"sw","iso639_2":"swa","name":"Swahili","nativeName":"Kiswahili"}],"translations":{"de":"Uganda","es":"Uganda","fr":"Uganda","ja":"ウガンダ","it":"Uganda","br":"Uganda","pt":"Uganda","nl":"Oeganda","hr":"Uganda","fa":"اوگاندا"},"flag":"https://restcountries.eu/data/uga.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"UGA"} +{"name":"Ukraine","topLevelDomain":[".ua"],"alpha2Code":"UA","alpha3Code":"UKR","callingCodes":["380"],"capital":"Kiev","altSpellings":["UA","Ukrayina"],"region":"Europe","subregion":"Eastern Europe","population":42692393,"latlng":[49.0,32.0],"demonym":"Ukrainian","area":603700.0,"gini":26.4,"timezones":["UTC+02:00"],"borders":["BLR","HUN","MDA","POL","ROU","RUS","SVK"],"nativeName":"Україна","numericCode":"804","currencies":[{"code":"UAH","name":"Ukrainian hryvnia","symbol":"₴"}],"languages":[{"iso639_1":"uk","iso639_2":"ukr","name":"Ukrainian","nativeName":"Українська"}],"translations":{"de":"Ukraine","es":"Ucrania","fr":"Ukraine","ja":"ウクライナ","it":"Ucraina","br":"Ucrânia","pt":"Ucrânia","nl":"Oekraïne","hr":"Ukrajina","fa":"وکراین"},"flag":"https://restcountries.eu/data/ukr.svg","regionalBlocs":[],"cioc":"UKR"} +{"name":"United Arab Emirates","topLevelDomain":[".ae"],"alpha2Code":"AE","alpha3Code":"ARE","callingCodes":["971"],"capital":"Abu Dhabi","altSpellings":["AE","UAE"],"region":"Asia","subregion":"Western Asia","population":9856000,"latlng":[24.0,54.0],"demonym":"Emirati","area":83600.0,"gini":null,"timezones":["UTC+04"],"borders":["OMN","SAU"],"nativeName":"دولة الإمارات العربية المتحدة","numericCode":"784","currencies":[{"code":"AED","name":"United Arab Emirates dirham","symbol":"د.إ"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Vereinigte Arabische Emirate","es":"Emiratos Árabes Unidos","fr":"Émirats arabes unis","ja":"アラブ首長国連邦","it":"Emirati Arabi Uniti","br":"Emirados árabes Unidos","pt":"Emirados árabes Unidos","nl":"Verenigde Arabische Emiraten","hr":"Ujedinjeni Arapski Emirati","fa":"امارات متحده عربی"},"flag":"https://restcountries.eu/data/are.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"UAE"} +{"name":"United Kingdom of Great Britain and Northern Ireland","topLevelDomain":[".uk"],"alpha2Code":"GB","alpha3Code":"GBR","callingCodes":["44"],"capital":"London","altSpellings":["GB","UK","Great Britain"],"region":"Europe","subregion":"Northern Europe","population":65110000,"latlng":[54.0,-2.0],"demonym":"British","area":242900.0,"gini":34.0,"timezones":["UTC-08:00","UTC-05:00","UTC-04:00","UTC-03:00","UTC-02:00","UTC","UTC+01:00","UTC+02:00","UTC+06:00"],"borders":["IRL"],"nativeName":"United Kingdom","numericCode":"826","currencies":[{"code":"GBP","name":"British pound","symbol":"£"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Vereinigtes Königreich","es":"Reino Unido","fr":"Royaume-Uni","ja":"イギリス","it":"Regno Unito","br":"Reino Unido","pt":"Reino Unido","nl":"Verenigd Koninkrijk","hr":"Ujedinjeno Kraljevstvo","fa":"بریتانیای کبیر و ایرلند شمالی"},"flag":"https://restcountries.eu/data/gbr.svg","regionalBlocs":[{"acronym":"EU","name":"European Union","otherAcronyms":[],"otherNames":[]}],"cioc":"GBR"} +{"name":"United States of America","topLevelDomain":[".us"],"alpha2Code":"US","alpha3Code":"USA","callingCodes":["1"],"capital":"Washington, D.C.","altSpellings":["US","USA","United States of America"],"region":"Americas","subregion":"Northern America","population":323947000,"latlng":[38.0,-97.0],"demonym":"American","area":9629091.0,"gini":48.0,"timezones":["UTC-12:00","UTC-11:00","UTC-10:00","UTC-09:00","UTC-08:00","UTC-07:00","UTC-06:00","UTC-05:00","UTC-04:00","UTC+10:00","UTC+12:00"],"borders":["CAN","MEX"],"nativeName":"United States","numericCode":"840","currencies":[{"code":"USD","name":"United States dollar","symbol":"$"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Vereinigte Staaten von Amerika","es":"Estados Unidos","fr":"États-Unis","ja":"アメリカ合衆国","it":"Stati Uniti D'America","br":"Estados Unidos","pt":"Estados Unidos","nl":"Verenigde Staten","hr":"Sjedinjene Američke Države","fa":"ایالات متحده آمریکا"},"flag":"https://restcountries.eu/data/usa.svg","regionalBlocs":[{"acronym":"NAFTA","name":"North American Free Trade Agreement","otherAcronyms":[],"otherNames":["Tratado de Libre Comercio de América del Norte","Accord de Libre-échange Nord-Américain"]}],"cioc":"USA"} +{"name":"Uruguay","topLevelDomain":[".uy"],"alpha2Code":"UY","alpha3Code":"URY","callingCodes":["598"],"capital":"Montevideo","altSpellings":["UY","Oriental Republic of Uruguay","República Oriental del Uruguay"],"region":"Americas","subregion":"South America","population":3480222,"latlng":[-33.0,-56.0],"demonym":"Uruguayan","area":181034.0,"gini":39.7,"timezones":["UTC-03:00"],"borders":["ARG","BRA"],"nativeName":"Uruguay","numericCode":"858","currencies":[{"code":"UYU","name":"Uruguayan peso","symbol":"$"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Uruguay","es":"Uruguay","fr":"Uruguay","ja":"ウルグアイ","it":"Uruguay","br":"Uruguai","pt":"Uruguai","nl":"Uruguay","hr":"Urugvaj","fa":"اروگوئه"},"flag":"https://restcountries.eu/data/ury.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"URU"} +{"name":"Uzbekistan","topLevelDomain":[".uz"],"alpha2Code":"UZ","alpha3Code":"UZB","callingCodes":["998"],"capital":"Tashkent","altSpellings":["UZ","Republic of Uzbekistan","O‘zbekiston Respublikasi","Ўзбекистон Республикаси"],"region":"Asia","subregion":"Central Asia","population":31576400,"latlng":[41.0,64.0],"demonym":"Uzbekistani","area":447400.0,"gini":36.7,"timezones":["UTC+05:00"],"borders":["AFG","KAZ","KGZ","TJK","TKM"],"nativeName":"O‘zbekiston","numericCode":"860","currencies":[{"code":"UZS","name":"Uzbekistani so'm","symbol":null}],"languages":[{"iso639_1":"uz","iso639_2":"uzb","name":"Uzbek","nativeName":"Oʻzbek"},{"iso639_1":"ru","iso639_2":"rus","name":"Russian","nativeName":"Русский"}],"translations":{"de":"Usbekistan","es":"Uzbekistán","fr":"Ouzbékistan","ja":"ウズベキスタン","it":"Uzbekistan","br":"Uzbequistão","pt":"Usbequistão","nl":"Oezbekistan","hr":"Uzbekistan","fa":"ازبکستان"},"flag":"https://restcountries.eu/data/uzb.svg","regionalBlocs":[],"cioc":"UZB"} +{"name":"Vanuatu","topLevelDomain":[".vu"],"alpha2Code":"VU","alpha3Code":"VUT","callingCodes":["678"],"capital":"Port Vila","altSpellings":["VU","Republic of Vanuatu","Ripablik blong Vanuatu","République de Vanuatu"],"region":"Oceania","subregion":"Melanesia","population":277500,"latlng":[-16.0,167.0],"demonym":"Ni-Vanuatu","area":12189.0,"gini":null,"timezones":["UTC+11:00"],"borders":[],"nativeName":"Vanuatu","numericCode":"548","currencies":[{"code":"VUV","name":"Vanuatu vatu","symbol":"Vt"}],"languages":[{"iso639_1":"bi","iso639_2":"bis","name":"Bislama","nativeName":"Bislama"},{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Vanuatu","es":"Vanuatu","fr":"Vanuatu","ja":"バヌアツ","it":"Vanuatu","br":"Vanuatu","pt":"Vanuatu","nl":"Vanuatu","hr":"Vanuatu","fa":"وانواتو"},"flag":"https://restcountries.eu/data/vut.svg","regionalBlocs":[],"cioc":"VAN"} +{"name":"Venezuela (Bolivarian Republic of)","topLevelDomain":[".ve"],"alpha2Code":"VE","alpha3Code":"VEN","callingCodes":["58"],"capital":"Caracas","altSpellings":["VE","Bolivarian Republic of Venezuela","República Bolivariana de Venezuela"],"region":"Americas","subregion":"South America","population":31028700,"latlng":[8.0,-66.0],"demonym":"Venezuelan","area":916445.0,"gini":44.8,"timezones":["UTC-04:00"],"borders":["BRA","COL","GUY"],"nativeName":"Venezuela","numericCode":"862","currencies":[{"code":"VEF","name":"Venezuelan bolívar","symbol":"Bs F"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Venezuela","es":"Venezuela","fr":"Venezuela","ja":"ベネズエラ・ボリバル共和国","it":"Venezuela","br":"Venezuela","pt":"Venezuela","nl":"Venezuela","hr":"Venezuela","fa":"ونزوئلا"},"flag":"https://restcountries.eu/data/ven.svg","regionalBlocs":[{"acronym":"USAN","name":"Union of South American Nations","otherAcronyms":["UNASUR","UNASUL","UZAN"],"otherNames":["Unión de Naciones Suramericanas","União de Nações Sul-Americanas","Unie van Zuid-Amerikaanse Naties","South American Union"]}],"cioc":"VEN"} +{"name":"Viet Nam","topLevelDomain":[".vn"],"alpha2Code":"VN","alpha3Code":"VNM","callingCodes":["84"],"capital":"Hanoi","altSpellings":["VN","Socialist Republic of Vietnam","Cộng hòa Xã hội chủ nghĩa Việt Nam"],"region":"Asia","subregion":"South-Eastern Asia","population":92700000,"latlng":[16.16666666,107.83333333],"demonym":"Vietnamese","area":331212.0,"gini":35.6,"timezones":["UTC+07:00"],"borders":["KHM","CHN","LAO"],"nativeName":"Việt Nam","numericCode":"704","currencies":[{"code":"VND","name":"Vietnamese đồng","symbol":"₫"}],"languages":[{"iso639_1":"vi","iso639_2":"vie","name":"Vietnamese","nativeName":"Tiếng Việt"}],"translations":{"de":"Vietnam","es":"Vietnam","fr":"Viêt Nam","ja":"ベトナム","it":"Vietnam","br":"Vietnã","pt":"Vietname","nl":"Vietnam","hr":"Vijetnam","fa":"ویتنام"},"flag":"https://restcountries.eu/data/vnm.svg","regionalBlocs":[{"acronym":"ASEAN","name":"Association of Southeast Asian Nations","otherAcronyms":[],"otherNames":[]}],"cioc":"VIE"} +{"name":"Wallis and Futuna","topLevelDomain":[".wf"],"alpha2Code":"WF","alpha3Code":"WLF","callingCodes":["681"],"capital":"Mata-Utu","altSpellings":["WF","Territory of the Wallis and Futuna Islands","Territoire des îles Wallis et Futuna"],"region":"Oceania","subregion":"Polynesia","population":11750,"latlng":[-13.3,-176.2],"demonym":"Wallis and Futuna Islander","area":142.0,"gini":null,"timezones":["UTC+12:00"],"borders":[],"nativeName":"Wallis et Futuna","numericCode":"876","currencies":[{"code":"XPF","name":"CFP franc","symbol":"Fr"}],"languages":[{"iso639_1":"fr","iso639_2":"fra","name":"French","nativeName":"français"}],"translations":{"de":"Wallis und Futuna","es":"Wallis y Futuna","fr":"Wallis-et-Futuna","ja":"ウォリス・フツナ","it":"Wallis e Futuna","br":"Wallis e Futuna","pt":"Wallis e Futuna","nl":"Wallis en Futuna","hr":"Wallis i Fortuna","fa":"والیس و فوتونا"},"flag":"https://restcountries.eu/data/wlf.svg","regionalBlocs":[],"cioc":""} +{"name":"Western Sahara","topLevelDomain":[".eh"],"alpha2Code":"EH","alpha3Code":"ESH","callingCodes":["212"],"capital":"El Aaiún","altSpellings":["EH","Taneẓroft Tutrimt"],"region":"Africa","subregion":"Northern Africa","population":510713,"latlng":[24.5,-13.0],"demonym":"Sahrawi","area":266000.0,"gini":null,"timezones":["UTC+00:00"],"borders":["DZA","MRT","MAR"],"nativeName":"الصحراء الغربية","numericCode":"732","currencies":[{"code":"MAD","name":"Moroccan dirham","symbol":"د.م."},{"code":"DZD","name":"Algerian dinar","symbol":"د.ج"}],"languages":[{"iso639_1":"es","iso639_2":"spa","name":"Spanish","nativeName":"Español"}],"translations":{"de":"Westsahara","es":"Sahara Occidental","fr":"Sahara Occidental","ja":"西サハラ","it":"Sahara Occidentale","br":"Saara Ocidental","pt":"Saara Ocidental","nl":"Westelijke Sahara","hr":"Zapadna Sahara","fa":"جمهوری دموکراتیک عربی صحرا"},"flag":"https://restcountries.eu/data/esh.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":""} +{"name":"Yemen","topLevelDomain":[".ye"],"alpha2Code":"YE","alpha3Code":"YEM","callingCodes":["967"],"capital":"Sana'a","altSpellings":["YE","Yemeni Republic","al-Jumhūriyyah al-Yamaniyyah"],"region":"Asia","subregion":"Western Asia","population":27478000,"latlng":[15.0,48.0],"demonym":"Yemeni","area":527968.0,"gini":37.7,"timezones":["UTC+03:00"],"borders":["OMN","SAU"],"nativeName":"اليَمَن","numericCode":"887","currencies":[{"code":"YER","name":"Yemeni rial","symbol":"﷼"}],"languages":[{"iso639_1":"ar","iso639_2":"ara","name":"Arabic","nativeName":"العربية"}],"translations":{"de":"Jemen","es":"Yemen","fr":"Yémen","ja":"イエメン","it":"Yemen","br":"Iêmen","pt":"Iémen","nl":"Jemen","hr":"Jemen","fa":"یمن"},"flag":"https://restcountries.eu/data/yem.svg","regionalBlocs":[{"acronym":"AL","name":"Arab League","otherAcronyms":[],"otherNames":["جامعة الدول العربية","Jāmiʻat ad-Duwal al-ʻArabīyah","League of Arab States"]}],"cioc":"YEM"} +{"name":"Zambia","topLevelDomain":[".zm"],"alpha2Code":"ZM","alpha3Code":"ZMB","callingCodes":["260"],"capital":"Lusaka","altSpellings":["ZM","Republic of Zambia"],"region":"Africa","subregion":"Eastern Africa","population":15933883,"latlng":[-15.0,30.0],"demonym":"Zambian","area":752612.0,"gini":54.6,"timezones":["UTC+02:00"],"borders":["AGO","BWA","COD","MWI","MOZ","NAM","TZA","ZWE"],"nativeName":"Zambia","numericCode":"894","currencies":[{"code":"ZMW","name":"Zambian kwacha","symbol":"ZK"}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"}],"translations":{"de":"Sambia","es":"Zambia","fr":"Zambie","ja":"ザンビア","it":"Zambia","br":"Zâmbia","pt":"Zâmbia","nl":"Zambia","hr":"Zambija","fa":"زامبیا"},"flag":"https://restcountries.eu/data/zmb.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"ZAM"} +{"name":"Zimbabwe","topLevelDomain":[".zw"],"alpha2Code":"ZW","alpha3Code":"ZWE","callingCodes":["263"],"capital":"Harare","altSpellings":["ZW","Republic of Zimbabwe"],"region":"Africa","subregion":"Eastern Africa","population":14240168,"latlng":[-20.0,30.0],"demonym":"Zimbabwean","area":390757.0,"gini":null,"timezones":["UTC+02:00"],"borders":["BWA","MOZ","ZAF","ZMB"],"nativeName":"Zimbabwe","numericCode":"716","currencies":[{"code":"BWP","name":"Botswana pula","symbol":"P"},{"code":"GBP","name":"British pound","symbol":"£"},{"code":"CNY","name":"Chinese yuan","symbol":"¥"},{"code":"EUR","name":"Euro","symbol":"€"},{"code":"INR","name":"Indian rupee","symbol":"₹"},{"code":"JPY","name":"Japanese yen","symbol":"¥"},{"code":"ZAR","name":"South African rand","symbol":"Rs"},{"code":"USD","name":"United States dollar","symbol":"$"},{"code":"(none)","name":null,"symbol":null}],"languages":[{"iso639_1":"en","iso639_2":"eng","name":"English","nativeName":"English"},{"iso639_1":"sn","iso639_2":"sna","name":"Shona","nativeName":"chiShona"},{"iso639_1":"nd","iso639_2":"nde","name":"Northern Ndebele","nativeName":"isiNdebele"}],"translations":{"de":"Simbabwe","es":"Zimbabue","fr":"Zimbabwe","ja":"ジンバブエ","it":"Zimbabwe","br":"Zimbabwe","pt":"Zimbabué","nl":"Zimbabwe","hr":"Zimbabve","fa":"زیمباوه"},"flag":"https://restcountries.eu/data/zwe.svg","regionalBlocs":[{"acronym":"AU","name":"African Union","otherAcronyms":[],"otherNames":["الاتحاد الأفريقي","Union africaine","União Africana","Unión Africana","Umoja wa Afrika"]}],"cioc":"ZIM"} \ No newline at end of file diff --git a/persistence-modules/jnosql/jnosql-diana/pom.xml b/persistence-modules/jnosql/jnosql-diana/pom.xml index 22e066d36d..79c455646c 100644 --- a/persistence-modules/jnosql/jnosql-diana/pom.xml +++ b/persistence-modules/jnosql/jnosql-diana/pom.xml @@ -55,7 +55,7 @@ org.codehaus.mojo exec-maven-plugin - 1.6.0 + ${exec-maven-plugin.version} document diff --git a/persistence-modules/jnosql/pom.xml b/persistence-modules/jnosql/pom.xml index b96722de18..fb7ac72b05 100644 --- a/persistence-modules/jnosql/pom.xml +++ b/persistence-modules/jnosql/pom.xml @@ -11,9 +11,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -22,8 +21,6 @@ - 1.8 - 1.8 0.0.5 diff --git a/persistence-modules/jpa-hibernate-cascade-type/pom.xml b/persistence-modules/jpa-hibernate-cascade-type/pom.xml index a545723746..1fc119592c 100644 --- a/persistence-modules/jpa-hibernate-cascade-type/pom.xml +++ b/persistence-modules/jpa-hibernate-cascade-type/pom.xml @@ -4,13 +4,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 jpa-hibernate-cascade-type - 1.0.0-SNAPSHOT - com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -48,24 +45,12 @@ - - jpa-hibernate-cascade-type - - - src/test/resources - true - - - - 5.4.3.Final 3.12.2 6.0.17.Final 3.0.0 3.0.1-b11 - 1.8 - 1.8 \ No newline at end of file diff --git a/persistence-modules/liquibase/pom.xml b/persistence-modules/liquibase/pom.xml index 39e86b5186..af1af2259e 100644 --- a/persistence-modules/liquibase/pom.xml +++ b/persistence-modules/liquibase/pom.xml @@ -7,9 +7,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/orientdb/pom.xml b/persistence-modules/orientdb/pom.xml index 7b0bef7fc5..5b28fb01b0 100644 --- a/persistence-modules/orientdb/pom.xml +++ b/persistence-modules/orientdb/pom.xml @@ -10,9 +10,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/persistence-libraries/pom.xml b/persistence-modules/persistence-libraries/pom.xml index 74ff262637..a72654f2aa 100644 --- a/persistence-modules/persistence-libraries/pom.xml +++ b/persistence-modules/persistence-libraries/pom.xml @@ -10,7 +10,6 @@ com.baeldung persistence-modules 1.0.0-SNAPSHOT - .. @@ -25,30 +24,10 @@ ${hsqldb.version} test - - junit - junit - ${junit.version} - test - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - - - - - 2.4.0 - 4.12 1.6.0 diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index c0f7c07b70..15b62d5d77 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -10,7 +10,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - .. @@ -42,7 +41,7 @@ redis solr - spring-boot-jdbi + spring-boot-persistence-2 spring-boot-mysql spring-boot-persistence spring-boot-persistence-h2 diff --git a/persistence-modules/querydsl/pom.xml b/persistence-modules/querydsl/pom.xml index 690e65d737..9f6802ff77 100644 --- a/persistence-modules/querydsl/pom.xml +++ b/persistence-modules/querydsl/pom.xml @@ -6,13 +6,11 @@ 0.1-SNAPSHOT querydsl jar - http://maven.apache.org com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/r2dbc/pom.xml b/persistence-modules/r2dbc/pom.xml index 3b2a57401c..2c06931487 100644 --- a/persistence-modules/r2dbc/pom.xml +++ b/persistence-modules/r2dbc/pom.xml @@ -61,32 +61,10 @@ - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - 1.8 - 0.8.0.M8 + 0.8.1.RELEASE + 1.4.200 diff --git a/persistence-modules/redis/pom.xml b/persistence-modules/redis/pom.xml index c4a928bb4a..fffcfbb96b 100644 --- a/persistence-modules/redis/pom.xml +++ b/persistence-modules/redis/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -38,7 +37,7 @@ - 2.9.0 + 3.2.0 0.6 3.3.0 5.0.1.RELEASE diff --git a/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/client/RedisClient.java b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/client/RedisClient.java new file mode 100644 index 0000000000..2fe7a787e0 --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/client/RedisClient.java @@ -0,0 +1,149 @@ +package com.baeldung.redis_scan.client; + +import com.baeldung.redis_scan.iterator.RedisIterator; +import com.baeldung.redis_scan.strategy.ScanStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; + +public class RedisClient { + private static Logger log = LoggerFactory.getLogger(RedisClient.class); + + private static volatile RedisClient instance = null; + + private static JedisPool jedisPool; + + public static RedisClient getInstance(String ip, final int port) { + if (instance == null) { + synchronized (RedisClient.class) { + if (instance == null) { + instance = new RedisClient(ip, port); + } + } + } + return instance; + } + + private RedisClient(String ip, int port) { + try { + if (jedisPool == null) { + jedisPool = new JedisPool(new URI("http://" + ip + ":" + port)); + } + } catch (URISyntaxException e) { + log.error("Malformed server address", e); + } + } + + public Long lpush(final String key, final String[] strings) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.lpush(key, strings); + } catch (Exception ex) { + log.error("Exception caught in lpush", ex); + } + return null; + } + + public List lrange(final String key, final long start, final long stop) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.lrange(key, start, stop); + } catch (Exception ex) { + log.error("Exception caught in lrange", ex); + } + return new LinkedList(); + } + + public String hmset(final String key, final Map hash) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.hmset(key, hash); + } catch (Exception ex) { + log.error("Exception caught in hmset", ex); + } + return null; + } + + public Map hgetAll(final String key) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.hgetAll(key); + } catch (Exception ex) { + log.error("Exception caught in hgetAll", ex); + } + return new HashMap(); + } + + public Long sadd(final String key, final String... members) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.sadd(key, members); + } catch (Exception ex) { + log.error("Exception caught in sadd", ex); + } + return null; + } + + public Set smembers(final String key) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.smembers(key); + } catch (Exception ex) { + log.error("Exception caught in smembers", ex); + } + return new HashSet(); + } + + public Long zadd(final String key, final Map scoreMembers) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.zadd(key, scoreMembers); + } catch (Exception ex) { + log.error("Exception caught in zadd", ex); + } + return 0L; + } + + public Set zrange(final String key, final long start, final long stop) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.zrange(key, start, stop); + } catch (Exception ex) { + log.error("Exception caught in zrange", ex); + } + return new HashSet(); + } + + public String mset(final HashMap keysValues) { + try (Jedis jedis = jedisPool.getResource()) { + ArrayList keysValuesArrayList = new ArrayList(); + keysValues.forEach((key, value) -> { + keysValuesArrayList.add(key); + keysValuesArrayList.add(value); + }); + return jedis.mset((keysValuesArrayList.toArray(new String[keysValues.size()]))); + } catch (Exception ex) { + log.error("Exception caught in mset", ex); + } + return null; + } + + public Set keys(final String pattern) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.keys(pattern); + } catch (Exception ex) { + log.error("Exception caught in keys", ex); + } + return new HashSet(); + } + + public RedisIterator iterator(int initialScanCount, String pattern, ScanStrategy strategy) { + return new RedisIterator(jedisPool, initialScanCount, pattern, strategy); + } + + public void flushAll() { + try (Jedis jedis = jedisPool.getResource()) { + jedis.flushAll(); + } catch (Exception ex) { + log.error("Exception caught in flushAll", ex); + } + } + +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/iterator/RedisIterator.java b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/iterator/RedisIterator.java new file mode 100644 index 0000000000..5fbd798ac2 --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/iterator/RedisIterator.java @@ -0,0 +1,60 @@ +package com.baeldung.redis_scan.iterator; + +import com.baeldung.redis_scan.strategy.ScanStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.ScanParams; +import redis.clients.jedis.ScanResult; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +public class RedisIterator implements Iterator> { + + private static Logger log = LoggerFactory.getLogger(RedisIterator.class); + private static final int DEFAULT_SCAN_COUNT = 10; + + private final JedisPool jedisPool; + private ScanParams scanParams; + private String cursor; + private ScanStrategy strategy; + + public RedisIterator(JedisPool jedisPool, int initialScanCount, String pattern, ScanStrategy strategy) { + super(); + this.jedisPool = jedisPool; + this.scanParams = new ScanParams().match(pattern).count(initialScanCount); + this.strategy = strategy; + } + + public RedisIterator(JedisPool jedisPool, String pattern, ScanStrategy strategy) { + super(); + this.jedisPool = jedisPool; + this.scanParams = new ScanParams().match(pattern).count(DEFAULT_SCAN_COUNT); + this.strategy = strategy; + } + + @Override + public boolean hasNext() { + return !"0".equals(cursor); + } + + @Override + public List next() { + if (cursor == null) { + cursor = "0"; + } + try (Jedis jedis = jedisPool.getResource()) { + ScanResult scanResult = strategy.scan(jedis, cursor, scanParams); + cursor = scanResult.getCursor(); + return scanResult.getResult(); + + } catch (Exception ex) { + log.error("Exception caught in next()", ex); + } + return new LinkedList(); + } + +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/ScanStrategy.java b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/ScanStrategy.java new file mode 100644 index 0000000000..39d9e44a63 --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/ScanStrategy.java @@ -0,0 +1,9 @@ +package com.baeldung.redis_scan.strategy; + +import redis.clients.jedis.Jedis; +import redis.clients.jedis.ScanParams; +import redis.clients.jedis.ScanResult; + +public interface ScanStrategy { + ScanResult scan(Jedis jedis, String cursor, ScanParams scanParams); +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Hscan.java b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Hscan.java new file mode 100644 index 0000000000..fd5ecd14ec --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Hscan.java @@ -0,0 +1,25 @@ +package com.baeldung.redis_scan.strategy.impl; + +import com.baeldung.redis_scan.strategy.ScanStrategy; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.ScanParams; +import redis.clients.jedis.ScanResult; + +import java.util.Map; +import java.util.Map.Entry; + +public class Hscan implements ScanStrategy> { + + private String key; + + public Hscan(String key) { + super(); + this.key = key; + } + + @Override + public ScanResult> scan(Jedis jedis, String cursor, ScanParams scanParams) { + return jedis.hscan(key, cursor, scanParams); + } + +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Scan.java b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Scan.java new file mode 100644 index 0000000000..f28b56e34c --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Scan.java @@ -0,0 +1,14 @@ +package com.baeldung.redis_scan.strategy.impl; + +import com.baeldung.redis_scan.strategy.ScanStrategy; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.ScanParams; +import redis.clients.jedis.ScanResult; + +public class Scan implements ScanStrategy { + + + public ScanResult scan(Jedis jedis, String cursor, ScanParams scanParams) { + return jedis.scan(cursor, scanParams); + } +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Sscan.java b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Sscan.java new file mode 100644 index 0000000000..ed47f7087e --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Sscan.java @@ -0,0 +1,29 @@ +package com.baeldung.redis_scan.strategy.impl; + +import com.baeldung.redis_scan.strategy.ScanStrategy; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.ScanParams; +import redis.clients.jedis.ScanResult; + +public class Sscan implements ScanStrategy { + + private String key; + + + public Sscan(String key) { + super(); + this.key = key; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public ScanResult scan(Jedis jedis, String cursor, ScanParams scanParams) { + return jedis.sscan(key, cursor, scanParams); + } +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Zscan.java b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Zscan.java new file mode 100644 index 0000000000..bdffc15883 --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/redis_scan/strategy/impl/Zscan.java @@ -0,0 +1,25 @@ +package com.baeldung.redis_scan.strategy.impl; + +import com.baeldung.redis_scan.strategy.ScanStrategy; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.ScanParams; +import redis.clients.jedis.ScanResult; +import redis.clients.jedis.Tuple; + +public class Zscan implements ScanStrategy { + + private String key; + + + public Zscan(String key) { + super(); + this.key = key; + } + + + @Override + public ScanResult scan(Jedis jedis, String cursor, ScanParams scanParams) { + return jedis.zscan(key, cursor, scanParams); + } + +} diff --git a/persistence-modules/redis/src/test/java/com/baeldung/redis_scan/NaiveApproachIntegrationTest.java b/persistence-modules/redis/src/test/java/com/baeldung/redis_scan/NaiveApproachIntegrationTest.java new file mode 100644 index 0000000000..c24b88e20c --- /dev/null +++ b/persistence-modules/redis/src/test/java/com/baeldung/redis_scan/NaiveApproachIntegrationTest.java @@ -0,0 +1,96 @@ +package com.baeldung.redis_scan; + +import com.baeldung.redis_scan.client.RedisClient; +import org.junit.*; +import redis.embedded.RedisServer; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class NaiveApproachIntegrationTest { + private static RedisServer redisServer; + private static int port; + private static RedisClient redisClient; + + @BeforeClass + public static void setUp() throws IOException { + + // Take an available port + ServerSocket s = new ServerSocket(0); + port = s.getLocalPort(); + s.close(); + + redisServer = new RedisServer(port); + redisServer.start(); + } + + @AfterClass + public static void destroy() { + if (redisServer.isActive()) + redisServer.stop(); + } + + @Before + public void init() { + if (!redisServer.isActive()) { + redisServer.start(); + } + redisClient = RedisClient.getInstance("127.0.0.1", port); + } + + @After + public void flushAll() { + redisClient.flushAll(); + } + + @Test + public void testKeys() { + HashMap keyValues = new HashMap(); + keyValues.put("balls:cricket", "160"); + keyValues.put("balls:football", "450"); + keyValues.put("balls:volleyball", "270"); + redisClient.mset(keyValues); + Set readKeys = redisClient.keys("ball*"); + Assert.assertEquals(keyValues.size(), readKeys.size()); + + } + + @Test + public void testSmembers() { + HashSet setMembers = new HashSet(); + setMembers.add("cricket_160"); + setMembers.add("football_450"); + setMembers.add("volleyball_270"); + redisClient.sadd("balls", setMembers.toArray(new String[setMembers.size()])); + Set readSetMembers = redisClient.smembers("balls"); + Assert.assertEquals(setMembers.size(), readSetMembers.size()); + } + + @Test + public void testHgetAll() { + HashMap keyValues = new HashMap(); + keyValues.put("balls:cricket", "160"); + keyValues.put("balls:football", "450"); + keyValues.put("balls:volleyball", "270"); + redisClient.hmset("balls", keyValues); + Map readHash = redisClient.hgetAll("balls"); + Assert.assertEquals(keyValues.size(), readHash.size()); + } + + @Test + public void testZRange() { + HashMap scoreMembers = new HashMap(); + scoreMembers.put("cricket", (double) 160); + scoreMembers.put("football", (double) 450); + scoreMembers.put("volleyball", (double) 270); + redisClient.zadd("balls", scoreMembers); + Set readSetMembers = redisClient.zrange("balls", 0, -1); + + Assert.assertEquals(readSetMembers.size(), scoreMembers.size()); + } + +} diff --git a/persistence-modules/redis/src/test/java/com/baeldung/redis_scan/ScanStrategyIntegrationTest.java b/persistence-modules/redis/src/test/java/com/baeldung/redis_scan/ScanStrategyIntegrationTest.java new file mode 100644 index 0000000000..828b7a3183 --- /dev/null +++ b/persistence-modules/redis/src/test/java/com/baeldung/redis_scan/ScanStrategyIntegrationTest.java @@ -0,0 +1,129 @@ +package com.baeldung.redis_scan; + +import com.baeldung.redis_scan.client.RedisClient; +import com.baeldung.redis_scan.iterator.RedisIterator; +import com.baeldung.redis_scan.strategy.ScanStrategy; +import com.baeldung.redis_scan.strategy.impl.Hscan; +import com.baeldung.redis_scan.strategy.impl.Scan; +import com.baeldung.redis_scan.strategy.impl.Sscan; +import com.baeldung.redis_scan.strategy.impl.Zscan; +import org.junit.*; +import redis.clients.jedis.Tuple; +import redis.embedded.RedisServer; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.*; + + +public class ScanStrategyIntegrationTest { + + private static RedisServer redisServer; + private static int port; + private static RedisClient redisClient; + + @BeforeClass + public static void setUp() throws IOException { + + // Take an available port + ServerSocket s = new ServerSocket(0); + String ip = "127.0.0.1"; + port = s.getLocalPort(); + s.close(); + + redisServer = new RedisServer(port); + redisServer.start(); + } + + @AfterClass + public static void destroy() { + if (redisServer.isActive()) + redisServer.stop(); + } + + @Before + public void init() { + if (!redisServer.isActive()) { + redisServer.start(); + } + redisClient = RedisClient.getInstance("127.0.0.1", port); + } + + @After + public void flushAll() { + redisClient.flushAll(); + } + + @Test + public void testScanStrategy() { + HashMap keyValues = new HashMap(); + keyValues.put("balls:cricket", "160"); + keyValues.put("balls:football", "450"); + keyValues.put("balls:volleyball", "270"); + redisClient.mset(keyValues); + + ScanStrategy scanStrategy = new Scan(); + int iterationCount = 2; + RedisIterator iterator = redisClient.iterator(iterationCount, "ball*", scanStrategy); + List results = new LinkedList(); + while (iterator.hasNext()) { + results.addAll(iterator.next()); + } + Assert.assertEquals(keyValues.size(), results.size()); + } + + @Test + public void testSscanStrategy() { + HashSet setMembers = new HashSet(); + setMembers.add("cricket_160"); + setMembers.add("football_450"); + setMembers.add("volleyball_270"); + redisClient.sadd("balls", setMembers.toArray(new String[setMembers.size()])); + + Sscan scanStrategy = new Sscan("balls"); + int iterationCount = 2; + RedisIterator iterator = redisClient.iterator(iterationCount, "*", scanStrategy); + List results = new LinkedList(); + while (iterator.hasNext()) { + results.addAll(iterator.next()); + } + Assert.assertEquals(setMembers.size(), results.size()); + } + + @Test + public void testHscanStrategy() { + HashMap hash = new HashMap(); + hash.put("cricket", "160"); + hash.put("football", "450"); + hash.put("volleyball", "270"); + redisClient.hmset("balls", hash); + + Hscan scanStrategy = new Hscan("balls"); + int iterationCount = 2; + RedisIterator iterator = redisClient.iterator(iterationCount, "*", scanStrategy); + List> results = new LinkedList>(); + while (iterator.hasNext()) { + results.addAll(iterator.next()); + } + Assert.assertEquals(hash.size(), results.size()); + } + + @Test + public void testZscanStrategy() { + HashMap memberScores = new HashMap(); + memberScores.put("cricket", (double) 160); + memberScores.put("football", (double) 450); + memberScores.put("volleyball", (double) 270); + redisClient.zadd("balls", memberScores); + + Zscan scanStrategy = new Zscan("balls"); + int iterationCount = 2; + RedisIterator iterator = redisClient.iterator(iterationCount, "*", scanStrategy); + List results = new LinkedList(); + while (iterator.hasNext()) { + results.addAll(iterator.next()); + } + Assert.assertEquals(memberScores.size(), results.size()); + } + +} diff --git a/persistence-modules/sirix/README.md b/persistence-modules/sirix/README.md index ab7fb65e44..923b111e7a 100644 --- a/persistence-modules/sirix/README.md +++ b/persistence-modules/sirix/README.md @@ -1,4 +1,3 @@ ## Relevant articles: -- [Introduction to Sirix](https://www.baeldung.com/introduction-to-sirix) - [A Guide to SirixDB](https://www.baeldung.com/sirix) diff --git a/persistence-modules/sirix/pom.xml b/persistence-modules/sirix/pom.xml index ccaec79775..d8e065ec2f 100644 --- a/persistence-modules/sirix/pom.xml +++ b/persistence-modules/sirix/pom.xml @@ -30,7 +30,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} ${maven.release.version} ${project.build.sourceEncoding} @@ -39,7 +39,7 @@ org.ow2.asm asm - 6.1 + ${asm.version} @@ -50,6 +50,8 @@ UTF-8 11 0.9.3 + 3.8.0 + 6.1 diff --git a/persistence-modules/solr/pom.xml b/persistence-modules/solr/pom.xml index 5902d42a82..fd993e0c67 100644 --- a/persistence-modules/solr/pom.xml +++ b/persistence-modules/solr/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/spring-boot-mysql/pom.xml b/persistence-modules/spring-boot-mysql/pom.xml index e4456b2eaf..9f6ec73522 100644 --- a/persistence-modules/spring-boot-mysql/pom.xml +++ b/persistence-modules/spring-boot-mysql/pom.xml @@ -37,18 +37,7 @@ - - spring-boot-mysql - - - src/main/resources - true - - - - - UTF-8 8.0.12 diff --git a/persistence-modules/spring-boot-jdbi/HELP.md b/persistence-modules/spring-boot-persistence-2/HELP.md similarity index 100% rename from persistence-modules/spring-boot-jdbi/HELP.md rename to persistence-modules/spring-boot-persistence-2/HELP.md diff --git a/persistence-modules/spring-boot-jdbi/README.md b/persistence-modules/spring-boot-persistence-2/README.md similarity index 100% rename from persistence-modules/spring-boot-jdbi/README.md rename to persistence-modules/spring-boot-persistence-2/README.md diff --git a/persistence-modules/spring-boot-jdbi/pom.xml b/persistence-modules/spring-boot-persistence-2/pom.xml similarity index 91% rename from persistence-modules/spring-boot-jdbi/pom.xml rename to persistence-modules/spring-boot-persistence-2/pom.xml index db36185acd..048dd45c7f 100644 --- a/persistence-modules/spring-boot-jdbi/pom.xml +++ b/persistence-modules/spring-boot-persistence-2/pom.xml @@ -3,17 +3,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.baeldung.boot.jdbi - spring-boot-jdbi + com.baeldung.boot.persistence + spring-boot-persistence-2 0.0.1-SNAPSHOT spring-boot-jdbi Sample SpringBoot JDBI Project com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../pom.xml @@ -21,7 +20,7 @@ org.springframework.boot spring-boot-dependencies - 2.1.8.RELEASE + ${spring.boot.dependencies} pom import @@ -95,8 +94,8 @@ - 1.8 3.9.1 + 2.1.8.RELEASE diff --git a/persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/JdbiConfiguration.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/JdbiConfiguration.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/JdbiConfiguration.java rename to persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/JdbiConfiguration.java diff --git a/persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/SpringBootJdbiApplication.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/SpringBootJdbiApplication.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/SpringBootJdbiApplication.java rename to persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/SpringBootJdbiApplication.java diff --git a/persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/dao/CarMakerDao.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/dao/CarMakerDao.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/dao/CarMakerDao.java rename to persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/dao/CarMakerDao.java diff --git a/persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/dao/CarModelDao.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/dao/CarModelDao.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/dao/CarModelDao.java rename to persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/dao/CarModelDao.java diff --git a/persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/domain/CarMaker.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/domain/CarMaker.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/domain/CarMaker.java rename to persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/domain/CarMaker.java diff --git a/persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/domain/CarModel.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/domain/CarModel.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/domain/CarModel.java rename to persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/domain/CarModel.java diff --git a/persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/mapper/CarMakerMapper.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/mapper/CarMakerMapper.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/mapper/CarMakerMapper.java rename to persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/mapper/CarMakerMapper.java diff --git a/persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/mapper/CarModelMapper.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/mapper/CarModelMapper.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/mapper/CarModelMapper.java rename to persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/mapper/CarModelMapper.java diff --git a/persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/service/CarMakerService.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/service/CarMakerService.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/java/com/baeldung/boot/jdbi/service/CarMakerService.java rename to persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/boot/jdbi/service/CarMakerService.java diff --git a/persistence-modules/spring-boot-jdbi/src/main/resources/application.yml b/persistence-modules/spring-boot-persistence-2/src/main/resources/application.yml similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/resources/application.yml rename to persistence-modules/spring-boot-persistence-2/src/main/resources/application.yml diff --git a/persistence-modules/spring-boot-jdbi/src/main/resources/com/baeldung/boot/jdbi/dao/CarMakerDao/findById.sql b/persistence-modules/spring-boot-persistence-2/src/main/resources/com/baeldung/boot/jdbi/dao/CarMakerDao/findById.sql similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/resources/com/baeldung/boot/jdbi/dao/CarMakerDao/findById.sql rename to persistence-modules/spring-boot-persistence-2/src/main/resources/com/baeldung/boot/jdbi/dao/CarMakerDao/findById.sql diff --git a/persistence-modules/spring-boot-jdbi/src/main/resources/com/baeldung/boot/jdbi/dao/CarMakerDao/insert.sql b/persistence-modules/spring-boot-persistence-2/src/main/resources/com/baeldung/boot/jdbi/dao/CarMakerDao/insert.sql similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/resources/com/baeldung/boot/jdbi/dao/CarMakerDao/insert.sql rename to persistence-modules/spring-boot-persistence-2/src/main/resources/com/baeldung/boot/jdbi/dao/CarMakerDao/insert.sql diff --git a/persistence-modules/spring-boot-jdbi/src/main/resources/com/baeldung/boot/jdbi/dao/CarModelDao/findByMakerIdAndSku.sql b/persistence-modules/spring-boot-persistence-2/src/main/resources/com/baeldung/boot/jdbi/dao/CarModelDao/findByMakerIdAndSku.sql similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/resources/com/baeldung/boot/jdbi/dao/CarModelDao/findByMakerIdAndSku.sql rename to persistence-modules/spring-boot-persistence-2/src/main/resources/com/baeldung/boot/jdbi/dao/CarModelDao/findByMakerIdAndSku.sql diff --git a/persistence-modules/spring-boot-jdbi/src/main/resources/com/baeldung/boot/jdbi/dao/CarModelDao/insert.sql b/persistence-modules/spring-boot-persistence-2/src/main/resources/com/baeldung/boot/jdbi/dao/CarModelDao/insert.sql similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/main/resources/com/baeldung/boot/jdbi/dao/CarModelDao/insert.sql rename to persistence-modules/spring-boot-persistence-2/src/main/resources/com/baeldung/boot/jdbi/dao/CarModelDao/insert.sql diff --git a/persistence-modules/spring-boot-jdbi/src/test/java/com/baeldung/boot/jdbi/SpringBootJdbiApplicationUnitTest.java b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/boot/jdbi/SpringBootJdbiApplicationUnitTest.java similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/test/java/com/baeldung/boot/jdbi/SpringBootJdbiApplicationUnitTest.java rename to persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/boot/jdbi/SpringBootJdbiApplicationUnitTest.java diff --git a/persistence-modules/spring-boot-jdbi/src/test/resources/data.sql b/persistence-modules/spring-boot-persistence-2/src/test/resources/data.sql similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/test/resources/data.sql rename to persistence-modules/spring-boot-persistence-2/src/test/resources/data.sql diff --git a/persistence-modules/spring-boot-jdbi/src/test/resources/schema.sql b/persistence-modules/spring-boot-persistence-2/src/test/resources/schema.sql similarity index 100% rename from persistence-modules/spring-boot-jdbi/src/test/resources/schema.sql rename to persistence-modules/spring-boot-persistence-2/src/test/resources/schema.sql diff --git a/persistence-modules/spring-boot-persistence-h2/pom.xml b/persistence-modules/spring-boot-persistence-h2/pom.xml index 9a0a72ba23..5b5e255211 100644 --- a/persistence-modules/spring-boot-persistence-h2/pom.xml +++ b/persistence-modules/spring-boot-persistence-h2/pom.xml @@ -5,7 +5,6 @@ 4.0.0 com.baeldung.h2db spring-boot-persistence-h2 - 0.0.1-SNAPSHOT spring-boot-persistence-h2 jar Demo Spring Boot applications that starts H2 in memory database @@ -32,19 +31,7 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - UTF-8 - UTF-8 - 1.8 com.baeldung.h2db.demo.server.SpringBootApp 2.0.4.RELEASE diff --git a/persistence-modules/spring-boot-persistence-mongodb/pom.xml b/persistence-modules/spring-boot-persistence-mongodb/pom.xml index da48f066f9..de52a4b2d6 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/pom.xml +++ b/persistence-modules/spring-boot-persistence-mongodb/pom.xml @@ -34,80 +34,6 @@ de.flapdoodle.embed.mongo test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - - - org.junit.platform - junit-platform-launcher - ${junit-platform.version} - test - - - org.springframework.boot - spring-boot-starter-test - test - - - spring-boot-persistence-mongodb - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-war-plugin - - - - - - - autoconfiguration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*LiveTest.java - **/*IntegrationTest.java - **/*IntTest.java - - - - - - - json - - - - - - - - - + \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/pom.xml b/persistence-modules/spring-boot-persistence/pom.xml index 049e7225ac..c58e8dbf86 100644 --- a/persistence-modules/spring-boot-persistence/pom.xml +++ b/persistence-modules/spring-boot-persistence/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 spring-boot-persistence 0.1.0 @@ -17,17 +18,14 @@ org.springframework.boot spring-boot-starter-web - ${spring-boot.version} org.springframework.boot spring-boot-starter-thymeleaf - ${spring-boot.version} org.springframework.boot spring-boot-starter-data-jpa - ${spring-boot.version} com.zaxxer @@ -38,7 +36,6 @@ org.springframework.boot spring-boot-starter-test - ${spring-boot.version} org.mockito @@ -61,7 +58,6 @@ javax.validation validation-api - ${validation-api.version} org.xerial @@ -70,39 +66,17 @@ org.apache.derby derby - ${derby.version} org.hsqldb hsqldb - ${hsqldb.version} - - spring-boot-persistence - - - src/main/resources - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - UTF-8 - 8.0.12 - 9.0.10 2.23.0 2.0.1.Final - 10.13.1.1 - 2.3.4 2.1.7.RELEASE diff --git a/persistence-modules/spring-data-cassandra-reactive/pom.xml b/persistence-modules/spring-data-cassandra-reactive/pom.xml index a57ebbe703..70a5f556e2 100644 --- a/persistence-modules/spring-data-cassandra-reactive/pom.xml +++ b/persistence-modules/spring-data-cassandra-reactive/pom.xml @@ -1,10 +1,8 @@ - + 4.0.0 spring-data-cassandra-reactive - 0.0.1-SNAPSHOT spring-data-cassandra-reactive jar Spring Data Cassandra reactive @@ -20,7 +18,6 @@ org.springframework.data spring-data-cassandra - ${spring-data-cassandra.version} io.projectreactor @@ -54,10 +51,6 @@ - UTF-8 - UTF-8 - - 2.1.2.RELEASE 3.11.2.0 diff --git a/persistence-modules/spring-data-cassandra/pom.xml b/persistence-modules/spring-data-cassandra/pom.xml index 9ea39f3f55..0f0aae4ebf 100644 --- a/persistence-modules/spring-data-cassandra/pom.xml +++ b/persistence-modules/spring-data-cassandra/pom.xml @@ -3,7 +3,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-data-cassandra - 0.0.1-SNAPSHOT spring-data-cassandra jar @@ -80,7 +79,6 @@ 2.1.9.2 2.1.9.2 2.0-0 - 19.0 diff --git a/persistence-modules/spring-data-couchbase-2/pom.xml b/persistence-modules/spring-data-couchbase-2/pom.xml index 56456fc04b..484561ddaa 100644 --- a/persistence-modules/spring-data-couchbase-2/pom.xml +++ b/persistence-modules/spring-data-couchbase-2/pom.xml @@ -11,9 +11,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/spring-data-dynamodb/pom.xml b/persistence-modules/spring-data-dynamodb/pom.xml index 7b936817d1..fceceb40ba 100644 --- a/persistence-modules/spring-data-dynamodb/pom.xml +++ b/persistence-modules/spring-data-dynamodb/pom.xml @@ -138,18 +138,25 @@ - spring-data-dynamodb - - - src/main/resources - true - - - org.apache.maven.plugins - maven-war-plugin + maven-dependency-plugin + ${maven-dependency-plugin.version} + + + copy-dependencies + test-compile + + copy-dependencies + + + test + so,dll,dylib + ${project.basedir}/native-libs + + + @@ -174,6 +181,7 @@ 1.11.106 1.11.86 https://s3-us-west-2.amazonaws.com/dynamodb-local/release + 3.1.1 diff --git a/persistence-modules/spring-data-dynamodb/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-dynamodb/src/test/java/com/baeldung/SpringContextTest.java similarity index 94% rename from persistence-modules/spring-data-dynamodb/src/test/java/org/baeldung/SpringContextTest.java rename to persistence-modules/spring-data-dynamodb/src/test/java/com/baeldung/SpringContextTest.java index 5e68a8e64f..3ad54e2267 100644 --- a/persistence-modules/spring-data-dynamodb/src/test/java/org/baeldung/SpringContextTest.java +++ b/persistence-modules/spring-data-dynamodb/src/test/java/com/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/persistence-modules/spring-data-eclipselink/pom.xml b/persistence-modules/spring-data-eclipselink/pom.xml index bb596d4a8a..4ae43de07a 100644 --- a/persistence-modules/spring-data-eclipselink/pom.xml +++ b/persistence-modules/spring-data-eclipselink/pom.xml @@ -7,9 +7,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/spring-data-elasticsearch/pom.xml b/persistence-modules/spring-data-elasticsearch/pom.xml index ccd2f94e59..3446528323 100644 --- a/persistence-modules/spring-data-elasticsearch/pom.xml +++ b/persistence-modules/spring-data-elasticsearch/pom.xml @@ -2,7 +2,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-data-elasticsearch - 0.0.1-SNAPSHOT spring-data-elasticsearch jar @@ -89,8 +88,6 @@ - 1.8 - 1.8 3.0.8.RELEASE 4.5.2 5.6.0 diff --git a/persistence-modules/spring-data-gemfire/pom.xml b/persistence-modules/spring-data-gemfire/pom.xml index 6bd689192c..a0cc4d5360 100644 --- a/persistence-modules/spring-data-gemfire/pom.xml +++ b/persistence-modules/spring-data-gemfire/pom.xml @@ -8,9 +8,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/spring-data-geode/pom.xml b/persistence-modules/spring-data-geode/pom.xml index 2a9cbe35e9..557d09376a 100644 --- a/persistence-modules/spring-data-geode/pom.xml +++ b/persistence-modules/spring-data-geode/pom.xml @@ -9,16 +9,15 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ org.springframework.boot spring-boot-starter - 2.1.9.RELEASE + ${spring.boot.starter.version} org.springframework.boot @@ -89,6 +88,7 @@ UTF-8 com.baeldung.springdatageode.app.ClientCacheApp 1.1.1.RELEASE + 2.1.9.RELEASE \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-3/pom.xml b/persistence-modules/spring-data-jpa-3/pom.xml index 8a949b3008..d02d089ba3 100644 --- a/persistence-modules/spring-data-jpa-3/pom.xml +++ b/persistence-modules/spring-data-jpa-3/pom.xml @@ -52,34 +52,6 @@ runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - junit - junit - - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.junit.platform - junit-platform-launcher - test - - org.testcontainers @@ -94,9 +66,6 @@ 1.4.1 21.0 1.12.2 - 42.2.8 - 1.12.2 - 1.4.200 diff --git a/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java b/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java index 022099eed0..6ce9bcad45 100644 --- a/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java +++ b/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java @@ -5,9 +5,9 @@ import java.util.List; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.PagingAndSortingRepository; -import com.baeldung.multipledb.model.product.ProductMultipleDB; +import com.baeldung.multipledb.model.product.Product; -public interface ProductRepository extends PagingAndSortingRepository { +public interface ProductRepository extends PagingAndSortingRepository { - List findAllByPrice(double price, Pageable pageable); + List findAllByPrice(double price, Pageable pageable); } diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/model/product/ProductMultipleDB.java b/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/Product.java old mode 100755 new mode 100644 similarity index 80% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/model/product/ProductMultipleDB.java rename to persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/Product.java index 8bdff340ac..eaf471043c --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/model/product/ProductMultipleDB.java +++ b/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/Product.java @@ -6,7 +6,7 @@ import javax.persistence.Table; @Entity @Table(schema = "products") -public class ProductMultipleDB { +public class Product { @Id private int id; @@ -15,19 +15,19 @@ public class ProductMultipleDB { private double price; - public ProductMultipleDB() { + public Product() { super(); } - private ProductMultipleDB(int id, String name, double price) { + private Product(int id, String name, double price) { super(); this.id = id; this.name = name; this.price = price; } - public static ProductMultipleDB from(int id, String name, double price) { - return new ProductMultipleDB(id, name, price); + public static Product from(int id, String name, double price) { + return new Product(id, name, price); } public int getId() { diff --git a/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java b/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java index 17ee6a94ba..b2581b8034 100644 --- a/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java +++ b/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java @@ -266,7 +266,7 @@ public class UserRepositoryCommon { userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - List usersSortByName = userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); + List usersSortByName = userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); assertThat(usersSortByName.get(0) .getName()).isEqualTo(USER_NAME_ADAM); @@ -278,7 +278,7 @@ public class UserRepositoryCommon { userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); + userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); List usersSortByNameLength = userRepository.findAll(Sort.by("LENGTH(name)")); diff --git a/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java index cdbb307d7f..831790af95 100644 --- a/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-3/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java @@ -23,7 +23,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; import com.baeldung.multipledb.dao.product.ProductRepository; -import com.baeldung.multipledb.model.product.ProductMultipleDB; +import com.baeldung.multipledb.model.product.Product; @RunWith(SpringRunner.class) @SpringBootTest(classes=MultipleDbApplication.class) @@ -36,22 +36,22 @@ public class ProductRepositoryIntegrationTest { @Before @Transactional("productTransactionManager") public void setUp() { - productRepository.save(ProductMultipleDB.from(1001, "Book", 21)); - productRepository.save(ProductMultipleDB.from(1002, "Coffee", 10)); - productRepository.save(ProductMultipleDB.from(1003, "Jeans", 30)); - productRepository.save(ProductMultipleDB.from(1004, "Shirt", 32)); - productRepository.save(ProductMultipleDB.from(1005, "Bacon", 10)); + productRepository.save(Product.from(1001, "Book", 21)); + productRepository.save(Product.from(1002, "Coffee", 10)); + productRepository.save(Product.from(1003, "Jeans", 30)); + productRepository.save(Product.from(1004, "Shirt", 32)); + productRepository.save(Product.from(1005, "Bacon", 10)); } @Test public void whenRequestingFirstPageOfSizeTwo_ThenReturnFirstPage() { Pageable pageRequest = PageRequest.of(0, 2); - Page result = productRepository.findAll(pageRequest); + Page result = productRepository.findAll(pageRequest); assertThat(result.getContent(), hasSize(2)); assertTrue(result.stream() - .map(ProductMultipleDB::getId) + .map(Product::getId) .allMatch(id -> Arrays.asList(1001, 1002) .contains(id))); } @@ -60,11 +60,11 @@ public class ProductRepositoryIntegrationTest { public void whenRequestingSecondPageOfSizeTwo_ThenReturnSecondPage() { Pageable pageRequest = PageRequest.of(1, 2); - Page result = productRepository.findAll(pageRequest); + Page result = productRepository.findAll(pageRequest); assertThat(result.getContent(), hasSize(2)); assertTrue(result.stream() - .map(ProductMultipleDB::getId) + .map(Product::getId) .allMatch(id -> Arrays.asList(1003, 1004) .contains(id))); } @@ -73,11 +73,11 @@ public class ProductRepositoryIntegrationTest { public void whenRequestingLastPage_ThenReturnLastPageWithRemData() { Pageable pageRequest = PageRequest.of(2, 2); - Page result = productRepository.findAll(pageRequest); + Page result = productRepository.findAll(pageRequest); assertThat(result.getContent(), hasSize(1)); assertTrue(result.stream() - .map(ProductMultipleDB::getId) + .map(Product::getId) .allMatch(id -> Arrays.asList(1005) .contains(id))); } @@ -86,12 +86,12 @@ public class ProductRepositoryIntegrationTest { public void whenSortingByNameAscAndPaging_ThenReturnSortedPagedResult() { Pageable pageRequest = PageRequest.of(0, 3, Sort.by("name")); - Page result = productRepository.findAll(pageRequest); + Page result = productRepository.findAll(pageRequest); assertThat(result.getContent(), hasSize(3)); assertThat(result.getContent() .stream() - .map(ProductMultipleDB::getId) + .map(Product::getId) .collect(Collectors.toList()), equalTo(Arrays.asList(1005, 1001, 1002))); } @@ -101,12 +101,12 @@ public class ProductRepositoryIntegrationTest { Pageable pageRequest = PageRequest.of(0, 3, Sort.by("price") .descending()); - Page result = productRepository.findAll(pageRequest); + Page result = productRepository.findAll(pageRequest); assertThat(result.getContent(), hasSize(3)); assertThat(result.getContent() .stream() - .map(ProductMultipleDB::getId) + .map(Product::getId) .collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001))); } @@ -117,12 +117,12 @@ public class ProductRepositoryIntegrationTest { .descending() .and(Sort.by("name"))); - Page result = productRepository.findAll(pageRequest); + Page result = productRepository.findAll(pageRequest); assertThat(result.getContent(), hasSize(5)); assertThat(result.getContent() .stream() - .map(ProductMultipleDB::getId) + .map(Product::getId) .collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001, 1005, 1002))); } @@ -131,11 +131,11 @@ public class ProductRepositoryIntegrationTest { public void whenRequestingFirstPageOfSizeTwoUsingCustomMethod_ThenReturnFirstPage() { Pageable pageRequest = PageRequest.of(0, 2); - List result = productRepository.findAllByPrice(10, pageRequest); + List result = productRepository.findAllByPrice(10, pageRequest); assertThat(result, hasSize(2)); assertTrue(result.stream() - .map(ProductMultipleDB::getId) + .map(Product::getId) .allMatch(id -> Arrays.asList(1002, 1005) .contains(id))); } diff --git a/persistence-modules/spring-data-jpa-4/pom.xml b/persistence-modules/spring-data-jpa-4/pom.xml index 44b7c3c268..e0b441231e 100644 --- a/persistence-modules/spring-data-jpa-4/pom.xml +++ b/persistence-modules/spring-data-jpa-4/pom.xml @@ -27,12 +27,6 @@ com.h2database h2 - - - org.springframework.boot - spring-boot-starter-test - test - \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/ElementCollectionApplication.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/ElementCollectionApplication.java new file mode 100644 index 0000000000..3f152a6ffc --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/ElementCollectionApplication.java @@ -0,0 +1,11 @@ +package com.baeldung.elementcollection; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ElementCollectionApplication { + public static void main(String[] args) { + SpringApplication.run(ElementCollectionApplication.class, args); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/model/Employee.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/model/Employee.java new file mode 100644 index 0000000000..8b98164d63 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/model/Employee.java @@ -0,0 +1,68 @@ +package com.baeldung.elementcollection.model; + +import javax.persistence.*; +import java.util.List; +import java.util.Objects; + +@Entity +public class Employee { + @Id + private int id; + private String name; + @ElementCollection + @CollectionTable(name = "employee_phone", joinColumns = @JoinColumn(name = "employee_id")) + private List phones; + + public Employee() { + } + + public Employee(int id) { + this.id = id; + } + + public Employee(int id, String name) { + this.id = id; + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getPhones() { + return phones; + } + + public void setPhones(List phones) { + this.phones = phones; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Employee)) { + return false; + } + Employee user = (Employee) o; + return getId() == user.getId(); + } + + @Override + public int hashCode() { + return Objects.hash(getId()); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/model/Phone.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/model/Phone.java new file mode 100644 index 0000000000..d73d30c47a --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/model/Phone.java @@ -0,0 +1,62 @@ +package com.baeldung.elementcollection.model; + +import javax.persistence.Embeddable; +import java.util.Objects; + +@Embeddable +public class Phone { + private String type; + private String areaCode; + private String number; + + public Phone() { + } + + public Phone(String type, String areaCode, String number) { + this.type = type; + this.areaCode = areaCode; + this.number = number; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Phone)) { + return false; + } + Phone phone = (Phone) o; + return getType().equals(phone.getType()) && getAreaCode().equals(phone.getAreaCode()) + && getNumber().equals(phone.getNumber()); + } + + @Override + public int hashCode() { + return Objects.hash(getType(), getAreaCode(), getNumber()); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/repository/EmployeeRepository.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/repository/EmployeeRepository.java new file mode 100644 index 0000000000..49180c35eb --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/elementcollection/repository/EmployeeRepository.java @@ -0,0 +1,46 @@ +package com.baeldung.elementcollection.repository; + +import com.baeldung.elementcollection.model.Employee; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import javax.persistence.EntityGraph; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import java.util.HashMap; +import java.util.Map; + +@Repository +public class EmployeeRepository { + + @PersistenceContext + private EntityManager em; + + @Transactional + public void save(Employee employee) { + em.persist(employee); + } + + @Transactional + public void remove(int id) { + Employee employee = findById(id); + em.remove(employee); + } + + public Employee findById(int id) { + return em.find(Employee.class, id); + } + + public Employee findByJPQL(int id) { + return em.createQuery("SELECT u FROM Employee AS u JOIN FETCH u.phones WHERE u.id=:id", Employee.class) + .setParameter("id", id).getSingleResult(); + } + + public Employee findByEntityGraph(int id) { + EntityGraph entityGraph = em.createEntityGraph(Employee.class); + entityGraph.addAttributeNodes("name", "phones"); + Map properties = new HashMap<>(); + properties.put("javax.persistence.fetchgraph", entityGraph); + return em.find(Employee.class, id, properties); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/SpringBootLifecycleEventApplication.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/SpringBootLifecycleEventApplication.java new file mode 100644 index 0000000000..fbc861c5fe --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/SpringBootLifecycleEventApplication.java @@ -0,0 +1,11 @@ +package com.baeldung.lifecycleevents; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootLifecycleEventApplication { + public static void main(String[] args) { + SpringApplication.run(SpringBootLifecycleEventApplication.class, args); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/model/AuditTrailListener.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/model/AuditTrailListener.java new file mode 100644 index 0000000000..26ebff42e4 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/model/AuditTrailListener.java @@ -0,0 +1,39 @@ +package com.baeldung.lifecycleevents.model; + +import javax.persistence.PostLoad; +import javax.persistence.PostPersist; +import javax.persistence.PostRemove; +import javax.persistence.PostUpdate; +import javax.persistence.PrePersist; +import javax.persistence.PreRemove; +import javax.persistence.PreUpdate; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class AuditTrailListener { + private static Log log = LogFactory.getLog(AuditTrailListener.class); + + @PrePersist + @PreUpdate + @PreRemove + private void beforeAnyUpdate(User user) { + if (user.getId() == 0) { + log.info("[USER AUDIT] About to add a user"); + } else { + log.info("[USER AUDIT] About to update/delete user: " + user.getId()); + } + } + + @PostPersist + @PostUpdate + @PostRemove + private void afterAnyUpdate(User user) { + log.info("[USER AUDIT] add/update/delete complete for user: " + user.getId()); + } + + @PostLoad + private void afterLoad(User user) { + log.info("[USER AUDIT] user loaded from database: " + user.getId()); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/model/User.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/model/User.java new file mode 100644 index 0000000000..a080cb3bf2 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/model/User.java @@ -0,0 +1,104 @@ +package com.baeldung.lifecycleevents.model; + +import javax.persistence.Entity; +import javax.persistence.EntityListeners; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.PostLoad; +import javax.persistence.PostPersist; +import javax.persistence.PostRemove; +import javax.persistence.PostUpdate; +import javax.persistence.PrePersist; +import javax.persistence.PreRemove; +import javax.persistence.PreUpdate; +import javax.persistence.Transient; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +@Entity +@EntityListeners(AuditTrailListener.class) +public class User { + private static Log log = LogFactory.getLog(User.class); + + @Id + @GeneratedValue + private int id; + + private String userName; + private String firstName; + private String lastName; + @Transient + private String fullName; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + 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; + } + + public String getFullName() { + return fullName; + } + + @PrePersist + public void logNewUserAttempt() { + log.info("Attempting to add new user with username: " + userName); + } + + @PostPersist + public void logNewUserAdded() { + log.info("Added user '" + userName + "' with ID: " + id); + } + + @PreRemove + public void logUserRemovalAttempt() { + log.info("Attempting to delete user: " + userName); + } + + @PostRemove + public void logUserRemoval() { + log.info("Deleted user: " + userName); + } + + @PreUpdate + public void logUserUpdateAttempt() { + log.info("Attempting to update user: " + userName); + } + + @PostUpdate + public void logUserUpdate() { + log.info("Updated user: " + userName); + } + + @PostLoad + public void logUserLoad() { + fullName = firstName + " " + lastName; + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/repository/UserRepository.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/repository/UserRepository.java new file mode 100644 index 0000000000..af14117ebb --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/lifecycleevents/repository/UserRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.lifecycleevents.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.baeldung.lifecycleevents.model.User; + +public interface UserRepository extends JpaRepository { + public User findByUserName(String userName); +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/elementcollection/ElementCollectionIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/elementcollection/ElementCollectionIntegrationTest.java new file mode 100644 index 0000000000..306798aa68 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/elementcollection/ElementCollectionIntegrationTest.java @@ -0,0 +1,64 @@ +package com.baeldung.elementcollection; + +import com.baeldung.elementcollection.model.Employee; +import com.baeldung.elementcollection.model.Phone; +import com.baeldung.elementcollection.repository.EmployeeRepository; +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.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ElementCollectionApplication.class) +public class ElementCollectionIntegrationTest { + + @Autowired + private EmployeeRepository employeeRepository; + + @Before + public void init() { + Employee employee = new Employee(1, "Fred"); + employee.setPhones( + Arrays.asList(new Phone("work", "+55", "99999-9999"), new Phone("home", "+55", "98888-8888"))); + employeeRepository.save(employee); + } + + @After + public void clean() { + employeeRepository.remove(1); + } + + @Test(expected = org.hibernate.LazyInitializationException.class) + public void whenAccessLazyCollection_thenThrowLazyInitializationException() { + Employee employee = employeeRepository.findById(1); + assertThat(employee.getPhones().size(), is(2)); + } + + @Test + public void whenUseJPAQL_thenFetchResult() { + Employee employee = employeeRepository.findByJPQL(1); + assertThat(employee.getPhones().size(), is(2)); + } + + @Test + public void whenUseEntityGraph_thenFetchResult() { + Employee employee = employeeRepository.findByEntityGraph(1); + assertThat(employee.getPhones().size(), is(2)); + } + + @Test + @Transactional + public void whenUseTransaction_thenFetchResult() { + Employee employee = employeeRepository.findById(1); + assertThat(employee.getPhones().size(), is(2)); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/lifecycleevents/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/lifecycleevents/UserRepositoryIntegrationTest.java new file mode 100644 index 0000000000..078f437474 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/lifecycleevents/UserRepositoryIntegrationTest.java @@ -0,0 +1,80 @@ +package lifecycleevents; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; + +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.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.lifecycleevents.SpringBootLifecycleEventApplication; +import com.baeldung.lifecycleevents.model.User; +import com.baeldung.lifecycleevents.repository.UserRepository; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = SpringBootLifecycleEventApplication.class) +public class UserRepositoryIntegrationTest { + + @Autowired + private UserRepository userRepository; + + @Before + public void setup() { + User user = new User(); + user.setFirstName("Jane"); + user.setLastName("Smith"); + user.setUserName("jsmith123"); + userRepository.save(user); + } + + @After + public void cleanup() { + userRepository.deleteAll(); + } + + @Test + public void whenNewUserProvided_userIsAdded() { + User user = new User(); + user.setFirstName("John"); + user.setLastName("Doe"); + user.setUserName("jdoe123"); + user = userRepository.save(user); + assertTrue(user.getId() > 0); + } + + @Test + public void whenUserNameProvided_userIsLoaded() { + User user = userRepository.findByUserName("jsmith123"); + assertNotNull(user); + assertEquals("jsmith123", user.getUserName()); + } + + @Test + public void whenExistingUserProvided_userIsUpdated() { + User user = userRepository.findByUserName("jsmith123"); + user.setFirstName("Joe"); + user = userRepository.save(user); + assertEquals("Joe", user.getFirstName()); + } + + @Test + public void whenExistingUserDeleted_userIsDeleted() { + User user = userRepository.findByUserName("jsmith123"); + userRepository.delete(user); + user = userRepository.findByUserName("jsmith123"); + assertNull(user); + } + + @Test + public void whenExistingUserLoaded_fullNameIsAvailable() { + String expectedFullName = "Jane Smith"; + User user = userRepository.findByUserName("jsmith123"); + assertEquals(expectedFullName, user.getFullName()); + } +} diff --git a/persistence-modules/spring-data-jpa/pom.xml b/persistence-modules/spring-data-jpa/pom.xml index 27b8ce5eaf..ddd7e17dcd 100644 --- a/persistence-modules/spring-data-jpa/pom.xml +++ b/persistence-modules/spring-data-jpa/pom.xml @@ -1,7 +1,6 @@ - + 4.0.0 spring-data-jpa spring-data-jpa @@ -43,7 +42,6 @@ org.postgresql postgresql - ${postgresql.version} @@ -67,26 +65,6 @@ guava ${guava.version} - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - - - org.junit.platform - junit-platform-launcher - ${junit-platform.version} - test - diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java index 9b235776dc..f1256e2c72 100755 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/dao/product/ProductRepository.java @@ -1,9 +1,14 @@ package com.baeldung.multipledb.dao.product; +import java.util.List; + +import org.springframework.data.domain.Pageable; import org.springframework.data.repository.PagingAndSortingRepository; -import com.baeldung.multipledb.model.product.ProductMultipleDB; +import com.baeldung.multipledb.model.product.Product; -public interface ProductRepository extends PagingAndSortingRepository { +public interface ProductRepository extends PagingAndSortingRepository { -} \ No newline at end of file + + List findAllByPrice(double price, Pageable pageable); +} diff --git a/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/ProductMultipleDB.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/model/product/Product.java old mode 100644 new mode 100755 similarity index 80% rename from persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/ProductMultipleDB.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/model/product/Product.java index 8bdff340ac..eaf471043c --- a/persistence-modules/spring-data-jpa-3/src/main/java/com/baeldung/multipledb/model/product/ProductMultipleDB.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/multipledb/model/product/Product.java @@ -6,7 +6,7 @@ import javax.persistence.Table; @Entity @Table(schema = "products") -public class ProductMultipleDB { +public class Product { @Id private int id; @@ -15,19 +15,19 @@ public class ProductMultipleDB { private double price; - public ProductMultipleDB() { + public Product() { super(); } - private ProductMultipleDB(int id, String name, double price) { + private Product(int id, String name, double price) { super(); this.id = id; this.name = name; this.price = price; } - public static ProductMultipleDB from(int id, String name, double price) { - return new ProductMultipleDB(id, name, price); + public static Product from(int id, String name, double price) { + return new Product(id, name, price); } public int getId() { diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java index 17ee6a94ba..b2581b8034 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/boot/daos/UserRepositoryCommon.java @@ -266,7 +266,7 @@ public class UserRepositoryCommon { userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - List usersSortByName = userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); + List usersSortByName = userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); assertThat(usersSortByName.get(0) .getName()).isEqualTo(USER_NAME_ADAM); @@ -278,7 +278,7 @@ public class UserRepositoryCommon { userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); + userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); List usersSortByNameLength = userRepository.findAll(Sort.by("LENGTH(name)")); diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java index 6ba10a4d49..a1f4a3fa2c 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/JpaMultipleDBIntegrationTest.java @@ -19,7 +19,7 @@ import org.springframework.transaction.annotation.Transactional; import com.baeldung.multipledb.dao.product.ProductRepository; import com.baeldung.multipledb.dao.user.PossessionRepository; import com.baeldung.multipledb.dao.user.UserRepository; -import com.baeldung.multipledb.model.product.ProductMultipleDB; +import com.baeldung.multipledb.model.product.Product; import com.baeldung.multipledb.model.user.PossessionMultipleDB; import com.baeldung.multipledb.model.user.UserMultipleDB; @@ -84,7 +84,7 @@ public class JpaMultipleDBIntegrationTest { @Test @Transactional("productTransactionManager") public void whenCreatingProduct_thenCreated() { - ProductMultipleDB product = new ProductMultipleDB(); + Product product = new Product(); product.setName("Book"); product.setId(2); product.setPrice(20); diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java new file mode 100644 index 0000000000..9bfba61a3b --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/multipledb/ProductRepositoryIntegrationTest.java @@ -0,0 +1,144 @@ +package com.baeldung.multipledb; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasSize; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +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.context.SpringBootTest; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.transaction.annotation.Transactional; + +import com.baeldung.multipledb.PersistenceProductConfiguration; +import com.baeldung.multipledb.dao.product.ProductRepository; +import com.baeldung.multipledb.model.product.Product; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes=MultipleDbApplication.class) +@EnableTransactionManagement +public class ProductRepositoryIntegrationTest { + + @Autowired + private ProductRepository productRepository; + + @Before + @Transactional("productTransactionManager") + public void setUp() { + productRepository.save(Product.from(1001, "Book", 21)); + productRepository.save(Product.from(1002, "Coffee", 10)); + productRepository.save(Product.from(1003, "Jeans", 30)); + productRepository.save(Product.from(1004, "Shirt", 32)); + productRepository.save(Product.from(1005, "Bacon", 10)); + } + + @Test + public void whenRequestingFirstPageOfSizeTwo_ThenReturnFirstPage() { + Pageable pageRequest = PageRequest.of(0, 2); + + Page result = productRepository.findAll(pageRequest); + + assertThat(result.getContent(), hasSize(2)); + assertTrue(result.stream() + .map(Product::getId) + .allMatch(id -> Arrays.asList(1001, 1002) + .contains(id))); + } + + @Test + public void whenRequestingSecondPageOfSizeTwo_ThenReturnSecondPage() { + Pageable pageRequest = PageRequest.of(1, 2); + + Page result = productRepository.findAll(pageRequest); + + assertThat(result.getContent(), hasSize(2)); + assertTrue(result.stream() + .map(Product::getId) + .allMatch(id -> Arrays.asList(1003, 1004) + .contains(id))); + } + + @Test + public void whenRequestingLastPage_ThenReturnLastPageWithRemData() { + Pageable pageRequest = PageRequest.of(2, 2); + + Page result = productRepository.findAll(pageRequest); + + assertThat(result.getContent(), hasSize(1)); + assertTrue(result.stream() + .map(Product::getId) + .allMatch(id -> Arrays.asList(1005) + .contains(id))); + } + + @Test + public void whenSortingByNameAscAndPaging_ThenReturnSortedPagedResult() { + Pageable pageRequest = PageRequest.of(0, 3, Sort.by("name")); + + Page result = productRepository.findAll(pageRequest); + + assertThat(result.getContent(), hasSize(3)); + assertThat(result.getContent() + .stream() + .map(Product::getId) + .collect(Collectors.toList()), equalTo(Arrays.asList(1005, 1001, 1002))); + + } + + @Test + public void whenSortingByPriceDescAndPaging_ThenReturnSortedPagedResult() { + Pageable pageRequest = PageRequest.of(0, 3, Sort.by("price") + .descending()); + + Page result = productRepository.findAll(pageRequest); + + assertThat(result.getContent(), hasSize(3)); + assertThat(result.getContent() + .stream() + .map(Product::getId) + .collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001))); + + } + + @Test + public void whenSortingByPriceDescAndNameAscAndPaging_ThenReturnSortedPagedResult() { + Pageable pageRequest = PageRequest.of(0, 5, Sort.by("price") + .descending() + .and(Sort.by("name"))); + + Page result = productRepository.findAll(pageRequest); + + assertThat(result.getContent(), hasSize(5)); + assertThat(result.getContent() + .stream() + .map(Product::getId) + .collect(Collectors.toList()), equalTo(Arrays.asList(1004, 1003, 1001, 1005, 1002))); + + } + + @Test + public void whenRequestingFirstPageOfSizeTwoUsingCustomMethod_ThenReturnFirstPage() { + Pageable pageRequest = PageRequest.of(0, 2); + + List result = productRepository.findAllByPrice(10, pageRequest); + + assertThat(result, hasSize(2)); + assertTrue(result.stream() + .map(Product::getId) + .allMatch(id -> Arrays.asList(1002, 1005) + .contains(id))); + } +} diff --git a/persistence-modules/spring-data-keyvalue/src/main/java/com/baeldung/spring/data/keyvalue/services/impl/EmployeeServicesWithKeyValueTemplate.java b/persistence-modules/spring-data-keyvalue/src/main/java/com/baeldung/spring/data/keyvalue/services/impl/EmployeeServicesWithKeyValueTemplate.java index 3eb1d0f66a..fe3c332f33 100644 --- a/persistence-modules/spring-data-keyvalue/src/main/java/com/baeldung/spring/data/keyvalue/services/impl/EmployeeServicesWithKeyValueTemplate.java +++ b/persistence-modules/spring-data-keyvalue/src/main/java/com/baeldung/spring/data/keyvalue/services/impl/EmployeeServicesWithKeyValueTemplate.java @@ -49,7 +49,7 @@ public class EmployeeServicesWithKeyValueTemplate implements EmployeeService { @Override public Iterable getSortedListOfEmployeesBySalary() { KeyValueQuery query = new KeyValueQuery(); - query.setSort(new Sort(Sort.Direction.DESC, "salary")); + query.setSort(Sort.by(Sort.Direction.DESC, "salary")); return keyValueTemplate.find(query, Employee.class); } diff --git a/persistence-modules/spring-data-neo4j/pom.xml b/persistence-modules/spring-data-neo4j/pom.xml index 625e2c5fc1..d827c32a3c 100644 --- a/persistence-modules/spring-data-neo4j/pom.xml +++ b/persistence-modules/spring-data-neo4j/pom.xml @@ -8,9 +8,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ diff --git a/persistence-modules/spring-data-redis/pom.xml b/persistence-modules/spring-data-redis/pom.xml index a304108fee..d2bf074d03 100644 --- a/persistence-modules/spring-data-redis/pom.xml +++ b/persistence-modules/spring-data-redis/pom.xml @@ -4,7 +4,7 @@ 4.0.0 spring-data-redis 1.0 - spring-data-redis + spring-data-redis jar @@ -62,7 +62,6 @@ redis.clients jedis - ${jedis.version} jar @@ -97,10 +96,9 @@ 3.2.4 - 2.9.0 0.10.0 - 2.0.3.RELEASE 0.6 + 2.1.9.RELEASE diff --git a/persistence-modules/spring-data-solr/pom.xml b/persistence-modules/spring-data-solr/pom.xml index 1a17a2e321..9d96c75082 100644 --- a/persistence-modules/spring-data-solr/pom.xml +++ b/persistence-modules/spring-data-solr/pom.xml @@ -3,7 +3,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-data-solr - 0.0.1-SNAPSHOT spring-data-solr jar diff --git a/persistence-modules/spring-hibernate-3/pom.xml b/persistence-modules/spring-hibernate-3/pom.xml index e677776a95..b28895f86d 100644 --- a/persistence-modules/spring-hibernate-3/pom.xml +++ b/persistence-modules/spring-hibernate-3/pom.xml @@ -8,9 +8,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -73,16 +72,6 @@ - - spring-hibernate-3 - - - src/main/resources - true - - - - 4.3.4.RELEASE diff --git a/persistence-modules/spring-hibernate-5/pom.xml b/persistence-modules/spring-hibernate-5/pom.xml index 546dcb1ce0..8a8b6c15e3 100644 --- a/persistence-modules/spring-hibernate-5/pom.xml +++ b/persistence-modules/spring-hibernate-5/pom.xml @@ -8,9 +8,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -125,16 +124,6 @@ - - spring-hibernate-5 - - - src/main/resources - true - - - - 5.0.2.RELEASE diff --git a/persistence-modules/spring-hibernate4/pom.xml b/persistence-modules/spring-hibernate4/pom.xml index 41c7fdb098..5e931d5cff 100644 --- a/persistence-modules/spring-hibernate4/pom.xml +++ b/persistence-modules/spring-hibernate4/pom.xml @@ -136,16 +136,6 @@ - - spring-hibernate4 - - - src/main/resources - true - - - - 4.3.4.RELEASE @@ -166,15 +156,6 @@ 19.0 - - 4.4.1 - 4.5 - - 2.9.0 - - - 2.7 - diff --git a/persistence-modules/spring-jpa/pom.xml b/persistence-modules/spring-jpa/pom.xml index 4972a20cf6..ef05269c92 100644 --- a/persistence-modules/spring-jpa/pom.xml +++ b/persistence-modules/spring-jpa/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -129,27 +128,6 @@ - - spring-jpa - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - src/main/webapp - false - - - - - 5.1.5.RELEASE diff --git a/persistence-modules/spring-persistence-simple/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml index 3ecb9c3d7d..8a03310048 100644 --- a/persistence-modules/spring-persistence-simple/pom.xml +++ b/persistence-modules/spring-persistence-simple/pom.xml @@ -8,9 +8,8 @@ com.baeldung - parent-modules + persistence-modules 1.0.0-SNAPSHOT - ../../ @@ -106,13 +105,6 @@ - spring-persistence-simple - - - src/main/resources - true - - com.mysema.maven diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java index e202e45b32..7d3a881827 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java @@ -15,6 +15,7 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostPro import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.JpaVendorAdapter; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; @@ -39,12 +40,12 @@ public class PersistenceJPAConfig { // beans @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java index fde1857ca2..72031a2232 100644 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java +++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/persistence/service/transactional/PersistenceTransactionalTestConfig.java @@ -14,6 +14,7 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostPro import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.JpaVendorAdapter; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; @@ -91,12 +92,12 @@ public class PersistenceTransactionalTestConfig { // beans @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); - final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); diff --git a/play-framework/websockets/README.md b/play-framework/websockets/README.md new file mode 100644 index 0000000000..d056b8f059 --- /dev/null +++ b/play-framework/websockets/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [WebSockets with the Play Framework and Akka](https://www.baeldung.com/akka-play-websockets) diff --git a/pom.xml b/pom.xml index 63d4e04291..6e6316edd6 100644 --- a/pom.xml +++ b/pom.xml @@ -332,19 +332,23 @@ parent-spring-5 parent-java parent-kotlin - + + akka-http akka-streams + algorithms-genetic algorithms-miscellaneous-1 algorithms-miscellaneous-2 algorithms-miscellaneous-3 algorithms-miscellaneous-4 algorithms-miscellaneous-5 - algorithms-sorting algorithms-searching + algorithms-sorting + algorithms-sorting-2 animal-sniffer-mvn-plugin annotations antlr + apache-avro apache-bval apache-curator @@ -356,6 +360,7 @@ apache-opennlp apache-poi apache-pulsar + apache-rocketmq apache-shiro apache-solrj apache-spark @@ -364,12 +369,18 @@ apache-tika apache-velocity apache-zookeeper + asciidoctor asm + atomix + aws aws-lambda + aws-reactive + axon + azure bazel @@ -379,83 +390,18 @@ cas cdi checker-plugin - cloud-foundry-uaa/cf-uaa-oauth2-client - cloud-foundry-uaa/cf-uaa-oauth2-resource-server + + cloud-foundry-uaa code-generation + core-groovy core-groovy-2 core-groovy-collections - - - - core-java-modules/core-java-8 - core-java-modules/core-java-8-2 - core-java-modules/core-java-annotations - core-java-modules/core-java-streams - core-java-modules/core-java-streams-2 - core-java-modules/core-java-streams-3 - - core-java-modules/core-java-function - core-java-modules/core-java-lang-math - - - core-java-modules/core-java-text - core-java-modules/core-java-lambdas - - - core-java-modules/core-java-arrays - core-java-modules/core-java-arrays-2 - core-java-modules/core-java-collections - core-java-modules/core-java-collections-2 - core-java-modules/core-java-collections-3 - core-java-modules/core-java-collections-list - core-java-modules/core-java-collections-list-2 - core-java-modules/core-java-collections-list-3 - core-java-modules/core-java-collections-array-list - core-java-modules/core-java-collections-set - core-java-modules/core-java-concurrency-basic - core-java-modules/core-java-concurrency-basic-2 - core-java-modules/core-java-concurrency-collections - core-java-modules/core-java-io - core-java-modules/core-java-io-2 - core-java-modules/core-java-io-apis - core-java-modules/core-java-io-conversions - core-java-modules/core-java-nio - core-java-modules/core-java-nio-2 - core-java-modules/core-java-security - core-java-modules/core-java-exceptions - core-java-modules/core-java-lang-syntax - core-java-modules/core-java-lang-syntax-2 - core-java-modules/core-java-lang - core-java-modules/core-java-lang-2 - core-java-modules/core-java-lang-oop - core-java-modules/core-java-lang-oop-2 - core-java-modules/core-java-lang-oop-3 - core-java-modules/core-java-lang-oop-4 + core-java-modules - core-java-modules/core-java-networking - core-java-modules/core-java-perf - core-java-modules/core-java-reflection - core-java-modules/core-java-sun - core-java-modules/core-java-string-conversions - core-java-modules/core-java-string-conversions-2 - core-java-modules/core-java-string-operations - core-java-modules/core-java-string-operations-2 - core-java-modules/core-java-string-algorithms - core-java-modules/core-java-string-algorithms-2 - core-java-modules/core-java-string-apis - core-java-modules/core-java-strings - core-java-modules/core-java - core-java-modules/core-java-jar - core-java-modules/core-java-jvm core-kotlin-modules core-scala + couchbase custom-pmd @@ -466,6 +412,7 @@ disruptor dozer drools + dropwizard dubbo ethereum @@ -477,15 +424,16 @@ google-cloud google-web-toolkit + graphql/graphql-java grpc gson guava - guava-io guava-collections guava-collections-map guava-collections-set + guava-io guava-modules guice @@ -499,35 +447,32 @@ image-processing immutables - jackson + jackson-modules jackson-simple - jackson-annotations - jackson-exceptions - jackson-conversions - jackson-conversions-2 - jackson-custom-conversions + java-blockchain + java-collections-conversions java-collections-conversions-2 java-collections-maps java-collections-maps-2 - java-jdi - + + javafx + java-jdi java-lite java-math java-math-2 java-numbers java-numbers-2 + java-numbers-3 java-rmi java-spi java-vavr-stream java-websocket - javafx javax-servlets javaxval jaxb - + jee-7 jee-7-security jee-kotlin jersey @@ -542,6 +487,7 @@ jooby jsf json + json-2 json-path jsoup jta @@ -549,51 +495,52 @@ kotlin-libraries kotlin-libraries-2 + kotlin-quasar - libraries libraries-2 libraries-3 + libraries-apache-commons + libraries-apache-commons-collections + libraries-apache-commons-io libraries-data libraries-data-2 libraries-data-db libraries-data-io - libraries-apache-commons - libraries-apache-commons-collections - libraries-apache-commons-io - libraries-primitive - libraries-testing - libraries-security - libraries-server libraries-http libraries-io + libraries-primitive + libraries-security + libraries-server + libraries-testing linkrest logging-modules lombok + lombok-custom lucene + machine-learning mapstruct - - maven-all/maven - maven-all/maven-custom-plugin/counter-maven-plugin - maven-all/maven-war-plugin - maven-all/profiles - maven-all/versions-maven-plugin + + maven-all maven-archetype - - maven-polyglot/maven-polyglot-json-extension - + + maven-polyglot + mesos-marathon metrics - + micronaut microprofile msf4j - + mustache mybatis - netflix + netflix-modules + ninja + open-liberty + oauth2-framework-impl optaplanner orika osgi @@ -601,11 +548,12 @@ patterns pdf performance-tests + persistence-modules protobuffer - persistence-modules quarkus + quarkus-extension rabbitmq @@ -613,31 +561,12 @@ reactor-core resteasy restx - - rule-engines rsocket + rule-engines rxjava-core + rxjava-libraries rxjava-observables rxjava-operators - rxjava-libraries - software-security/sql-injection-samples - - tensorflow-java - spf4j - spring-boot-config-jpa-error - spring-boot-flowable - spring-boot-mvc-2 - spring-boot-performance - spring-boot-properties - - spring-security-modules/spring-security-kerberos - oauth2-framework-impl - - spring-boot-nashorn - java-blockchain - machine-learning - wildfly - quarkus-extension @@ -673,8 +602,6 @@ - netflix - parent-boot-1 parent-boot-2 parent-spring-4 @@ -683,12 +610,14 @@ parent-kotlin saas + software-security/sql-injection-samples + spark-java + spf4j spring-4 spring-5 - spring-5-webflux spring-5-data-reactive spring-5-mvc spring-5-reactive @@ -697,55 +626,23 @@ spring-5-reactive-oauth spring-5-reactive-security spring-5-security - spring-5-security-oauth spring-5-security-cognito + spring-5-security-oauth + spring-5-webflux spring-activiti spring-akka spring-amqp spring-aop spring-apache-camel + spring-batch spring-bom - - spring-boot - spring-boot-admin - spring-boot-angular - spring-boot-autoconfiguration - spring-boot-bootstrap - spring-boot-camel - - spring-boot-config-jpa-error - spring-boot-client - - spring-boot-crud - spring-boot-ctx-fluent - spring-boot-custom-starter - - spring-boot-jasypt - spring-boot-keycloak - spring-boot-kotlin - spring-boot-logging-log4j2 - spring-boot-mvc - spring-boot-mvc-birt - spring-boot-environment - spring-boot-deployment - spring-boot-runtime - spring-boot-runtime/disabling-console-jul - spring-boot-runtime/disabling-console-log4j2 - spring-boot-runtime/disabling-console-logback - spring-boot-artifacts - spring-boot-rest - spring-boot-data spring-boot-parent - spring-boot-property-exp + spring-boot-rest spring-boot-security - spring-boot-springdoc - spring-boot-testing - spring-boot-vue + spring-caching - spring-boot-libraries - spring-cloud spring-cloud-bus @@ -759,9 +656,9 @@ spring-data-rest spring-data-rest-querydsl + spring-di spring-dispatcher-servlet spring-drools - spring-di spring-ehcache spring-ejb @@ -786,59 +683,41 @@ spring-mobile spring-mockito + + spring-mvc-basics spring-mvc-basics-2 + spring-mvc-basics-3 + spring-mvc-basics-4 + spring-mvc-forms-jsp spring-mvc-forms-thymeleaf spring-mvc-java spring-mvc-kotlin - spring-mvc-simple - spring-mvc-simple-2 - spring-mvc-views + spring-mvc-velocity + spring-mvc-views spring-mvc-webflow spring-mvc-xml spring-protobuf - - spring-quartz spring-reactive-kotlin spring-reactor spring-remoting - spring-rest-http spring-rest-angular spring-rest-compress - spring-rest-testing spring-rest-hal-browser + spring-rest-http spring-rest-query-language spring-rest-shell spring-rest-simple spring-resttemplate + spring-rest-testing spring-roo + spring-scheduling - spring-security-modules/spring-security-acl - spring-security-modules/spring-security-angular/server - spring-security-modules/spring-security-cache-control - spring-security-modules/spring-security-core - spring-security-modules/spring-security-mvc - spring-security-modules/spring-security-mvc-boot - spring-security-modules/spring-security-mvc-custom - spring-security-modules/spring-security-mvc-digest-auth - spring-security-modules/spring-security-mvc-jsonview - spring-security-modules/spring-security-mvc-ldap - spring-security-modules/spring-security-mvc-login - spring-security-modules/spring-security-mvc-persisted-remember-me - spring-security-modules/spring-security-mvc-socket - spring-security-modules/spring-security-openid - - spring-security-modules/spring-security-rest - spring-security-modules/spring-security-rest-basic-auth - spring-security-modules/spring-security-rest-custom - spring-security-modules/spring-security-sso - spring-security-modules/spring-security-stormpath - spring-security-modules/spring-security-thymeleaf - spring-security-modules/spring-security-x509 + spring-security-modules spring-session spring-shell spring-sleuth @@ -850,17 +729,20 @@ spring-swagger-codegen spring-thymeleaf + spring-thymeleaf-2 spring-vault spring-vertx spring-webflux-amqp + spring-websockets static-analysis stripe structurizr struts-2 + tensorflow-java testing-modules twilio @@ -873,18 +755,11 @@ video-tutorials vraptor + webrtc wicket - + wildfly xml xstream - - tensorflow-java - spring-boot-flowable - spring-security-modules/spring-security-kerberos - - spring-boot-nashorn - java-blockchain - @@ -927,23 +802,11 @@ parent-java parent-kotlin - core-java-modules/core-java-concurrency-advanced - core-java-modules/core-java-concurrency-advanced-2 - core-java-modules/core-java-concurrency-advanced-3 - core-kotlin - core-kotlin-2 - jenkins/plugins jhipster jws libraries - persistence-modules/hibernate5 - persistence-modules/hibernate-mapping - persistence-modules/java-jpa - persistence-modules/java-jpa-2 - persistence-modules/java-mongodb - persistence-modules/jnosql vaadin vavr @@ -979,19 +842,23 @@ parent-spring-5 parent-java parent-kotlin - + + akka-http akka-streams + algorithms-genetic algorithms-miscellaneous-1 algorithms-miscellaneous-2 algorithms-miscellaneous-3 algorithms-miscellaneous-4 algorithms-miscellaneous-5 - algorithms-sorting algorithms-searching + algorithms-sorting + algorithms-sorting-2 animal-sniffer-mvn-plugin annotations antlr + apache-avro apache-bval apache-curator @@ -1003,6 +870,7 @@ apache-opennlp apache-poi apache-pulsar + apache-rocketmq apache-shiro apache-solrj apache-spark @@ -1011,90 +879,39 @@ apache-tika apache-velocity apache-zookeeper + asciidoctor asm + atomix + aws aws-lambda + aws-reactive + axon + azure + bazel + blade bootique cas cdi checker-plugin - cloud-foundry-uaa/cf-uaa-oauth2-client - cloud-foundry-uaa/cf-uaa-oauth2-resource-server + + cloud-foundry-uaa code-generation + core-groovy core-groovy-2 core-groovy-collections - - - core-java-modules/core-java-8 - core-java-modules/core-java-8-2 - core-java-modules/core-java-annotations - core-java-modules/core-java-streams - core-java-modules/core-java-streams-2 - core-java-modules/core-java-streams-3 - - core-java-modules/core-java-function - core-java-modules/core-java-lang-math - - - core-java-modules/core-java-text - - - core-java-modules/core-java-arrays - core-java-modules/core-java-arrays-2 - core-java-modules/core-java-collections - core-java-modules/core-java-collections-2 - core-java-modules/core-java-collections-3 - core-java-modules/core-java-collections-list - core-java-modules/core-java-collections-list-2 - core-java-modules/core-java-collections-list-3 - core-java-modules/core-java-collections-array-list - core-java-modules/core-java-collections-set - core-java-modules/core-java-concurrency-basic - core-java-modules/core-java-concurrency-basic-2 - core-java-modules/core-java-concurrency-collections - core-java-modules/core-java-io - core-java-modules/core-java-io-2 - core-java-modules/core-java-io-apis - core-java-modules/core-java-io-conversions - core-java-modules/core-java-nio - core-java-modules/core-java-nio-2 - core-java-modules/core-java-security - core-java-modules/core-java-exceptions - core-java-modules/core-java-lang-syntax - core-java-modules/core-java-lang-syntax-2 - core-java-modules/core-java-lang - core-java-modules/core-java-lang-2 - core-java-modules/core-java-lang-oop - core-java-modules/core-java-lang-oop-2 - core-java-modules/core-java-lang-oop-3 - core-java-modules/core-java-lang-oop-4 + core-java-modules - core-java-modules/core-java-networking - core-java-modules/core-java-perf - core-java-modules/core-java-sun - core-java-modules/core-java-string-conversions - core-java-modules/core-java-string-conversions-2 - core-java-modules/core-java-string-operations - core-java-modules/core-java-string-operations-2 - core-java-modules/core-java-string-algorithms - core-java-modules/core-java-string-algorithms-2 - core-java-modules/core-java-string-apis - core-java-modules/core-java-strings core-kotlin-modules core-scala + couchbase custom-pmd @@ -1105,6 +922,7 @@ disruptor dozer drools + dropwizard dubbo ethereum @@ -1116,15 +934,16 @@ google-cloud google-web-toolkit + graphql/graphql-java grpc gson guava - guava-io guava-collections guava-collections-map guava-collections-set + guava-io guava-modules guice @@ -1138,35 +957,32 @@ image-processing immutables - jackson + jackson-modules jackson-simple - jackson-annotations - jackson-exceptions - jackson-conversions - jackson-conversions-2 - jackson-custom-conversions + java-blockchain + java-collections-conversions java-collections-conversions-2 java-collections-maps java-collections-maps-2 + + + javafx java-jdi - - java-ee-8-security-api java-lite java-math - java-math-2 + java-math-2 java-numbers java-numbers-2 + java-numbers-3 java-rmi java-spi java-vavr-stream java-websocket - javafx javax-servlets javaxval jaxb - + jee-7 jee-7-security jee-kotlin jersey @@ -1187,49 +1003,53 @@ kotlin-libraries + kotlin-libraries-2 + kotlin-quasar - libraries + libraries-2 libraries-3 + libraries-apache-commons + libraries-apache-commons-collections + libraries-apache-commons-io libraries-data libraries-data-2 libraries-data-db libraries-data-io - libraries-apache-commons - libraries-apache-commons-collections - libraries-apache-commons-io - libraries-testing + libraries-http + libraries-io + libraries-primitive libraries-security libraries-server - libraries-http + libraries-testing linkrest logging-modules lombok + lombok-custom lucene + machine-learning mapstruct - - maven-all/maven - maven-all/maven-custom-plugin/counter-maven-plugin - maven-all/maven-war-plugin - maven-all/profiles - maven-all/versions-maven-plugin - + + maven-all maven-archetype - - maven-polyglot/maven-polyglot-json-extension - + + maven-polyglot + mesos-marathon metrics - + micronaut microprofile msf4j - + mustache mybatis - netflix + netflix-modules + ninja + open-liberty + oauth2-framework-impl optaplanner orika osgi @@ -1237,10 +1057,12 @@ patterns pdf performance-tests + persistence-modules protobuffer - persistence-modules + quarkus + quarkus-extension rabbitmq @@ -1248,20 +1070,12 @@ reactor-core resteasy restx - - rule-engines rsocket + rule-engines rxjava-core + rxjava-libraries rxjava-observables rxjava-operators - rxjava-libraries - oauth2-framework-impl - spf4j - spring-boot-performance - spring-boot-properties - - - @@ -1297,7 +1111,10 @@ parent-kotlin saas + software-security/sql-injection-samples + spark-java + spf4j spring-4 @@ -1310,48 +1127,24 @@ spring-5-reactive-oauth spring-5-reactive-security spring-5-security - spring-5-security-oauth spring-5-security-cognito + spring-5-security-oauth + spring-5-webflux + spring-activiti spring-akka spring-amqp spring-aop spring-apache-camel + spring-batch spring-bom - - spring-boot - spring-boot-admin - spring-boot-angular - spring-boot-autoconfiguration - spring-boot-bootstrap - spring-boot-camel - - spring-boot-client - spring-boot-crud - spring-boot-ctx-fluent - spring-boot-custom-starter - - spring-boot-jasypt - spring-boot-keycloak - spring-boot-logging-log4j2 - spring-boot-mvc - spring-boot-mvc-birt - spring-boot-environment - spring-boot-deployment - spring-boot-runtime - spring-boot-runtime/disabling-console-jul - spring-boot-runtime/disabling-console-log4j2 - spring-boot-runtime/disabling-console-logback - spring-boot-artifacts - spring-boot-rest - spring-boot-data spring-boot-parent - spring-boot-property-exp + spring-boot-rest spring-boot-security - spring-boot-springdoc - spring-boot-vue + spring-caching + spring-cloud spring-cloud-bus @@ -1364,9 +1157,9 @@ spring-data-rest spring-data-rest-querydsl + spring-di spring-dispatcher-servlet spring-drools - spring-di spring-ehcache spring-ejb @@ -1391,59 +1184,41 @@ spring-mobile spring-mockito + + spring-mvc-basics spring-mvc-basics-2 + spring-mvc-basics-3 + spring-mvc-basics-4 + spring-mvc-forms-jsp spring-mvc-forms-thymeleaf spring-mvc-java spring-mvc-kotlin - spring-mvc-simple - spring-mvc-simple-2 - spring-mvc-views + spring-mvc-velocity + spring-mvc-views spring-mvc-webflow spring-mvc-xml spring-protobuf - - spring-quartz spring-reactive-kotlin spring-reactor spring-remoting - spring-rest-http spring-rest-angular spring-rest-compress - spring-rest-testing spring-rest-hal-browser + spring-rest-http spring-rest-query-language spring-rest-shell spring-rest-simple spring-resttemplate + spring-rest-testing spring-roo spring-scheduling - spring-security-modules/spring-security-acl - spring-security-modules/spring-security-angular/server - spring-security-modules/spring-security-cache-control - spring-security-modules/spring-security-core - spring-security-modules/spring-security-mvc - spring-security-modules/spring-security-mvc-boot - spring-security-modules/spring-security-mvc-custom - spring-security-modules/spring-security-mvc-digest-auth - spring-security-modules/spring-security-mvc-ldap - spring-security-modules/spring-security-mvc-login - spring-security-modules/spring-security-mvc-persisted-remember-me - spring-security-modules/spring-security-mvc-socket - spring-security-modules/spring-security-openid - - spring-security-modules/spring-security-rest - spring-security-modules/spring-security-rest-basic-auth - spring-security-modules/spring-security-rest-custom - spring-security-modules/spring-security-sso - spring-security-modules/spring-security-stormpath - spring-security-modules/spring-security-thymeleaf - spring-security-modules/spring-security-x509 + spring-security-modules spring-session spring-shell spring-sleuth @@ -1455,17 +1230,20 @@ spring-swagger-codegen spring-thymeleaf + spring-thymeleaf-2 spring-vault spring-vertx spring-webflux-amqp + spring-websockets static-analysis stripe structurizr struts-2 + tensorflow-java testing-modules twilio @@ -1478,8 +1256,9 @@ video-tutorials vraptor + webrtc wicket - + wildfly xml xstream @@ -1516,27 +1295,12 @@ parent-java parent-kotlin - core-java-modules/core-java - core-java-modules/core-java-jar - core-java-modules/core-java-concurrency-advanced - core-java-modules/core-java-concurrency-advanced-2 - core-java-modules/core-java-concurrency-advanced-3 - core-kotlin - core-kotlin-2 - jenkins/plugins jhipster jws libraries - persistence-modules/hibernate5 - persistence-modules/hibernate-mapping - persistence-modules/java-jpa - persistence-modules/java-jpa-2 - persistence-modules/java-mongodb - persistence-modules/jnosql - vaadin vavr diff --git a/quarkus-extension/README.md b/quarkus-extension/README.md new file mode 100644 index 0000000000..782ec75957 --- /dev/null +++ b/quarkus-extension/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [How to Implement a Quarkus Extension](https://www.baeldung.com/quarkus-extension-java) diff --git a/quarkus-extension/pom.xml b/quarkus-extension/pom.xml index 38d7c3d548..394376e59e 100644 --- a/quarkus-extension/pom.xml +++ b/quarkus-extension/pom.xml @@ -9,6 +9,12 @@ quarkus-extension pom + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + quarkus-liquibase quarkus-app diff --git a/quarkus-extension/quarkus-app/pom.xml b/quarkus-extension/quarkus-app/pom.xml index 6e4cce3ae7..6d3f4c7c28 100644 --- a/quarkus-extension/quarkus-app/pom.xml +++ b/quarkus-extension/quarkus-app/pom.xml @@ -5,7 +5,12 @@ 4.0.0 com.baeldung.quarkus.app quarkus-app - 1.0-SNAPSHOT + + + com.baeldung.quarkus.extension + quarkus-extension + 1.0-SNAPSHOT + @@ -22,13 +27,12 @@ com.baeldung.quarkus.liquibase - quarkus-liquibase - 1.0-SNAPSHOT + quarkus-liquibase-runtime + ${project.version} io.quarkus quarkus-jdbc-h2 - ${quarkus.version} @@ -46,31 +50,11 @@ - - maven-compiler-plugin - ${compiler-plugin.version} - - - maven-surefire-plugin - ${surefire-plugin.version} - - - org.jboss.logmanager.LogManager - - - - UTF-8 - 2.22.0 - true 1.0.0.Final - 3.8.1 - 1.8 - UTF-8 - 1.8 diff --git a/quarkus-extension/quarkus-liquibase/deployment/pom.xml b/quarkus-extension/quarkus-liquibase/deployment/pom.xml index f005ac4e8c..c85d986390 100644 --- a/quarkus-extension/quarkus-liquibase/deployment/pom.xml +++ b/quarkus-extension/quarkus-liquibase/deployment/pom.xml @@ -30,7 +30,7 @@ com.baeldung.quarkus.liquibase - quarkus-liquibase + quarkus-liquibase-runtime ${project.version} @@ -40,7 +40,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + ${compiler.plugin.version} @@ -54,4 +54,8 @@ + + 3.8.1 + + \ No newline at end of file diff --git a/quarkus-extension/quarkus-liquibase/pom.xml b/quarkus-extension/quarkus-liquibase/pom.xml index e1f3e243ab..9536561701 100644 --- a/quarkus-extension/quarkus-liquibase/pom.xml +++ b/quarkus-extension/quarkus-liquibase/pom.xml @@ -5,19 +5,21 @@ 4.0.0 com.baeldung.quarkus.liquibase quarkus-liquibase-parent - 1.0-SNAPSHOT quarkus-liquibase-parent pom + + com.baeldung.quarkus.extension + quarkus-extension + 1.0-SNAPSHOT + + runtime deployment - 1.8 - 1.8 - UTF-8 1.0.0.Final diff --git a/quarkus-extension/quarkus-liquibase/runtime/pom.xml b/quarkus-extension/quarkus-liquibase/runtime/pom.xml index a1d705c691..83f7c8d4cc 100644 --- a/quarkus-extension/quarkus-liquibase/runtime/pom.xml +++ b/quarkus-extension/quarkus-liquibase/runtime/pom.xml @@ -1,7 +1,6 @@ - + 4.0.0 quarkus-liquibase-runtime quarkus-liquibase-runtime @@ -26,7 +25,7 @@ org.liquibase liquibase-core - 3.8.1 + ${liquibase-core.version} @@ -42,7 +41,7 @@ extension-descriptor - ${project.groupId}:${project.artifactId}-deployment:${project.version} + ${project.groupId}:quarkus-liquibase-deployment:${project.version} @@ -51,7 +50,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + ${compiler.plugin.version} @@ -65,4 +64,10 @@ + + 3.8.1 + 3.8.1 + 3.8.1 + + \ No newline at end of file diff --git a/quarkus/pom.xml b/quarkus/pom.xml index de4c2ca9a3..09eb90d110 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -118,9 +118,6 @@ 2.22.0 0.15.0 - 1.8 - UTF-8 - 1.8 diff --git a/rabbitmq/pom.xml b/rabbitmq/pom.xml index b544da4c44..33ccf5402f 100644 --- a/rabbitmq/pom.xml +++ b/rabbitmq/pom.xml @@ -5,7 +5,6 @@ rabbitmq 0.1-SNAPSHOT rabbitmq - http://maven.apache.org com.baeldung diff --git a/ratpack/pom.xml b/ratpack/pom.xml index a00be905ee..9ad654fa7d 100644 --- a/ratpack/pom.xml +++ b/ratpack/pom.xml @@ -6,7 +6,6 @@ 1.0-SNAPSHOT ratpack jar - http://maven.apache.org com.baeldung @@ -85,18 +84,7 @@ - - ${project.artifactId} - - - src/main/resources - - - - - 1.8 - 1.8 1.5.4 4.5.3 4.4.6 diff --git a/restx/pom.xml b/restx/pom.xml index 17c25fcdc0..ee25c88047 100644 --- a/restx/pom.xml +++ b/restx/pom.xml @@ -148,8 +148,6 @@ - 1.8 - 1.8 0.35-rc4 1.2.3 diff --git a/rsocket/pom.xml b/rsocket/pom.xml index 70f21064b6..5b407c2bd0 100644 --- a/rsocket/pom.xml +++ b/rsocket/pom.xml @@ -24,43 +24,10 @@ rsocket-transport-netty ${rsocket.version} - - junit - junit - ${junit.version} - test - - - org.hamcrest - hamcrest-core - ${hamcrest.version} - test - - - ch.qos.logback - logback-classic - ${logback.version} - - - ch.qos.logback - logback-core - ${logback.version} - - - org.slf4j - slf4j-api - ${slf4j-api.version} - - 1.8 - 1.8 - 3.0.1 0.11.13 - 1.3 - 1.2.3 - 1.7.25 diff --git a/rule-engines/easy-rules/pom.xml b/rule-engines/easy-rules/pom.xml index c1ba829045..b9661cd1c3 100644 --- a/rule-engines/easy-rules/pom.xml +++ b/rule-engines/easy-rules/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-modules + rule-engines 1.0.0-SNAPSHOT - ../.. diff --git a/rule-engines/openl-tablets/pom.xml b/rule-engines/openl-tablets/pom.xml index d1c7baabcc..25c4b8365a 100644 --- a/rule-engines/openl-tablets/pom.xml +++ b/rule-engines/openl-tablets/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-modules + rule-engines 1.0.0-SNAPSHOT - ../.. diff --git a/rule-engines/pom.xml b/rule-engines/pom.xml index cc015c600b..d3d3127ce0 100644 --- a/rule-engines/pom.xml +++ b/rule-engines/pom.xml @@ -10,7 +10,6 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - .. diff --git a/rule-engines/rulebook/pom.xml b/rule-engines/rulebook/pom.xml index b021adea10..95ededa5f9 100644 --- a/rule-engines/rulebook/pom.xml +++ b/rule-engines/rulebook/pom.xml @@ -9,9 +9,8 @@ com.baeldung - parent-modules + rule-engines 1.0.0-SNAPSHOT - ../.. diff --git a/rxjava-core/README.md b/rxjava-core/README.md index 2773bd9423..95a374668d 100644 --- a/rxjava-core/README.md +++ b/rxjava-core/README.md @@ -13,4 +13,5 @@ This module contains articles about RxJava. - [RxJava Maybe](https://www.baeldung.com/rxjava-maybe) - [Combining RxJava Completables](https://www.baeldung.com/rxjava-completable) - [RxJava Hooks](https://www.baeldung.com/rxjava-hooks) +- [Introduction to rxjava-jdbc](https://www.baeldung.com/rxjava-jdbc) - More articles: [[next -->]](/rxjava-2) diff --git a/slack/pom.xml b/slack/pom.xml new file mode 100644 index 0000000000..ebe5ce2f60 --- /dev/null +++ b/slack/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + com.baeldung.examples + slack + 1.0 + slack + jar + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + com.hubspot.slack + slack-base + ${slack.version} + + + com.hubspot.slack + slack-java-client + ${slack.version} + + + + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + + true + com.baeldung.examples.slack.MainClass + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + com.baeldung.examples.slack.MainClass + + + + + + + 1.4 + 2.4 + + + diff --git a/slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java b/slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java new file mode 100644 index 0000000000..7a3f5cd607 --- /dev/null +++ b/slack/src/main/java/com/baeldung/examples/slack/DiskSpaceErrorChecker.java @@ -0,0 +1,42 @@ +package com.baeldung.examples.slack; + +import java.io.IOException; +import java.nio.file.FileSystems; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DiskSpaceErrorChecker implements ErrorChecker { + private static final Logger LOG = LoggerFactory.getLogger(DiskSpaceErrorChecker.class); + + private final ErrorReporter errorReporter; + + private final double limit; + + public DiskSpaceErrorChecker(ErrorReporter errorReporter, double limit) { + this.errorReporter = errorReporter; + this.limit = limit; + } + + @Override + public void check() { + LOG.info("Checking disk space"); + FileSystems.getDefault().getFileStores().forEach(fileStore -> { + try { + long totalSpace = fileStore.getTotalSpace(); + long usableSpace = fileStore.getUsableSpace(); + double usablePercentage = ((double) usableSpace) / totalSpace; + LOG.debug("File store {} has {} of {} ({}) usable space", + fileStore, usableSpace, totalSpace, usablePercentage); + + if (totalSpace > 0 && usablePercentage < limit) { + String error = String.format("File store %s only has %d%% usable disk space", + fileStore.name(), (int)(usablePercentage * 100)); + errorReporter.reportProblem(error); + } + } catch (IOException e) { + LOG.error("Error getting disk space for file store {}", fileStore, e); + } + }); + } +} diff --git a/slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java b/slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java new file mode 100644 index 0000000000..08db9a7817 --- /dev/null +++ b/slack/src/main/java/com/baeldung/examples/slack/ErrorChecker.java @@ -0,0 +1,5 @@ +package com.baeldung.examples.slack; + +public interface ErrorChecker { + void check(); +} diff --git a/slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java b/slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java new file mode 100644 index 0000000000..ba6165af9b --- /dev/null +++ b/slack/src/main/java/com/baeldung/examples/slack/ErrorReporter.java @@ -0,0 +1,5 @@ +package com.baeldung.examples.slack; + +public interface ErrorReporter { + void reportProblem(String problem); +} diff --git a/slack/src/main/java/com/baeldung/examples/slack/MainClass.java b/slack/src/main/java/com/baeldung/examples/slack/MainClass.java new file mode 100644 index 0000000000..ac25e97cf6 --- /dev/null +++ b/slack/src/main/java/com/baeldung/examples/slack/MainClass.java @@ -0,0 +1,41 @@ +package com.baeldung.examples.slack; + +import java.io.IOException; +import java.util.Timer; +import java.util.TimerTask; + +import com.hubspot.slack.client.SlackClient; +import com.hubspot.slack.client.SlackClientFactory; +import com.hubspot.slack.client.SlackClientRuntimeConfig; + +public class MainClass { + public static final long MINUTES = 1000 * 60; + + public static void main(String[] args) throws IOException { + SlackClientRuntimeConfig runtimeConfig = SlackClientRuntimeConfig.builder() + .setTokenSupplier(() -> "") + .build(); + + SlackClient slackClient = SlackClientFactory.defaultFactory().build(runtimeConfig); + + ErrorReporter slackChannelErrorReporter = new SlackChannelErrorReporter(slackClient, "general"); + ErrorReporter slackUserErrorReporter = new SlackUserErrorReporter(slackClient, "testuser@baeldung.com"); + + ErrorChecker diskSpaceErrorChecker10pct = new DiskSpaceErrorChecker(slackChannelErrorReporter, 0.1); + ErrorChecker diskSpaceErrorChecker2pct = new DiskSpaceErrorChecker(slackUserErrorReporter, 0.02); + + Timer timer = new Timer(); + timer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + diskSpaceErrorChecker10pct.check(); + } + }, 0, 5 * MINUTES); + timer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + diskSpaceErrorChecker2pct.check(); + } + }, 0, 5 * MINUTES); + } +} diff --git a/slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java b/slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java new file mode 100644 index 0000000000..f7abcecc2e --- /dev/null +++ b/slack/src/main/java/com/baeldung/examples/slack/SlackChannelErrorReporter.java @@ -0,0 +1,30 @@ +package com.baeldung.examples.slack; + +import com.hubspot.slack.client.SlackClient; +import com.hubspot.slack.client.methods.params.chat.ChatPostMessageParams; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SlackChannelErrorReporter implements ErrorReporter { + private static final Logger LOG = LoggerFactory.getLogger(SlackChannelErrorReporter.class); + + private final SlackClient slackClient; + + private final String channel; + + public SlackChannelErrorReporter(SlackClient slackClient, String channel) { + this.slackClient = slackClient; + this.channel = channel; + } + + @Override + public void reportProblem(String problem) { + LOG.debug("Sending message to channel {}: {}", channel, problem); + slackClient.postMessage( + ChatPostMessageParams.builder() + .setText(problem) + .setChannelId(channel) + .build() + ).join().unwrapOrElseThrow(); + } +} diff --git a/slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java b/slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java new file mode 100644 index 0000000000..8fa4f9016b --- /dev/null +++ b/slack/src/main/java/com/baeldung/examples/slack/SlackUserErrorReporter.java @@ -0,0 +1,52 @@ +package com.baeldung.examples.slack; + +import java.util.List; + +import com.hubspot.slack.client.SlackClient; +import com.hubspot.slack.client.methods.params.chat.ChatPostMessageParams; +import com.hubspot.slack.client.methods.params.conversations.ConversationCreateParams; +import com.hubspot.slack.client.methods.params.im.ImOpenParams; +import com.hubspot.slack.client.methods.params.users.UserEmailParams; +import com.hubspot.slack.client.methods.params.users.UsersInfoParams; +import com.hubspot.slack.client.models.response.im.ImOpenResponse; +import com.hubspot.slack.client.models.response.users.UsersInfoResponse; +import com.hubspot.slack.client.models.users.SlackUser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SlackUserErrorReporter implements ErrorReporter { + private static final Logger LOG = LoggerFactory.getLogger(SlackUserErrorReporter.class); + + private final SlackClient slackClient; + + private final String user; + + public SlackUserErrorReporter(SlackClient slackClient, String user) { + this.slackClient = slackClient; + this.user = user; + } + + @Override + public void reportProblem(String problem) { + LOG.debug("Sending message to user {}: {}", user, problem); + UsersInfoResponse usersInfoResponse = slackClient + .lookupUserByEmail(UserEmailParams.builder() + .setEmail(user) + .build() + ).join().unwrapOrElseThrow(); + + ImOpenResponse imOpenResponse = slackClient.openIm(ImOpenParams.builder() + .setUserId(usersInfoResponse.getUser().getId()) + .build() + ).join().unwrapOrElseThrow(); + + imOpenResponse.getChannel().ifPresent(channel -> { + slackClient.postMessage( + ChatPostMessageParams.builder() + .setText(problem) + .setChannelId(channel.getId()) + .build() + ).join().unwrapOrElseThrow(); + }); + } +} diff --git a/spring-mvc-simple/src/main/resources/logback.xml b/slack/src/main/resources/logback.xml similarity index 93% rename from spring-mvc-simple/src/main/resources/logback.xml rename to slack/src/main/resources/logback.xml index 7d900d8ea8..c8c077ba1d 100644 --- a/spring-mvc-simple/src/main/resources/logback.xml +++ b/slack/src/main/resources/logback.xml @@ -7,7 +7,7 @@ - + \ No newline at end of file diff --git a/spf4j/spf4j-aspects-app/pom.xml b/spf4j/spf4j-aspects-app/pom.xml index 2458e2d8ad..db6a18f26a 100644 --- a/spf4j/spf4j-aspects-app/pom.xml +++ b/spf4j/spf4j-aspects-app/pom.xml @@ -39,16 +39,16 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 1.8 - 1.8 + ${java.version} + ${java.version} org.apache.maven.plugins maven-dependency-plugin - 3.1.1 + ${dependency.plugin.version} copy-dependencies @@ -84,6 +84,8 @@ UTF-8 8.6.10 1.7.21 + 3.8.0 + 3.1.1 diff --git a/spf4j/spf4j-core-app/pom.xml b/spf4j/spf4j-core-app/pom.xml index 45300fd4a4..48cbf4a1c9 100644 --- a/spf4j/spf4j-core-app/pom.xml +++ b/spf4j/spf4j-core-app/pom.xml @@ -39,16 +39,16 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + ${compiler.plugin.version} - 1.8 - 1.8 + ${java.version} + ${java.version} org.apache.maven.plugins maven-dependency-plugin - 3.1.1 + ${dependency.plugin.version} copy-dependencies @@ -84,6 +84,8 @@ UTF-8 8.6.10 1.7.21 + 3.8.0 + 3.1.1 diff --git a/spring-4/src/main/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java b/spring-4/src/main/java/com/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java similarity index 86% rename from spring-4/src/main/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java rename to spring-4/src/main/java/com/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java index df1d173bd2..d11ca10873 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java +++ b/spring-4/src/main/java/com/baeldung/spring43/attributeannotations/AttributeAnnotationsTestController.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.attributeannotations; +package com.baeldung.spring43.attributeannotations; import org.springframework.web.bind.annotation.*; diff --git a/spring-4/src/main/java/org/baeldung/spring43/attributeannotations/ParamInterceptor.java b/spring-4/src/main/java/com/baeldung/spring43/attributeannotations/ParamInterceptor.java similarity index 91% rename from spring-4/src/main/java/org/baeldung/spring43/attributeannotations/ParamInterceptor.java rename to spring-4/src/main/java/com/baeldung/spring43/attributeannotations/ParamInterceptor.java index 9cf6020a93..3d6e0ad8b9 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/attributeannotations/ParamInterceptor.java +++ b/spring-4/src/main/java/com/baeldung/spring43/attributeannotations/ParamInterceptor.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.attributeannotations; +package com.baeldung.spring43.attributeannotations; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/spring-4/src/main/java/org/baeldung/spring43/cache/Foo.java b/spring-4/src/main/java/com/baeldung/spring43/cache/Foo.java similarity index 94% rename from spring-4/src/main/java/org/baeldung/spring43/cache/Foo.java rename to spring-4/src/main/java/com/baeldung/spring43/cache/Foo.java index ce34adf6c1..731ac68e70 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/cache/Foo.java +++ b/spring-4/src/main/java/com/baeldung/spring43/cache/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.cache; +package com.baeldung.spring43.cache; import java.util.concurrent.atomic.AtomicInteger; diff --git a/spring-4/src/main/java/org/baeldung/spring43/cache/FooService.java b/spring-4/src/main/java/com/baeldung/spring43/cache/FooService.java similarity index 87% rename from spring-4/src/main/java/org/baeldung/spring43/cache/FooService.java rename to spring-4/src/main/java/com/baeldung/spring43/cache/FooService.java index ad4c8b395f..9c0aa583c5 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/cache/FooService.java +++ b/spring-4/src/main/java/com/baeldung/spring43/cache/FooService.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.cache; +package com.baeldung.spring43.cache; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; diff --git a/spring-4/src/main/java/com/baeldung/spring43/composedmapping/Appointment.java b/spring-4/src/main/java/com/baeldung/spring43/composedmapping/Appointment.java new file mode 100644 index 0000000000..4d8ba86f4b --- /dev/null +++ b/spring-4/src/main/java/com/baeldung/spring43/composedmapping/Appointment.java @@ -0,0 +1,5 @@ +package com.baeldung.spring43.composedmapping; + +public class Appointment { + +} diff --git a/spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentService.java b/spring-4/src/main/java/com/baeldung/spring43/composedmapping/AppointmentService.java similarity index 72% rename from spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentService.java rename to spring-4/src/main/java/com/baeldung/spring43/composedmapping/AppointmentService.java index c4c5e82f65..1ca389e16b 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentService.java +++ b/spring-4/src/main/java/com/baeldung/spring43/composedmapping/AppointmentService.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.composedmapping; +package com.baeldung.spring43.composedmapping; import java.util.Map; diff --git a/spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentsController.java b/spring-4/src/main/java/com/baeldung/spring43/composedmapping/AppointmentsController.java similarity index 94% rename from spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentsController.java rename to spring-4/src/main/java/com/baeldung/spring43/composedmapping/AppointmentsController.java index e83a33eb89..3ff3a237ac 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/composedmapping/AppointmentsController.java +++ b/spring-4/src/main/java/com/baeldung/spring43/composedmapping/AppointmentsController.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.composedmapping; +package com.baeldung.spring43.composedmapping; import java.util.Map; diff --git a/spring-4/src/main/java/com/baeldung/spring43/ctor/FooRepository.java b/spring-4/src/main/java/com/baeldung/spring43/ctor/FooRepository.java new file mode 100644 index 0000000000..f1d8425682 --- /dev/null +++ b/spring-4/src/main/java/com/baeldung/spring43/ctor/FooRepository.java @@ -0,0 +1,5 @@ +package com.baeldung.spring43.ctor; + +public class FooRepository { + +} diff --git a/spring-4/src/main/java/org/baeldung/spring43/ctor/FooService.java b/spring-4/src/main/java/com/baeldung/spring43/ctor/FooService.java similarity index 87% rename from spring-4/src/main/java/org/baeldung/spring43/ctor/FooService.java rename to spring-4/src/main/java/com/baeldung/spring43/ctor/FooService.java index bf92d1bd32..cb481f99b2 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/ctor/FooService.java +++ b/spring-4/src/main/java/com/baeldung/spring43/ctor/FooService.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.ctor; +package com.baeldung.spring43.ctor; public class FooService { diff --git a/spring-4/src/main/java/org/baeldung/spring43/defaultmethods/DateHolder.java b/spring-4/src/main/java/com/baeldung/spring43/defaultmethods/DateHolder.java similarity index 87% rename from spring-4/src/main/java/org/baeldung/spring43/defaultmethods/DateHolder.java rename to spring-4/src/main/java/com/baeldung/spring43/defaultmethods/DateHolder.java index 9ae62cf484..a5307ec37c 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/defaultmethods/DateHolder.java +++ b/spring-4/src/main/java/com/baeldung/spring43/defaultmethods/DateHolder.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.defaultmethods; +package com.baeldung.spring43.defaultmethods; import java.time.LocalDate; diff --git a/spring-4/src/main/java/org/baeldung/spring43/defaultmethods/IDateHolder.java b/spring-4/src/main/java/com/baeldung/spring43/defaultmethods/IDateHolder.java similarity index 87% rename from spring-4/src/main/java/org/baeldung/spring43/defaultmethods/IDateHolder.java rename to spring-4/src/main/java/com/baeldung/spring43/defaultmethods/IDateHolder.java index e37d27f9fc..66eca031c0 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/defaultmethods/IDateHolder.java +++ b/spring-4/src/main/java/com/baeldung/spring43/defaultmethods/IDateHolder.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.defaultmethods; +package com.baeldung.spring43.defaultmethods; import java.time.LocalDate; import java.time.format.DateTimeFormatter; diff --git a/spring-4/src/main/java/org/baeldung/spring43/depresolution/FooRepository.java b/spring-4/src/main/java/com/baeldung/spring43/depresolution/FooRepository.java similarity index 68% rename from spring-4/src/main/java/org/baeldung/spring43/depresolution/FooRepository.java rename to spring-4/src/main/java/com/baeldung/spring43/depresolution/FooRepository.java index 313f6fc8c5..281a4f29fd 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/depresolution/FooRepository.java +++ b/spring-4/src/main/java/com/baeldung/spring43/depresolution/FooRepository.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.depresolution; +package com.baeldung.spring43.depresolution; import org.springframework.stereotype.Repository; diff --git a/spring-4/src/main/java/org/baeldung/spring43/depresolution/FooService.java b/spring-4/src/main/java/com/baeldung/spring43/depresolution/FooService.java similarity index 90% rename from spring-4/src/main/java/org/baeldung/spring43/depresolution/FooService.java rename to spring-4/src/main/java/com/baeldung/spring43/depresolution/FooService.java index b76fa84749..1a6b13dc23 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/depresolution/FooService.java +++ b/spring-4/src/main/java/com/baeldung/spring43/depresolution/FooService.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.depresolution; +package com.baeldung.spring43.depresolution; import org.springframework.beans.factory.ObjectProvider; import org.springframework.stereotype.Service; diff --git a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/AppPreferences.java b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/AppPreferences.java similarity index 81% rename from spring-4/src/main/java/org/baeldung/spring43/scopeannotations/AppPreferences.java rename to spring-4/src/main/java/com/baeldung/spring43/scopeannotations/AppPreferences.java index 45b90c4609..ede2849a51 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/AppPreferences.java +++ b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/AppPreferences.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.scopeannotations; +package com.baeldung.spring43.scopeannotations; import org.springframework.stereotype.Component; import org.springframework.web.context.annotation.ApplicationScope; diff --git a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/InstanceCountingService.java b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/InstanceCountingService.java similarity index 86% rename from spring-4/src/main/java/org/baeldung/spring43/scopeannotations/InstanceCountingService.java rename to spring-4/src/main/java/com/baeldung/spring43/scopeannotations/InstanceCountingService.java index 4fb90566d8..e6879e0544 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/InstanceCountingService.java +++ b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/InstanceCountingService.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.scopeannotations; +package com.baeldung.spring43.scopeannotations; import java.util.concurrent.atomic.AtomicInteger; diff --git a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/LoginAction.java b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/LoginAction.java similarity index 80% rename from spring-4/src/main/java/org/baeldung/spring43/scopeannotations/LoginAction.java rename to spring-4/src/main/java/com/baeldung/spring43/scopeannotations/LoginAction.java index 60017b4b94..132e701b5a 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/LoginAction.java +++ b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/LoginAction.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.scopeannotations; +package com.baeldung.spring43.scopeannotations; import org.springframework.stereotype.Component; import org.springframework.web.context.annotation.RequestScope; diff --git a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/ScopeTestController.java b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/ScopeTestController.java similarity index 95% rename from spring-4/src/main/java/org/baeldung/spring43/scopeannotations/ScopeTestController.java rename to spring-4/src/main/java/com/baeldung/spring43/scopeannotations/ScopeTestController.java index 8f4390dfc0..bd3e3e9b92 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/ScopeTestController.java +++ b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/ScopeTestController.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.scopeannotations; +package com.baeldung.spring43.scopeannotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; diff --git a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/UserPreferences.java b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/UserPreferences.java similarity index 81% rename from spring-4/src/main/java/org/baeldung/spring43/scopeannotations/UserPreferences.java rename to spring-4/src/main/java/com/baeldung/spring43/scopeannotations/UserPreferences.java index ce49c4b1fe..27f313b2cb 100644 --- a/spring-4/src/main/java/org/baeldung/spring43/scopeannotations/UserPreferences.java +++ b/spring-4/src/main/java/com/baeldung/spring43/scopeannotations/UserPreferences.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.scopeannotations; +package com.baeldung.spring43.scopeannotations; import org.springframework.stereotype.Component; import org.springframework.web.context.annotation.SessionScope; diff --git a/spring-4/src/main/java/org/baeldung/spring43/composedmapping/Appointment.java b/spring-4/src/main/java/org/baeldung/spring43/composedmapping/Appointment.java deleted file mode 100644 index af06249768..0000000000 --- a/spring-4/src/main/java/org/baeldung/spring43/composedmapping/Appointment.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.spring43.composedmapping; - -public class Appointment { - -} diff --git a/spring-4/src/main/java/org/baeldung/spring43/ctor/FooRepository.java b/spring-4/src/main/java/org/baeldung/spring43/ctor/FooRepository.java deleted file mode 100644 index 96dbeb8642..0000000000 --- a/spring-4/src/main/java/org/baeldung/spring43/ctor/FooRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.spring43.ctor; - -public class FooRepository { - -} diff --git a/spring-4/src/main/resources/defaultmethods-context.xml b/spring-4/src/main/resources/defaultmethods-context.xml index 2b55037405..5725d0cabf 100644 --- a/spring-4/src/main/resources/defaultmethods-context.xml +++ b/spring-4/src/main/resources/defaultmethods-context.xml @@ -3,7 +3,7 @@ xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + diff --git a/spring-4/src/main/resources/implicit-ctor-context.xml b/spring-4/src/main/resources/implicit-ctor-context.xml index c978ca17bd..3dc0058f94 100644 --- a/spring-4/src/main/resources/implicit-ctor-context.xml +++ b/spring-4/src/main/resources/implicit-ctor-context.xml @@ -3,8 +3,8 @@ xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + diff --git a/spring-4/src/test/java/org/baeldung/SpringContextTest.java b/spring-4/src/test/java/com/baeldung/SpringContextTest.java similarity index 96% rename from spring-4/src/test/java/org/baeldung/SpringContextTest.java rename to spring-4/src/test/java/com/baeldung/SpringContextTest.java index cccdaff0cd..46308d41ea 100644 --- a/spring-4/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-4/src/test/java/com/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java b/spring-4/src/test/java/com/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java similarity index 95% rename from spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java rename to spring-4/src/test/java/com/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java index 97ae651473..97b92a943c 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java +++ b/spring-4/src/test/java/com/baeldung/spring43/attributeannotations/AttributeAnnotationConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.attributeannotations; +package com.baeldung.spring43.attributeannotations; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; diff --git a/spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java b/spring-4/src/test/java/com/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java similarity index 96% rename from spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java rename to spring-4/src/test/java/com/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java index fff2716a64..f696a6f537 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.attributeannotations; +package com.baeldung.spring43.attributeannotations; import org.junit.Assert; import org.junit.Before; diff --git a/spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsConfiguration.java b/spring-4/src/test/java/com/baeldung/spring43/cache/CacheRefinementsConfiguration.java similarity index 95% rename from spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsConfiguration.java rename to spring-4/src/test/java/com/baeldung/spring43/cache/CacheRefinementsConfiguration.java index e4610e5a83..45acb11f72 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsConfiguration.java +++ b/spring-4/src/test/java/com/baeldung/spring43/cache/CacheRefinementsConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.cache; +package com.baeldung.spring43.cache; import java.util.Collections; diff --git a/spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java b/spring-4/src/test/java/com/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java similarity index 96% rename from spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java rename to spring-4/src/test/java/com/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java index fa72ed6d43..3f56bb21ff 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.cache; +package com.baeldung.spring43.cache; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; diff --git a/spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java b/spring-4/src/test/java/com/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java similarity index 96% rename from spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java rename to spring-4/src/test/java/com/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java index f1028ebefb..c3a0ceba36 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java +++ b/spring-4/src/test/java/com/baeldung/spring43/composedmapping/ComposedMappingConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.composedmapping; +package com.baeldung.spring43.composedmapping; import java.util.Collections; diff --git a/spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java b/spring-4/src/test/java/com/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java similarity index 96% rename from spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java rename to spring-4/src/test/java/com/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java index d0af48cd0e..d5c912b69b 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.composedmapping; +package com.baeldung.spring43.composedmapping; import org.junit.Before; import org.junit.Test; diff --git a/spring-4/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java b/spring-4/src/test/java/com/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java similarity index 94% rename from spring-4/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java rename to spring-4/src/test/java/com/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java index 871a985479..848fa44365 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.ctor; +package com.baeldung.spring43.ctor; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-4/src/test/java/org/baeldung/spring43/ctor/FooRepositoryConfiguration.java b/spring-4/src/test/java/com/baeldung/spring43/ctor/FooRepositoryConfiguration.java similarity index 88% rename from spring-4/src/test/java/org/baeldung/spring43/ctor/FooRepositoryConfiguration.java rename to spring-4/src/test/java/com/baeldung/spring43/ctor/FooRepositoryConfiguration.java index a05a36529f..fb33942844 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/ctor/FooRepositoryConfiguration.java +++ b/spring-4/src/test/java/com/baeldung/spring43/ctor/FooRepositoryConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.ctor; +package com.baeldung.spring43.ctor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-4/src/test/java/org/baeldung/spring43/ctor/FooServiceConfiguration.java b/spring-4/src/test/java/com/baeldung/spring43/ctor/FooServiceConfiguration.java similarity index 92% rename from spring-4/src/test/java/org/baeldung/spring43/ctor/FooServiceConfiguration.java rename to spring-4/src/test/java/com/baeldung/spring43/ctor/FooServiceConfiguration.java index 41f1719320..5ab09e37ec 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/ctor/FooServiceConfiguration.java +++ b/spring-4/src/test/java/com/baeldung/spring43/ctor/FooServiceConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.ctor; +package com.baeldung.spring43.ctor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-4/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java b/spring-4/src/test/java/com/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java similarity index 94% rename from spring-4/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java rename to spring-4/src/test/java/com/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java index 83fa11294e..5296927ef2 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.ctor; +package com.baeldung.spring43.ctor; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java b/spring-4/src/test/java/com/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java similarity index 93% rename from spring-4/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java rename to spring-4/src/test/java/com/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java index 956df44821..f617d48920 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.defaultmethods; +package com.baeldung.spring43.defaultmethods; import java.time.LocalDate; diff --git a/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java b/spring-4/src/test/java/com/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java similarity index 92% rename from spring-4/src/test/java/org/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java rename to spring-4/src/test/java/com/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java index 3c180e91c8..a8f44d722d 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/defaultmethods/ITransactionalUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.defaultmethods; +package com.baeldung.spring43.defaultmethods; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java b/spring-4/src/test/java/com/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java similarity index 91% rename from spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java rename to spring-4/src/test/java/com/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java index dde153487d..7df6040456 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.defaultmethods; +package com.baeldung.spring43.defaultmethods; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java b/spring-4/src/test/java/com/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java similarity index 95% rename from spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java rename to spring-4/src/test/java/com/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java index 8a8cec3f86..6323854099 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java +++ b/spring-4/src/test/java/com/baeldung/spring43/defaultmethods/TransactionalTestConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.defaultmethods; +package com.baeldung.spring43.defaultmethods; import javax.sql.DataSource; diff --git a/spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderConfiguration.java b/spring-4/src/test/java/com/baeldung/spring43/depresolution/ObjectProviderConfiguration.java similarity index 81% rename from spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderConfiguration.java rename to spring-4/src/test/java/com/baeldung/spring43/depresolution/ObjectProviderConfiguration.java index 530c4d9f4a..020b50ceb2 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderConfiguration.java +++ b/spring-4/src/test/java/com/baeldung/spring43/depresolution/ObjectProviderConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.depresolution; +package com.baeldung.spring43.depresolution; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java b/spring-4/src/test/java/com/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java similarity index 93% rename from spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java rename to spring-4/src/test/java/com/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java index 6d06bfdc2a..29ce530a50 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.depresolution; +package com.baeldung.spring43.depresolution; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java b/spring-4/src/test/java/com/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java similarity index 93% rename from spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java rename to spring-4/src/test/java/com/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java index 24c1ec2f34..a7d9c16721 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java +++ b/spring-4/src/test/java/com/baeldung/spring43/scopeannotations/ScopeAnnotationsConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.scopeannotations; +package com.baeldung.spring43.scopeannotations; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; diff --git a/spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java b/spring-4/src/test/java/com/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java similarity index 98% rename from spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java rename to spring-4/src/test/java/com/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java index 69cce15029..f2cea121cc 100644 --- a/spring-4/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java +++ b/spring-4/src/test/java/com/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring43.scopeannotations; +package com.baeldung.spring43.scopeannotations; import org.junit.Before; import org.junit.Test; diff --git a/spring-5-data-reactive/pom.xml b/spring-5-data-reactive/pom.xml index 230f25768e..aeaf6daf1a 100644 --- a/spring-5-data-reactive/pom.xml +++ b/spring-5-data-reactive/pom.xml @@ -17,6 +17,7 @@ io.projectreactor reactor-core + ${reactor-core.version} org.springframework.boot @@ -213,31 +214,16 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - - 1.2.40 1.2.40 - 5.2.0.M2 - 1.0.0.M2 - 0.8.0.M8 + 5.2.2.RELEASE + 1.0.0.RELEASE + 0.8.1.RELEASE 4.5.2 - 1.4.199 + 1.4.200 1.5.23 + 3.3.1.RELEASE diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java index 33b653140e..20f7642a7c 100644 --- a/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java +++ b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java @@ -1,8 +1,10 @@ package com.baeldung.r2dbc.repository; -import com.baeldung.r2dbc.model.Player; -import org.springframework.data.r2dbc.repository.query.Query; +import org.springframework.data.r2dbc.repository.Query; import org.springframework.data.repository.reactive.ReactiveCrudRepository; + +import com.baeldung.r2dbc.model.Player; + import reactor.core.publisher.Flux; public interface PlayerRepository extends ReactiveCrudRepository { diff --git a/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java b/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java index ffd2e98f8e..1af570587e 100644 --- a/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java +++ b/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java @@ -43,8 +43,7 @@ public class R2dbcApplicationIntegrationTest { "DROP TABLE IF EXISTS player;", "CREATE table player (id INT AUTO_INCREMENT NOT NULL, name VARCHAR2, age INT NOT NULL);"); - statements.forEach(it -> client.execute() // - .sql(it) // + statements.forEach(it -> client.execute(it) // .fetch() // .rowsUpdated() // .as(StepVerifier::create) // diff --git a/spring-5-reactive-security/pom.xml b/spring-5-reactive-security/pom.xml index 2024cb5138..58c993bda5 100644 --- a/spring-5-reactive-security/pom.xml +++ b/spring-5-reactive-security/pom.xml @@ -128,6 +128,7 @@ 1.0 4.1 3.1.6.RELEASE + 2.2.2.RELEASE diff --git a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverApplication.java b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverApplication.java new file mode 100644 index 0000000000..bad5768c20 --- /dev/null +++ b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.reactive.authresolver; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.reactive.config.EnableWebFlux; + +@EnableWebFlux +@SpringBootApplication +public class AuthResolverApplication { + + public static void main(String[] args) { + SpringApplication.run(AuthResolverApplication.class, args); + } + +} diff --git a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverController.java b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverController.java new file mode 100644 index 0000000000..1d70ded5e4 --- /dev/null +++ b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverController.java @@ -0,0 +1,25 @@ +package com.baeldung.reactive.authresolver; + +import java.security.Principal; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; + +@RestController +public class AuthResolverController { + + @GetMapping("/customer/welcome") + public Mono sayWelcomeToCustomer(Mono principal) { + return principal + .map(Principal::getName) + .map(name -> String.format("Welcome to our site, %s!", name)); + } + + @GetMapping("/employee/welcome") + public Mono sayWelcomeToEmployee(Mono principal) { + return principal + .map(Principal::getName) + .map(name -> String.format("Welcome to our company, %s!", name)); + } + +} diff --git a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java new file mode 100644 index 0000000000..d07a991089 --- /dev/null +++ b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java @@ -0,0 +1,96 @@ +package com.baeldung.reactive.authresolver; + +import java.util.Collections; +import org.springframework.context.annotation.Bean; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.security.authentication.ReactiveAuthenticationManager; +import org.springframework.security.authentication.ReactiveAuthenticationManagerResolver; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity; +import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; +import org.springframework.security.config.web.server.SecurityWebFiltersOrder; +import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.web.server.SecurityWebFilterChain; +import org.springframework.security.web.server.authentication.AuthenticationWebFilter; +import reactor.core.publisher.Mono; + +@EnableWebFluxSecurity +@EnableReactiveMethodSecurity +public class CustomWebSecurityConfig { + + @Bean + public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { + return http + .authorizeExchange() + .pathMatchers("/**") + .authenticated() + .and() + .httpBasic() + .disable() + .addFilterAfter(authenticationWebFilter(), SecurityWebFiltersOrder.REACTOR_CONTEXT) + .build(); + } + + public AuthenticationWebFilter authenticationWebFilter() { + return new AuthenticationWebFilter(resolver()); + } + + public ReactiveAuthenticationManagerResolver resolver() { + return request -> { + if (request + .getPath() + .subPath(0) + .value() + .startsWith("/employee")) { + return Mono.just(employeesAuthenticationManager()); + } + return Mono.just(customersAuthenticationManager()); + }; + } + + public ReactiveAuthenticationManager customersAuthenticationManager() { + return authentication -> customer(authentication) + .switchIfEmpty(Mono.error(new UsernameNotFoundException(authentication + .getPrincipal() + .toString()))) + .map(b -> new UsernamePasswordAuthenticationToken(authentication.getPrincipal(), + authentication.getCredentials(), + Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")) + ) + ); + } + + public ReactiveAuthenticationManager employeesAuthenticationManager() { + return authentication -> employee(authentication) + .switchIfEmpty(Mono.error(new UsernameNotFoundException(authentication + .getPrincipal() + .toString()))) + .map( + b -> new UsernamePasswordAuthenticationToken(authentication.getPrincipal(), + authentication.getCredentials(), + Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")) + ) + ); + } + + public Mono customer(Authentication authentication) { + return Mono.justOrEmpty(authentication + .getPrincipal() + .toString() + .startsWith("customer") ? authentication + .getPrincipal() + .toString() : null); + } + + public Mono employee(Authentication authentication) { + return Mono.justOrEmpty(authentication + .getPrincipal() + .toString() + .startsWith("employee") ? authentication + .getPrincipal() + .toString() : null); + } +} diff --git a/spring-5-reactive-security/src/test/java/com/baeldung/reactive/authresolver/AuthResolverIntegrationTest.java b/spring-5-reactive-security/src/test/java/com/baeldung/reactive/authresolver/AuthResolverIntegrationTest.java new file mode 100644 index 0000000000..691243b3ea --- /dev/null +++ b/spring-5-reactive-security/src/test/java/com/baeldung/reactive/authresolver/AuthResolverIntegrationTest.java @@ -0,0 +1,63 @@ +package com.baeldung.reactive.authresolver; + +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.util.Base64Utils; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = AuthResolverApplication.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class AuthResolverIntegrationTest { + @Autowired + private WebTestClient testClient; + + @Test + public void givenCustomerCredential_whenWelcomeCustomer_thenExpectOk() { + testClient + .get() + .uri("/customer/welcome") + .header("Authorization", "Basic " + Base64Utils.encodeToString("customer1:pass1".getBytes())) + .exchange() + .expectStatus() + .isOk(); + } + + @Test + public void givenEmployeeCredential_whenWelcomeCustomer_thenExpect401Status() { + testClient + .get() + .uri("/customer/welcome") + .header("Authorization", "Basic " + Base64Utils.encodeToString("employee1:pass1".getBytes())) + .exchange() + .expectStatus() + .isUnauthorized(); + } + + @Test + public void givenEmployeeCredential_whenWelcomeEmployee_thenExpectOk() { + testClient + .get() + .uri("/employee/welcome") + .header("Authorization", "Basic " + Base64Utils.encodeToString("employee1:pass1".getBytes())) + .exchange() + .expectStatus() + .isOk(); + } + + @Test + public void givenCustomerCredential_whenWelcomeEmployee_thenExpect401Status() { + testClient + .get() + .uri("/employee/welcome") + .header("Authorization", "Basic " + Base64Utils.encodeToString("customer1:pass1".getBytes())) + .exchange() + .expectStatus() + .isUnauthorized(); + } +} diff --git a/spring-5-reactive-security/src/test/java/com/baeldung/reactive/functional/EmployeeSpringFunctionalIntegrationTest.java b/spring-5-reactive-security/src/test/java/com/baeldung/reactive/functional/EmployeeSpringFunctionalIntegrationTest.java index 6e73e8072c..d8e2f0b23b 100644 --- a/spring-5-reactive-security/src/test/java/com/baeldung/reactive/functional/EmployeeSpringFunctionalIntegrationTest.java +++ b/spring-5-reactive-security/src/test/java/com/baeldung/reactive/functional/EmployeeSpringFunctionalIntegrationTest.java @@ -1,11 +1,7 @@ package com.baeldung.reactive.functional; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; - -import java.util.ArrayList; -import java.util.List; - +import com.baeldung.webflux.Employee; +import com.baeldung.webflux.EmployeeRepository; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; @@ -15,13 +11,15 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.reactive.server.WebTestClient; - -import com.baeldung.webflux.Employee; -import com.baeldung.webflux.EmployeeRepository; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import java.util.Arrays; +import java.util.List; + +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.verify; + @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = EmployeeSpringFunctionalApplication.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -58,15 +56,11 @@ public class EmployeeSpringFunctionalIntegrationTest { .bindToRouterFunction(config.getAllEmployeesRoute()) .build(); - List employeeList = new ArrayList<>(); + List employees = Arrays.asList( + new Employee("1", "Employee 1"), + new Employee("2", "Employee 2")); - Employee employee1 = new Employee("1", "Employee 1"); - Employee employee2 = new Employee("2", "Employee 2"); - - employeeList.add(employee1); - employeeList.add(employee2); - - Flux employeeFlux = Flux.fromIterable(employeeList); + Flux employeeFlux = Flux.fromIterable(employees); given(employeeRepository.findAllEmployees()).willReturn(employeeFlux); client.get() @@ -75,7 +69,7 @@ public class EmployeeSpringFunctionalIntegrationTest { .expectStatus() .isOk() .expectBodyList(Employee.class) - .isEqualTo(employeeList); + .isEqualTo(employees); } @Test diff --git a/spring-5-security/pom.xml b/spring-5-security/pom.xml index c486d5346b..3fd31c8bc5 100644 --- a/spring-5-security/pom.xml +++ b/spring-5-security/pom.xml @@ -60,5 +60,8 @@ + + 2.2.1.RELEASE + diff --git a/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverApplication.java b/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverApplication.java new file mode 100644 index 0000000000..96ee674b15 --- /dev/null +++ b/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverApplication.java @@ -0,0 +1,11 @@ +package com.baeldung.authresolver; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AuthResolverApplication { + public static void main(String[] args) { + SpringApplication.run(AuthResolverApplication.class, args); + } +} diff --git a/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverController.java b/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverController.java new file mode 100644 index 0000000000..7dc6900b5a --- /dev/null +++ b/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverController.java @@ -0,0 +1,18 @@ +package com.baeldung.authresolver; + +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class AuthResolverController { + @GetMapping("/customer/welcome") + public String sayWelcomeToCustomer(Authentication authentication) { + return String.format("Welcome to our site, %s!", authentication.getPrincipal()); + } + + @GetMapping("/employee/welcome") + public String sayWelcomeToEmployee(Authentication authentication) { + return String.format("Welcome to our company, %s!", authentication.getPrincipal()); + } +} diff --git a/spring-5-security/src/main/java/com/baeldung/authresolver/CustomWebSecurityConfigurer.java b/spring-5-security/src/main/java/com/baeldung/authresolver/CustomWebSecurityConfigurer.java new file mode 100644 index 0000000000..33ef692173 --- /dev/null +++ b/spring-5-security/src/main/java/com/baeldung/authresolver/CustomWebSecurityConfigurer.java @@ -0,0 +1,96 @@ +package com.baeldung.authresolver; + +import java.util.Collections; +import javax.servlet.http.HttpServletRequest; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.AuthenticationManagerResolver; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.web.authentication.AuthenticationConverter; +import org.springframework.security.web.authentication.AuthenticationFilter; +import org.springframework.security.web.authentication.www.BasicAuthenticationConverter; +import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; + +@Configuration +public class CustomWebSecurityConfigurer extends WebSecurityConfigurerAdapter { + + public AuthenticationConverter authenticationConverter() { + return new BasicAuthenticationConverter(); + } + + public AuthenticationManagerResolver resolver() { + return request -> { + if (request + .getPathInfo() + .startsWith("/employee")) { + return employeesAuthenticationManager(); + } + return customersAuthenticationManager(); + }; + } + + public AuthenticationManager customersAuthenticationManager() { + return authentication -> { + if (isCustomer(authentication)) { + return new UsernamePasswordAuthenticationToken( + authentication.getPrincipal(), + authentication.getCredentials(), + Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")) + ); + } + throw new UsernameNotFoundException(authentication + .getPrincipal() + .toString()); + }; + } + + private boolean isCustomer(Authentication authentication) { + return (authentication + .getPrincipal() + .toString() + .startsWith("customer")); + } + + private boolean isEmployee(Authentication authentication) { + return (authentication + .getPrincipal() + .toString() + .startsWith("employee")); + } + + private AuthenticationFilter authenticationFilter() { + AuthenticationFilter filter = new AuthenticationFilter( + resolver(), authenticationConverter()); + filter.setSuccessHandler((request, response, auth) -> {}); + return filter; + } + + private AuthenticationManager employeesAuthenticationManager() { + return authentication -> { + if (isEmployee(authentication)) { + return new UsernamePasswordAuthenticationToken( + authentication.getPrincipal(), + authentication.getCredentials(), + Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER")) + ); + } + throw new UsernameNotFoundException(authentication + .getPrincipal() + .toString()); + }; + } + + @Override + protected void configure(HttpSecurity http) { + http.addFilterBefore( + authenticationFilter(), + BasicAuthenticationFilter.class + ); + } + +} diff --git a/spring-5-security/src/test/java/com/baeldung/authresolver/AuthResolverIntegrationTest.java b/spring-5-security/src/test/java/com/baeldung/authresolver/AuthResolverIntegrationTest.java new file mode 100644 index 0000000000..c87f8c1a3a --- /dev/null +++ b/spring-5-security/src/test/java/com/baeldung/authresolver/AuthResolverIntegrationTest.java @@ -0,0 +1,82 @@ +package com.baeldung.authresolver; + +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.web.FilterChainProxy; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.util.Base64Utils; +import org.springframework.web.context.WebApplicationContext; + +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = AuthResolverApplication.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class AuthResolverIntegrationTest { + + @Autowired + private FilterChainProxy springSecurityFilterChain; + + @Autowired + private WebApplicationContext wac; + + private MockMvc mockMvc; + + @Before + public void setup() { + this.mockMvc = MockMvcBuilders + .webAppContextSetup(wac) + .apply(springSecurity(springSecurityFilterChain)) + .build(); + } + + @Test + public void givenCustomerCredential_whenWelcomeCustomer_thenExpectOk() throws Exception { + this.mockMvc + .perform(get("/customer/welcome") + .header( + "Authorization", String.format("Basic %s", Base64Utils.encodeToString("customer1:pass1".getBytes())) + ) + ) + .andExpect(status().is2xxSuccessful()); + } + + @Test + public void givenEmployeeCredential_whenWelcomeCustomer_thenExpect401Status() throws Exception { + this.mockMvc + .perform(get("/customer/welcome") + .header( + "Authorization", "Basic " + Base64Utils.encodeToString("employee1:pass1".getBytes())) + ) + .andExpect(status().isUnauthorized()); + } + + @Test + public void givenEmployeeCredential_whenWelcomeEmployee_thenExpectOk() throws Exception { + this.mockMvc + .perform(get("/employee/welcome") + .header( + "Authorization", "Basic " + Base64Utils.encodeToString("employee1:pass1".getBytes())) + ) + .andExpect(status().is2xxSuccessful()); + } + + @Test + public void givenCustomerCredential_whenWelcomeEmployee_thenExpect401Status() throws Exception { + this.mockMvc + .perform(get("/employee/welcome") + .header( + "Authorization", "Basic " + Base64Utils.encodeToString("customer1:pass1".getBytes())) + ) + .andExpect(status().isUnauthorized()); + } +} diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index 84ee3e332c..22f429da2a 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -64,38 +64,6 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - - 2.2.0.RELEASE diff --git a/spring-5/pom.xml b/spring-5/pom.xml index eadfb5e512..a242c29933 100644 --- a/spring-5/pom.xml +++ b/spring-5/pom.xml @@ -149,6 +149,7 @@ + 2.1.9.RELEASE 1.0 1.5.6 4.1 diff --git a/spring-akka/src/main/java/org/baeldung/akka/AppConfiguration.java b/spring-akka/src/main/java/com/baeldung/akka/AppConfiguration.java similarity index 76% rename from spring-akka/src/main/java/org/baeldung/akka/AppConfiguration.java rename to spring-akka/src/main/java/com/baeldung/akka/AppConfiguration.java index 9211ae0fdb..3568026d6d 100644 --- a/spring-akka/src/main/java/org/baeldung/akka/AppConfiguration.java +++ b/spring-akka/src/main/java/com/baeldung/akka/AppConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.akka; +package com.baeldung.akka; import akka.actor.ActorSystem; import org.springframework.beans.factory.annotation.Autowired; @@ -7,8 +7,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import static org.baeldung.akka.SpringExtension.SPRING_EXTENSION_PROVIDER; - @Configuration @ComponentScan public class AppConfiguration { @@ -19,7 +17,7 @@ public class AppConfiguration { @Bean public ActorSystem actorSystem() { ActorSystem system = ActorSystem.create("akka-spring-demo"); - SPRING_EXTENSION_PROVIDER.get(system).initialize(applicationContext); + SpringExtension.SPRING_EXTENSION_PROVIDER.get(system).initialize(applicationContext); return system; } diff --git a/spring-akka/src/main/java/org/baeldung/akka/GreetingActor.java b/spring-akka/src/main/java/com/baeldung/akka/GreetingActor.java similarity index 97% rename from spring-akka/src/main/java/org/baeldung/akka/GreetingActor.java rename to spring-akka/src/main/java/com/baeldung/akka/GreetingActor.java index 6366c277a4..35dcd254d6 100644 --- a/spring-akka/src/main/java/org/baeldung/akka/GreetingActor.java +++ b/spring-akka/src/main/java/com/baeldung/akka/GreetingActor.java @@ -1,4 +1,4 @@ -package org.baeldung.akka; +package com.baeldung.akka; import akka.actor.UntypedActor; import org.springframework.beans.factory.config.ConfigurableBeanFactory; diff --git a/spring-akka/src/main/java/org/baeldung/akka/GreetingService.java b/spring-akka/src/main/java/com/baeldung/akka/GreetingService.java similarity index 86% rename from spring-akka/src/main/java/org/baeldung/akka/GreetingService.java rename to spring-akka/src/main/java/com/baeldung/akka/GreetingService.java index 801921887d..aa6883648b 100644 --- a/spring-akka/src/main/java/org/baeldung/akka/GreetingService.java +++ b/spring-akka/src/main/java/com/baeldung/akka/GreetingService.java @@ -1,4 +1,4 @@ -package org.baeldung.akka; +package com.baeldung.akka; import org.springframework.stereotype.Component; diff --git a/spring-akka/src/main/java/org/baeldung/akka/SpringActorProducer.java b/spring-akka/src/main/java/com/baeldung/akka/SpringActorProducer.java similarity index 96% rename from spring-akka/src/main/java/org/baeldung/akka/SpringActorProducer.java rename to spring-akka/src/main/java/com/baeldung/akka/SpringActorProducer.java index 20813ab60a..289acb4447 100644 --- a/spring-akka/src/main/java/org/baeldung/akka/SpringActorProducer.java +++ b/spring-akka/src/main/java/com/baeldung/akka/SpringActorProducer.java @@ -1,4 +1,4 @@ -package org.baeldung.akka; +package com.baeldung.akka; import akka.actor.Actor; import akka.actor.IndirectActorProducer; diff --git a/spring-akka/src/main/java/org/baeldung/akka/SpringExtension.java b/spring-akka/src/main/java/com/baeldung/akka/SpringExtension.java similarity index 97% rename from spring-akka/src/main/java/org/baeldung/akka/SpringExtension.java rename to spring-akka/src/main/java/com/baeldung/akka/SpringExtension.java index aa5941c763..96f62da179 100644 --- a/spring-akka/src/main/java/org/baeldung/akka/SpringExtension.java +++ b/spring-akka/src/main/java/com/baeldung/akka/SpringExtension.java @@ -1,4 +1,4 @@ -package org.baeldung.akka; +package com.baeldung.akka; import akka.actor.AbstractExtensionId; import akka.actor.ExtendedActorSystem; diff --git a/spring-akka/src/test/java/org/baeldung/akka/SpringAkkaIntegrationTest.java b/spring-akka/src/test/java/com/baeldung/akka/SpringAkkaIntegrationTest.java similarity index 90% rename from spring-akka/src/test/java/org/baeldung/akka/SpringAkkaIntegrationTest.java rename to spring-akka/src/test/java/com/baeldung/akka/SpringAkkaIntegrationTest.java index c5da0f747e..3915a46507 100644 --- a/spring-akka/src/test/java/org/baeldung/akka/SpringAkkaIntegrationTest.java +++ b/spring-akka/src/test/java/com/baeldung/akka/SpringAkkaIntegrationTest.java @@ -1,11 +1,11 @@ -package org.baeldung.akka; +package com.baeldung.akka; import java.util.concurrent.TimeUnit; import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.util.Timeout; -import org.baeldung.akka.GreetingActor.Greet; +import com.baeldung.akka.GreetingActor.Greet; import org.junit.After; import org.junit.Assert; import org.junit.Test; @@ -17,7 +17,7 @@ import scala.concurrent.Future; import scala.concurrent.duration.FiniteDuration; import static akka.pattern.Patterns.ask; -import static org.baeldung.akka.SpringExtension.SPRING_EXTENSION_PROVIDER; +import static com.baeldung.akka.SpringExtension.SPRING_EXTENSION_PROVIDER; @ContextConfiguration(classes = AppConfiguration.class) public class SpringAkkaIntegrationTest extends AbstractJUnit4SpringContextTests { diff --git a/spring-amqp/README.md b/spring-amqp/README.md index 0ae4eda12e..6b09aec10a 100644 --- a/spring-amqp/README.md +++ b/spring-amqp/README.md @@ -5,4 +5,5 @@ This module contains articles about Spring with the AMQP messaging system ## Relevant articles: - [Messaging With Spring AMQP](https://www.baeldung.com/spring-amqp) -- [RabbitMQ Message Dispatching with Spring AMQP](https://www.baeldung.com/rabbitmq-spring-amqp) \ No newline at end of file +- [RabbitMQ Message Dispatching with Spring AMQP](https://www.baeldung.com/rabbitmq-spring-amqp) +- [Error Handling with Spring AMQP](https://www.baeldung.com/spring-amqp-error-handling) diff --git a/spring-aop/README.md b/spring-aop/README.md index 061e736d31..4522cd63c1 100644 --- a/spring-aop/README.md +++ b/spring-aop/README.md @@ -3,8 +3,9 @@ This module contains articles about Spring aspect oriented programming (AOP) ### Relevant articles - - [Implementing a Custom Spring AOP Annotation](https://www.baeldung.com/spring-aop-annotation) - [Intro to AspectJ](https://www.baeldung.com/aspectj) - [Spring Performance Logging](https://www.baeldung.com/spring-performance-logging) - [Introduction to Spring AOP](https://www.baeldung.com/spring-aop) +- [Introduction to Pointcut Expressions in Spring](https://www.baeldung.com/spring-aop-pointcut-tutorial) +- [Introduction to Advice Types in Spring](https://www.baeldung.com/spring-aop-advice-tutorial) \ No newline at end of file diff --git a/spring-aop/src/main/java/org/baeldung/Application.java b/spring-aop/src/main/java/com/baeldung/Application.java similarity index 92% rename from spring-aop/src/main/java/org/baeldung/Application.java rename to spring-aop/src/main/java/com/baeldung/Application.java index e5c764ef7e..c0490d50c6 100644 --- a/spring-aop/src/main/java/org/baeldung/Application.java +++ b/spring-aop/src/main/java/com/baeldung/Application.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -6,7 +6,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { - public static void main(String[] args) { SpringApplication.run(Application.class, args); } diff --git a/spring-aop/src/main/java/org/baeldung/ExampleAspect.java b/spring-aop/src/main/java/com/baeldung/ExampleAspect.java similarity index 88% rename from spring-aop/src/main/java/org/baeldung/ExampleAspect.java rename to spring-aop/src/main/java/com/baeldung/ExampleAspect.java index 7c3b5fb599..482f4b8c08 100644 --- a/spring-aop/src/main/java/org/baeldung/ExampleAspect.java +++ b/spring-aop/src/main/java/com/baeldung/ExampleAspect.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component; @Component public class ExampleAspect { - @Around("@annotation(LogExecutionTime)") + @Around("@annotation(com.baeldung.LogExecutionTime)") public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable { final long start = System.currentTimeMillis(); diff --git a/spring-aop/src/main/java/org/baeldung/LogExecutionTime.java b/spring-aop/src/main/java/com/baeldung/LogExecutionTime.java similarity index 92% rename from spring-aop/src/main/java/org/baeldung/LogExecutionTime.java rename to spring-aop/src/main/java/com/baeldung/LogExecutionTime.java index c10f97e78f..c58a3cb7ee 100644 --- a/spring-aop/src/main/java/org/baeldung/LogExecutionTime.java +++ b/spring-aop/src/main/java/com/baeldung/LogExecutionTime.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-aop/src/main/java/org/baeldung/Service.java b/spring-aop/src/main/java/com/baeldung/Service.java similarity index 90% rename from spring-aop/src/main/java/org/baeldung/Service.java rename to spring-aop/src/main/java/com/baeldung/Service.java index e4bee38438..01315c9723 100644 --- a/spring-aop/src/main/java/org/baeldung/Service.java +++ b/spring-aop/src/main/java/com/baeldung/Service.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.springframework.stereotype.Component; diff --git a/spring-aop/src/main/java/org/baeldung/aspectj/Account.java b/spring-aop/src/main/java/com/baeldung/aspectj/Account.java similarity index 88% rename from spring-aop/src/main/java/org/baeldung/aspectj/Account.java rename to spring-aop/src/main/java/com/baeldung/aspectj/Account.java index 2c551116f4..bc9ca375aa 100644 --- a/spring-aop/src/main/java/org/baeldung/aspectj/Account.java +++ b/spring-aop/src/main/java/com/baeldung/aspectj/Account.java @@ -1,4 +1,4 @@ -package org.baeldung.aspectj; +package com.baeldung.aspectj; public class Account { int balance = 20; diff --git a/spring-aop/src/main/java/org/baeldung/aspectj/AccountAspect.aj b/spring-aop/src/main/java/com/baeldung/aspectj/AccountAspect.aj similarity index 86% rename from spring-aop/src/main/java/org/baeldung/aspectj/AccountAspect.aj rename to spring-aop/src/main/java/com/baeldung/aspectj/AccountAspect.aj index f08d7dc281..0c79e5546a 100644 --- a/spring-aop/src/main/java/org/baeldung/aspectj/AccountAspect.aj +++ b/spring-aop/src/main/java/com/baeldung/aspectj/AccountAspect.aj @@ -1,4 +1,4 @@ -package org.baeldung.aspectj; +package com.baeldung.aspectj; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -8,7 +8,7 @@ public aspect AccountAspect { final int MIN_BALANCE = 10; pointcut callWithDraw(int amount, Account account): - call(boolean Account.withdraw(int)) && args(amount) && target(account); + call(boolean com.baeldung.aspectj.Account.withdraw(int)) && args(amount) && target(account); before(int amount, Account account) : callWithDraw(amount, account) { logger.info(" Balance before withdrawal: {}", account.balance); diff --git a/spring-aop/src/main/java/org/baeldung/aspectj/Secured.java b/spring-aop/src/main/java/com/baeldung/aspectj/Secured.java similarity index 90% rename from spring-aop/src/main/java/org/baeldung/aspectj/Secured.java rename to spring-aop/src/main/java/com/baeldung/aspectj/Secured.java index 08711d5db1..923f208c2f 100644 --- a/spring-aop/src/main/java/org/baeldung/aspectj/Secured.java +++ b/spring-aop/src/main/java/com/baeldung/aspectj/Secured.java @@ -1,4 +1,4 @@ -package org.baeldung.aspectj; +package com.baeldung.aspectj; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethod.java b/spring-aop/src/main/java/com/baeldung/aspectj/SecuredMethod.java similarity index 94% rename from spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethod.java rename to spring-aop/src/main/java/com/baeldung/aspectj/SecuredMethod.java index d1f7d43738..aa4b733a00 100644 --- a/spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethod.java +++ b/spring-aop/src/main/java/com/baeldung/aspectj/SecuredMethod.java @@ -1,4 +1,4 @@ -package org.baeldung.aspectj; +package com.baeldung.aspectj; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethodAspect.java b/spring-aop/src/main/java/com/baeldung/aspectj/SecuredMethodAspect.java similarity index 96% rename from spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethodAspect.java rename to spring-aop/src/main/java/com/baeldung/aspectj/SecuredMethodAspect.java index b474f266ab..9ea45ec43b 100644 --- a/spring-aop/src/main/java/org/baeldung/aspectj/SecuredMethodAspect.java +++ b/spring-aop/src/main/java/com/baeldung/aspectj/SecuredMethodAspect.java @@ -1,4 +1,4 @@ -package org.baeldung.aspectj; +package com.baeldung.aspectj; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderAfterAspect.java b/spring-aop/src/main/java/com/baeldung/logger/AdderAfterAspect.java similarity index 86% rename from spring-aop/src/main/java/org/baeldung/logger/AdderAfterAspect.java rename to spring-aop/src/main/java/com/baeldung/logger/AdderAfterAspect.java index 59afa38f06..658eb8a726 100644 --- a/spring-aop/src/main/java/org/baeldung/logger/AdderAfterAspect.java +++ b/spring-aop/src/main/java/com/baeldung/logger/AdderAfterAspect.java @@ -1,13 +1,13 @@ -package org.baeldung.logger; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AdderAfterAspect { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - public void afterAdvice() throws Throwable { - logger.info("I'm done calling the method"); - } -} +package com.baeldung.logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderAfterAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public void afterAdvice() throws Throwable { + logger.info("I'm done calling the method"); + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderAfterReturnAspect.java b/spring-aop/src/main/java/com/baeldung/logger/AdderAfterReturnAspect.java similarity index 88% rename from spring-aop/src/main/java/org/baeldung/logger/AdderAfterReturnAspect.java rename to spring-aop/src/main/java/com/baeldung/logger/AdderAfterReturnAspect.java index a2b1959374..faec9547aa 100644 --- a/spring-aop/src/main/java/org/baeldung/logger/AdderAfterReturnAspect.java +++ b/spring-aop/src/main/java/com/baeldung/logger/AdderAfterReturnAspect.java @@ -1,13 +1,13 @@ -package org.baeldung.logger; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AdderAfterReturnAspect { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - public void afterReturn(final Object returnValue) throws Throwable { - logger.info("value return was {}", returnValue); - } -} +package com.baeldung.logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderAfterReturnAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public void afterReturn(final Object returnValue) throws Throwable { + logger.info("value return was {}", returnValue); + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderAfterThrowAspect.java b/spring-aop/src/main/java/com/baeldung/logger/AdderAfterThrowAspect.java similarity index 88% rename from spring-aop/src/main/java/org/baeldung/logger/AdderAfterThrowAspect.java rename to spring-aop/src/main/java/com/baeldung/logger/AdderAfterThrowAspect.java index 1f19af05e4..8637730b8a 100644 --- a/spring-aop/src/main/java/org/baeldung/logger/AdderAfterThrowAspect.java +++ b/spring-aop/src/main/java/com/baeldung/logger/AdderAfterThrowAspect.java @@ -1,13 +1,13 @@ -package org.baeldung.logger; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AdderAfterThrowAspect { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - public void afterThrow(final Exception exception) throws Throwable { - logger.info("Exception thrown was {}", exception.getMessage()); - } -} +package com.baeldung.logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderAfterThrowAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public void afterThrow(final Exception exception) throws Throwable { + logger.info("Exception thrown was {}", exception.getMessage()); + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderAroundAspect.java b/spring-aop/src/main/java/com/baeldung/logger/AdderAroundAspect.java similarity index 92% rename from spring-aop/src/main/java/org/baeldung/logger/AdderAroundAspect.java rename to spring-aop/src/main/java/com/baeldung/logger/AdderAroundAspect.java index fceba87d15..1524576085 100644 --- a/spring-aop/src/main/java/org/baeldung/logger/AdderAroundAspect.java +++ b/spring-aop/src/main/java/com/baeldung/logger/AdderAroundAspect.java @@ -1,18 +1,18 @@ -package org.baeldung.logger; - -import java.util.Arrays; -import org.aspectj.lang.ProceedingJoinPoint; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AdderAroundAspect { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - public Object aroundAdvice(final ProceedingJoinPoint joinPoint) throws Throwable { - logger.info("Arguments passed to method are: " + Arrays.toString(joinPoint.getArgs())); - final Object result = joinPoint.proceed(); - logger.info("Result from method is: " + result); - return result; - } -} +package com.baeldung.logger; + +import java.util.Arrays; +import org.aspectj.lang.ProceedingJoinPoint; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderAroundAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public Object aroundAdvice(final ProceedingJoinPoint joinPoint) throws Throwable { + logger.info("Arguments passed to method are: " + Arrays.toString(joinPoint.getArgs())); + final Object result = joinPoint.proceed(); + logger.info("Result from method is: " + result); + return result; + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderBeforeAspect.java b/spring-aop/src/main/java/com/baeldung/logger/AdderBeforeAspect.java similarity index 87% rename from spring-aop/src/main/java/org/baeldung/logger/AdderBeforeAspect.java rename to spring-aop/src/main/java/com/baeldung/logger/AdderBeforeAspect.java index 750e7ba122..0d30622088 100644 --- a/spring-aop/src/main/java/org/baeldung/logger/AdderBeforeAspect.java +++ b/spring-aop/src/main/java/com/baeldung/logger/AdderBeforeAspect.java @@ -1,13 +1,13 @@ -package org.baeldung.logger; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AdderBeforeAspect { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - public void beforeAdvice() throws Throwable { - logger.info("I would be executed just before method starts"); - } -} +package com.baeldung.logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderBeforeAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public void beforeAdvice() throws Throwable { + logger.info("I would be executed just before method starts"); + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/SampleAdder.java b/spring-aop/src/main/java/com/baeldung/logger/SampleAdder.java similarity index 85% rename from spring-aop/src/main/java/org/baeldung/logger/SampleAdder.java rename to spring-aop/src/main/java/com/baeldung/logger/SampleAdder.java index 96fda1b0b9..0ef13ca7f0 100644 --- a/spring-aop/src/main/java/org/baeldung/logger/SampleAdder.java +++ b/spring-aop/src/main/java/com/baeldung/logger/SampleAdder.java @@ -1,12 +1,12 @@ -package org.baeldung.logger; - -public class SampleAdder { - - public int add(int a, int b) { - if (a < 0 || b < 0) { - throw new IllegalArgumentException("Make sure all the arguments are greater than zero."); - } - return a + b; - } - -} +package com.baeldung.logger; + +public class SampleAdder { + + public int add(int a, int b) { + if (a < 0 || b < 0) { + throw new IllegalArgumentException("Make sure all the arguments are greater than zero."); + } + return a + b; + } + +} diff --git a/spring-aop/src/main/java/org/baeldung/performancemonitor/AopConfiguration.java b/spring-aop/src/main/java/com/baeldung/performancemonitor/AopConfiguration.java similarity index 85% rename from spring-aop/src/main/java/org/baeldung/performancemonitor/AopConfiguration.java rename to spring-aop/src/main/java/com/baeldung/performancemonitor/AopConfiguration.java index 00026baf07..3df14e2f45 100644 --- a/spring-aop/src/main/java/org/baeldung/performancemonitor/AopConfiguration.java +++ b/spring-aop/src/main/java/com/baeldung/performancemonitor/AopConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.performancemonitor; +package com.baeldung.performancemonitor; import org.aspectj.lang.annotation.Pointcut; import org.springframework.aop.Advisor; @@ -16,10 +16,10 @@ import java.time.Month; @EnableAspectJAutoProxy public class AopConfiguration { - @Pointcut("execution(public String org.baeldung.performancemonitor.PersonService.getFullName(..))") + @Pointcut("execution(public String com.baeldung.performancemonitor.PersonService.getFullName(..))") public void monitor() { } - @Pointcut("execution(public int org.baeldung.performancemonitor.PersonService.getAge(..))") + @Pointcut("execution(public int com.baeldung.performancemonitor.PersonService.getAge(..))") public void myMonitor() { } @Bean @@ -30,7 +30,7 @@ public class AopConfiguration { @Bean public Advisor performanceMonitorAdvisor() { AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); - pointcut.setExpression("org.baeldung.performancemonitor.AopConfiguration.monitor()"); + pointcut.setExpression("com.baeldung.performancemonitor.AopConfiguration.monitor()"); return new DefaultPointcutAdvisor(pointcut, performanceMonitorInterceptor()); } @@ -52,7 +52,7 @@ public class AopConfiguration { @Bean public Advisor myPerformanceMonitorAdvisor() { AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); - pointcut.setExpression("org.baeldung.performancemonitor.AopConfiguration.myMonitor()"); + pointcut.setExpression("com.baeldung.performancemonitor.AopConfiguration.myMonitor()"); return new DefaultPointcutAdvisor(pointcut, myPerformanceMonitorInterceptor()); } diff --git a/spring-aop/src/main/java/org/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java b/spring-aop/src/main/java/com/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java similarity index 96% rename from spring-aop/src/main/java/org/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java rename to spring-aop/src/main/java/com/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java index d098d9466c..dfc6606c6a 100644 --- a/spring-aop/src/main/java/org/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java +++ b/spring-aop/src/main/java/com/baeldung/performancemonitor/MyPerformanceMonitorInterceptor.java @@ -1,4 +1,4 @@ -package org.baeldung.performancemonitor; +package com.baeldung.performancemonitor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; diff --git a/spring-aop/src/main/java/org/baeldung/performancemonitor/PerfomanceApp.java b/spring-aop/src/main/java/com/baeldung/performancemonitor/PerfomanceApp.java similarity index 93% rename from spring-aop/src/main/java/org/baeldung/performancemonitor/PerfomanceApp.java rename to spring-aop/src/main/java/com/baeldung/performancemonitor/PerfomanceApp.java index d0fb3a5393..00268c978e 100644 --- a/spring-aop/src/main/java/org/baeldung/performancemonitor/PerfomanceApp.java +++ b/spring-aop/src/main/java/com/baeldung/performancemonitor/PerfomanceApp.java @@ -1,4 +1,4 @@ -package org.baeldung.performancemonitor; +package com.baeldung.performancemonitor; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-aop/src/main/java/org/baeldung/performancemonitor/Person.java b/spring-aop/src/main/java/com/baeldung/performancemonitor/Person.java similarity index 95% rename from spring-aop/src/main/java/org/baeldung/performancemonitor/Person.java rename to spring-aop/src/main/java/com/baeldung/performancemonitor/Person.java index abd2465764..f16f28fdef 100644 --- a/spring-aop/src/main/java/org/baeldung/performancemonitor/Person.java +++ b/spring-aop/src/main/java/com/baeldung/performancemonitor/Person.java @@ -1,4 +1,4 @@ -package org.baeldung.performancemonitor; +package com.baeldung.performancemonitor; import java.time.LocalDate; diff --git a/spring-aop/src/main/java/org/baeldung/performancemonitor/PersonService.java b/spring-aop/src/main/java/com/baeldung/performancemonitor/PersonService.java similarity index 89% rename from spring-aop/src/main/java/org/baeldung/performancemonitor/PersonService.java rename to spring-aop/src/main/java/com/baeldung/performancemonitor/PersonService.java index 5b98aaf436..f5bfdddc12 100644 --- a/spring-aop/src/main/java/org/baeldung/performancemonitor/PersonService.java +++ b/spring-aop/src/main/java/com/baeldung/performancemonitor/PersonService.java @@ -1,4 +1,4 @@ -package org.baeldung.performancemonitor; +package com.baeldung.performancemonitor; import java.time.LocalDate; import java.time.Period; diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/Foo.java b/spring-aop/src/main/java/com/baeldung/pointcutadvice/Foo.java similarity index 76% rename from spring-mvc-java/src/main/java/com/baeldung/model/Foo.java rename to spring-aop/src/main/java/com/baeldung/pointcutadvice/Foo.java index 01f5f43f60..b20c9a3ccf 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/model/Foo.java +++ b/spring-aop/src/main/java/com/baeldung/pointcutadvice/Foo.java @@ -1,6 +1,6 @@ -package com.baeldung.model; +package com.baeldung.pointcutadvice; -import com.baeldung.aop.annotations.Entity; +import com.baeldung.pointcutadvice.annotations.Entity; @Entity public class Foo { diff --git a/spring-mvc-java/src/main/java/com/baeldung/aop/LoggingAspect.java b/spring-aop/src/main/java/com/baeldung/pointcutadvice/LoggingAspect.java similarity index 87% rename from spring-mvc-java/src/main/java/com/baeldung/aop/LoggingAspect.java rename to spring-aop/src/main/java/com/baeldung/pointcutadvice/LoggingAspect.java index 169d664471..481e1d323a 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/aop/LoggingAspect.java +++ b/spring-aop/src/main/java/com/baeldung/pointcutadvice/LoggingAspect.java @@ -1,4 +1,4 @@ -package com.baeldung.aop; +package com.baeldung.pointcutadvice; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; @@ -23,15 +23,15 @@ public class LoggingAspect { } }; - @Pointcut("within(com.baeldung..*) && execution(* com.baeldung.dao.FooDao.*(..))") + @Pointcut("within(com.baeldung..*) && execution(* com.baeldung.pointcutadvice.dao.FooDao.*(..))") public void repositoryMethods() { } - @Pointcut("within(com.baeldung..*) && @annotation(com.baeldung.aop.annotations.Loggable)") + @Pointcut("within(com.baeldung..*) && @annotation(com.baeldung.pointcutadvice.annotations.Loggable)") public void loggableMethods() { } - @Pointcut("within(com.baeldung..*) && @args(com.baeldung.aop.annotations.Entity)") + @Pointcut("within(com.baeldung..*) && @args(com.baeldung.pointcutadvice.annotations.Entity)") public void methodsAcceptingEntities() { } diff --git a/spring-mvc-java/src/main/java/com/baeldung/aop/PerformanceAspect.java b/spring-aop/src/main/java/com/baeldung/pointcutadvice/PerformanceAspect.java similarity index 93% rename from spring-mvc-java/src/main/java/com/baeldung/aop/PerformanceAspect.java rename to spring-aop/src/main/java/com/baeldung/pointcutadvice/PerformanceAspect.java index 8f374cc1e5..4f445e301e 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/aop/PerformanceAspect.java +++ b/spring-aop/src/main/java/com/baeldung/pointcutadvice/PerformanceAspect.java @@ -1,4 +1,4 @@ -package com.baeldung.aop; +package com.baeldung.pointcutadvice; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -15,7 +15,7 @@ public class PerformanceAspect { private static Logger logger = Logger.getLogger(PerformanceAspect.class.getName()); - @Pointcut("within(com.baeldung..*) && execution(* com.baeldung.dao.FooDao.*(..))") + @Pointcut("within(com.baeldung..*) && execution(* com.baeldung.pointcutadvice.dao.FooDao.*(..))") public void repositoryClassMethods() { } diff --git a/spring-mvc-java/src/main/java/com/baeldung/aop/PublishingAspect.java b/spring-aop/src/main/java/com/baeldung/pointcutadvice/PublishingAspect.java similarity index 86% rename from spring-mvc-java/src/main/java/com/baeldung/aop/PublishingAspect.java rename to spring-aop/src/main/java/com/baeldung/pointcutadvice/PublishingAspect.java index a45402dc18..bb96e08772 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/aop/PublishingAspect.java +++ b/spring-aop/src/main/java/com/baeldung/pointcutadvice/PublishingAspect.java @@ -1,6 +1,6 @@ -package com.baeldung.aop; +package com.baeldung.pointcutadvice; -import com.baeldung.events.FooCreationEvent; +import com.baeldung.pointcutadvice.events.FooCreationEvent; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Aspect; @@ -20,11 +20,11 @@ public class PublishingAspect { this.eventPublisher = eventPublisher; } - @Pointcut("within(com.baeldung..*) && execution(* com.baeldung.dao.FooDao.*(..))") + @Pointcut("within(com.baeldung..*) && execution(* com.baeldung.pointcutadvice.dao.FooDao.*(..))") public void repositoryMethods() { } - @Pointcut("within(com.baeldung..*) && execution(* com.baeldung.dao.FooDao.create*(Long,..))") + @Pointcut("within(com.baeldung..*) && execution(* com.baeldung.pointcutadvice.dao.FooDao.create*(Long,..))") public void firstLongParamMethods() { } diff --git a/spring-mvc-java/src/main/java/com/baeldung/aop/annotations/Entity.java b/spring-aop/src/main/java/com/baeldung/pointcutadvice/annotations/Entity.java similarity index 83% rename from spring-mvc-java/src/main/java/com/baeldung/aop/annotations/Entity.java rename to spring-aop/src/main/java/com/baeldung/pointcutadvice/annotations/Entity.java index 61d91b0777..e6753cdd61 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/aop/annotations/Entity.java +++ b/spring-aop/src/main/java/com/baeldung/pointcutadvice/annotations/Entity.java @@ -1,4 +1,4 @@ -package com.baeldung.aop.annotations; +package com.baeldung.pointcutadvice.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-mvc-java/src/main/java/com/baeldung/aop/annotations/Loggable.java b/spring-aop/src/main/java/com/baeldung/pointcutadvice/annotations/Loggable.java similarity index 84% rename from spring-mvc-java/src/main/java/com/baeldung/aop/annotations/Loggable.java rename to spring-aop/src/main/java/com/baeldung/pointcutadvice/annotations/Loggable.java index 92aa950e58..921003be63 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/aop/annotations/Loggable.java +++ b/spring-aop/src/main/java/com/baeldung/pointcutadvice/annotations/Loggable.java @@ -1,4 +1,4 @@ -package com.baeldung.aop.annotations; +package com.baeldung.pointcutadvice.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-mvc-java/src/main/java/com/baeldung/dao/FooDao.java b/spring-aop/src/main/java/com/baeldung/pointcutadvice/dao/FooDao.java similarity index 69% rename from spring-mvc-java/src/main/java/com/baeldung/dao/FooDao.java rename to spring-aop/src/main/java/com/baeldung/pointcutadvice/dao/FooDao.java index 1d28b082ec..72a9762991 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/dao/FooDao.java +++ b/spring-aop/src/main/java/com/baeldung/pointcutadvice/dao/FooDao.java @@ -1,7 +1,7 @@ -package com.baeldung.dao; +package com.baeldung.pointcutadvice.dao; -import com.baeldung.aop.annotations.Loggable; -import com.baeldung.model.Foo; +import com.baeldung.pointcutadvice.Foo; +import com.baeldung.pointcutadvice.annotations.Loggable; import org.springframework.stereotype.Repository; @Repository diff --git a/spring-mvc-java/src/main/java/com/baeldung/events/FooCreationEvent.java b/spring-aop/src/main/java/com/baeldung/pointcutadvice/events/FooCreationEvent.java similarity index 81% rename from spring-mvc-java/src/main/java/com/baeldung/events/FooCreationEvent.java rename to spring-aop/src/main/java/com/baeldung/pointcutadvice/events/FooCreationEvent.java index 5ea4b46c04..8cee80fa0c 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/events/FooCreationEvent.java +++ b/spring-aop/src/main/java/com/baeldung/pointcutadvice/events/FooCreationEvent.java @@ -1,4 +1,4 @@ -package com.baeldung.events; +package com.baeldung.pointcutadvice.events; import org.springframework.context.ApplicationEvent; diff --git a/spring-mvc-java/src/main/java/com/baeldung/events/FooCreationEventListener.java b/spring-aop/src/main/java/com/baeldung/pointcutadvice/events/FooCreationEventListener.java similarity index 91% rename from spring-mvc-java/src/main/java/com/baeldung/events/FooCreationEventListener.java rename to spring-aop/src/main/java/com/baeldung/pointcutadvice/events/FooCreationEventListener.java index c0aa744bc1..4a55b2138d 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/events/FooCreationEventListener.java +++ b/spring-aop/src/main/java/com/baeldung/pointcutadvice/events/FooCreationEventListener.java @@ -1,4 +1,4 @@ -package com.baeldung.events; +package com.baeldung.pointcutadvice.events; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; diff --git a/spring-aop/src/main/resources/META-INF/aop.xml b/spring-aop/src/main/resources/META-INF/aop.xml index e5bddcc30c..f930cde942 100644 --- a/spring-aop/src/main/resources/META-INF/aop.xml +++ b/spring-aop/src/main/resources/META-INF/aop.xml @@ -1,6 +1,6 @@ - + diff --git a/spring-aop/src/main/resources/org.baeldung.logger/springAop-applicationContext.xml b/spring-aop/src/main/resources/com.baeldung.logger/springAop-applicationContext.xml similarity index 75% rename from spring-aop/src/main/resources/org.baeldung.logger/springAop-applicationContext.xml rename to spring-aop/src/main/resources/com.baeldung.logger/springAop-applicationContext.xml index 058beaa7a1..595e7e46e6 100644 --- a/spring-aop/src/main/resources/org.baeldung.logger/springAop-applicationContext.xml +++ b/spring-aop/src/main/resources/com.baeldung.logger/springAop-applicationContext.xml @@ -1,54 +1,54 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-aop/src/main/resources/logback.xml b/spring-aop/src/main/resources/logback.xml index 7c15f603a0..4eaa556705 100644 --- a/spring-aop/src/main/resources/logback.xml +++ b/spring-aop/src/main/resources/logback.xml @@ -13,7 +13,7 @@ - + diff --git a/spring-mvc-java/src/main/resources/com/baeldung/aop/beans.xml b/spring-aop/src/main/resources/pointcutadvice/beans.xml similarity index 83% rename from spring-mvc-java/src/main/resources/com/baeldung/aop/beans.xml rename to spring-aop/src/main/resources/pointcutadvice/beans.xml index e6aa9d77c4..ad96827a13 100644 --- a/spring-mvc-java/src/main/resources/com/baeldung/aop/beans.xml +++ b/spring-aop/src/main/resources/pointcutadvice/beans.xml @@ -7,8 +7,8 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd"> - - + + diff --git a/spring-aop/src/test/java/org/baeldung/CustomAnnotationIntegrationTest.java b/spring-aop/src/test/java/com/baeldung/CustomAnnotationIntegrationTest.java similarity index 95% rename from spring-aop/src/test/java/org/baeldung/CustomAnnotationIntegrationTest.java rename to spring-aop/src/test/java/com/baeldung/CustomAnnotationIntegrationTest.java index b109e3a39e..155f8e1c96 100644 --- a/spring-aop/src/test/java/org/baeldung/CustomAnnotationIntegrationTest.java +++ b/spring-aop/src/test/java/com/baeldung/CustomAnnotationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-aop/src/test/java/org/baeldung/SpringContextTest.java b/spring-aop/src/test/java/com/baeldung/SpringContextTest.java similarity index 94% rename from spring-aop/src/test/java/org/baeldung/SpringContextTest.java rename to spring-aop/src/test/java/com/baeldung/SpringContextTest.java index 4d3ed953c4..13c1c162f1 100644 --- a/spring-aop/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-aop/src/test/java/com/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-aop/src/test/java/org/baeldung/aspectj/AccountUnitTest.java b/spring-aop/src/test/java/com/baeldung/aspectj/AccountUnitTest.java similarity index 94% rename from spring-aop/src/test/java/org/baeldung/aspectj/AccountUnitTest.java rename to spring-aop/src/test/java/com/baeldung/aspectj/AccountUnitTest.java index 3d5384a7f7..3af1f963da 100644 --- a/spring-aop/src/test/java/org/baeldung/aspectj/AccountUnitTest.java +++ b/spring-aop/src/test/java/com/baeldung/aspectj/AccountUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.aspectj; +package com.baeldung.aspectj; import org.junit.Before; import org.junit.Test; diff --git a/spring-aop/src/test/java/org/baeldung/aspectj/SecuredMethodUnitTest.java b/spring-aop/src/test/java/com/baeldung/aspectj/SecuredMethodUnitTest.java similarity index 89% rename from spring-aop/src/test/java/org/baeldung/aspectj/SecuredMethodUnitTest.java rename to spring-aop/src/test/java/com/baeldung/aspectj/SecuredMethodUnitTest.java index cbdb2db057..e1a2553610 100644 --- a/spring-aop/src/test/java/org/baeldung/aspectj/SecuredMethodUnitTest.java +++ b/spring-aop/src/test/java/com/baeldung/aspectj/SecuredMethodUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.aspectj; +package com.baeldung.aspectj; import org.junit.Test; diff --git a/spring-aop/src/test/java/org/baeldung/logger/CalculatorIntegrationTest.java b/spring-aop/src/test/java/com/baeldung/logger/CalculatorIntegrationTest.java similarity index 93% rename from spring-aop/src/test/java/org/baeldung/logger/CalculatorIntegrationTest.java rename to spring-aop/src/test/java/com/baeldung/logger/CalculatorIntegrationTest.java index 8c31b7f892..66e06f7928 100644 --- a/spring-aop/src/test/java/org/baeldung/logger/CalculatorIntegrationTest.java +++ b/spring-aop/src/test/java/com/baeldung/logger/CalculatorIntegrationTest.java @@ -1,29 +1,29 @@ -package org.baeldung.logger; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(value = {"classpath:springAop-applicationContext.xml"}) -public class CalculatorIntegrationTest { - - @Autowired - private SampleAdder sampleAdder; - - @Test - public void whenAddValidValues_returnsSucessfully() { - final int addedValue = sampleAdder.add(12, 12); - - assertEquals(24, addedValue); - } - - @Test (expected = IllegalArgumentException.class) - public void whenAddInValidValues_throwsException() { - sampleAdder.add(12, -12); - } - -} +package com.baeldung.logger; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(value = {"classpath:springAop-applicationContext.xml"}) +public class CalculatorIntegrationTest { + + @Autowired + private SampleAdder sampleAdder; + + @Test + public void whenAddValidValues_returnsSucessfully() { + final int addedValue = sampleAdder.add(12, 12); + + assertEquals(24, addedValue); + } + + @Test (expected = IllegalArgumentException.class) + public void whenAddInValidValues_throwsException() { + sampleAdder.add(12, -12); + } + +} diff --git a/spring-mvc-java/src/test/java/com/baeldung/aop/AopLoggingIntegrationTest.java b/spring-aop/src/test/java/com/baeldung/pointcutadvice/AopLoggingIntegrationTest.java similarity index 91% rename from spring-mvc-java/src/test/java/com/baeldung/aop/AopLoggingIntegrationTest.java rename to spring-aop/src/test/java/com/baeldung/pointcutadvice/AopLoggingIntegrationTest.java index 698bae4c0f..a687eec388 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/aop/AopLoggingIntegrationTest.java +++ b/spring-aop/src/test/java/com/baeldung/pointcutadvice/AopLoggingIntegrationTest.java @@ -1,8 +1,7 @@ -package com.baeldung.aop; +package com.baeldung.pointcutadvice; -import com.baeldung.config.TestConfig; -import com.baeldung.dao.FooDao; -import com.baeldung.model.Foo; +import com.baeldung.Application; +import com.baeldung.pointcutadvice.dao.FooDao; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -24,7 +23,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {TestConfig.class}, loader = AnnotationConfigContextLoader.class) +@ContextConfiguration(classes = {Application.class}, loader = AnnotationConfigContextLoader.class) public class AopLoggingIntegrationTest { @Before diff --git a/spring-mvc-java/src/test/java/com/baeldung/aop/AopPerformanceIntegrationTest.java b/spring-aop/src/test/java/com/baeldung/pointcutadvice/AopPerformanceIntegrationTest.java similarity index 89% rename from spring-mvc-java/src/test/java/com/baeldung/aop/AopPerformanceIntegrationTest.java rename to spring-aop/src/test/java/com/baeldung/pointcutadvice/AopPerformanceIntegrationTest.java index c9ab2fb4bb..5a7797e5cd 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/aop/AopPerformanceIntegrationTest.java +++ b/spring-aop/src/test/java/com/baeldung/pointcutadvice/AopPerformanceIntegrationTest.java @@ -1,7 +1,7 @@ -package com.baeldung.aop; +package com.baeldung.pointcutadvice; -import com.baeldung.config.TestConfig; -import com.baeldung.dao.FooDao; +import com.baeldung.Application; +import com.baeldung.pointcutadvice.dao.FooDao; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -23,7 +23,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { TestConfig.class }, loader = AnnotationConfigContextLoader.class) +@ContextConfiguration(classes = {Application.class}, loader = AnnotationConfigContextLoader.class) public class AopPerformanceIntegrationTest { @Before diff --git a/spring-mvc-java/src/test/java/com/baeldung/aop/AopPublishingIntegrationTest.java b/spring-aop/src/test/java/com/baeldung/pointcutadvice/AopPublishingIntegrationTest.java similarity index 85% rename from spring-mvc-java/src/test/java/com/baeldung/aop/AopPublishingIntegrationTest.java rename to spring-aop/src/test/java/com/baeldung/pointcutadvice/AopPublishingIntegrationTest.java index 2503900e69..996b56d61e 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/aop/AopPublishingIntegrationTest.java +++ b/spring-aop/src/test/java/com/baeldung/pointcutadvice/AopPublishingIntegrationTest.java @@ -1,9 +1,8 @@ -package com.baeldung.aop; +package com.baeldung.pointcutadvice; -import com.baeldung.config.TestConfig; -import com.baeldung.dao.FooDao; -import com.baeldung.events.FooCreationEventListener; -import com.baeldung.model.Foo; +import com.baeldung.Application; +import com.baeldung.pointcutadvice.dao.FooDao; +import com.baeldung.pointcutadvice.events.FooCreationEventListener; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -22,7 +21,7 @@ import java.util.regex.Pattern; import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {TestConfig.class}, loader = AnnotationConfigContextLoader.class) +@ContextConfiguration(classes = {Application.class}, loader = AnnotationConfigContextLoader.class) public class AopPublishingIntegrationTest { @Before diff --git a/spring-mvc-java/src/test/java/com/baeldung/aop/AopXmlConfigPerformanceIntegrationTest.java b/spring-aop/src/test/java/com/baeldung/pointcutadvice/AopXmlConfigPerformanceIntegrationTest.java similarity index 93% rename from spring-mvc-java/src/test/java/com/baeldung/aop/AopXmlConfigPerformanceIntegrationTest.java rename to spring-aop/src/test/java/com/baeldung/pointcutadvice/AopXmlConfigPerformanceIntegrationTest.java index 3b380315e8..5727cfd7bc 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/aop/AopXmlConfigPerformanceIntegrationTest.java +++ b/spring-aop/src/test/java/com/baeldung/pointcutadvice/AopXmlConfigPerformanceIntegrationTest.java @@ -1,6 +1,6 @@ -package com.baeldung.aop; +package com.baeldung.pointcutadvice; -import com.baeldung.dao.FooDao; +import com.baeldung.pointcutadvice.dao.FooDao; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,7 +21,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("/com/baeldung/aop/beans.xml") +@ContextConfiguration("/pointcutadvice/beans.xml") public class AopXmlConfigPerformanceIntegrationTest { @Before diff --git a/spring-aop/src/test/resources/springAop-applicationContext.xml b/spring-aop/src/test/resources/springAop-applicationContext.xml index 4d88bd3711..fb71052567 100644 --- a/spring-aop/src/test/resources/springAop-applicationContext.xml +++ b/spring-aop/src/test/resources/springAop-applicationContext.xml @@ -6,45 +6,45 @@ xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd"> + class="com.baeldung.logger.SampleAdder" /> - - - - - + + + + + + expression="execution(* com.baeldung.logger.SampleAdder+.*(..))" /> + expression="execution(* com.baeldung.logger.SampleAdder+.*(..))" /> + expression="execution(* com.baeldung.logger.SampleAdder+.*(..))" /> + expression="execution(* com.baeldung.logger.SampleAdder+.*(..))" /> + expression="execution(* com.baeldung.logger.SampleAdder+.*(..))" /> diff --git a/spring-boot-bootstrap/src/main/resources/application-mysql.properties b/spring-boot-bootstrap/src/main/resources/application-mysql.properties deleted file mode 100644 index a1823b5d7f..0000000000 --- a/spring-boot-bootstrap/src/main/resources/application-mysql.properties +++ /dev/null @@ -1 +0,0 @@ -spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect \ No newline at end of file diff --git a/spring-boot-gradle/gradle/wrapper/gradle-wrapper.jar b/spring-boot-gradle/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 1ce6e58f1c..0000000000 Binary files a/spring-boot-gradle/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/spring-boot-gradle/gradlew.bat b/spring-boot-gradle/gradlew.bat deleted file mode 100644 index e95643d6a2..0000000000 --- a/spring-boot-gradle/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/spring-boot-libraries/.mvn/wrapper/maven-wrapper.jar b/spring-boot-libraries/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 5fd4d5023f..0000000000 Binary files a/spring-boot-libraries/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/spring-boot-modules/README.md b/spring-boot-modules/README.md new file mode 100644 index 0000000000..cd916f48a7 --- /dev/null +++ b/spring-boot-modules/README.md @@ -0,0 +1,3 @@ +## Spring Boot Modules + +This module contains various modules of Spring Boot diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml new file mode 100644 index 0000000000..e28b077d5c --- /dev/null +++ b/spring-boot-modules/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + com.baeldung.spring-boot-modules + spring-boot-modules + spring-boot-modules + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + spring-boot + spring-boot-admin + spring-boot-angular + spring-boot-artifacts + spring-boot-autoconfiguration + spring-boot-bootstrap + spring-boot-client + spring-boot-config-jpa-error + spring-boot-ctx-fluent + spring-boot-deployment + spring-boot-camel + + spring-boot-custom-starter + spring-boot-crud + spring-boot-data + spring-boot-environment + spring-boot-flowable + + spring-boot-jasypt + spring-boot-keycloak + spring-boot-libraries + spring-boot-logging-log4j2 + spring-boot-kotlin + spring-boot-mvc + spring-boot-mvc-2 + spring-boot-mvc-birt + spring-boot-nashorn + spring-boot-properties + spring-boot-property-exp + spring-boot-runtime + spring-boot-springdoc + spring-boot-testing + spring-boot-vue + + + diff --git a/spring-boot-admin/README.md b/spring-boot-modules/spring-boot-admin/README.md similarity index 100% rename from spring-boot-admin/README.md rename to spring-boot-modules/spring-boot-admin/README.md diff --git a/spring-boot-admin/pom.xml b/spring-boot-modules/spring-boot-admin/pom.xml similarity index 92% rename from spring-boot-admin/pom.xml rename to spring-boot-modules/spring-boot-admin/pom.xml index ab2b92102c..f7dc98770a 100644 --- a/spring-boot-admin/pom.xml +++ b/spring-boot-modules/spring-boot-admin/pom.xml @@ -11,6 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT + ../../parent-boot-2 diff --git a/spring-boot-admin/spring-boot-admin-client/.gitignore b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/.gitignore similarity index 100% rename from spring-boot-admin/spring-boot-admin-client/.gitignore rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-client/.gitignore diff --git a/spring-boot-admin/spring-boot-admin-client/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml similarity index 95% rename from spring-boot-admin/spring-boot-admin-client/pom.xml rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml index 47abfdddc2..8bb8c7bac3 100644 --- a/spring-boot-admin/spring-boot-admin-client/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml @@ -12,7 +12,6 @@ com.baeldung spring-boot-admin 0.0.1-SNAPSHOT - ../../spring-boot-admin @@ -59,7 +58,7 @@ - 2.1.6 + 2.2.2 2.0.4.RELEASE diff --git a/spring-boot-admin/spring-boot-admin-client/src/main/java/com/baeldung/springbootadminclient/SpringBootAdminClientApplication.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/main/java/com/baeldung/springbootadminclient/SpringBootAdminClientApplication.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-client/src/main/java/com/baeldung/springbootadminclient/SpringBootAdminClientApplication.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/main/java/com/baeldung/springbootadminclient/SpringBootAdminClientApplication.java diff --git a/spring-boot-admin/spring-boot-admin-client/src/main/resources/application.properties b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/main/resources/application.properties similarity index 100% rename from spring-boot-admin/spring-boot-admin-client/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/main/resources/application.properties diff --git a/spring-boot-admin/spring-boot-admin-client/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/main/resources/logback.xml similarity index 100% rename from spring-boot-admin/spring-boot-admin-client/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/main/resources/logback.xml diff --git a/spring-boot-admin/spring-boot-admin-client/src/test/java/com/baeldung/springbootadminclient/SpringBootAdminClientApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/com/baeldung/springbootadminclient/SpringBootAdminClientApplicationIntegrationTest.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-client/src/test/java/com/baeldung/springbootadminclient/SpringBootAdminClientApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/com/baeldung/springbootadminclient/SpringBootAdminClientApplicationIntegrationTest.java diff --git a/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-admin/spring-boot-admin-server/.gitignore b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/.gitignore similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/.gitignore rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/.gitignore diff --git a/spring-boot-admin/spring-boot-admin-server/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml similarity index 94% rename from spring-boot-admin/spring-boot-admin-server/pom.xml rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml index d0d2d7a1ef..118b270812 100644 --- a/spring-boot-admin/spring-boot-admin-server/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml @@ -12,7 +12,6 @@ com.baeldung spring-boot-admin 0.0.1-SNAPSHOT - ../../spring-boot-admin @@ -80,8 +79,8 @@ - 2.1.6 - 2.1.6 + 2.2.2 + 2.2.2 1.5.7 2.0.4.RELEASE diff --git a/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/SpringBootAdminServerApplication.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/SpringBootAdminServerApplication.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/SpringBootAdminServerApplication.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/SpringBootAdminServerApplication.java diff --git a/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/HazelcastConfig.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/HazelcastConfig.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/HazelcastConfig.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/HazelcastConfig.java diff --git a/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/NotifierConfiguration.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/NotifierConfiguration.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/NotifierConfiguration.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/NotifierConfiguration.java diff --git a/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/WebSecurityConfig.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/WebSecurityConfig.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/WebSecurityConfig.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/java/com/baeldung/springbootadminserver/configs/WebSecurityConfig.java diff --git a/spring-boot-admin/spring-boot-admin-server/src/main/resources/application.properties b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/resources/application.properties similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/resources/application.properties diff --git a/spring-boot-admin/spring-boot-admin-server/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/resources/logback.xml similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/main/resources/logback.xml diff --git a/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/HazelcastConfigIntegrationTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/HazelcastConfigIntegrationTest.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/HazelcastConfigIntegrationTest.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/HazelcastConfigIntegrationTest.java diff --git a/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/NotifierConfigurationIntegrationTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/NotifierConfigurationIntegrationTest.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/NotifierConfigurationIntegrationTest.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/NotifierConfigurationIntegrationTest.java diff --git a/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/WebSecurityConfigIntegrationTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/WebSecurityConfigIntegrationTest.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/WebSecurityConfigIntegrationTest.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/springbootadminserver/WebSecurityConfigIntegrationTest.java diff --git a/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-angular/README.md b/spring-boot-modules/spring-boot-angular/README.md similarity index 100% rename from spring-boot-angular/README.md rename to spring-boot-modules/spring-boot-angular/README.md diff --git a/spring-boot-angular/pom.xml b/spring-boot-modules/spring-boot-angular/pom.xml similarity index 96% rename from spring-boot-angular/pom.xml rename to spring-boot-modules/spring-boot-angular/pom.xml index d78761e921..5cfc530100 100644 --- a/spring-boot-angular/pom.xml +++ b/spring-boot-modules/spring-boot-angular/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-angular/src/main/java/com/baeldung/application/Application.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/Application.java similarity index 97% rename from spring-boot-angular/src/main/java/com/baeldung/application/Application.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/Application.java index f1155c3106..0101ea3a3b 100644 --- a/spring-boot-angular/src/main/java/com/baeldung/application/Application.java +++ b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/Application.java @@ -1,28 +1,28 @@ -package com.baeldung.application; - -import com.baeldung.application.entities.User; -import com.baeldung.application.repositories.UserRepository; -import java.util.stream.Stream; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - - @Bean - CommandLineRunner init(UserRepository userRepository) { - return args -> { - Stream.of("John", "Julie", "Jennifer", "Helen", "Rachel").forEach(name -> { - User user = new User(name, name.toLowerCase() + "@domain.com"); - userRepository.save(user); - }); - userRepository.findAll().forEach(System.out::println); - }; - } -} +package com.baeldung.application; + +import com.baeldung.application.entities.User; +import com.baeldung.application.repositories.UserRepository; +import java.util.stream.Stream; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + @Bean + CommandLineRunner init(UserRepository userRepository) { + return args -> { + Stream.of("John", "Julie", "Jennifer", "Helen", "Rachel").forEach(name -> { + User user = new User(name, name.toLowerCase() + "@domain.com"); + userRepository.save(user); + }); + userRepository.findAll().forEach(System.out::println); + }; + } +} diff --git a/spring-boot-angular/src/main/java/com/baeldung/application/controllers/UserController.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/controllers/UserController.java similarity index 96% rename from spring-boot-angular/src/main/java/com/baeldung/application/controllers/UserController.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/controllers/UserController.java index 14c90d5b10..a87ac4e8d1 100644 --- a/spring-boot-angular/src/main/java/com/baeldung/application/controllers/UserController.java +++ b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/controllers/UserController.java @@ -1,31 +1,31 @@ -package com.baeldung.application.controllers; - -import com.baeldung.application.entities.User; -import com.baeldung.application.repositories.UserRepository; -import java.util.List; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@CrossOrigin(origins = "http://localhost:4200") -public class UserController { - - private final UserRepository userRepository; - - public UserController(UserRepository userRepository) { - this.userRepository = userRepository; - } - - @GetMapping("/users") - public List getUsers() { - return (List) userRepository.findAll(); - } - - @PostMapping("/users") - void addUser(@RequestBody User user) { - userRepository.save(user); - } -} +package com.baeldung.application.controllers; + +import com.baeldung.application.entities.User; +import com.baeldung.application.repositories.UserRepository; +import java.util.List; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@CrossOrigin(origins = "http://localhost:4200") +public class UserController { + + private final UserRepository userRepository; + + public UserController(UserRepository userRepository) { + this.userRepository = userRepository; + } + + @GetMapping("/users") + public List getUsers() { + return (List) userRepository.findAll(); + } + + @PostMapping("/users") + void addUser(@RequestBody User user) { + userRepository.save(user); + } +} diff --git a/spring-boot-angular/src/main/java/com/baeldung/application/entities/User.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/entities/User.java similarity index 95% rename from spring-boot-angular/src/main/java/com/baeldung/application/entities/User.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/entities/User.java index 4c346fa5b9..ea23edc7e2 100644 --- a/spring-boot-angular/src/main/java/com/baeldung/application/entities/User.java +++ b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/entities/User.java @@ -1,43 +1,43 @@ -package com.baeldung.application.entities; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - private final String name; - private final String email; - - public User() { - this.name = ""; - this.email = ""; - } - - public User(String name, String email) { - this.name = name; - this.email = email; - } - - public long getId() { - return id; - } - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } - - @Override - public String toString() { - return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; - } -} +package com.baeldung.application.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + private final String name; + private final String email; + + public User() { + this.name = ""; + this.email = ""; + } + + public User(String name, String email) { + this.name = name; + this.email = email; + } + + public long getId() { + return id; + } + + public String getName() { + return name; + } + + public String getEmail() { + return email; + } + + @Override + public String toString() { + return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; + } +} diff --git a/spring-boot-angular/src/main/java/com/baeldung/application/repositories/UserRepository.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/repositories/UserRepository.java similarity index 97% rename from spring-boot-angular/src/main/java/com/baeldung/application/repositories/UserRepository.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/repositories/UserRepository.java index 5a81cadcbe..7bd71c2f86 100644 --- a/spring-boot-angular/src/main/java/com/baeldung/application/repositories/UserRepository.java +++ b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/application/repositories/UserRepository.java @@ -1,9 +1,9 @@ -package com.baeldung.application.repositories; - -import com.baeldung.application.entities.User; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; -import org.springframework.web.bind.annotation.CrossOrigin; - -@Repository -public interface UserRepository extends CrudRepository{} +package com.baeldung.application.repositories; + +import com.baeldung.application.entities.User; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@Repository +public interface UserRepository extends CrudRepository{} diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/EcommerceApplication.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/EcommerceApplication.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/EcommerceApplication.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/EcommerceApplication.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/OrderController.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/OrderController.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/OrderController.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/OrderController.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/ProductController.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/ProductController.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/ProductController.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/ProductController.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/dto/OrderProductDto.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/dto/OrderProductDto.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/dto/OrderProductDto.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/dto/OrderProductDto.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ApiExceptionHandler.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ApiExceptionHandler.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ApiExceptionHandler.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ApiExceptionHandler.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ResourceNotFoundException.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ResourceNotFoundException.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ResourceNotFoundException.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ResourceNotFoundException.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Order.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Order.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Order.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Order.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProduct.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProduct.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProduct.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProduct.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProductPK.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProductPK.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProductPK.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProductPK.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderStatus.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderStatus.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderStatus.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderStatus.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Product.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Product.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Product.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Product.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderProductRepository.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderProductRepository.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderProductRepository.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderProductRepository.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderRepository.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderRepository.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderRepository.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderRepository.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/ProductRepository.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/ProductRepository.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/ProductRepository.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/ProductRepository.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductService.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductService.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductService.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductService.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductServiceImpl.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductServiceImpl.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductServiceImpl.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductServiceImpl.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderService.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderService.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderService.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderService.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderServiceImpl.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderServiceImpl.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderServiceImpl.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderServiceImpl.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductService.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductService.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductService.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductService.java diff --git a/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductServiceImpl.java b/spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductServiceImpl.java similarity index 100% rename from spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductServiceImpl.java rename to spring-boot-modules/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductServiceImpl.java diff --git a/spring-boot-angular/src/main/js/application/.angular-cli.json b/spring-boot-modules/spring-boot-angular/src/main/js/application/.angular-cli.json similarity index 100% rename from spring-boot-angular/src/main/js/application/.angular-cli.json rename to spring-boot-modules/spring-boot-angular/src/main/js/application/.angular-cli.json diff --git a/spring-boot-angular/src/main/js/application/.editorconfig b/spring-boot-modules/spring-boot-angular/src/main/js/application/.editorconfig similarity index 100% rename from spring-boot-angular/src/main/js/application/.editorconfig rename to spring-boot-modules/spring-boot-angular/src/main/js/application/.editorconfig diff --git a/spring-boot-angular/src/main/js/application/.gitignore b/spring-boot-modules/spring-boot-angular/src/main/js/application/.gitignore similarity index 100% rename from spring-boot-angular/src/main/js/application/.gitignore rename to spring-boot-modules/spring-boot-angular/src/main/js/application/.gitignore diff --git a/spring-boot-angular/src/main/js/application/README.md b/spring-boot-modules/spring-boot-angular/src/main/js/application/README.md similarity index 100% rename from spring-boot-angular/src/main/js/application/README.md rename to spring-boot-modules/spring-boot-angular/src/main/js/application/README.md diff --git a/spring-boot-angular/src/main/js/application/e2e/app.e2e-spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/e2e/app.e2e-spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/e2e/app.e2e-spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/e2e/app.e2e-spec.ts diff --git a/spring-boot-angular/src/main/js/application/e2e/app.po.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/e2e/app.po.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/e2e/app.po.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/e2e/app.po.ts diff --git a/spring-boot-angular/src/main/js/application/e2e/tsconfig.e2e.json b/spring-boot-modules/spring-boot-angular/src/main/js/application/e2e/tsconfig.e2e.json similarity index 100% rename from spring-boot-angular/src/main/js/application/e2e/tsconfig.e2e.json rename to spring-boot-modules/spring-boot-angular/src/main/js/application/e2e/tsconfig.e2e.json diff --git a/spring-boot-angular/src/main/js/application/karma.conf.js b/spring-boot-modules/spring-boot-angular/src/main/js/application/karma.conf.js similarity index 100% rename from spring-boot-angular/src/main/js/application/karma.conf.js rename to spring-boot-modules/spring-boot-angular/src/main/js/application/karma.conf.js diff --git a/spring-boot-angular/src/main/js/application/package-lock.json b/spring-boot-modules/spring-boot-angular/src/main/js/application/package-lock.json similarity index 100% rename from spring-boot-angular/src/main/js/application/package-lock.json rename to spring-boot-modules/spring-boot-angular/src/main/js/application/package-lock.json diff --git a/spring-boot-angular/src/main/js/application/package.json b/spring-boot-modules/spring-boot-angular/src/main/js/application/package.json similarity index 100% rename from spring-boot-angular/src/main/js/application/package.json rename to spring-boot-modules/spring-boot-angular/src/main/js/application/package.json diff --git a/spring-boot-angular/src/main/js/application/protractor.conf.js b/spring-boot-modules/spring-boot-angular/src/main/js/application/protractor.conf.js similarity index 100% rename from spring-boot-angular/src/main/js/application/protractor.conf.js rename to spring-boot-modules/spring-boot-angular/src/main/js/application/protractor.conf.js diff --git a/spring-boot-angular/src/main/js/application/src/app/app-routing.module.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app-routing.module.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/app-routing.module.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app-routing.module.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/app.component.css b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.component.css similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/app.component.css rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.component.css diff --git a/spring-boot-angular/src/main/js/application/src/app/app.component.html b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.component.html similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/app.component.html rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.component.html diff --git a/spring-boot-angular/src/main/js/application/src/app/app.component.spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.component.spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/app.component.spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.component.spec.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/app.component.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.component.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/app.component.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.component.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/app.module.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.module.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/app.module.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/app.module.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/model/user.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/model/user.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/model/user.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/model/user.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/service/user.service.spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/service/user.service.spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/service/user.service.spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/service/user.service.spec.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/service/user.service.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/service/user.service.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/service/user.service.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/service/user.service.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.css b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.css similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.css rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.css diff --git a/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.html b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.html similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.html rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.html diff --git a/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.spec.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.css b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.css similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.css rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.css diff --git a/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.html b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.html similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.html rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.html diff --git a/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.spec.ts diff --git a/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.ts diff --git a/spring-boot-angular/src/main/js/application/src/assets/.gitkeep b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/assets/.gitkeep similarity index 100% rename from spring-boot-angular/src/main/js/application/src/assets/.gitkeep rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/assets/.gitkeep diff --git a/spring-boot-angular/src/main/js/application/src/environments/environment.prod.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/environments/environment.prod.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/environments/environment.prod.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/environments/environment.prod.ts diff --git a/spring-boot-angular/src/main/js/application/src/environments/environment.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/environments/environment.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/environments/environment.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/environments/environment.ts diff --git a/spring-boot-angular/src/main/js/application/src/favicon.ico b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/favicon.ico similarity index 100% rename from spring-boot-angular/src/main/js/application/src/favicon.ico rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/favicon.ico diff --git a/spring-boot-angular/src/main/js/application/src/index.html b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/index.html similarity index 98% rename from spring-boot-angular/src/main/js/application/src/index.html rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/index.html index 1ce7ff1ca6..398190f439 100644 --- a/spring-boot-angular/src/main/js/application/src/index.html +++ b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/index.html @@ -14,4 +14,4 @@ - \ No newline at end of file + diff --git a/spring-boot-angular/src/main/js/application/src/main.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/main.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/main.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/main.ts diff --git a/spring-boot-angular/src/main/js/application/src/polyfills.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/polyfills.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/polyfills.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/polyfills.ts diff --git a/spring-boot-angular/src/main/js/application/src/styles.css b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/styles.css similarity index 100% rename from spring-boot-angular/src/main/js/application/src/styles.css rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/styles.css diff --git a/spring-boot-angular/src/main/js/application/src/tsconfig.app.json b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/tsconfig.app.json similarity index 100% rename from spring-boot-angular/src/main/js/application/src/tsconfig.app.json rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/tsconfig.app.json diff --git a/spring-boot-angular/src/main/js/application/src/tsconfig.spec.json b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/tsconfig.spec.json similarity index 100% rename from spring-boot-angular/src/main/js/application/src/tsconfig.spec.json rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/tsconfig.spec.json diff --git a/spring-boot-angular/src/main/js/application/src/typings.d.ts b/spring-boot-modules/spring-boot-angular/src/main/js/application/src/typings.d.ts similarity index 100% rename from spring-boot-angular/src/main/js/application/src/typings.d.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/application/src/typings.d.ts diff --git a/spring-boot-angular/src/main/js/application/tsconfig.json b/spring-boot-modules/spring-boot-angular/src/main/js/application/tsconfig.json similarity index 100% rename from spring-boot-angular/src/main/js/application/tsconfig.json rename to spring-boot-modules/spring-boot-angular/src/main/js/application/tsconfig.json diff --git a/spring-boot-angular/src/main/js/application/tslint.json b/spring-boot-modules/spring-boot-angular/src/main/js/application/tslint.json similarity index 100% rename from spring-boot-angular/src/main/js/application/tslint.json rename to spring-boot-modules/spring-boot-angular/src/main/js/application/tslint.json diff --git a/spring-boot-angular/src/main/js/ecommerce/.editorconfig b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/.editorconfig similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/.editorconfig rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/.editorconfig diff --git a/spring-boot-angular/src/main/js/ecommerce/README.md b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/README.md similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/README.md rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/README.md diff --git a/spring-boot-angular/src/main/js/ecommerce/angular.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/angular.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/angular.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/angular.json diff --git a/spring-boot-angular/src/main/js/ecommerce/e2e/protractor.conf.js b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/e2e/protractor.conf.js similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/e2e/protractor.conf.js rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/e2e/protractor.conf.js diff --git a/spring-boot-angular/src/main/js/ecommerce/e2e/src/app.e2e-spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/e2e/src/app.e2e-spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/e2e/src/app.e2e-spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/e2e/src/app.e2e-spec.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/e2e/src/app.po.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/e2e/src/app.po.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/e2e/src/app.po.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/e2e/src/app.po.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/e2e/tsconfig.e2e.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/e2e/tsconfig.e2e.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/e2e/tsconfig.e2e.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/e2e/tsconfig.e2e.json diff --git a/spring-boot-angular/src/main/js/ecommerce/package-lock.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/package-lock.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/package-lock.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/package-lock.json diff --git a/spring-boot-angular/src/main/js/ecommerce/package.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/package.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/package.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/package.json diff --git a/spring-boot-angular/src/main/js/ecommerce/proxy-conf.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/proxy-conf.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/proxy-conf.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/proxy-conf.json diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.css b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.css similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/app.component.css rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.css diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.html b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.html similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/app.component.html rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.html diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/app.component.spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.spec.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/app.component.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/app.module.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.module.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/app.module.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/app.module.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.css b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.css similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.css rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.css diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.html b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.html similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.html rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.html diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.spec.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-order.model.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-order.model.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-order.model.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-order.model.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-orders.model.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-orders.model.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-orders.model.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-orders.model.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product.model.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product.model.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product.model.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product.model.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.css b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.css similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.css rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.css diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.html b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.html similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.html rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.html diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.spec.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.css b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.css similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.css rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.css diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.html b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.html similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.html rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.html diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.spec.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/services/EcommerceService.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/services/EcommerceService.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/services/EcommerceService.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/services/EcommerceService.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.css b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.css similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.css rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.css diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.html b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.html similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.html rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.html diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.spec.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.spec.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.spec.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.spec.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/assets/.gitkeep b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/assets/.gitkeep similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/assets/.gitkeep rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/assets/.gitkeep diff --git a/spring-boot-angular/src/main/js/ecommerce/src/browserslist b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/browserslist similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/browserslist rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/browserslist diff --git a/spring-boot-angular/src/main/js/ecommerce/src/environments/environment.prod.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/environments/environment.prod.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/environments/environment.prod.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/environments/environment.prod.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/environments/environment.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/environments/environment.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/environments/environment.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/environments/environment.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/favicon.ico b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/favicon.ico similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/favicon.ico rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/favicon.ico diff --git a/spring-boot-angular/src/main/js/ecommerce/src/index.html b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/index.html similarity index 69% rename from spring-boot-angular/src/main/js/ecommerce/src/index.html rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/index.html index 3faefb6e8c..2578673a0f 100644 --- a/spring-boot-angular/src/main/js/ecommerce/src/index.html +++ b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/index.html @@ -6,7 +6,7 @@ - + diff --git a/spring-boot-angular/src/main/js/ecommerce/src/karma.conf.js b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/karma.conf.js similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/karma.conf.js rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/karma.conf.js diff --git a/spring-boot-angular/src/main/js/ecommerce/src/main.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/main.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/main.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/main.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/polyfills.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/polyfills.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/polyfills.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/polyfills.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/styles.css b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/styles.css similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/styles.css rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/styles.css diff --git a/spring-boot-angular/src/main/js/ecommerce/src/test.ts b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/test.ts similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/test.ts rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/test.ts diff --git a/spring-boot-angular/src/main/js/ecommerce/src/tsconfig.app.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/tsconfig.app.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/tsconfig.app.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/tsconfig.app.json diff --git a/spring-boot-angular/src/main/js/ecommerce/src/tsconfig.spec.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/tsconfig.spec.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/tsconfig.spec.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/tsconfig.spec.json diff --git a/spring-boot-angular/src/main/js/ecommerce/src/tslint.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/tslint.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/src/tslint.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/src/tslint.json diff --git a/spring-boot-angular/src/main/js/ecommerce/tsconfig.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/tsconfig.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/tsconfig.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/tsconfig.json diff --git a/spring-boot-angular/src/main/js/ecommerce/tslint.json b/spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/tslint.json similarity index 100% rename from spring-boot-angular/src/main/js/ecommerce/tslint.json rename to spring-boot-modules/spring-boot-angular/src/main/js/ecommerce/tslint.json diff --git a/spring-boot-angular/src/main/resources/application.properties b/spring-boot-modules/spring-boot-angular/src/main/resources/application.properties similarity index 100% rename from spring-boot-angular/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-angular/src/main/resources/application.properties diff --git a/core-kotlin-2/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-angular/src/main/resources/logback.xml similarity index 100% rename from core-kotlin-2/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-angular/src/main/resources/logback.xml diff --git a/spring-boot-angular/src/test/java/com/baeldung/ecommerce/EcommerceApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-angular/src/test/java/com/baeldung/ecommerce/EcommerceApplicationIntegrationTest.java similarity index 100% rename from spring-boot-angular/src/test/java/com/baeldung/ecommerce/EcommerceApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot-angular/src/test/java/com/baeldung/ecommerce/EcommerceApplicationIntegrationTest.java diff --git a/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-artifacts/README.md b/spring-boot-modules/spring-boot-artifacts/README.md similarity index 100% rename from spring-boot-artifacts/README.md rename to spring-boot-modules/spring-boot-artifacts/README.md diff --git a/spring-boot-artifacts/pom.xml b/spring-boot-modules/spring-boot-artifacts/pom.xml similarity index 99% rename from spring-boot-artifacts/pom.xml rename to spring-boot-modules/spring-boot-artifacts/pom.xml index 97d3c53b49..d6d3886c3e 100644 --- a/spring-boot-artifacts/pom.xml +++ b/spring-boot-modules/spring-boot-artifacts/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-artifacts/src/main/java/com/baeldung/webjar/TestController.java b/spring-boot-modules/spring-boot-artifacts/src/main/java/com/baeldung/webjar/TestController.java similarity index 100% rename from spring-boot-artifacts/src/main/java/com/baeldung/webjar/TestController.java rename to spring-boot-modules/spring-boot-artifacts/src/main/java/com/baeldung/webjar/TestController.java diff --git a/spring-boot-artifacts/src/main/java/com/baeldung/webjar/WebjarsdemoApplication.java b/spring-boot-modules/spring-boot-artifacts/src/main/java/com/baeldung/webjar/WebjarsdemoApplication.java similarity index 100% rename from spring-boot-artifacts/src/main/java/com/baeldung/webjar/WebjarsdemoApplication.java rename to spring-boot-modules/spring-boot-artifacts/src/main/java/com/baeldung/webjar/WebjarsdemoApplication.java diff --git a/spring-boot-artifacts/src/main/resources/application.properties b/spring-boot-modules/spring-boot-artifacts/src/main/resources/application.properties similarity index 100% rename from spring-boot-artifacts/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-artifacts/src/main/resources/application.properties diff --git a/core-kotlin/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-artifacts/src/main/resources/logback.xml similarity index 100% rename from core-kotlin/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-artifacts/src/main/resources/logback.xml diff --git a/spring-boot-artifacts/src/main/resources/templates/index.html b/spring-boot-modules/spring-boot-artifacts/src/main/resources/templates/index.html similarity index 100% rename from spring-boot-artifacts/src/main/resources/templates/index.html rename to spring-boot-modules/spring-boot-artifacts/src/main/resources/templates/index.html diff --git a/spring-boot-artifacts/src/test/java/com/baeldung/webjar/WebjarsdemoApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-artifacts/src/test/java/com/baeldung/webjar/WebjarsdemoApplicationIntegrationTest.java similarity index 100% rename from spring-boot-artifacts/src/test/java/com/baeldung/webjar/WebjarsdemoApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot-artifacts/src/test/java/com/baeldung/webjar/WebjarsdemoApplicationIntegrationTest.java diff --git a/spring-boot-autoconfiguration/.gitignore b/spring-boot-modules/spring-boot-autoconfiguration/.gitignore similarity index 100% rename from spring-boot-autoconfiguration/.gitignore rename to spring-boot-modules/spring-boot-autoconfiguration/.gitignore diff --git a/spring-boot-autoconfiguration/README.md b/spring-boot-modules/spring-boot-autoconfiguration/README.md similarity index 100% rename from spring-boot-autoconfiguration/README.md rename to spring-boot-modules/spring-boot-autoconfiguration/README.md diff --git a/spring-boot-autoconfiguration/pom.xml b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml similarity index 98% rename from spring-boot-autoconfiguration/pom.xml rename to spring-boot-modules/spring-boot-autoconfiguration/pom.xml index a39bf0f071..34db784176 100644 --- a/spring-boot-autoconfiguration/pom.xml +++ b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java similarity index 100% rename from spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java diff --git a/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/AnnotationProcessorApplication.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/AnnotationProcessorApplication.java similarity index 100% rename from spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/AnnotationProcessorApplication.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/AnnotationProcessorApplication.java diff --git a/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java similarity index 100% rename from spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java diff --git a/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/AutoconfigurationApplication.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/AutoconfigurationApplication.java similarity index 100% rename from spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/AutoconfigurationApplication.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/AutoconfigurationApplication.java diff --git a/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java similarity index 100% rename from spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java diff --git a/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUserRepository.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUserRepository.java similarity index 100% rename from spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUserRepository.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUserRepository.java diff --git a/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/CustomService.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/CustomService.java similarity index 100% rename from spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/CustomService.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/CustomService.java diff --git a/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/DefaultService.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/DefaultService.java similarity index 100% rename from spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/DefaultService.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/DefaultService.java diff --git a/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/SimpleService.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/SimpleService.java similarity index 100% rename from spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/SimpleService.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/service/SimpleService.java diff --git a/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories similarity index 100% rename from spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories diff --git a/spring-boot-autoconfiguration/src/main/resources/application.properties b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/application.properties similarity index 100% rename from spring-boot-autoconfiguration/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/application.properties diff --git a/spring-boot-angular/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/logback.xml similarity index 100% rename from spring-boot-angular/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/logback.xml diff --git a/spring-boot-autoconfiguration/src/main/resources/mysql.properties b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties similarity index 100% rename from spring-boot-autoconfiguration/src/main/resources/mysql.properties rename to spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties diff --git a/spring-boot-autoconfiguration/src/test/java/com/baeldung/SpringContextLiveTest.java b/spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/SpringContextLiveTest.java similarity index 100% rename from spring-boot-autoconfiguration/src/test/java/com/baeldung/SpringContextLiveTest.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/SpringContextLiveTest.java diff --git a/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/AutoconfigurationLiveTest.java b/spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/AutoconfigurationLiveTest.java similarity index 100% rename from spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/AutoconfigurationLiveTest.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/AutoconfigurationLiveTest.java diff --git a/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnBeanIntegrationTest.java b/spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnBeanIntegrationTest.java similarity index 100% rename from spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnBeanIntegrationTest.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnBeanIntegrationTest.java diff --git a/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnClassIntegrationTest.java b/spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnClassIntegrationTest.java similarity index 100% rename from spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnClassIntegrationTest.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnClassIntegrationTest.java diff --git a/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnPropertyIntegrationTest.java b/spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnPropertyIntegrationTest.java similarity index 100% rename from spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnPropertyIntegrationTest.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/ConditionalOnPropertyIntegrationTest.java diff --git a/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/SpringContextLiveTest.java b/spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/SpringContextLiveTest.java similarity index 100% rename from spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/SpringContextLiveTest.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/SpringContextLiveTest.java diff --git a/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/annotationprocessor/DatabasePropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/annotationprocessor/DatabasePropertiesIntegrationTest.java similarity index 100% rename from spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/annotationprocessor/DatabasePropertiesIntegrationTest.java rename to spring-boot-modules/spring-boot-autoconfiguration/src/test/java/com/baeldung/autoconfiguration/annotationprocessor/DatabasePropertiesIntegrationTest.java diff --git a/spring-boot-autoconfiguration/src/test/resources/ConditionalOnPropertyTest.properties b/spring-boot-modules/spring-boot-autoconfiguration/src/test/resources/ConditionalOnPropertyTest.properties similarity index 100% rename from spring-boot-autoconfiguration/src/test/resources/ConditionalOnPropertyTest.properties rename to spring-boot-modules/spring-boot-autoconfiguration/src/test/resources/ConditionalOnPropertyTest.properties diff --git a/spring-boot-autoconfiguration/src/test/resources/databaseproperties-test.properties b/spring-boot-modules/spring-boot-autoconfiguration/src/test/resources/databaseproperties-test.properties similarity index 100% rename from spring-boot-autoconfiguration/src/test/resources/databaseproperties-test.properties rename to spring-boot-modules/spring-boot-autoconfiguration/src/test/resources/databaseproperties-test.properties diff --git a/spring-boot-bootstrap/.gitignore b/spring-boot-modules/spring-boot-bootstrap/.gitignore similarity index 100% rename from spring-boot-bootstrap/.gitignore rename to spring-boot-modules/spring-boot-bootstrap/.gitignore diff --git a/spring-boot-bootstrap/README.md b/spring-boot-modules/spring-boot-bootstrap/README.md similarity index 100% rename from spring-boot-bootstrap/README.md rename to spring-boot-modules/spring-boot-bootstrap/README.md diff --git a/spring-boot-bootstrap/cloudfoundry/manifest.yml b/spring-boot-modules/spring-boot-bootstrap/cloudfoundry/manifest.yml similarity index 100% rename from spring-boot-bootstrap/cloudfoundry/manifest.yml rename to spring-boot-modules/spring-boot-bootstrap/cloudfoundry/manifest.yml diff --git a/spring-boot-bootstrap/openshift/configmap.yml b/spring-boot-modules/spring-boot-bootstrap/openshift/configmap.yml similarity index 100% rename from spring-boot-bootstrap/openshift/configmap.yml rename to spring-boot-modules/spring-boot-bootstrap/openshift/configmap.yml diff --git a/spring-boot-bootstrap/pom.xml b/spring-boot-modules/spring-boot-bootstrap/pom.xml similarity index 99% rename from spring-boot-bootstrap/pom.xml rename to spring-boot-modules/spring-boot-bootstrap/pom.xml index a81908d8b6..1dc75c7e61 100644 --- a/spring-boot-bootstrap/pom.xml +++ b/spring-boot-modules/spring-boot-bootstrap/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-bootstrap/src/main/appengine/app.yaml b/spring-boot-modules/spring-boot-bootstrap/src/main/appengine/app.yaml similarity index 100% rename from spring-boot-bootstrap/src/main/appengine/app.yaml rename to spring-boot-modules/spring-boot-bootstrap/src/main/appengine/app.yaml diff --git a/spring-boot-bootstrap/src/main/fabric8/deployment.yml b/spring-boot-modules/spring-boot-bootstrap/src/main/fabric8/deployment.yml similarity index 100% rename from spring-boot-bootstrap/src/main/fabric8/deployment.yml rename to spring-boot-modules/spring-boot-bootstrap/src/main/fabric8/deployment.yml diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/Application.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/Application.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/Application.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/Application.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/cloud/config/CloudDataSourceConfig.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/cloud/config/CloudDataSourceConfig.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/cloud/config/CloudDataSourceConfig.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/cloud/config/CloudDataSourceConfig.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/config/SecurityConfig.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/config/SecurityConfig.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/config/SecurityConfig.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/config/SecurityConfig.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/persistence/model/Book.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/persistence/model/Book.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/persistence/model/Book.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/persistence/model/Book.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/persistence/repo/BookRepository.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/persistence/repo/BookRepository.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/persistence/repo/BookRepository.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/persistence/repo/BookRepository.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/Application.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonService.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonService.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonService.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonService.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonServiceImpl.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonServiceImpl.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonServiceImpl.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/springbootconfiguration/PersonServiceImpl.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/web/BookController.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/BookController.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/web/BookController.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/BookController.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/web/RestExceptionHandler.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/RestExceptionHandler.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/web/RestExceptionHandler.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/RestExceptionHandler.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/web/SimpleController.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/SimpleController.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/web/SimpleController.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/SimpleController.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/web/exception/BookIdMismatchException.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/exception/BookIdMismatchException.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/web/exception/BookIdMismatchException.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/exception/BookIdMismatchException.java diff --git a/spring-boot-bootstrap/src/main/java/com/baeldung/web/exception/BookNotFoundException.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/exception/BookNotFoundException.java similarity index 100% rename from spring-boot-bootstrap/src/main/java/com/baeldung/web/exception/BookNotFoundException.java rename to spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/web/exception/BookNotFoundException.java diff --git a/spring-boot-bootstrap/src/main/resources/application-beanstalk.properties b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/application-beanstalk.properties similarity index 100% rename from spring-boot-bootstrap/src/main/resources/application-beanstalk.properties rename to spring-boot-modules/spring-boot-bootstrap/src/main/resources/application-beanstalk.properties diff --git a/spring-boot-bootstrap/src/main/resources/application-gcp.properties b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/application-gcp.properties similarity index 100% rename from spring-boot-bootstrap/src/main/resources/application-gcp.properties rename to spring-boot-modules/spring-boot-bootstrap/src/main/resources/application-gcp.properties diff --git a/spring-boot-bootstrap/src/main/resources/application-local.properties b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/application-local.properties similarity index 100% rename from spring-boot-bootstrap/src/main/resources/application-local.properties rename to spring-boot-modules/spring-boot-bootstrap/src/main/resources/application-local.properties diff --git a/spring-boot-modules/spring-boot-bootstrap/src/main/resources/application-mysql.properties b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/application-mysql.properties new file mode 100644 index 0000000000..069bf2e9d6 --- /dev/null +++ b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/application-mysql.properties @@ -0,0 +1,4 @@ +spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect +spring.application.name = spring-boot-bootstrap +spring.datasource.username = ${SPRING_DATASOURCE_USER} +spring.datasource.password = ${SPRING_DATASOURCE_PASSWORD} \ No newline at end of file diff --git a/spring-boot-bootstrap/src/main/resources/application.properties b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/application.properties similarity index 100% rename from spring-boot-bootstrap/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-bootstrap/src/main/resources/application.properties diff --git a/spring-boot-bootstrap/src/main/resources/logback-gcp.xml b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/logback-gcp.xml similarity index 100% rename from spring-boot-bootstrap/src/main/resources/logback-gcp.xml rename to spring-boot-modules/spring-boot-bootstrap/src/main/resources/logback-gcp.xml diff --git a/spring-boot-artifacts/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/logback.xml similarity index 100% rename from spring-boot-artifacts/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-bootstrap/src/main/resources/logback.xml diff --git a/spring-boot-bootstrap/src/main/resources/spring-cloud-bootstrap.properties b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/spring-cloud-bootstrap.properties similarity index 100% rename from spring-boot-bootstrap/src/main/resources/spring-cloud-bootstrap.properties rename to spring-boot-modules/spring-boot-bootstrap/src/main/resources/spring-cloud-bootstrap.properties diff --git a/spring-boot-bootstrap/src/main/resources/templates/error.html b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/templates/error.html similarity index 100% rename from spring-boot-bootstrap/src/main/resources/templates/error.html rename to spring-boot-modules/spring-boot-bootstrap/src/main/resources/templates/error.html diff --git a/spring-boot-bootstrap/src/main/resources/templates/home.html b/spring-boot-modules/spring-boot-bootstrap/src/main/resources/templates/home.html similarity index 100% rename from spring-boot-bootstrap/src/main/resources/templates/home.html rename to spring-boot-modules/spring-boot-bootstrap/src/main/resources/templates/home.html diff --git a/spring-boot-bootstrap/src/test/java/com/baeldung/SpringBootBootstrapLiveTest.java b/spring-boot-modules/spring-boot-bootstrap/src/test/java/com/baeldung/SpringBootBootstrapLiveTest.java similarity index 100% rename from spring-boot-bootstrap/src/test/java/com/baeldung/SpringBootBootstrapLiveTest.java rename to spring-boot-modules/spring-boot-bootstrap/src/test/java/com/baeldung/SpringBootBootstrapLiveTest.java diff --git a/spring-boot-bootstrap/src/test/java/com/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-bootstrap/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-bootstrap/src/test/java/com/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-bootstrap/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-boot-camel/README.md b/spring-boot-modules/spring-boot-camel/README.md similarity index 100% rename from spring-boot-camel/README.md rename to spring-boot-modules/spring-boot-camel/README.md diff --git a/spring-boot-camel/pom.xml b/spring-boot-modules/spring-boot-camel/pom.xml similarity index 95% rename from spring-boot-camel/pom.xml rename to spring-boot-modules/spring-boot-camel/pom.xml index 8bab0ed5c8..7c1e28b3ee 100644 --- a/spring-boot-camel/pom.xml +++ b/spring-boot-modules/spring-boot-camel/pom.xml @@ -8,8 +8,8 @@ spring-boot-camel - com.baeldung - parent-modules + com.baeldung.spring-boot-modules + spring-boot-modules 1.0.0-SNAPSHOT diff --git a/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java b/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java similarity index 100% rename from spring-boot-camel/src/main/java/com/baeldung/camel/Application.java rename to spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/Application.java diff --git a/spring-boot-camel/src/main/java/com/baeldung/camel/ExampleServices.java b/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/ExampleServices.java similarity index 100% rename from spring-boot-camel/src/main/java/com/baeldung/camel/ExampleServices.java rename to spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/ExampleServices.java diff --git a/spring-boot-camel/src/main/java/com/baeldung/camel/MyBean.java b/spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/MyBean.java similarity index 100% rename from spring-boot-camel/src/main/java/com/baeldung/camel/MyBean.java rename to spring-boot-modules/spring-boot-camel/src/main/java/com/baeldung/camel/MyBean.java diff --git a/spring-boot-camel/src/main/resources/application.properties b/spring-boot-modules/spring-boot-camel/src/main/resources/application.properties similarity index 100% rename from spring-boot-camel/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-camel/src/main/resources/application.properties diff --git a/spring-boot-camel/src/main/resources/application.yml b/spring-boot-modules/spring-boot-camel/src/main/resources/application.yml similarity index 100% rename from spring-boot-camel/src/main/resources/application.yml rename to spring-boot-modules/spring-boot-camel/src/main/resources/application.yml diff --git a/spring-boot-camel/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-camel/src/main/resources/logback.xml similarity index 100% rename from spring-boot-camel/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-camel/src/main/resources/logback.xml diff --git a/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-cli/README.md b/spring-boot-modules/spring-boot-cli/README.md similarity index 100% rename from spring-boot-cli/README.md rename to spring-boot-modules/spring-boot-cli/README.md diff --git a/spring-boot-cli/bash/groovy.sh b/spring-boot-modules/spring-boot-cli/bash/groovy.sh similarity index 100% rename from spring-boot-cli/bash/groovy.sh rename to spring-boot-modules/spring-boot-cli/bash/groovy.sh diff --git a/spring-boot-cli/bash/setup.sh b/spring-boot-modules/spring-boot-cli/bash/setup.sh similarity index 100% rename from spring-boot-cli/bash/setup.sh rename to spring-boot-modules/spring-boot-cli/bash/setup.sh diff --git a/spring-boot-cli/groovy/data/DataConfig.groovy b/spring-boot-modules/spring-boot-cli/groovy/data/DataConfig.groovy similarity index 100% rename from spring-boot-cli/groovy/data/DataConfig.groovy rename to spring-boot-modules/spring-boot-cli/groovy/data/DataConfig.groovy diff --git a/spring-boot-cli/groovy/security/Security.groovy b/spring-boot-modules/spring-boot-cli/groovy/security/Security.groovy similarity index 100% rename from spring-boot-cli/groovy/security/Security.groovy rename to spring-boot-modules/spring-boot-cli/groovy/security/Security.groovy diff --git a/spring-boot-cli/groovy/test/Test.groovy b/spring-boot-modules/spring-boot-cli/groovy/test/Test.groovy similarity index 100% rename from spring-boot-cli/groovy/test/Test.groovy rename to spring-boot-modules/spring-boot-cli/groovy/test/Test.groovy diff --git a/spring-boot-cli/groovy/yml/Application.groovy b/spring-boot-modules/spring-boot-cli/groovy/yml/Application.groovy similarity index 100% rename from spring-boot-cli/groovy/yml/Application.groovy rename to spring-boot-modules/spring-boot-cli/groovy/yml/Application.groovy diff --git a/spring-boot-cli/groovy/yml/config/application.yml b/spring-boot-modules/spring-boot-cli/groovy/yml/config/application.yml similarity index 100% rename from spring-boot-cli/groovy/yml/config/application.yml rename to spring-boot-modules/spring-boot-cli/groovy/yml/config/application.yml diff --git a/spring-boot-client/.gitignore b/spring-boot-modules/spring-boot-client/.gitignore similarity index 100% rename from spring-boot-client/.gitignore rename to spring-boot-modules/spring-boot-client/.gitignore diff --git a/spring-boot-client/README.MD b/spring-boot-modules/spring-boot-client/README.MD similarity index 100% rename from spring-boot-client/README.MD rename to spring-boot-modules/spring-boot-client/README.MD diff --git a/spring-boot-client/pom.xml b/spring-boot-modules/spring-boot-client/pom.xml similarity index 98% rename from spring-boot-client/pom.xml rename to spring-boot-modules/spring-boot-client/pom.xml index 2cfd413e93..40a8690953 100644 --- a/spring-boot-client/pom.xml +++ b/spring-boot-modules/spring-boot-client/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-client/src/main/java/org/baeldung/boot/Application.java b/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/Application.java similarity index 100% rename from spring-boot-client/src/main/java/org/baeldung/boot/Application.java rename to spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/Application.java diff --git a/spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java b/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java similarity index 100% rename from spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java rename to spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java diff --git a/spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java b/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java similarity index 100% rename from spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java rename to spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java diff --git a/spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java b/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java similarity index 100% rename from spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java rename to spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java diff --git a/spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java b/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java similarity index 100% rename from spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java rename to spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java diff --git a/spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java b/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java similarity index 100% rename from spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java rename to spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java diff --git a/spring-boot-client/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-client/src/main/resources/logback.xml similarity index 100% rename from spring-boot-client/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-client/src/main/resources/logback.xml diff --git a/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java similarity index 100% rename from spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java rename to spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java diff --git a/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java b/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java similarity index 100% rename from spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java rename to spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java diff --git a/spring-boot-config-jpa-error/README.md b/spring-boot-modules/spring-boot-config-jpa-error/README.md similarity index 100% rename from spring-boot-config-jpa-error/README.md rename to spring-boot-modules/spring-boot-config-jpa-error/README.md diff --git a/spring-boot-config-jpa-error/data-jpa-application/README.md b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/README.md similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-application/README.md rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/README.md diff --git a/spring-boot-config-jpa-error/data-jpa-application/pom.xml b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/pom.xml similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-application/pom.xml rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/pom.xml diff --git a/spring-boot-config-jpa-error/data-jpa-application/src/main/java/com/baeldung/data/jpa/ApplicationFound.java b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/main/java/com/baeldung/data/jpa/ApplicationFound.java similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-application/src/main/java/com/baeldung/data/jpa/ApplicationFound.java rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/main/java/com/baeldung/data/jpa/ApplicationFound.java diff --git a/spring-boot-config-jpa-error/data-jpa-application/src/main/java/com/baeldung/data/jpa/application/ApplicationNotFound.java b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/main/java/com/baeldung/data/jpa/application/ApplicationNotFound.java similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-application/src/main/java/com/baeldung/data/jpa/application/ApplicationNotFound.java rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/main/java/com/baeldung/data/jpa/application/ApplicationNotFound.java diff --git a/spring-boot-config-jpa-error/data-jpa-application/src/test/java/com/baeldung/data/jpa/DataJpaUnitTest.java b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/test/java/com/baeldung/data/jpa/DataJpaUnitTest.java similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-application/src/test/java/com/baeldung/data/jpa/DataJpaUnitTest.java rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-application/src/test/java/com/baeldung/data/jpa/DataJpaUnitTest.java diff --git a/spring-boot-config-jpa-error/data-jpa-library/README.md b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/README.md similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-library/README.md rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/README.md diff --git a/spring-boot-config-jpa-error/data-jpa-library/pom.xml b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/pom.xml similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-library/pom.xml rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/pom.xml diff --git a/spring-boot-config-jpa-error/data-jpa-library/src/main/java/com/baeldung/data/jpa/libarary/model/Example.java b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/main/java/com/baeldung/data/jpa/libarary/model/Example.java similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-library/src/main/java/com/baeldung/data/jpa/libarary/model/Example.java rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/main/java/com/baeldung/data/jpa/libarary/model/Example.java diff --git a/spring-boot-config-jpa-error/data-jpa-library/src/test/java/com/baeldung/data/jpa/TestApplication.java b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/test/java/com/baeldung/data/jpa/TestApplication.java similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-library/src/test/java/com/baeldung/data/jpa/TestApplication.java rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/test/java/com/baeldung/data/jpa/TestApplication.java diff --git a/spring-boot-config-jpa-error/data-jpa-library/src/test/java/com/baeldung/data/jpa/libarary/DataJpaUnitTest.java b/spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/test/java/com/baeldung/data/jpa/libarary/DataJpaUnitTest.java similarity index 100% rename from spring-boot-config-jpa-error/data-jpa-library/src/test/java/com/baeldung/data/jpa/libarary/DataJpaUnitTest.java rename to spring-boot-modules/spring-boot-config-jpa-error/data-jpa-library/src/test/java/com/baeldung/data/jpa/libarary/DataJpaUnitTest.java diff --git a/spring-boot-config-jpa-error/pom.xml b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml similarity index 96% rename from spring-boot-config-jpa-error/pom.xml rename to spring-boot-modules/spring-boot-config-jpa-error/pom.xml index 4b99f9be93..f578957a1a 100644 --- a/spring-boot-config-jpa-error/pom.xml +++ b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2/pom.xml + ../../parent-boot-2/pom.xml diff --git a/spring-boot-crud/README.md b/spring-boot-modules/spring-boot-crud/README.md similarity index 100% rename from spring-boot-crud/README.md rename to spring-boot-modules/spring-boot-crud/README.md diff --git a/spring-boot-crud/pom.xml b/spring-boot-modules/spring-boot-crud/pom.xml similarity index 95% rename from spring-boot-crud/pom.xml rename to spring-boot-modules/spring-boot-crud/pom.xml index e78e939f0c..676d522f84 100644 --- a/spring-boot-crud/pom.xml +++ b/spring-boot-modules/spring-boot-crud/pom.xml @@ -1,86 +1,86 @@ - - - 4.0.0 - spring-boot-crud - spring-boot-crud - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-test - - - org.mockito - mockito-core - test - - - com.h2database - h2 - runtime - - - - - spring-boot-crud - - - src/main/resources - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - org.apache.maven.plugins - maven-assembly-plugin - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - - - - UTF-8 - - - + + + 4.0.0 + spring-boot-crud + spring-boot-crud + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-test + + + org.mockito + mockito-core + test + + + com.h2database + h2 + runtime + + + + + spring-boot-crud + + + src/main/resources + true + + + + + org.springframework.boot + spring-boot-maven-plugin + + exec + + + + org.apache.maven.plugins + maven-assembly-plugin + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + + + + UTF-8 + + + diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java similarity index 97% rename from spring-boot-crud/src/main/java/com/baeldung/crud/Application.java rename to spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java index 0b686e90e9..a56a2a04c0 100644 --- a/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/Application.java @@ -1,23 +1,23 @@ -package com.baeldung.crud; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@SpringBootApplication -@EnableAutoConfiguration -@ComponentScan(basePackages={"com.baeldung.crud"}) -@EnableJpaRepositories(basePackages="com.baeldung.crud.repositories") -@EnableTransactionManagement -@EntityScan(basePackages="com.baeldung.crud.entities") -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} +package com.baeldung.crud; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@SpringBootApplication +@EnableAutoConfiguration +@ComponentScan(basePackages={"com.baeldung.crud"}) +@EnableJpaRepositories(basePackages="com.baeldung.crud.repositories") +@EnableTransactionManagement +@EntityScan(basePackages="com.baeldung.crud.entities") +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java similarity index 97% rename from spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java rename to spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java index 9a6cb477aa..726be6a384 100644 --- a/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java @@ -1,68 +1,68 @@ -package com.baeldung.crud.controllers; - -import javax.validation.Valid; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; - -import com.baeldung.crud.entities.User; -import com.baeldung.crud.repositories.UserRepository; - -@Controller -public class UserController { - - private final UserRepository userRepository; - - @Autowired - public UserController(UserRepository userRepository) { - this.userRepository = userRepository; - } - - @GetMapping("/signup") - public String showSignUpForm(User user) { - return "add-user"; - } - - @PostMapping("/adduser") - public String addUser(@Valid User user, BindingResult result, Model model) { - if (result.hasErrors()) { - return "add-user"; - } - - userRepository.save(user); - model.addAttribute("users", userRepository.findAll()); - return "index"; - } - - @GetMapping("/edit/{id}") - public String showUpdateForm(@PathVariable("id") long id, Model model) { - User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); - model.addAttribute("user", user); - return "update-user"; - } - - @PostMapping("/update/{id}") - public String updateUser(@PathVariable("id") long id, @Valid User user, BindingResult result, Model model) { - if (result.hasErrors()) { - user.setId(id); - return "update-user"; - } - - userRepository.save(user); - model.addAttribute("users", userRepository.findAll()); - return "index"; - } - - @GetMapping("/delete/{id}") - public String deleteUser(@PathVariable("id") long id, Model model) { - User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); - userRepository.delete(user); - model.addAttribute("users", userRepository.findAll()); - return "index"; - } -} +package com.baeldung.crud.controllers; + +import javax.validation.Valid; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + +import com.baeldung.crud.entities.User; +import com.baeldung.crud.repositories.UserRepository; + +@Controller +public class UserController { + + private final UserRepository userRepository; + + @Autowired + public UserController(UserRepository userRepository) { + this.userRepository = userRepository; + } + + @GetMapping("/signup") + public String showSignUpForm(User user) { + return "add-user"; + } + + @PostMapping("/adduser") + public String addUser(@Valid User user, BindingResult result, Model model) { + if (result.hasErrors()) { + return "add-user"; + } + + userRepository.save(user); + model.addAttribute("users", userRepository.findAll()); + return "index"; + } + + @GetMapping("/edit/{id}") + public String showUpdateForm(@PathVariable("id") long id, Model model) { + User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); + model.addAttribute("user", user); + return "update-user"; + } + + @PostMapping("/update/{id}") + public String updateUser(@PathVariable("id") long id, @Valid User user, BindingResult result, Model model) { + if (result.hasErrors()) { + user.setId(id); + return "update-user"; + } + + userRepository.save(user); + model.addAttribute("users", userRepository.findAll()); + return "index"; + } + + @GetMapping("/delete/{id}") + public String deleteUser(@PathVariable("id") long id, Model model) { + User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); + userRepository.delete(user); + model.addAttribute("users", userRepository.findAll()); + return "index"; + } +} diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java similarity index 95% rename from spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java rename to spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java index 2074268179..372327532f 100644 --- a/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/entities/User.java @@ -1,56 +1,56 @@ -package com.baeldung.crud.entities; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.validation.constraints.NotBlank; - -@Entity -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - @NotBlank(message = "Name is mandatory") - private String name; - - @NotBlank(message = "Email is mandatory") - private String email; - - public User() {} - - public User(String name, String email) { - this.name = name; - this.email = email; - } - - public void setId(long id) { - this.id = id; - } - - public long getId() { - return id; - } - - public void setName(String name) { - this.name = name; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } - - @Override - public String toString() { - return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; - } -} +package com.baeldung.crud.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.validation.constraints.NotBlank; + +@Entity +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + @NotBlank(message = "Name is mandatory") + private String name; + + @NotBlank(message = "Email is mandatory") + private String email; + + public User() {} + + public User(String name, String email) { + this.name = name; + this.email = email; + } + + public void setId(long id) { + this.id = id; + } + + public long getId() { + return id; + } + + public void setName(String name) { + this.name = name; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getName() { + return name; + } + + public String getEmail() { + return email; + } + + @Override + public String toString() { + return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; + } +} diff --git a/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java similarity index 96% rename from spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java rename to spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java index 72348463f2..c17ebc56ba 100644 --- a/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/repositories/UserRepository.java @@ -1,13 +1,13 @@ -package com.baeldung.crud.repositories; - -import com.baeldung.crud.entities.User; -import java.util.List; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface UserRepository extends CrudRepository { - - List findByName(String name); - -} +package com.baeldung.crud.repositories; + +import com.baeldung.crud.entities.User; +import java.util.List; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface UserRepository extends CrudRepository { + + List findByName(String name); + +} diff --git a/spring-boot-crud/src/main/resources/css/shards.min.css b/spring-boot-modules/spring-boot-crud/src/main/resources/css/shards.min.css similarity index 100% rename from spring-boot-crud/src/main/resources/css/shards.min.css rename to spring-boot-modules/spring-boot-crud/src/main/resources/css/shards.min.css diff --git a/spring-boot-crud/src/main/resources/templates/add-user.html b/spring-boot-modules/spring-boot-crud/src/main/resources/templates/add-user.html similarity index 100% rename from spring-boot-crud/src/main/resources/templates/add-user.html rename to spring-boot-modules/spring-boot-crud/src/main/resources/templates/add-user.html diff --git a/spring-boot-crud/src/main/resources/templates/index.html b/spring-boot-modules/spring-boot-crud/src/main/resources/templates/index.html similarity index 100% rename from spring-boot-crud/src/main/resources/templates/index.html rename to spring-boot-modules/spring-boot-crud/src/main/resources/templates/index.html diff --git a/spring-boot-crud/src/main/resources/templates/update-user.html b/spring-boot-modules/spring-boot-crud/src/main/resources/templates/update-user.html similarity index 100% rename from spring-boot-crud/src/main/resources/templates/update-user.html rename to spring-boot-modules/spring-boot-crud/src/main/resources/templates/update-user.html diff --git a/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java similarity index 97% rename from spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java rename to spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java index 2de0828ae5..033108c195 100644 --- a/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java +++ b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java @@ -1,83 +1,83 @@ -package com.baeldung.crud; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.ui.Model; -import org.springframework.validation.BindingResult; - -import com.baeldung.crud.controllers.UserController; -import com.baeldung.crud.entities.User; -import com.baeldung.crud.repositories.UserRepository; - -public class UserControllerUnitTest { - - private static UserController userController; - private static UserRepository mockedUserRepository; - private static BindingResult mockedBindingResult; - private static Model mockedModel; - - @BeforeClass - public static void setUpUserControllerInstance() { - mockedUserRepository = mock(UserRepository.class); - mockedBindingResult = mock(BindingResult.class); - mockedModel = mock(Model.class); - userController = new UserController(mockedUserRepository); - } - - @Test - public void whenCalledshowSignUpForm_thenCorrect() { - User user = new User("John", "john@domain.com"); - - assertThat(userController.showSignUpForm(user)).isEqualTo("add-user"); - } - - @Test - public void whenCalledaddUserAndValidUser_thenCorrect() { - User user = new User("John", "john@domain.com"); - - when(mockedBindingResult.hasErrors()).thenReturn(false); - - assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("index"); - } - - @Test - public void whenCalledaddUserAndInValidUser_thenCorrect() { - User user = new User("John", "john@domain.com"); - - when(mockedBindingResult.hasErrors()).thenReturn(true); - - assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("add-user"); - } - - @Test(expected = IllegalArgumentException.class) - public void whenCalledshowUpdateForm_thenIllegalArgumentException() { - assertThat(userController.showUpdateForm(0, mockedModel)).isEqualTo("update-user"); - } - - @Test - public void whenCalledupdateUserAndValidUser_thenCorrect() { - User user = new User("John", "john@domain.com"); - - when(mockedBindingResult.hasErrors()).thenReturn(false); - - assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("index"); - } - - @Test - public void whenCalledupdateUserAndInValidUser_thenCorrect() { - User user = new User("John", "john@domain.com"); - - when(mockedBindingResult.hasErrors()).thenReturn(true); - - assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("update-user"); - } - - @Test(expected = IllegalArgumentException.class) - public void whenCalleddeleteUser_thenIllegalArgumentException() { - assertThat(userController.deleteUser(1l, mockedModel)).isEqualTo("index"); - } -} +package com.baeldung.crud; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; + +import com.baeldung.crud.controllers.UserController; +import com.baeldung.crud.entities.User; +import com.baeldung.crud.repositories.UserRepository; + +public class UserControllerUnitTest { + + private static UserController userController; + private static UserRepository mockedUserRepository; + private static BindingResult mockedBindingResult; + private static Model mockedModel; + + @BeforeClass + public static void setUpUserControllerInstance() { + mockedUserRepository = mock(UserRepository.class); + mockedBindingResult = mock(BindingResult.class); + mockedModel = mock(Model.class); + userController = new UserController(mockedUserRepository); + } + + @Test + public void whenCalledshowSignUpForm_thenCorrect() { + User user = new User("John", "john@domain.com"); + + assertThat(userController.showSignUpForm(user)).isEqualTo("add-user"); + } + + @Test + public void whenCalledaddUserAndValidUser_thenCorrect() { + User user = new User("John", "john@domain.com"); + + when(mockedBindingResult.hasErrors()).thenReturn(false); + + assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("index"); + } + + @Test + public void whenCalledaddUserAndInValidUser_thenCorrect() { + User user = new User("John", "john@domain.com"); + + when(mockedBindingResult.hasErrors()).thenReturn(true); + + assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("add-user"); + } + + @Test(expected = IllegalArgumentException.class) + public void whenCalledshowUpdateForm_thenIllegalArgumentException() { + assertThat(userController.showUpdateForm(0, mockedModel)).isEqualTo("update-user"); + } + + @Test + public void whenCalledupdateUserAndValidUser_thenCorrect() { + User user = new User("John", "john@domain.com"); + + when(mockedBindingResult.hasErrors()).thenReturn(false); + + assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("index"); + } + + @Test + public void whenCalledupdateUserAndInValidUser_thenCorrect() { + User user = new User("John", "john@domain.com"); + + when(mockedBindingResult.hasErrors()).thenReturn(true); + + assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("update-user"); + } + + @Test(expected = IllegalArgumentException.class) + public void whenCalleddeleteUser_thenIllegalArgumentException() { + assertThat(userController.deleteUser(1l, mockedModel)).isEqualTo("index"); + } +} diff --git a/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java similarity index 96% rename from spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java rename to spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java index 565f6727c3..3e33e868ad 100644 --- a/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java +++ b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserUnitTest.java @@ -1,48 +1,48 @@ -package com.baeldung.crud; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; - -import com.baeldung.crud.entities.User; - -public class UserUnitTest { - - @Test - public void whenCalledGetName_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - - assertThat(user.getName()).isEqualTo("Julie"); - } - - @Test - public void whenCalledGetEmail_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - - assertThat(user.getEmail()).isEqualTo("julie@domain.com"); - } - - @Test - public void whenCalledSetName_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - - user.setName("John"); - - assertThat(user.getName()).isEqualTo("John"); - } - - @Test - public void whenCalledSetEmail_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - - user.setEmail("john@domain.com"); - - assertThat(user.getEmail()).isEqualTo("john@domain.com"); - } - - @Test - public void whenCalledtoString_thenCorrect() { - User user = new User("Julie", "julie@domain.com"); - assertThat(user.toString()).isEqualTo("User{id=0, name=Julie, email=julie@domain.com}"); - } -} +package com.baeldung.crud; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +import com.baeldung.crud.entities.User; + +public class UserUnitTest { + + @Test + public void whenCalledGetName_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + + assertThat(user.getName()).isEqualTo("Julie"); + } + + @Test + public void whenCalledGetEmail_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + + assertThat(user.getEmail()).isEqualTo("julie@domain.com"); + } + + @Test + public void whenCalledSetName_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + + user.setName("John"); + + assertThat(user.getName()).isEqualTo("John"); + } + + @Test + public void whenCalledSetEmail_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + + user.setEmail("john@domain.com"); + + assertThat(user.getEmail()).isEqualTo("john@domain.com"); + } + + @Test + public void whenCalledtoString_thenCorrect() { + User user = new User("Julie", "julie@domain.com"); + assertThat(user.toString()).isEqualTo("User{id=0, name=Julie, email=julie@domain.com}"); + } +} diff --git a/spring-boot-ctx-fluent/README.md b/spring-boot-modules/spring-boot-ctx-fluent/README.md similarity index 100% rename from spring-boot-ctx-fluent/README.md rename to spring-boot-modules/spring-boot-ctx-fluent/README.md diff --git a/spring-boot-ctx-fluent/pom.xml b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml similarity index 93% rename from spring-boot-ctx-fluent/pom.xml rename to spring-boot-modules/spring-boot-ctx-fluent/pom.xml index 782e1fd7f6..872e15d307 100644 --- a/spring-boot-ctx-fluent/pom.xml +++ b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Config.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Config.java similarity index 100% rename from spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Config.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Config.java diff --git a/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Controller.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Controller.java similarity index 100% rename from spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Controller.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/Ctx1Controller.java diff --git a/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/GreetingService.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/GreetingService.java similarity index 100% rename from spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/GreetingService.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx1/GreetingService.java diff --git a/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Config.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Config.java similarity index 100% rename from spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Config.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Config.java diff --git a/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java similarity index 100% rename from spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/ctx2/Ctx2Controller.java diff --git a/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/App.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/App.java similarity index 100% rename from spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/App.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/App.java diff --git a/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/HomeService.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/HomeService.java similarity index 100% rename from spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/HomeService.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/HomeService.java diff --git a/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/IHomeService.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/IHomeService.java similarity index 100% rename from spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/IHomeService.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/IHomeService.java diff --git a/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/ParentConfig.java b/spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/ParentConfig.java similarity index 100% rename from spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/ParentConfig.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/java/com/baeldung/parent/ParentConfig.java diff --git a/spring-boot-ctx-fluent/src/main/resources/ctx1.properties b/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx1.properties similarity index 100% rename from spring-boot-ctx-fluent/src/main/resources/ctx1.properties rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx1.properties diff --git a/spring-boot-ctx-fluent/src/main/resources/ctx2.properties b/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx2.properties similarity index 100% rename from spring-boot-ctx-fluent/src/main/resources/ctx2.properties rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/ctx2.properties diff --git a/spring-boot-autoconfiguration/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/logback.xml similarity index 100% rename from spring-boot-autoconfiguration/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-ctx-fluent/src/main/resources/logback.xml diff --git a/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-custom-starter/README.md b/spring-boot-modules/spring-boot-custom-starter/README.md similarity index 100% rename from spring-boot-custom-starter/README.md rename to spring-boot-modules/spring-boot-custom-starter/README.md diff --git a/spring-boot-custom-starter/greeter-library/README.md b/spring-boot-modules/spring-boot-custom-starter/greeter-library/README.md similarity index 100% rename from spring-boot-custom-starter/greeter-library/README.md rename to spring-boot-modules/spring-boot-custom-starter/greeter-library/README.md diff --git a/spring-boot-custom-starter/greeter-library/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-library/pom.xml similarity index 83% rename from spring-boot-custom-starter/greeter-library/pom.xml rename to spring-boot-modules/spring-boot-custom-starter/greeter-library/pom.xml index da30f2e4be..34cc530f2f 100644 --- a/spring-boot-custom-starter/greeter-library/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-library/pom.xml @@ -7,10 +7,9 @@ greeter-library - com.baeldung + com.baeldung.spring-boot-modules spring-boot-custom-starter 0.0.1-SNAPSHOT - ../../spring-boot-custom-starter \ No newline at end of file diff --git a/spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/Greeter.java b/spring-boot-modules/spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/Greeter.java similarity index 100% rename from spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/Greeter.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/Greeter.java diff --git a/spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/GreeterConfigParams.java b/spring-boot-modules/spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/GreeterConfigParams.java similarity index 100% rename from spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/GreeterConfigParams.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/GreeterConfigParams.java diff --git a/spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/GreetingConfig.java b/spring-boot-modules/spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/GreetingConfig.java similarity index 100% rename from spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/GreetingConfig.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-library/src/main/java/com/baeldung/greeter/library/GreetingConfig.java diff --git a/spring-boot-bootstrap/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-library/src/main/resources/logback.xml similarity index 100% rename from spring-boot-bootstrap/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-custom-starter/greeter-library/src/main/resources/logback.xml diff --git a/spring-boot-custom-starter/greeter-library/src/test/java/com/baeldung/greeter/GreeterIntegrationTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-library/src/test/java/com/baeldung/greeter/GreeterIntegrationTest.java similarity index 100% rename from spring-boot-custom-starter/greeter-library/src/test/java/com/baeldung/greeter/GreeterIntegrationTest.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-library/src/test/java/com/baeldung/greeter/GreeterIntegrationTest.java diff --git a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml similarity index 94% rename from spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml index 58dd683131..0bba2936a7 100644 --- a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml @@ -7,10 +7,9 @@ greeter-spring-boot-autoconfigure - com.baeldung + com.baeldung.spring-boot-modules spring-boot-custom-starter 0.0.1-SNAPSHOT - ../../spring-boot-custom-starter @@ -34,7 +33,7 @@ - com.baeldung + com.baeldung.spring-boot-modules greeter-library ${greeter.version} true diff --git a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/java/com/baeldung/greeter/autoconfigure/GreeterAutoConfiguration.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/java/com/baeldung/greeter/autoconfigure/GreeterAutoConfiguration.java similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/java/com/baeldung/greeter/autoconfigure/GreeterAutoConfiguration.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/java/com/baeldung/greeter/autoconfigure/GreeterAutoConfiguration.java diff --git a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/java/com/baeldung/greeter/autoconfigure/GreeterProperties.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/java/com/baeldung/greeter/autoconfigure/GreeterProperties.java similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/java/com/baeldung/greeter/autoconfigure/GreeterProperties.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/java/com/baeldung/greeter/autoconfigure/GreeterProperties.java diff --git a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories diff --git a/spring-boot-ctx-fluent/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/resources/logback.xml similarity index 100% rename from spring-boot-ctx-fluent/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/resources/logback.xml diff --git a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml similarity index 91% rename from spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml index bb1e656963..818ce5c107 100644 --- a/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml @@ -10,12 +10,12 @@ com.baeldung parent-boot-1 0.0.1-SNAPSHOT - ../../spring-boot-custom-starter + ../../../parent-boot-1 - com.baeldung + com.baeldung.spring-boot-modules greeter-spring-boot-starter ${greeter-starter.version} diff --git a/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/java/com/baeldung/greeter/sample/GreeterSampleApplication.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/java/com/baeldung/greeter/sample/GreeterSampleApplication.java similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/java/com/baeldung/greeter/sample/GreeterSampleApplication.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/java/com/baeldung/greeter/sample/GreeterSampleApplication.java diff --git a/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/resources/application.properties b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/resources/application.properties similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/resources/application.properties diff --git a/spring-boot-custom-starter/greeter-library/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/resources/logback.xml similarity index 100% rename from spring-boot-custom-starter/greeter-library/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/resources/logback.xml diff --git a/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/com/baeldung/greeter/sample/GreeterSampleApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/com/baeldung/greeter/sample/GreeterSampleApplicationIntegrationTest.java similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/com/baeldung/greeter/sample/GreeterSampleApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/com/baeldung/greeter/sample/GreeterSampleApplicationIntegrationTest.java diff --git a/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml similarity index 90% rename from spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml index d298756b8e..ba2b4101e8 100644 --- a/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml @@ -7,10 +7,9 @@ greeter-spring-boot-starter - com.baeldung + com.baeldung.spring-boot-modules spring-boot-custom-starter 0.0.1-SNAPSHOT - ../../spring-boot-custom-starter @@ -22,13 +21,13 @@ - com.baeldung + com.baeldung.spring-boot-modules greeter-spring-boot-autoconfigure ${project.version} - com.baeldung + com.baeldung.spring-boot-modules greeter-library ${greeter.version} diff --git a/spring-boot-custom-starter/greeter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml similarity index 90% rename from spring-boot-custom-starter/greeter/pom.xml rename to spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml index 3117cfa355..89119e2e99 100644 --- a/spring-boot-custom-starter/greeter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-boot-1 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../../parent-boot-1 \ No newline at end of file diff --git a/spring-boot-custom-starter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/pom.xml similarity index 87% rename from spring-boot-custom-starter/pom.xml rename to spring-boot-modules/spring-boot-custom-starter/pom.xml index 96c0d0a585..596b993f81 100644 --- a/spring-boot-custom-starter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/pom.xml @@ -8,8 +8,8 @@ pom - com.baeldung - parent-modules + com.baeldung.spring-boot-modules + spring-boot-modules 1.0.0-SNAPSHOT diff --git a/spring-boot-data/README.md b/spring-boot-modules/spring-boot-data/README.md similarity index 100% rename from spring-boot-data/README.md rename to spring-boot-modules/spring-boot-data/README.md diff --git a/spring-boot-data/pom.xml b/spring-boot-modules/spring-boot-data/pom.xml similarity index 92% rename from spring-boot-data/pom.xml rename to spring-boot-modules/spring-boot-data/pom.xml index 663ee640f3..f25b4ee472 100644 --- a/spring-boot-data/pom.xml +++ b/spring-boot-modules/spring-boot-data/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 @@ -97,8 +97,8 @@ org.apache.maven.plugins maven-compiler-plugin - 8 - 8 + ${source.version} + ${target.version} @@ -121,8 +121,8 @@ org.apache.maven.plugins maven-compiler-plugin - 8 - 8 + ${source.version} + ${target.version} @@ -156,8 +156,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -168,6 +168,8 @@ 5.6.3 2.2.4 + 1.8 + 1.8 diff --git a/spring-boot-data/src/main/java/com/baeldung/SpringBootDataApplication.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/SpringBootDataApplication.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/SpringBootDataApplication.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/SpringBootDataApplication.java diff --git a/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataJPA.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataJPA.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataJPA.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataJPA.java diff --git a/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataMongoDB.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataMongoDB.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataMongoDB.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataMongoDB.java diff --git a/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataRedis.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataRedis.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataRedis.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataRedis.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/README.md b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/README.md similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/README.md rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/README.md diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/SpringBootJaVersApplication.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/SpringBootJaVersApplication.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/SpringBootJaVersApplication.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/SpringBootJaVersApplication.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/config/JaversConfiguration.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/config/JaversConfiguration.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/config/JaversConfiguration.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/config/JaversConfiguration.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/domain/Address.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/domain/Address.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/domain/Address.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/domain/Address.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/domain/Product.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/domain/Product.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/domain/Product.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/domain/Product.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/domain/Store.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/domain/Store.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/domain/Store.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/domain/Store.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/repo/ProductRepository.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/repo/ProductRepository.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/repo/ProductRepository.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/repo/ProductRepository.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/repo/StoreRepository.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/repo/StoreRepository.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/repo/StoreRepository.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/repo/StoreRepository.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/service/StoreService.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/service/StoreService.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/service/StoreService.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/service/StoreService.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/web/RebrandStoreDto.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/web/RebrandStoreDto.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/web/RebrandStoreDto.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/web/RebrandStoreDto.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/web/StoreController.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/web/StoreController.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/web/StoreController.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/web/StoreController.java diff --git a/spring-boot-data/src/main/java/com/baeldung/javers/web/UpdatePriceDto.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/web/UpdatePriceDto.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/javers/web/UpdatePriceDto.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/web/UpdatePriceDto.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsondateformat/Contact.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/Contact.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsondateformat/Contact.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/Contact.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactApp.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactApp.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactApp.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactApp.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactAppConfig.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactAppConfig.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactAppConfig.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactAppConfig.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactController.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactController.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactController.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactController.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactWithJavaUtilDate.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactWithJavaUtilDate.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactWithJavaUtilDate.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/ContactWithJavaUtilDate.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsondateformat/PlainContact.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/PlainContact.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsondateformat/PlainContact.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/PlainContact.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsondateformat/PlainContactWithJavaUtilDate.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/PlainContactWithJavaUtilDate.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsondateformat/PlainContactWithJavaUtilDate.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsondateformat/PlainContactWithJavaUtilDate.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsonexception/CustomException.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsonexception/CustomException.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsonexception/CustomException.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsonexception/CustomException.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsonexception/ErrorHandler.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsonexception/ErrorHandler.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsonexception/ErrorHandler.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsonexception/ErrorHandler.java diff --git a/spring-boot-data/src/main/java/com/baeldung/jsonexception/MainController.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsonexception/MainController.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/jsonexception/MainController.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/jsonexception/MainController.java diff --git a/spring-boot-data/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/PropertyEditorApplication.java diff --git a/spring-boot-data/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/PropertyEditorRestController.java diff --git a/spring-boot-data/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCard.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCard.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCard.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCard.java diff --git a/spring-boot-data/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCardEditor.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCardEditor.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCardEditor.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/creditcard/CreditCardEditor.java diff --git a/spring-boot-data/src/main/java/com/baeldung/propertyeditor/exotictype/editor/CustomExoticTypeEditor.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/exotictype/editor/CustomExoticTypeEditor.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/propertyeditor/exotictype/editor/CustomExoticTypeEditor.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/exotictype/editor/CustomExoticTypeEditor.java diff --git a/spring-boot-data/src/main/java/com/baeldung/propertyeditor/exotictype/model/ExoticType.java b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/exotictype/model/ExoticType.java similarity index 100% rename from spring-boot-data/src/main/java/com/baeldung/propertyeditor/exotictype/model/ExoticType.java rename to spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/propertyeditor/exotictype/model/ExoticType.java diff --git a/spring-boot-data/src/main/resources/application.properties b/spring-boot-modules/spring-boot-data/src/main/resources/application.properties similarity index 100% rename from spring-boot-data/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-data/src/main/resources/application.properties diff --git a/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataJPAIntegrationTest.java b/spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataJPAIntegrationTest.java similarity index 100% rename from spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataJPAIntegrationTest.java rename to spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataJPAIntegrationTest.java diff --git a/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataMongoDBIntegrationTest.java b/spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataMongoDBIntegrationTest.java similarity index 100% rename from spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataMongoDBIntegrationTest.java rename to spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataMongoDBIntegrationTest.java diff --git a/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataRedisIntegrationTest.java b/spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataRedisIntegrationTest.java similarity index 100% rename from spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataRedisIntegrationTest.java rename to spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataRedisIntegrationTest.java diff --git a/spring-boot-data/src/test/java/com/baeldung/jsondateformat/ContactAppIntegrationTest.java b/spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/jsondateformat/ContactAppIntegrationTest.java similarity index 100% rename from spring-boot-data/src/test/java/com/baeldung/jsondateformat/ContactAppIntegrationTest.java rename to spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/jsondateformat/ContactAppIntegrationTest.java diff --git a/spring-boot-data/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerIntegrationTest.java b/spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerIntegrationTest.java similarity index 100% rename from spring-boot-data/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerIntegrationTest.java rename to spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerIntegrationTest.java diff --git a/spring-boot-data/src/test/java/com/baeldung/jsonexception/MainControllerIntegrationTest.java b/spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/jsonexception/MainControllerIntegrationTest.java similarity index 100% rename from spring-boot-data/src/test/java/com/baeldung/jsonexception/MainControllerIntegrationTest.java rename to spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/jsonexception/MainControllerIntegrationTest.java diff --git a/spring-boot-data/src/test/java/com/baeldung/propertyeditor/creditcard/CreditCardEditorUnitTest.java b/spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/propertyeditor/creditcard/CreditCardEditorUnitTest.java similarity index 100% rename from spring-boot-data/src/test/java/com/baeldung/propertyeditor/creditcard/CreditCardEditorUnitTest.java rename to spring-boot-modules/spring-boot-data/src/test/java/com/baeldung/propertyeditor/creditcard/CreditCardEditorUnitTest.java diff --git a/spring-boot-data/src/test/resources/application.properties b/spring-boot-modules/spring-boot-data/src/test/resources/application.properties similarity index 100% rename from spring-boot-data/src/test/resources/application.properties rename to spring-boot-modules/spring-boot-data/src/test/resources/application.properties diff --git a/spring-boot-deployment/README.md b/spring-boot-modules/spring-boot-deployment/README.md similarity index 100% rename from spring-boot-deployment/README.md rename to spring-boot-modules/spring-boot-deployment/README.md diff --git a/spring-boot-deployment/pom.xml b/spring-boot-modules/spring-boot-deployment/pom.xml similarity index 99% rename from spring-boot-deployment/pom.xml rename to spring-boot-modules/spring-boot-deployment/pom.xml index 6f724f312b..64c0e698f6 100644 --- a/spring-boot-deployment/pom.xml +++ b/spring-boot-modules/spring-boot-deployment/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-deployment/src/main/java/com/baeldung/compare/ComparisonApplication.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/compare/ComparisonApplication.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/compare/ComparisonApplication.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/compare/ComparisonApplication.java diff --git a/spring-boot-deployment/src/main/java/com/baeldung/compare/StartupEventHandler.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/compare/StartupEventHandler.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/compare/StartupEventHandler.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/compare/StartupEventHandler.java diff --git a/spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/GracefulShutdownApplication.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/GracefulShutdownApplication.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/GracefulShutdownApplication.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/GracefulShutdownApplication.java diff --git a/spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/beans/LongRunningProcessBean.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/beans/LongRunningProcessBean.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/beans/LongRunningProcessBean.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/beans/LongRunningProcessBean.java diff --git a/spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/config/SpringConfiguration.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/config/SpringConfiguration.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/config/SpringConfiguration.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/gracefulshutdown/config/SpringConfiguration.java diff --git a/spring-boot-deployment/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootconfiguration/SpringBootConfigurationApplication.java diff --git a/spring-boot-deployment/src/main/java/com/baeldung/springbootconfiguration/controller/GreetingsController.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootconfiguration/controller/GreetingsController.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/springbootconfiguration/controller/GreetingsController.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootconfiguration/controller/GreetingsController.java diff --git a/spring-boot-deployment/src/main/java/com/baeldung/springbootnonwebapp/SpringBootConsoleApplication.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootnonwebapp/SpringBootConsoleApplication.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/springbootnonwebapp/SpringBootConsoleApplication.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootnonwebapp/SpringBootConsoleApplication.java diff --git a/spring-boot-deployment/src/main/java/com/baeldung/springbootsimple/SpringBootTomcatApplication.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootsimple/SpringBootTomcatApplication.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/springbootsimple/SpringBootTomcatApplication.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootsimple/SpringBootTomcatApplication.java diff --git a/spring-boot-deployment/src/main/java/com/baeldung/springbootsimple/TomcatController.java b/spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootsimple/TomcatController.java similarity index 100% rename from spring-boot-deployment/src/main/java/com/baeldung/springbootsimple/TomcatController.java rename to spring-boot-modules/spring-boot-deployment/src/main/java/com/baeldung/springbootsimple/TomcatController.java diff --git a/spring-boot-deployment/src/main/resources/application.properties b/spring-boot-modules/spring-boot-deployment/src/main/resources/application.properties similarity index 100% rename from spring-boot-deployment/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-deployment/src/main/resources/application.properties diff --git a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-deployment/src/main/resources/logback.xml similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-deployment/src/main/resources/logback.xml diff --git a/spring-boot-deployment/src/test/java/com/baeldung/springbootconfiguration/SpringContextTest.java b/spring-boot-modules/spring-boot-deployment/src/test/java/com/baeldung/springbootconfiguration/SpringContextTest.java similarity index 100% rename from spring-boot-deployment/src/test/java/com/baeldung/springbootconfiguration/SpringContextTest.java rename to spring-boot-modules/spring-boot-deployment/src/test/java/com/baeldung/springbootconfiguration/SpringContextTest.java diff --git a/spring-boot-deployment/src/test/java/com/baeldung/springbootsimple/SpringBootTomcatApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-deployment/src/test/java/com/baeldung/springbootsimple/SpringBootTomcatApplicationIntegrationTest.java similarity index 100% rename from spring-boot-deployment/src/test/java/com/baeldung/springbootsimple/SpringBootTomcatApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot-deployment/src/test/java/com/baeldung/springbootsimple/SpringBootTomcatApplicationIntegrationTest.java diff --git a/spring-boot-environment/README.md b/spring-boot-modules/spring-boot-environment/README.md similarity index 100% rename from spring-boot-environment/README.md rename to spring-boot-modules/spring-boot-environment/README.md diff --git a/spring-boot-environment/pom.xml b/spring-boot-modules/spring-boot-environment/pom.xml similarity index 98% rename from spring-boot-environment/pom.xml rename to spring-boot-modules/spring-boot-environment/pom.xml index 531ef697d7..138c59847d 100644 --- a/spring-boot-environment/pom.xml +++ b/spring-boot-modules/spring-boot-environment/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/PriceCalculationApplication.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/PriceCalculationApplication.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/PriceCalculationApplication.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/PriceCalculationApplication.java diff --git a/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/PriceCalculationEnvironmentPostProcessor.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/PriceCalculationEnvironmentPostProcessor.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/PriceCalculationEnvironmentPostProcessor.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/PriceCalculationEnvironmentPostProcessor.java diff --git a/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/autoconfig/PriceCalculationAutoConfig.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/autoconfig/PriceCalculationAutoConfig.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/autoconfig/PriceCalculationAutoConfig.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/autoconfig/PriceCalculationAutoConfig.java diff --git a/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/GrossPriceCalculator.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/GrossPriceCalculator.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/GrossPriceCalculator.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/GrossPriceCalculator.java diff --git a/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/NetPriceCalculator.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/NetPriceCalculator.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/NetPriceCalculator.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/NetPriceCalculator.java diff --git a/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/PriceCalculator.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/PriceCalculator.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/PriceCalculator.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/calculator/PriceCalculator.java diff --git a/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/service/PriceCalculationService.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/service/PriceCalculationService.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/service/PriceCalculationService.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/environmentpostprocessor/service/PriceCalculationService.java diff --git a/spring-boot-environment/src/main/java/com/baeldung/properties/ConfProperties.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/properties/ConfProperties.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/properties/ConfProperties.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/properties/ConfProperties.java diff --git a/spring-boot-environment/src/main/java/com/baeldung/properties/ExternalPropertyConfigurer.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/properties/ExternalPropertyConfigurer.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/properties/ExternalPropertyConfigurer.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/properties/ExternalPropertyConfigurer.java diff --git a/spring-boot-environment/src/main/java/com/baeldung/properties/ExternalPropertyFileLoader.java b/spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/properties/ExternalPropertyFileLoader.java similarity index 100% rename from spring-boot-environment/src/main/java/com/baeldung/properties/ExternalPropertyFileLoader.java rename to spring-boot-modules/spring-boot-environment/src/main/java/com/baeldung/properties/ExternalPropertyFileLoader.java diff --git a/spring-boot-environment/src/main/resources/META-INF/spring.factories b/spring-boot-modules/spring-boot-environment/src/main/resources/META-INF/spring.factories similarity index 100% rename from spring-boot-environment/src/main/resources/META-INF/spring.factories rename to spring-boot-modules/spring-boot-environment/src/main/resources/META-INF/spring.factories diff --git a/spring-boot-environment/src/main/resources/application.properties b/spring-boot-modules/spring-boot-environment/src/main/resources/application.properties similarity index 100% rename from spring-boot-environment/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-environment/src/main/resources/application.properties diff --git a/spring-boot-environment/src/main/resources/external/conf.properties b/spring-boot-modules/spring-boot-environment/src/main/resources/external/conf.properties similarity index 100% rename from spring-boot-environment/src/main/resources/external/conf.properties rename to spring-boot-modules/spring-boot-environment/src/main/resources/external/conf.properties diff --git a/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-environment/src/main/resources/logback.xml similarity index 100% rename from spring-boot-custom-starter/greeter-spring-boot-sample-app/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-environment/src/main/resources/logback.xml diff --git a/spring-boot-environment/src/test/java/com/baeldung/environmentpostprocessor/PriceCalculationEnvironmentPostProcessorLiveTest.java b/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/environmentpostprocessor/PriceCalculationEnvironmentPostProcessorLiveTest.java similarity index 100% rename from spring-boot-environment/src/test/java/com/baeldung/environmentpostprocessor/PriceCalculationEnvironmentPostProcessorLiveTest.java rename to spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/environmentpostprocessor/PriceCalculationEnvironmentPostProcessorLiveTest.java diff --git a/spring-boot-environment/src/test/java/com/baeldung/properties/ExternalPropertyFileLoaderIntegrationTest.java b/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/properties/ExternalPropertyFileLoaderIntegrationTest.java similarity index 100% rename from spring-boot-environment/src/test/java/com/baeldung/properties/ExternalPropertyFileLoaderIntegrationTest.java rename to spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/properties/ExternalPropertyFileLoaderIntegrationTest.java diff --git a/spring-boot-flowable/README.md b/spring-boot-modules/spring-boot-flowable/README.md similarity index 100% rename from spring-boot-flowable/README.md rename to spring-boot-modules/spring-boot-flowable/README.md diff --git a/spring-boot-flowable/pom.xml b/spring-boot-modules/spring-boot-flowable/pom.xml similarity index 97% rename from spring-boot-flowable/pom.xml rename to spring-boot-modules/spring-boot-flowable/pom.xml index 96558b8595..7d9fb97cba 100644 --- a/spring-boot-flowable/pom.xml +++ b/spring-boot-modules/spring-boot-flowable/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-flowable/src/main/java/com/baeldung/Application.java b/spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/Application.java similarity index 100% rename from spring-boot-flowable/src/main/java/com/baeldung/Application.java rename to spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/Application.java diff --git a/spring-boot-flowable/src/main/java/com/baeldung/controller/ArticleWorkflowController.java b/spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/controller/ArticleWorkflowController.java similarity index 100% rename from spring-boot-flowable/src/main/java/com/baeldung/controller/ArticleWorkflowController.java rename to spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/controller/ArticleWorkflowController.java diff --git a/spring-boot-flowable/src/main/java/com/baeldung/domain/Approval.java b/spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/domain/Approval.java similarity index 100% rename from spring-boot-flowable/src/main/java/com/baeldung/domain/Approval.java rename to spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/domain/Approval.java diff --git a/spring-boot-flowable/src/main/java/com/baeldung/domain/Article.java b/spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/domain/Article.java similarity index 100% rename from spring-boot-flowable/src/main/java/com/baeldung/domain/Article.java rename to spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/domain/Article.java diff --git a/spring-boot-flowable/src/main/java/com/baeldung/service/ArticleWorkflowService.java b/spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/service/ArticleWorkflowService.java similarity index 100% rename from spring-boot-flowable/src/main/java/com/baeldung/service/ArticleWorkflowService.java rename to spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/service/ArticleWorkflowService.java diff --git a/spring-boot-flowable/src/main/java/com/baeldung/service/PublishArticleService.java b/spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/service/PublishArticleService.java similarity index 100% rename from spring-boot-flowable/src/main/java/com/baeldung/service/PublishArticleService.java rename to spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/service/PublishArticleService.java diff --git a/spring-boot-flowable/src/main/java/com/baeldung/service/SendMailService.java b/spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/service/SendMailService.java similarity index 100% rename from spring-boot-flowable/src/main/java/com/baeldung/service/SendMailService.java rename to spring-boot-modules/spring-boot-flowable/src/main/java/com/baeldung/service/SendMailService.java diff --git a/spring-boot-flowable/src/main/resources/application.properties b/spring-boot-modules/spring-boot-flowable/src/main/resources/application.properties similarity index 100% rename from spring-boot-flowable/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-flowable/src/main/resources/application.properties diff --git a/spring-boot-flowable/src/main/resources/processes/article-workflow.bpmn20.xml b/spring-boot-modules/spring-boot-flowable/src/main/resources/processes/article-workflow.bpmn20.xml similarity index 100% rename from spring-boot-flowable/src/main/resources/processes/article-workflow.bpmn20.xml rename to spring-boot-modules/spring-boot-flowable/src/main/resources/processes/article-workflow.bpmn20.xml diff --git a/spring-boot-flowable/src/test/java/com/baeldung/processes/ArticleWorkflowIntegrationTest.java b/spring-boot-modules/spring-boot-flowable/src/test/java/com/baeldung/processes/ArticleWorkflowIntegrationTest.java similarity index 100% rename from spring-boot-flowable/src/test/java/com/baeldung/processes/ArticleWorkflowIntegrationTest.java rename to spring-boot-modules/spring-boot-flowable/src/test/java/com/baeldung/processes/ArticleWorkflowIntegrationTest.java diff --git a/spring-boot-gradle/.gitignore b/spring-boot-modules/spring-boot-gradle/.gitignore similarity index 100% rename from spring-boot-gradle/.gitignore rename to spring-boot-modules/spring-boot-gradle/.gitignore diff --git a/spring-boot-gradle/README.md b/spring-boot-modules/spring-boot-gradle/README.md similarity index 100% rename from spring-boot-gradle/README.md rename to spring-boot-modules/spring-boot-gradle/README.md diff --git a/spring-boot-gradle/build.gradle b/spring-boot-modules/spring-boot-gradle/build.gradle similarity index 100% rename from spring-boot-gradle/build.gradle rename to spring-boot-modules/spring-boot-gradle/build.gradle diff --git a/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties b/spring-boot-modules/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties rename to spring-boot-modules/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties diff --git a/spring-boot-gradle/gradlew b/spring-boot-modules/spring-boot-gradle/gradlew similarity index 100% rename from spring-boot-gradle/gradlew rename to spring-boot-modules/spring-boot-gradle/gradlew diff --git a/core-kotlin/gradlew.bat b/spring-boot-modules/spring-boot-gradle/gradlew.bat old mode 100755 new mode 100644 similarity index 96% rename from core-kotlin/gradlew.bat rename to spring-boot-modules/spring-boot-gradle/gradlew.bat index e95643d6a2..f9553162f1 --- a/core-kotlin/gradlew.bat +++ b/spring-boot-modules/spring-boot-gradle/gradlew.bat @@ -1,84 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/spring-boot-gradle/settings.gradle b/spring-boot-modules/spring-boot-gradle/settings.gradle similarity index 100% rename from spring-boot-gradle/settings.gradle rename to spring-boot-modules/spring-boot-gradle/settings.gradle diff --git a/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java b/spring-boot-modules/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java similarity index 100% rename from spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java rename to spring-boot-modules/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java diff --git a/spring-boot-gradle/src/main/resources/application.properties b/spring-boot-modules/spring-boot-gradle/src/main/resources/application.properties similarity index 100% rename from spring-boot-gradle/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-gradle/src/main/resources/application.properties diff --git a/spring-boot-deployment/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-gradle/src/main/resources/logback.xml similarity index 100% rename from spring-boot-deployment/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-gradle/src/main/resources/logback.xml diff --git a/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java b/spring-boot-modules/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java similarity index 100% rename from spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java rename to spring-boot-modules/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java diff --git a/spring-boot-jasypt/.gitignore b/spring-boot-modules/spring-boot-jasypt/.gitignore similarity index 100% rename from spring-boot-jasypt/.gitignore rename to spring-boot-modules/spring-boot-jasypt/.gitignore diff --git a/spring-boot-jasypt/README.md b/spring-boot-modules/spring-boot-jasypt/README.md similarity index 100% rename from spring-boot-jasypt/README.md rename to spring-boot-modules/spring-boot-jasypt/README.md diff --git a/spring-boot-jasypt/pom.xml b/spring-boot-modules/spring-boot-jasypt/pom.xml similarity index 96% rename from spring-boot-jasypt/pom.xml rename to spring-boot-modules/spring-boot-jasypt/pom.xml index 76a501c455..e63a02729f 100644 --- a/spring-boot-jasypt/pom.xml +++ b/spring-boot-modules/spring-boot-jasypt/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/Main.java b/spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/Main.java similarity index 100% rename from spring-boot-jasypt/src/main/java/com/baeldung/jasypt/Main.java rename to spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/Main.java diff --git a/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/simple/AppConfigForJasyptSimple.java b/spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/simple/AppConfigForJasyptSimple.java similarity index 100% rename from spring-boot-jasypt/src/main/java/com/baeldung/jasypt/simple/AppConfigForJasyptSimple.java rename to spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/simple/AppConfigForJasyptSimple.java diff --git a/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/simple/PropertyServiceForJasyptSimple.java b/spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/simple/PropertyServiceForJasyptSimple.java similarity index 100% rename from spring-boot-jasypt/src/main/java/com/baeldung/jasypt/simple/PropertyServiceForJasyptSimple.java rename to spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/simple/PropertyServiceForJasyptSimple.java diff --git a/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/starter/AppConfigForJasyptStarter.java b/spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/starter/AppConfigForJasyptStarter.java similarity index 100% rename from spring-boot-jasypt/src/main/java/com/baeldung/jasypt/starter/AppConfigForJasyptStarter.java rename to spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/starter/AppConfigForJasyptStarter.java diff --git a/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/starter/PropertyServiceForJasyptStarter.java b/spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/starter/PropertyServiceForJasyptStarter.java similarity index 100% rename from spring-boot-jasypt/src/main/java/com/baeldung/jasypt/starter/PropertyServiceForJasyptStarter.java rename to spring-boot-modules/spring-boot-jasypt/src/main/java/com/baeldung/jasypt/starter/PropertyServiceForJasyptStarter.java diff --git a/spring-boot-jasypt/src/main/resources/application.properties b/spring-boot-modules/spring-boot-jasypt/src/main/resources/application.properties similarity index 100% rename from spring-boot-jasypt/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-jasypt/src/main/resources/application.properties diff --git a/spring-boot-jasypt/src/main/resources/encrypted.properties b/spring-boot-modules/spring-boot-jasypt/src/main/resources/encrypted.properties similarity index 100% rename from spring-boot-jasypt/src/main/resources/encrypted.properties rename to spring-boot-modules/spring-boot-jasypt/src/main/resources/encrypted.properties diff --git a/spring-boot-jasypt/src/main/resources/encryptedv2.properties b/spring-boot-modules/spring-boot-jasypt/src/main/resources/encryptedv2.properties similarity index 100% rename from spring-boot-jasypt/src/main/resources/encryptedv2.properties rename to spring-boot-modules/spring-boot-jasypt/src/main/resources/encryptedv2.properties diff --git a/spring-boot-environment/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-jasypt/src/main/resources/logback.xml similarity index 100% rename from spring-boot-environment/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-jasypt/src/main/resources/logback.xml diff --git a/spring-boot-jasypt/src/test/java/com/baeldung/jasypt/CustomJasyptIntegrationTest.java b/spring-boot-modules/spring-boot-jasypt/src/test/java/com/baeldung/jasypt/CustomJasyptIntegrationTest.java similarity index 100% rename from spring-boot-jasypt/src/test/java/com/baeldung/jasypt/CustomJasyptIntegrationTest.java rename to spring-boot-modules/spring-boot-jasypt/src/test/java/com/baeldung/jasypt/CustomJasyptIntegrationTest.java diff --git a/spring-boot-jasypt/src/test/java/com/baeldung/jasypt/JasyptSimpleIntegrationTest.java b/spring-boot-modules/spring-boot-jasypt/src/test/java/com/baeldung/jasypt/JasyptSimpleIntegrationTest.java similarity index 100% rename from spring-boot-jasypt/src/test/java/com/baeldung/jasypt/JasyptSimpleIntegrationTest.java rename to spring-boot-modules/spring-boot-jasypt/src/test/java/com/baeldung/jasypt/JasyptSimpleIntegrationTest.java diff --git a/spring-boot-jasypt/src/test/java/com/baeldung/jasypt/JasyptWithStarterIntegrationTest.java b/spring-boot-modules/spring-boot-jasypt/src/test/java/com/baeldung/jasypt/JasyptWithStarterIntegrationTest.java similarity index 100% rename from spring-boot-jasypt/src/test/java/com/baeldung/jasypt/JasyptWithStarterIntegrationTest.java rename to spring-boot-modules/spring-boot-jasypt/src/test/java/com/baeldung/jasypt/JasyptWithStarterIntegrationTest.java diff --git a/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-keycloak/.gitignore b/spring-boot-modules/spring-boot-keycloak/.gitignore similarity index 100% rename from spring-boot-keycloak/.gitignore rename to spring-boot-modules/spring-boot-keycloak/.gitignore diff --git a/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.jar b/spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.jar similarity index 100% rename from spring-boot-keycloak/.mvn/wrapper/maven-wrapper.jar rename to spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.jar diff --git a/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties b/spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties rename to spring-boot-modules/spring-boot-keycloak/.mvn/wrapper/maven-wrapper.properties diff --git a/spring-boot-keycloak/README.md b/spring-boot-modules/spring-boot-keycloak/README.md similarity index 100% rename from spring-boot-keycloak/README.md rename to spring-boot-modules/spring-boot-keycloak/README.md diff --git a/spring-boot-keycloak/mvnw b/spring-boot-modules/spring-boot-keycloak/mvnw similarity index 100% rename from spring-boot-keycloak/mvnw rename to spring-boot-modules/spring-boot-keycloak/mvnw diff --git a/spring-boot-keycloak/mvnw.cmd b/spring-boot-modules/spring-boot-keycloak/mvnw.cmd similarity index 100% rename from spring-boot-keycloak/mvnw.cmd rename to spring-boot-modules/spring-boot-keycloak/mvnw.cmd diff --git a/spring-boot-keycloak/pom.xml b/spring-boot-modules/spring-boot-keycloak/pom.xml similarity index 98% rename from spring-boot-keycloak/pom.xml rename to spring-boot-modules/spring-boot-keycloak/pom.xml index 609b4d1dec..c29c1a738b 100644 --- a/spring-boot-keycloak/pom.xml +++ b/spring-boot-modules/spring-boot-keycloak/pom.xml @@ -13,7 +13,7 @@ com.baeldung parent-boot-1 0.0.1-SNAPSHOT - ../parent-boot-1 + ../../parent-boot-1 diff --git a/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/Customer.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/Customer.java similarity index 100% rename from spring-boot-keycloak/src/main/java/com/baeldung/keycloak/Customer.java rename to spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/Customer.java diff --git a/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/CustomerDAO.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/CustomerDAO.java similarity index 100% rename from spring-boot-keycloak/src/main/java/com/baeldung/keycloak/CustomerDAO.java rename to spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/CustomerDAO.java diff --git a/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java similarity index 100% rename from spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java rename to spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SecurityConfig.java diff --git a/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SpringBoot.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SpringBoot.java similarity index 100% rename from spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SpringBoot.java rename to spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/SpringBoot.java diff --git a/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/WebController.java b/spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/WebController.java similarity index 100% rename from spring-boot-keycloak/src/main/java/com/baeldung/keycloak/WebController.java rename to spring-boot-modules/spring-boot-keycloak/src/main/java/com/baeldung/keycloak/WebController.java diff --git a/spring-boot-keycloak/src/main/resources/application.properties b/spring-boot-modules/spring-boot-keycloak/src/main/resources/application.properties similarity index 100% rename from spring-boot-keycloak/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-keycloak/src/main/resources/application.properties diff --git a/spring-boot-gradle/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-keycloak/src/main/resources/logback.xml similarity index 100% rename from spring-boot-gradle/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-keycloak/src/main/resources/logback.xml diff --git a/spring-boot-keycloak/src/main/resources/templates/customers.html b/spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/customers.html similarity index 100% rename from spring-boot-keycloak/src/main/resources/templates/customers.html rename to spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/customers.html diff --git a/spring-boot-keycloak/src/main/resources/templates/external.html b/spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/external.html similarity index 100% rename from spring-boot-keycloak/src/main/resources/templates/external.html rename to spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/external.html diff --git a/spring-boot-keycloak/src/main/resources/templates/layout.html b/spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/layout.html similarity index 100% rename from spring-boot-keycloak/src/main/resources/templates/layout.html rename to spring-boot-modules/spring-boot-keycloak/src/main/resources/templates/layout.html diff --git a/spring-boot-keycloak/src/test/java/com/baeldung/keycloak/KeycloakConfigurationIntegrationTest.java b/spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloak/KeycloakConfigurationIntegrationTest.java similarity index 100% rename from spring-boot-keycloak/src/test/java/com/baeldung/keycloak/KeycloakConfigurationIntegrationTest.java rename to spring-boot-modules/spring-boot-keycloak/src/test/java/com/baeldung/keycloak/KeycloakConfigurationIntegrationTest.java diff --git a/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-kotlin/README.md b/spring-boot-modules/spring-boot-kotlin/README.md similarity index 74% rename from spring-boot-kotlin/README.md rename to spring-boot-modules/spring-boot-kotlin/README.md index d393805ed1..fb91fdee15 100644 --- a/spring-boot-kotlin/README.md +++ b/spring-boot-modules/spring-boot-kotlin/README.md @@ -3,4 +3,4 @@ This module contains articles about Kotlin in Spring Boot projects. ### Relevant Articles: -- [Non-blocking Spring Boot with Kotlin Coroutines](https://www.baeldung.com/non-blocking-spring-boot-with-kotlin-coroutines) +- [Non-blocking Spring Boot with Kotlin Coroutines](https://www.baeldung.com/spring-boot-kotlin-coroutines) diff --git a/spring-boot-kotlin/pom.xml b/spring-boot-modules/spring-boot-kotlin/pom.xml similarity index 98% rename from spring-boot-kotlin/pom.xml rename to spring-boot-modules/spring-boot-kotlin/pom.xml index a98d76a398..79d62645da 100644 --- a/spring-boot-kotlin/pom.xml +++ b/spring-boot-modules/spring-boot-kotlin/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-kotlin 1.0.0-SNAPSHOT - ../parent-kotlin + ../../parent-kotlin diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/SpringApplication.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/SpringApplication.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/SpringApplication.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/SpringApplication.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/DatastoreConfig.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/DatastoreConfig.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/DatastoreConfig.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/DatastoreConfig.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/RouterConfiguration.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/RouterConfiguration.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/RouterConfiguration.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/RouterConfiguration.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/WebClientConfiguration.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/WebClientConfiguration.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/WebClientConfiguration.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/WebClientConfiguration.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductController.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductController.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductController.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductController.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductControllerCoroutines.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductControllerCoroutines.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductControllerCoroutines.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductControllerCoroutines.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductStockView.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductStockView.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductStockView.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductStockView.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/handlers/ProductsHandler.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/handlers/ProductsHandler.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/handlers/ProductsHandler.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/handlers/ProductsHandler.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/model/Product.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/model/Product.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/model/Product.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/model/Product.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepository.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepository.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepository.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepository.kt diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepositoryCoroutines.kt b/spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepositoryCoroutines.kt similarity index 100% rename from spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepositoryCoroutines.kt rename to spring-boot-modules/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepositoryCoroutines.kt diff --git a/spring-boot-kotlin/src/main/resources/application.properties b/spring-boot-modules/spring-boot-kotlin/src/main/resources/application.properties similarity index 100% rename from spring-boot-kotlin/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-kotlin/src/main/resources/application.properties diff --git a/spring-boot-jasypt/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-kotlin/src/main/resources/logback.xml similarity index 100% rename from spring-boot-jasypt/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-kotlin/src/main/resources/logback.xml diff --git a/spring-boot-kotlin/src/test/kotlin/com/baeldung/nonblockingcoroutines/ProductHandlerTest.kt b/spring-boot-modules/spring-boot-kotlin/src/test/kotlin/com/baeldung/nonblockingcoroutines/ProductHandlerTest.kt similarity index 100% rename from spring-boot-kotlin/src/test/kotlin/com/baeldung/nonblockingcoroutines/ProductHandlerTest.kt rename to spring-boot-modules/spring-boot-kotlin/src/test/kotlin/com/baeldung/nonblockingcoroutines/ProductHandlerTest.kt diff --git a/spring-boot-libraries/.gitignore b/spring-boot-modules/spring-boot-libraries/.gitignore similarity index 100% rename from spring-boot-libraries/.gitignore rename to spring-boot-modules/spring-boot-libraries/.gitignore diff --git a/spring-boot-libraries/README.md b/spring-boot-modules/spring-boot-libraries/README.md similarity index 100% rename from spring-boot-libraries/README.md rename to spring-boot-modules/spring-boot-libraries/README.md diff --git a/spring-boot-libraries/mvnw b/spring-boot-modules/spring-boot-libraries/mvnw similarity index 100% rename from spring-boot-libraries/mvnw rename to spring-boot-modules/spring-boot-libraries/mvnw diff --git a/spring-boot-libraries/mvnw.cmd b/spring-boot-modules/spring-boot-libraries/mvnw.cmd similarity index 100% rename from spring-boot-libraries/mvnw.cmd rename to spring-boot-modules/spring-boot-libraries/mvnw.cmd diff --git a/spring-boot-libraries/pom.xml b/spring-boot-modules/spring-boot-libraries/pom.xml similarity index 99% rename from spring-boot-libraries/pom.xml rename to spring-boot-modules/spring-boot-libraries/pom.xml index d9c9073542..ba1164dd59 100644 --- a/spring-boot-libraries/pom.xml +++ b/spring-boot-modules/spring-boot-libraries/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/Application.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/Application.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/boot/Application.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/Application.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/SpringProblemApplication.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/SpringProblemApplication.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/boot/problem/SpringProblemApplication.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/SpringProblemApplication.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/ExceptionHandler.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/ExceptionHandler.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/ExceptionHandler.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/ExceptionHandler.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/SecurityExceptionHandler.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/SecurityExceptionHandler.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/SecurityExceptionHandler.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/SecurityExceptionHandler.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/ProblemDemoConfiguration.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/ProblemDemoConfiguration.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/ProblemDemoConfiguration.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/ProblemDemoConfiguration.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/SecurityConfiguration.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/SecurityConfiguration.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/SecurityConfiguration.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/SecurityConfiguration.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/controller/ProblemDemoController.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/controller/ProblemDemoController.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/boot/problem/controller/ProblemDemoController.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/controller/ProblemDemoController.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/dto/Task.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/dto/Task.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/boot/problem/dto/Task.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/dto/Task.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/problems/TaskNotFoundProblem.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/problems/TaskNotFoundProblem.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/boot/problem/problems/TaskNotFoundProblem.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/problems/TaskNotFoundProblem.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/SchedulerConfiguration.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/SchedulerConfiguration.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/SchedulerConfiguration.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/SchedulerConfiguration.java diff --git a/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/TaskScheduler.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/TaskScheduler.java similarity index 100% rename from spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/TaskScheduler.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/TaskScheduler.java diff --git a/spring-boot-libraries/src/main/resources/application-problem.properties b/spring-boot-modules/spring-boot-libraries/src/main/resources/application-problem.properties similarity index 100% rename from spring-boot-libraries/src/main/resources/application-problem.properties rename to spring-boot-modules/spring-boot-libraries/src/main/resources/application-problem.properties diff --git a/spring-boot-libraries/src/test/java/com/baeldung/boot/problem/controller/ProblemDemoControllerIntegrationTest.java b/spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/boot/problem/controller/ProblemDemoControllerIntegrationTest.java similarity index 100% rename from spring-boot-libraries/src/test/java/com/baeldung/boot/problem/controller/ProblemDemoControllerIntegrationTest.java rename to spring-boot-modules/spring-boot-libraries/src/test/java/com/baeldung/boot/problem/controller/ProblemDemoControllerIntegrationTest.java diff --git a/spring-boot-logging-log4j2/.gitignore b/spring-boot-modules/spring-boot-logging-log4j2/.gitignore similarity index 100% rename from spring-boot-logging-log4j2/.gitignore rename to spring-boot-modules/spring-boot-logging-log4j2/.gitignore diff --git a/spring-boot-logging-log4j2/README.md b/spring-boot-modules/spring-boot-logging-log4j2/README.md similarity index 100% rename from spring-boot-logging-log4j2/README.md rename to spring-boot-modules/spring-boot-logging-log4j2/README.md diff --git a/spring-boot-logging-log4j2/pom.xml b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml similarity index 98% rename from spring-boot-logging-log4j2/pom.xml rename to spring-boot-modules/spring-boot-logging-log4j2/pom.xml index a7065bc925..6e709230dd 100644 --- a/spring-boot-logging-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.2.1.RELEASE + 2.2.2.RELEASE diff --git a/spring-boot-logging-log4j2/src/main/java/com/baeldung/graylog/GraylogDemoApplication.java b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/graylog/GraylogDemoApplication.java similarity index 100% rename from spring-boot-logging-log4j2/src/main/java/com/baeldung/graylog/GraylogDemoApplication.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/graylog/GraylogDemoApplication.java diff --git a/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LoggingController.java b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LoggingController.java similarity index 100% rename from spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LoggingController.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LoggingController.java diff --git a/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java similarity index 100% rename from spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java diff --git a/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/SpringBootLoggingApplication.java b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/SpringBootLoggingApplication.java similarity index 100% rename from spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/SpringBootLoggingApplication.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/SpringBootLoggingApplication.java diff --git a/spring-boot-logging-log4j2/src/main/resources/application.properties b/spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/application.properties similarity index 100% rename from spring-boot-logging-log4j2/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/application.properties diff --git a/spring-boot-logging-log4j2/src/main/resources/log4j.xml b/spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/log4j.xml similarity index 100% rename from spring-boot-logging-log4j2/src/main/resources/log4j.xml rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/log4j.xml diff --git a/spring-boot-logging-log4j2/src/main/resources/log4j2-spring.xml b/spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/log4j2-spring.xml similarity index 100% rename from spring-boot-logging-log4j2/src/main/resources/log4j2-spring.xml rename to spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/log4j2-spring.xml diff --git a/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-mvc-2/.gitignore b/spring-boot-modules/spring-boot-mvc-2/.gitignore similarity index 100% rename from spring-boot-mvc-2/.gitignore rename to spring-boot-modules/spring-boot-mvc-2/.gitignore diff --git a/spring-boot-mvc-2/README.md b/spring-boot-modules/spring-boot-mvc-2/README.md similarity index 69% rename from spring-boot-mvc-2/README.md rename to spring-boot-modules/spring-boot-mvc-2/README.md index 0ff0f1f156..dae815a1c1 100644 --- a/spring-boot-mvc-2/README.md +++ b/spring-boot-modules/spring-boot-mvc-2/README.md @@ -5,4 +5,5 @@ This module contains articles about Spring Web MVC in Spring Boot projects. ### Relevant Articles: - [Functional Controllers in Spring MVC](https://www.baeldung.com/spring-mvc-functional-controllers) +- [Specify an array of strings as body parameter in Swagger API](https://www.baeldung.com/swagger-body-array-of-strings) - More articles: [[prev -->]](/spring-boot-mvc) diff --git a/spring-boot-mvc-2/pom.xml b/spring-boot-modules/spring-boot-mvc-2/pom.xml similarity index 51% rename from spring-boot-mvc-2/pom.xml rename to spring-boot-modules/spring-boot-mvc-2/pom.xml index e6538c4418..edebd41986 100644 --- a/spring-boot-mvc-2/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-2/pom.xml @@ -1,7 +1,7 @@ + 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"> 4.0.0 spring-boot-mvc-2 spring-boot-mvc-2 @@ -9,10 +9,10 @@ Module For Spring Boot MVC Web Fn - org.springframework.boot - spring-boot-starter-parent - 2.2.0.BUILD-SNAPSHOT - + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 @@ -20,6 +20,36 @@ org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-devtools + true + + + + + io.springfox + springfox-swagger2 + ${spring.fox.version} + + + + io.springfox + springfox-swagger-ui + ${spring.fox.version} + + + + io.springfox + springfox-spring-webmvc + ${spring.fox.version} + + + + org.apache.commons + commons-lang3 + @@ -28,7 +58,7 @@ org.springframework.boot spring-boot-maven-plugin - com.baeldung.springbootmvc.SpringBootMvcFnApplication + ${start-class} JAR @@ -49,6 +79,7 @@ Spring Milestones https://repo.spring.io/milestone + @@ -67,4 +98,11 @@ + + 3.0.0-SNAPSHOT + com.baeldung.swagger2boot.SpringBootSwaggerApplication + + 2.2.0.BUILD-SNAPSHOT + + \ No newline at end of file diff --git a/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/SpringBootMvcFnApplication.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/SpringBootMvcFnApplication.java similarity index 100% rename from spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/SpringBootMvcFnApplication.java rename to spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/SpringBootMvcFnApplication.java diff --git a/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/ctrl/ProductController.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/ctrl/ProductController.java similarity index 100% rename from spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/ctrl/ProductController.java rename to spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/ctrl/ProductController.java diff --git a/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/model/Product.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/model/Product.java similarity index 100% rename from spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/model/Product.java rename to spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/model/Product.java diff --git a/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/svc/ProductService.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/svc/ProductService.java similarity index 100% rename from spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/svc/ProductService.java rename to spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/springbootmvc/svc/ProductService.java diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java new file mode 100644 index 0000000000..0f68f75d16 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.swagger2boot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootSwaggerApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootSwaggerApplication.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/config/Swagger2Config.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/config/Swagger2Config.java new file mode 100644 index 0000000000..a0048eb505 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/config/Swagger2Config.java @@ -0,0 +1,34 @@ +package com.baeldung.swagger2boot.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; + +@Configuration +@EnableSwagger2WebMvc +public class Swagger2Config { + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2).select() + .apis(RequestHandlerSelectors.basePackage("com.baeldung.swagger2boot.controller")) + .paths(PathSelectors.regex("/.*")) + .build() + .apiInfo(apiEndPointsInfo()); + } + + private ApiInfo apiEndPointsInfo() { + return new ApiInfoBuilder().title("Swagger Array") + .description("This is a sample Swagger description for an Array server") + .license("Apache 2.0") + .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") + .version("1.0.0") + .build(); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/FooController.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/FooController.java new file mode 100644 index 0000000000..ac6d99c40c --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/FooController.java @@ -0,0 +1,35 @@ +package com.baeldung.swagger2boot.controller; + +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; + +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +import com.baeldung.swagger2boot.model.Foo; + +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; + +@Controller +public class FooController { + + public FooController() { + super(); + } + + // API - write + @RequestMapping(method = RequestMethod.POST, value = "/foos") + @ResponseStatus(HttpStatus.CREATED) + @ResponseBody + @ApiImplicitParams({ @ApiImplicitParam(name = "foo", value = "List of strings", paramType = "body", dataType = "Foo") }) + public Foo create(@RequestBody final Foo foo) { + foo.setId(Long.parseLong(randomNumeric(2))); + return foo; + } + +} diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/Foo.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/Foo.java new file mode 100644 index 0000000000..e48c2016c0 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/Foo.java @@ -0,0 +1,44 @@ +package com.baeldung.swagger2boot.model; + +import java.util.List; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class Foo { + private long id; + + @ApiModelProperty(name = "name", dataType = "List", example = "[\"str1\", \"str2\", \"str3\"]") + private List name; + + public Foo() { + super(); + } + + public Foo(final long id, final List name) { + super(); + + this.id = id; + this.name = name; + } + + // + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public List getName() { + return name; + } + + public void setName(final List name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/spring-boot-mvc-2/src/main/resources/application.properties b/spring-boot-modules/spring-boot-mvc-2/src/main/resources/application.properties similarity index 100% rename from spring-boot-mvc-2/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-mvc-2/src/main/resources/application.properties diff --git a/spring-boot-keycloak/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-mvc-2/src/main/resources/logback.xml similarity index 100% rename from spring-boot-keycloak/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-mvc-2/src/main/resources/logback.xml diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/resources/swagger-description.yml b/spring-boot-modules/spring-boot-mvc-2/src/main/resources/swagger-description.yml new file mode 100644 index 0000000000..b40ddc80f0 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc-2/src/main/resources/swagger-description.yml @@ -0,0 +1,33 @@ +swagger: "2.0" +info: + description: "This is a sample Swagger description for an Array server" + version: "1.0.0" + title: "Swagger Array" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" +basePath: "/localhost:8080/" +tags: +- name: "foo-controller" + description: "Foo controller" + +paths: + /foos: + post: + tags: + - "foo-controller" + summary: "create" + description: "" + parameters: + - in: body + description: "" + required: true + name: name + schema: + type: array + items: + type: string + example: ["str1", "str2", "str3"] + responses: + default: + description: OK \ No newline at end of file diff --git a/spring-boot-mvc-birt/README.md b/spring-boot-modules/spring-boot-mvc-birt/README.md similarity index 100% rename from spring-boot-mvc-birt/README.md rename to spring-boot-modules/spring-boot-mvc-birt/README.md diff --git a/spring-boot-mvc-birt/pom.xml b/spring-boot-modules/spring-boot-mvc-birt/pom.xml similarity index 98% rename from spring-boot-mvc-birt/pom.xml rename to spring-boot-modules/spring-boot-mvc-birt/pom.xml index 76760e661b..f65b851f30 100644 --- a/spring-boot-mvc-birt/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-birt/pom.xml @@ -13,7 +13,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-mvc-birt/reports/csv_data_report.rptdesign b/spring-boot-modules/spring-boot-mvc-birt/reports/csv_data_report.rptdesign similarity index 100% rename from spring-boot-mvc-birt/reports/csv_data_report.rptdesign rename to spring-boot-modules/spring-boot-mvc-birt/reports/csv_data_report.rptdesign diff --git a/spring-boot-mvc-birt/reports/data.csv b/spring-boot-modules/spring-boot-mvc-birt/reports/data.csv similarity index 100% rename from spring-boot-mvc-birt/reports/data.csv rename to spring-boot-modules/spring-boot-mvc-birt/reports/data.csv diff --git a/spring-boot-mvc-birt/reports/static_report.rptdesign b/spring-boot-modules/spring-boot-mvc-birt/reports/static_report.rptdesign similarity index 100% rename from spring-boot-mvc-birt/reports/static_report.rptdesign rename to spring-boot-modules/spring-boot-mvc-birt/reports/static_report.rptdesign diff --git a/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/designer/ReportDesignApplication.java b/spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/designer/ReportDesignApplication.java similarity index 100% rename from spring-boot-mvc-birt/src/main/java/com/baeldung/birt/designer/ReportDesignApplication.java rename to spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/designer/ReportDesignApplication.java diff --git a/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/ReportEngineApplication.java b/spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/ReportEngineApplication.java similarity index 100% rename from spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/ReportEngineApplication.java rename to spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/ReportEngineApplication.java diff --git a/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/controller/BirtReportController.java b/spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/controller/BirtReportController.java similarity index 100% rename from spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/controller/BirtReportController.java rename to spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/controller/BirtReportController.java diff --git a/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/dto/OutputType.java b/spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/dto/OutputType.java similarity index 100% rename from spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/dto/OutputType.java rename to spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/dto/OutputType.java diff --git a/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/dto/Report.java b/spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/dto/Report.java similarity index 100% rename from spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/dto/Report.java rename to spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/dto/Report.java diff --git a/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/service/BirtReportService.java b/spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/service/BirtReportService.java similarity index 100% rename from spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/service/BirtReportService.java rename to spring-boot-modules/spring-boot-mvc-birt/src/main/java/com/baeldung/birt/engine/service/BirtReportService.java diff --git a/spring-boot-mvc-birt/src/main/resources/application.properties b/spring-boot-modules/spring-boot-mvc-birt/src/main/resources/application.properties similarity index 100% rename from spring-boot-mvc-birt/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-mvc-birt/src/main/resources/application.properties diff --git a/spring-boot-mvc/.gitignore b/spring-boot-modules/spring-boot-mvc/.gitignore similarity index 100% rename from spring-boot-mvc/.gitignore rename to spring-boot-modules/spring-boot-mvc/.gitignore diff --git a/spring-boot-mvc/README.md b/spring-boot-modules/spring-boot-mvc/README.md similarity index 100% rename from spring-boot-mvc/README.md rename to spring-boot-modules/spring-boot-mvc/README.md diff --git a/spring-boot-mvc/pom.xml b/spring-boot-modules/spring-boot-mvc/pom.xml similarity index 94% rename from spring-boot-mvc/pom.xml rename to spring-boot-modules/spring-boot-mvc/pom.xml index 1c79a423bf..6a951ace93 100644 --- a/spring-boot-mvc/pom.xml +++ b/spring-boot-modules/spring-boot-mvc/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 @@ -47,9 +47,16 @@ org.springframework.boot spring-boot-starter-data-jpa + - com.h2database - h2 + mysql + mysql-connector-java + + + + org.hsqldb + hsqldb + runtime @@ -111,12 +118,6 @@ ${spring.fox.version} - - org.apache.tomcat.embed - tomcat-embed-jasper - provided - - org.aspectj diff --git a/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/Bike.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Bike.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/Bike.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Bike.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/Biker.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Biker.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/Biker.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Biker.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/Car.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Car.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/Car.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Car.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarMechanic.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarMechanic.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/CarMechanic.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarMechanic.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarUtility.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarUtility.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/CarUtility.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarUtility.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomException.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomException.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomException.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomException.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/Driver.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Driver.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/Driver.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Driver.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/Engine.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Engine.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/Engine.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Engine.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/PerformanceAspect.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/PerformanceAspect.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/PerformanceAspect.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/PerformanceAspect.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/Vehicle.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Vehicle.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/Vehicle.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/Vehicle.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleController.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleController.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRepository.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRepository.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRepository.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRepository.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRestController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRestController.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRestController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRestController.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleService.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleService.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleService.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleService.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanA.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanA.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanA.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanA.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanB.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanB.java similarity index 93% rename from spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanB.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanB.java index f0cc263504..9fc228b201 100644 --- a/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanB.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/BeanB.java @@ -1,5 +1,5 @@ -package com.baeldung.nosuchbeandefinitionexception; - -public class BeanB { - -} +package com.baeldung.nosuchbeandefinitionexception; + +public class BeanB { + +} diff --git a/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/NoSuchBeanDefinitionDemoApp.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/NoSuchBeanDefinitionDemoApp.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/NoSuchBeanDefinitionDemoApp.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/nosuchbeandefinitionexception/NoSuchBeanDefinitionDemoApp.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/responseentity/CustomResponseController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/responseentity/CustomResponseController.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/responseentity/CustomResponseController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/responseentity/CustomResponseController.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/responseentity/CustomResponseWithBuilderController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/responseentity/CustomResponseWithBuilderController.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/responseentity/CustomResponseWithBuilderController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/responseentity/CustomResponseWithBuilderController.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedApplication.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedApplication.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedApplication.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedApplication.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedController.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedController.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedView.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedView.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedView.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedView.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJob.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJob.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJob.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJob.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/scheduling/SchedulingApplication.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/SchedulingApplication.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/scheduling/SchedulingApplication.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/scheduling/SchedulingApplication.java diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootannotations/MySQLAutoconfiguration.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootannotations/MySQLAutoconfiguration.java new file mode 100644 index 0000000000..62b1329a54 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootannotations/MySQLAutoconfiguration.java @@ -0,0 +1,118 @@ +package com.baeldung.springbootannotations; + +import java.util.Arrays; +import java.util.Properties; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureOrder; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.condition.ConditionalOnResource; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.Ordered; +import org.springframework.core.env.Environment; +import org.springframework.core.type.AnnotatedTypeMetadata; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.util.ClassUtils; + +@Configuration +@ConditionalOnClass(DataSource.class) +@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) +@PropertySource("classpath:mysql.properties") +public class MySQLAutoconfiguration { + + @Autowired + private Environment env; + + @Bean + @ConditionalOnProperty(name = "usemysql", havingValue = "local") + @ConditionalOnMissingBean + public DataSource dataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://localhost:3306/myDb?createDatabaseIfNotExist=true&&serverTimezone=UTC"); + dataSource.setUsername("mysqluser"); + dataSource.setPassword("mysqlpass"); + + return dataSource; + } + + @Bean(name = "dataSource") + @ConditionalOnProperty(name = "usemysql", havingValue = "custom") + @ConditionalOnMissingBean + public DataSource dataSource2() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl(env.getProperty("mysql.url")); + dataSource.setUsername(env.getProperty("mysql.user") != null ? env.getProperty("mysql.user") : ""); + dataSource.setPassword(env.getProperty("mysql.pass") != null ? env.getProperty("mysql.pass") : ""); + + return dataSource; + } + + @Bean + @ConditionalOnBean(name = "dataSource") + @ConditionalOnMissingBean + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(dataSource()); + em.setPackagesToScan("com.baeldung.autoconfiguration.example"); + em.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); + if (additionalProperties() != null) { + em.setJpaProperties(additionalProperties()); + } + return em; + } + + @Bean + @ConditionalOnMissingBean(type = "JpaTransactionManager") + JpaTransactionManager transactionManager(final EntityManagerFactory entityManagerFactory) { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactory); + return transactionManager; + } + + @ConditionalOnResource(resources = "classpath:mysql.properties") + @Conditional(HibernateCondition.class) + final Properties additionalProperties() { + final Properties hibernateProperties = new Properties(); + + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("mysql-hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("mysql-hibernate.dialect")); + hibernateProperties.setProperty("hibernate.show_sql", env.getProperty("mysql-hibernate.show_sql") != null ? env.getProperty("mysql-hibernate.show_sql") : "false"); + + return hibernateProperties; + } + + static class HibernateCondition extends SpringBootCondition { + + private static final String[] CLASS_NAMES = { "org.hibernate.ejb.HibernateEntityManager", "org.hibernate.jpa.HibernateEntityManager" }; + + @Override + public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { + ConditionMessage.Builder message = ConditionMessage.forCondition("Hibernate"); + + return Arrays.stream(CLASS_NAMES).filter(className -> ClassUtils.isPresent(className, context.getClassLoader())).map(className -> ConditionOutcome.match(message.found("class").items(Style.NORMAL, className))).findAny() + .orElseGet(() -> ConditionOutcome.noMatch(message.didNotFind("class", "classes").items(Style.NORMAL, Arrays.asList(CLASS_NAMES)))); + } + + } +} diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/LoggingController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/LoggingController.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/LoggingController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/LoggingController.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/LoginController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/LoginController.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/LoginController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/LoginController.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/SpringBootMvcApplication.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/SpringBootMvcApplication.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/SpringBootMvcApplication.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/SpringBootMvcApplication.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/CustomMessageSourceConfiguration.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/CustomMessageSourceConfiguration.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/CustomMessageSourceConfiguration.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/CustomMessageSourceConfiguration.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/FaviconConfiguration.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/FaviconConfiguration.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/FaviconConfiguration.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/config/FaviconConfiguration.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/JsfApplication.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/JsfApplication.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/JsfApplication.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/JsfApplication.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/controller/JsfController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/controller/JsfController.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/controller/JsfController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/controller/JsfController.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/Dao.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/Dao.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/Dao.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/Dao.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/Todo.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/Todo.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/Todo.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/Todo.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/TodoDao.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/TodoDao.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/TodoDao.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/model/TodoDao.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/service/TodoService.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/service/TodoService.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/service/TodoService.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/jsfapplication/service/TodoService.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/model/LoginForm.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/model/LoginForm.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/model/LoginForm.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springbootmvc/model/LoginForm.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/Application.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/Application.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/Application.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/Application.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/controller/RegularRestController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/controller/RegularRestController.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/controller/RegularRestController.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/controller/RegularRestController.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/model/User.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/model/User.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/model/User.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/model/User.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java diff --git a/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/repository/UserRepository.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/repository/UserRepository.java similarity index 100% rename from spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/repository/UserRepository.java rename to spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/repository/UserRepository.java diff --git a/spring-boot-mvc/src/main/resources/application.properties b/spring-boot-modules/spring-boot-mvc/src/main/resources/application.properties similarity index 100% rename from spring-boot-mvc/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-mvc/src/main/resources/application.properties diff --git a/spring-boot-mvc/src/main/resources/com/baeldung/images/favicon.ico b/spring-boot-modules/spring-boot-mvc/src/main/resources/com/baeldung/images/favicon.ico similarity index 100% rename from spring-boot-mvc/src/main/resources/com/baeldung/images/favicon.ico rename to spring-boot-modules/spring-boot-mvc/src/main/resources/com/baeldung/images/favicon.ico diff --git a/spring-boot-mvc/src/main/resources/favicon.ico b/spring-boot-modules/spring-boot-mvc/src/main/resources/favicon.ico similarity index 100% rename from spring-boot-mvc/src/main/resources/favicon.ico rename to spring-boot-modules/spring-boot-mvc/src/main/resources/favicon.ico diff --git a/spring-boot-kotlin/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-mvc/src/main/resources/logback.xml similarity index 100% rename from spring-boot-kotlin/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-mvc/src/main/resources/logback.xml diff --git a/spring-boot-mvc/src/main/resources/messages.properties b/spring-boot-modules/spring-boot-mvc/src/main/resources/messages.properties similarity index 100% rename from spring-boot-mvc/src/main/resources/messages.properties rename to spring-boot-modules/spring-boot-mvc/src/main/resources/messages.properties diff --git a/spring-boot-mvc/src/main/resources/messages_fr.properties b/spring-boot-modules/spring-boot-mvc/src/main/resources/messages_fr.properties similarity index 100% rename from spring-boot-mvc/src/main/resources/messages_fr.properties rename to spring-boot-modules/spring-boot-mvc/src/main/resources/messages_fr.properties diff --git a/spring-boot-modules/spring-boot-mvc/src/main/resources/mysql.properties b/spring-boot-modules/spring-boot-mvc/src/main/resources/mysql.properties new file mode 100644 index 0000000000..74f1ee1373 --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc/src/main/resources/mysql.properties @@ -0,0 +1,5 @@ +usemysql=local + +mysql-hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +mysql-hibernate.show_sql=true +mysql-hibernate.hbm2ddl.auto=create-drop \ No newline at end of file diff --git a/spring-boot-mvc/src/main/resources/static/favicon.ico b/spring-boot-modules/spring-boot-mvc/src/main/resources/static/favicon.ico similarity index 100% rename from spring-boot-mvc/src/main/resources/static/favicon.ico rename to spring-boot-modules/spring-boot-mvc/src/main/resources/static/favicon.ico diff --git a/spring-boot-mvc/src/main/resources/static/index.html b/spring-boot-modules/spring-boot-mvc/src/main/resources/static/index.html similarity index 100% rename from spring-boot-mvc/src/main/resources/static/index.html rename to spring-boot-modules/spring-boot-mvc/src/main/resources/static/index.html diff --git a/spring-boot-mvc/src/main/resources/templates/thymeleaf/index.html b/spring-boot-modules/spring-boot-mvc/src/main/resources/templates/thymeleaf/index.html similarity index 100% rename from spring-boot-mvc/src/main/resources/templates/thymeleaf/index.html rename to spring-boot-modules/spring-boot-mvc/src/main/resources/templates/thymeleaf/index.html diff --git a/spring-boot-mvc/src/main/webapp/WEB-INF/faces-config.xml b/spring-boot-modules/spring-boot-mvc/src/main/webapp/WEB-INF/faces-config.xml similarity index 100% rename from spring-boot-mvc/src/main/webapp/WEB-INF/faces-config.xml rename to spring-boot-modules/spring-boot-mvc/src/main/webapp/WEB-INF/faces-config.xml diff --git a/spring-boot-mvc/src/main/webapp/WEB-INF/web.xml b/spring-boot-modules/spring-boot-mvc/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-boot-mvc/src/main/webapp/WEB-INF/web.xml rename to spring-boot-modules/spring-boot-mvc/src/main/webapp/WEB-INF/web.xml diff --git a/spring-boot-mvc/src/main/webapp/index.xhtml b/spring-boot-modules/spring-boot-mvc/src/main/webapp/index.xhtml similarity index 100% rename from spring-boot-mvc/src/main/webapp/index.xhtml rename to spring-boot-modules/spring-boot-mvc/src/main/webapp/index.xhtml diff --git a/spring-boot-mvc/src/main/webapp/js/jquery.js b/spring-boot-modules/spring-boot-mvc/src/main/webapp/js/jquery.js similarity index 100% rename from spring-boot-mvc/src/main/webapp/js/jquery.js rename to spring-boot-modules/spring-boot-mvc/src/main/webapp/js/jquery.js diff --git a/spring-boot-mvc/src/main/webapp/js/script-async-jquery.js b/spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script-async-jquery.js similarity index 100% rename from spring-boot-mvc/src/main/webapp/js/script-async-jquery.js rename to spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script-async-jquery.js diff --git a/spring-boot-mvc/src/main/webapp/js/script-async.js b/spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script-async.js similarity index 100% rename from spring-boot-mvc/src/main/webapp/js/script-async.js rename to spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script-async.js diff --git a/spring-boot-mvc/src/main/webapp/js/script.js b/spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script.js similarity index 100% rename from spring-boot-mvc/src/main/webapp/js/script.js rename to spring-boot-modules/spring-boot-mvc/src/main/webapp/js/script.js diff --git a/spring-boot-mvc/src/main/webapp/todo.xhtml b/spring-boot-modules/spring-boot-mvc/src/main/webapp/todo.xhtml similarity index 100% rename from spring-boot-mvc/src/main/webapp/todo.xhtml rename to spring-boot-modules/spring-boot-mvc/src/main/webapp/todo.xhtml diff --git a/spring-boot-mvc/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java similarity index 100% rename from spring-boot-mvc/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java rename to spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java diff --git a/spring-boot-mvc/src/test/java/com/baeldung/rss/RssFeedUnitTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/rss/RssFeedUnitTest.java similarity index 100% rename from spring-boot-mvc/src/test/java/com/baeldung/rss/RssFeedUnitTest.java rename to spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/rss/RssFeedUnitTest.java diff --git a/spring-boot-mvc/src/test/java/com/baeldung/springbootmvc/LoginControllerUnitTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/springbootmvc/LoginControllerUnitTest.java similarity index 95% rename from spring-boot-mvc/src/test/java/com/baeldung/springbootmvc/LoginControllerUnitTest.java rename to spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/springbootmvc/LoginControllerUnitTest.java index 68229f459c..8ccf451e86 100644 --- a/spring-boot-mvc/src/test/java/com/baeldung/springbootmvc/LoginControllerUnitTest.java +++ b/spring-boot-modules/spring-boot-mvc/src/test/java/com/baeldung/springbootmvc/LoginControllerUnitTest.java @@ -15,7 +15,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import com.baeldung.springbootmvc.config.CustomMessageSourceConfiguration; @RunWith(SpringRunner.class) -@WebMvcTest(value = LoginController.class, secure = false) +@WebMvcTest(value = LoginController.class) @ContextConfiguration(classes = { SpringBootMvcApplication.class, CustomMessageSourceConfiguration.class }) public class LoginControllerUnitTest { diff --git a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java new file mode 100644 index 0000000000..069dd41b8d --- /dev/null +++ b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java @@ -0,0 +1,19 @@ +package org.baeldung; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; + +import com.baeldung.springbootannotations.MySQLAutoconfiguration; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = MySQLAutoconfiguration.class) +@WebAppConfiguration +public class SpringContextLiveTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} \ No newline at end of file diff --git a/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-nashorn/README.md b/spring-boot-modules/spring-boot-nashorn/README.md similarity index 100% rename from spring-boot-nashorn/README.md rename to spring-boot-modules/spring-boot-nashorn/README.md diff --git a/spring-boot-nashorn/pom.xml b/spring-boot-modules/spring-boot-nashorn/pom.xml similarity index 96% rename from spring-boot-nashorn/pom.xml rename to spring-boot-modules/spring-boot-nashorn/pom.xml index af11f14fdc..c60997005d 100644 --- a/spring-boot-nashorn/pom.xml +++ b/spring-boot-modules/spring-boot-nashorn/pom.xml @@ -13,7 +13,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/Application.java b/spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/Application.java similarity index 100% rename from spring-boot-nashorn/src/main/java/com/baeldung/nashorn/Application.java rename to spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/Application.java diff --git a/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyRestController.java b/spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyRestController.java similarity index 100% rename from spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyRestController.java rename to spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyRestController.java diff --git a/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyWebController.java b/spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyWebController.java similarity index 100% rename from spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyWebController.java rename to spring-boot-modules/spring-boot-nashorn/src/main/java/com/baeldung/nashorn/controller/MyWebController.java diff --git a/spring-boot-nashorn/src/main/resources/application.properties b/spring-boot-modules/spring-boot-nashorn/src/main/resources/application.properties similarity index 100% rename from spring-boot-nashorn/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/application.properties diff --git a/spring-boot-nashorn/src/main/resources/static/app.js b/spring-boot-modules/spring-boot-nashorn/src/main/resources/static/app.js similarity index 100% rename from spring-boot-nashorn/src/main/resources/static/app.js rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/static/app.js diff --git a/spring-boot-nashorn/src/main/resources/static/js/react-dom-server.js b/spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react-dom-server.js similarity index 100% rename from spring-boot-nashorn/src/main/resources/static/js/react-dom-server.js rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react-dom-server.js diff --git a/spring-boot-nashorn/src/main/resources/static/js/react-dom.js b/spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react-dom.js similarity index 100% rename from spring-boot-nashorn/src/main/resources/static/js/react-dom.js rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react-dom.js diff --git a/spring-boot-nashorn/src/main/resources/static/js/react.js b/spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react.js similarity index 100% rename from spring-boot-nashorn/src/main/resources/static/js/react.js rename to spring-boot-modules/spring-boot-nashorn/src/main/resources/static/js/react.js diff --git a/spring-boot-nashorn/src/main/webapp/WEB-INF/jsp/index.jsp b/spring-boot-modules/spring-boot-nashorn/src/main/webapp/WEB-INF/jsp/index.jsp similarity index 100% rename from spring-boot-nashorn/src/main/webapp/WEB-INF/jsp/index.jsp rename to spring-boot-modules/spring-boot-nashorn/src/main/webapp/WEB-INF/jsp/index.jsp diff --git a/spring-boot-properties/README.md b/spring-boot-modules/spring-boot-properties/README.md similarity index 100% rename from spring-boot-properties/README.md rename to spring-boot-modules/spring-boot-properties/README.md diff --git a/spring-boot-properties/extra.properties b/spring-boot-modules/spring-boot-properties/extra.properties similarity index 100% rename from spring-boot-properties/extra.properties rename to spring-boot-modules/spring-boot-properties/extra.properties diff --git a/spring-boot-properties/extra2.properties b/spring-boot-modules/spring-boot-properties/extra2.properties similarity index 100% rename from spring-boot-properties/extra2.properties rename to spring-boot-modules/spring-boot-properties/extra2.properties diff --git a/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml similarity index 98% rename from spring-boot-properties/pom.xml rename to spring-boot-modules/spring-boot-properties/pom.xml index 705a0eb786..5fa1a37792 100644 --- a/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ConfigProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ConfigProperties.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ConfigProperties.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ConfigProperties.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Employee.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Employee.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Employee.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Employee.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/EmployeeConverter.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/EmployeeConverter.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/configurationproperties/EmployeeConverter.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/EmployeeConverter.java diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableConfigPropertiesApp.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableConfigPropertiesApp.java new file mode 100644 index 0000000000..b9d84238c3 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableConfigPropertiesApp.java @@ -0,0 +1,14 @@ +package com.baeldung.configurationproperties; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; + +@SpringBootApplication +@ConfigurationPropertiesScan +public class ImmutableConfigPropertiesApp { + + public static void main(String[] args) { + SpringApplication.run(ImmutableConfigPropertiesApp.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableCredentials.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableCredentials.java new file mode 100644 index 0000000000..a58e4143e5 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableCredentials.java @@ -0,0 +1,31 @@ +package com.baeldung.configurationproperties; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.ConstructorBinding; + +@ConfigurationProperties(prefix = "mail.credentials") +@ConstructorBinding +public class ImmutableCredentials { + + private final String authMethod; + private final String username; + private final String password; + + public ImmutableCredentials(String authMethod, String username, String password) { + this.authMethod = authMethod; + this.username = username; + this.password = password; + } + + public String getAuthMethod() { + return authMethod; + } + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } +} diff --git a/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Item.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Item.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Item.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Item.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/PropertiesConversionApplication.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/PropertiesConversionApplication.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/configurationproperties/PropertiesConversionApplication.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/PropertiesConversionApplication.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/PropertyConversion.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/PropertyConversion.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/configurationproperties/PropertyConversion.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/PropertyConversion.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/AdditionalConfiguration.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/AdditionalConfiguration.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/AdditionalConfiguration.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/AdditionalConfiguration.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/AdditionalProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/AdditionalProperties.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/AdditionalProperties.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/AdditionalProperties.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/CustomJsonProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/CustomJsonProperties.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/CustomJsonProperties.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/CustomJsonProperties.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/JsonProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/JsonProperties.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/JsonProperties.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/JsonProperties.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/JsonPropertyContextInitializer.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/JsonPropertyContextInitializer.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/JsonPropertyContextInitializer.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/JsonPropertyContextInitializer.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/JsonPropertySourceFactory.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/JsonPropertySourceFactory.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/JsonPropertySourceFactory.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/JsonPropertySourceFactory.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/core/ComponentInXmlUsingProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/core/ComponentInXmlUsingProperties.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/core/ComponentInXmlUsingProperties.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/core/ComponentInXmlUsingProperties.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/core/ComponentUsingProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/core/ComponentUsingProperties.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/core/ComponentUsingProperties.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/core/ComponentUsingProperties.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigTwo.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigTwo.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigTwo.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigTwo.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/SpringBootPropertiesApplication.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/SpringBootPropertiesApplication.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/reloading/SpringBootPropertiesApplication.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/SpringBootPropertiesApplication.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/PropertiesException.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/PropertiesException.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/PropertiesException.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/PropertiesException.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadableProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadableProperties.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadableProperties.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadableProperties.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySource.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySource.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySource.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySource.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySourceConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySourceConfig.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySourceConfig.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySourceConfig.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySourceFactory.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySourceFactory.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySourceFactory.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySourceFactory.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/spring/BasicPropertiesWithJavaConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/BasicPropertiesWithJavaConfig.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/spring/BasicPropertiesWithJavaConfig.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/BasicPropertiesWithJavaConfig.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfig.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfig.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfig.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfigOther.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfigOther.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfigOther.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfigOther.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithPlaceHolderConfigurer.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithPlaceHolderConfigurer.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithPlaceHolderConfigurer.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithPlaceHolderConfigurer.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/value/ClassNotManagedBySpring.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/value/ClassNotManagedBySpring.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/value/ClassNotManagedBySpring.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/value/ClassNotManagedBySpring.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/value/InitializerBean.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/value/InitializerBean.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/value/InitializerBean.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/value/InitializerBean.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/value/SomeBean.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/value/SomeBean.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/value/SomeBean.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/value/SomeBean.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/value/ValuesApp.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/value/ValuesApp.java similarity index 100% rename from spring-boot-properties/src/main/java/com/baeldung/value/ValuesApp.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/value/ValuesApp.java diff --git a/spring-boot-properties/src/main/java/com/baeldung/valuewithdefaults/ValuesWithDefaultsApp.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/valuewithdefaults/ValuesWithDefaultsApp.java similarity index 97% rename from spring-boot-properties/src/main/java/com/baeldung/valuewithdefaults/ValuesWithDefaultsApp.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/valuewithdefaults/ValuesWithDefaultsApp.java index d2cda19ae6..589f891e6b 100644 --- a/spring-boot-properties/src/main/java/com/baeldung/valuewithdefaults/ValuesWithDefaultsApp.java +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/valuewithdefaults/ValuesWithDefaultsApp.java @@ -1,75 +1,75 @@ -package com.baeldung.valuewithdefaults; - -import java.util.Arrays; -import java.util.List; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.util.Assert; - -import com.google.common.collect.Lists; -import com.google.common.primitives.Ints; - -/** - * Demonstrates setting defaults for @Value annotation. Note that there are no properties - * defined in the specified property source. We also assume that the user here - * does not have a system property named some.key. - * - */ -@Configuration -@PropertySource(name = "myProperties", value = "valueswithdefaults.properties") -public class ValuesWithDefaultsApp { - - @Value("${some.key:my default value}") - private String stringWithDefaultValue; - - @Value("${some.key:}") - private String stringWithBlankDefaultValue; - - @Value("${some.key:true}") - private boolean booleanWithDefaultValue; - - @Value("${some.key:42}") - private int intWithDefaultValue; - - @Value("${some.key:one,two,three}") - private String[] stringArrayWithDefaults; - - @Value("${some.key:1,2,3}") - private int[] intArrayWithDefaults; - - @Value("#{systemProperties['some.key'] ?: 'my default system property value'}") - private String spelWithDefaultValue; - - - public static void main(String[] args) { - ApplicationContext applicationContext = new AnnotationConfigApplicationContext(ValuesWithDefaultsApp.class); - } - - @PostConstruct - public void afterInitialize() { - // strings - Assert.isTrue(stringWithDefaultValue.equals("my default value")); - Assert.isTrue(stringWithBlankDefaultValue.equals("")); - - // other primitives - Assert.isTrue(booleanWithDefaultValue); - Assert.isTrue(intWithDefaultValue == 42); - - // arrays - List stringListValues = Lists.newArrayList("one", "two", "three"); - Assert.isTrue(Arrays.asList(stringArrayWithDefaults).containsAll(stringListValues)); - - List intListValues = Lists.newArrayList(1, 2, 3); - Assert.isTrue(Ints.asList(intArrayWithDefaults).containsAll(intListValues)); - - // SpEL - Assert.isTrue(spelWithDefaultValue.equals("my default system property value")); - - } -} +package com.baeldung.valuewithdefaults; + +import java.util.Arrays; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.util.Assert; + +import com.google.common.collect.Lists; +import com.google.common.primitives.Ints; + +/** + * Demonstrates setting defaults for @Value annotation. Note that there are no properties + * defined in the specified property source. We also assume that the user here + * does not have a system property named some.key. + * + */ +@Configuration +@PropertySource(name = "myProperties", value = "valueswithdefaults.properties") +public class ValuesWithDefaultsApp { + + @Value("${some.key:my default value}") + private String stringWithDefaultValue; + + @Value("${some.key:}") + private String stringWithBlankDefaultValue; + + @Value("${some.key:true}") + private boolean booleanWithDefaultValue; + + @Value("${some.key:42}") + private int intWithDefaultValue; + + @Value("${some.key:one,two,three}") + private String[] stringArrayWithDefaults; + + @Value("${some.key:1,2,3}") + private int[] intArrayWithDefaults; + + @Value("#{systemProperties['some.key'] ?: 'my default system property value'}") + private String spelWithDefaultValue; + + + public static void main(String[] args) { + ApplicationContext applicationContext = new AnnotationConfigApplicationContext(ValuesWithDefaultsApp.class); + } + + @PostConstruct + public void afterInitialize() { + // strings + Assert.isTrue(stringWithDefaultValue.equals("my default value")); + Assert.isTrue(stringWithBlankDefaultValue.equals("")); + + // other primitives + Assert.isTrue(booleanWithDefaultValue); + Assert.isTrue(intWithDefaultValue == 42); + + // arrays + List stringListValues = Lists.newArrayList("one", "two", "three"); + Assert.isTrue(Arrays.asList(stringArrayWithDefaults).containsAll(stringListValues)); + + List intListValues = Lists.newArrayList(1, 2, 3); + Assert.isTrue(Ints.asList(intArrayWithDefaults).containsAll(intListValues)); + + // SpEL + Assert.isTrue(spelWithDefaultValue.equals("my default system property value")); + + } +} diff --git a/spring-boot-properties/src/main/java/com/baeldung/yaml/MyApplication.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/yaml/MyApplication.java similarity index 97% rename from spring-boot-properties/src/main/java/com/baeldung/yaml/MyApplication.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/yaml/MyApplication.java index 4a585df998..d42b731213 100644 --- a/spring-boot-properties/src/main/java/com/baeldung/yaml/MyApplication.java +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/yaml/MyApplication.java @@ -1,31 +1,31 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.baeldung.yaml; - -import java.util.Collections; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class MyApplication implements CommandLineRunner { - - @Autowired - private YAMLConfig myConfig; - - public static void main(String[] args) { - SpringApplication app = new SpringApplication(MyApplication.class); - app.run(); - } - - public void run(String... args) throws Exception { - System.out.println("using environment:" + myConfig.getEnvironment()); - System.out.println("name:" + myConfig.getName()); - System.out.println("servers:" + myConfig.getServers()); - } - -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.baeldung.yaml; + +import java.util.Collections; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MyApplication implements CommandLineRunner { + + @Autowired + private YAMLConfig myConfig; + + public static void main(String[] args) { + SpringApplication app = new SpringApplication(MyApplication.class); + app.run(); + } + + public void run(String... args) throws Exception { + System.out.println("using environment:" + myConfig.getEnvironment()); + System.out.println("name:" + myConfig.getName()); + System.out.println("servers:" + myConfig.getServers()); + } + +} diff --git a/spring-boot-properties/src/main/java/com/baeldung/yaml/YAMLConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/yaml/YAMLConfig.java similarity index 95% rename from spring-boot-properties/src/main/java/com/baeldung/yaml/YAMLConfig.java rename to spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/yaml/YAMLConfig.java index 313b920502..ad633c4b56 100644 --- a/spring-boot-properties/src/main/java/com/baeldung/yaml/YAMLConfig.java +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/yaml/YAMLConfig.java @@ -1,41 +1,41 @@ -package com.baeldung.yaml; - -import java.util.ArrayList; -import java.util.List; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableConfigurationProperties -@ConfigurationProperties -public class YAMLConfig { - private String name; - private String environment; - private List servers = new ArrayList(); - - public List getServers() { - return servers; - } - - public void setServers(List servers) { - this.servers = servers; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getEnvironment() { - return environment; - } - - public void setEnvironment(String environment) { - this.environment = environment; - } - -} +package com.baeldung.yaml; + +import java.util.ArrayList; +import java.util.List; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableConfigurationProperties +@ConfigurationProperties +public class YAMLConfig { + private String name; + private String environment; + private List servers = new ArrayList(); + + public List getServers() { + return servers; + } + + public void setServers(List servers) { + this.servers = servers; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEnvironment() { + return environment; + } + + public void setEnvironment(String environment) { + this.environment = environment; + } + +} diff --git a/spring-boot-properties/src/main/resources/application.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties similarity index 100% rename from spring-boot-properties/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-properties/src/main/resources/application.properties diff --git a/spring-boot-properties/src/main/resources/application.yml b/spring-boot-modules/spring-boot-properties/src/main/resources/application.yml similarity index 100% rename from spring-boot-properties/src/main/resources/application.yml rename to spring-boot-modules/spring-boot-properties/src/main/resources/application.yml diff --git a/spring-boot-properties/src/main/resources/bar.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/bar.properties similarity index 100% rename from spring-boot-properties/src/main/resources/bar.properties rename to spring-boot-modules/spring-boot-properties/src/main/resources/bar.properties diff --git a/spring-boot-properties/src/main/resources/basicConfigForProperties.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/basicConfigForProperties.xml similarity index 100% rename from spring-boot-properties/src/main/resources/basicConfigForProperties.xml rename to spring-boot-modules/spring-boot-properties/src/main/resources/basicConfigForProperties.xml diff --git a/spring-boot-properties/src/main/resources/basicConfigForPropertiesOne.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/basicConfigForPropertiesOne.xml similarity index 100% rename from spring-boot-properties/src/main/resources/basicConfigForPropertiesOne.xml rename to spring-boot-modules/spring-boot-properties/src/main/resources/basicConfigForPropertiesOne.xml diff --git a/spring-boot-properties/src/main/resources/basicConfigForPropertiesTwo.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/basicConfigForPropertiesTwo.xml similarity index 100% rename from spring-boot-properties/src/main/resources/basicConfigForPropertiesTwo.xml rename to spring-boot-modules/spring-boot-properties/src/main/resources/basicConfigForPropertiesTwo.xml diff --git a/spring-boot-properties/src/main/resources/child.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/child.properties similarity index 100% rename from spring-boot-properties/src/main/resources/child.properties rename to spring-boot-modules/spring-boot-properties/src/main/resources/child.properties diff --git a/spring-boot-properties/src/main/resources/configForProperties.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml similarity index 100% rename from spring-boot-properties/src/main/resources/configForProperties.xml rename to spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml diff --git a/spring-boot-properties/src/main/resources/configForPropertiesOne.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertiesOne.xml similarity index 100% rename from spring-boot-properties/src/main/resources/configForPropertiesOne.xml rename to spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertiesOne.xml diff --git a/spring-boot-properties/src/main/resources/configprops.json b/spring-boot-modules/spring-boot-properties/src/main/resources/configprops.json similarity index 100% rename from spring-boot-properties/src/main/resources/configprops.json rename to spring-boot-modules/spring-boot-properties/src/main/resources/configprops.json diff --git a/spring-boot-properties/src/main/resources/configprops.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/configprops.properties similarity index 100% rename from spring-boot-properties/src/main/resources/configprops.properties rename to spring-boot-modules/spring-boot-properties/src/main/resources/configprops.properties diff --git a/spring-boot-properties/src/main/resources/conversion.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/conversion.properties similarity index 100% rename from spring-boot-properties/src/main/resources/conversion.properties rename to spring-boot-modules/spring-boot-properties/src/main/resources/conversion.properties diff --git a/spring-boot-properties/src/main/resources/foo.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/foo.properties similarity index 100% rename from spring-boot-properties/src/main/resources/foo.properties rename to spring-boot-modules/spring-boot-properties/src/main/resources/foo.properties diff --git a/spring-boot-properties/src/main/resources/parent.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/parent.properties similarity index 100% rename from spring-boot-properties/src/main/resources/parent.properties rename to spring-boot-modules/spring-boot-properties/src/main/resources/parent.properties diff --git a/spring-boot-properties/src/main/resources/values.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/values.properties similarity index 100% rename from spring-boot-properties/src/main/resources/values.properties rename to spring-boot-modules/spring-boot-properties/src/main/resources/values.properties diff --git a/spring-boot-properties/src/main/resources/valueswithdefaults.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/valueswithdefaults.properties similarity index 100% rename from spring-boot-properties/src/main/resources/valueswithdefaults.properties rename to spring-boot-modules/spring-boot-properties/src/main/resources/valueswithdefaults.properties diff --git a/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ImmutableConfigurationPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ImmutableConfigurationPropertiesIntegrationTest.java new file mode 100644 index 0000000000..a45932f7be --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ImmutableConfigurationPropertiesIntegrationTest.java @@ -0,0 +1,26 @@ +package com.baeldung.configurationproperties; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ImmutableConfigPropertiesApp.class) +@TestPropertySource("classpath:configprops-test.properties") +public class ImmutableConfigurationPropertiesIntegrationTest { + + @Autowired + private ImmutableCredentials immutableCredentials; + + @Test + public void whenConstructorBindingUsed_thenPropertiesCorrectlyBound() { + assertThat(immutableCredentials.getAuthMethod()).isEqualTo("SHA1"); + assertThat(immutableCredentials.getUsername()).isEqualTo("john"); + assertThat(immutableCredentials.getPassword()).isEqualTo("password"); + } +} diff --git a/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/PropertiesConversionIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/PropertiesConversionIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/configurationproperties/PropertiesConversionIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/PropertiesConversionIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/JsonPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/JsonPropertiesIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/JsonPropertiesIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/JsonPropertiesIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/basic/BasicPropertiesWithJavaIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/BasicPropertiesWithJavaIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/basic/BasicPropertiesWithJavaIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/BasicPropertiesWithJavaIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/basic/ExtendedPropertiesWithJavaIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/ExtendedPropertiesWithJavaIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/basic/ExtendedPropertiesWithJavaIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/ExtendedPropertiesWithJavaIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithJavaIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithJavaIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithJavaIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithJavaIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithMultipleXmlsIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithMultipleXmlsIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithMultipleXmlsIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithMultipleXmlsIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithXmlIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithXmlIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithXmlIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/basic/PropertiesWithXmlIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithJavaIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithJavaIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithJavaIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithJavaIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithMultipleXmlsIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithMultipleXmlsIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithMultipleXmlsIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithMultipleXmlsIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithXmlManualTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithXmlManualTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithXmlManualTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/external/ExternalPropertiesWithXmlManualTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesJavaConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesJavaConfigIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesJavaConfigIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesJavaConfigIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ChildValueHolder.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ChildValueHolder.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ChildValueHolder.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ChildValueHolder.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentValueHolder.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentValueHolder.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentValueHolder.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentValueHolder.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig2.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig2.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig2.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig2.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig2.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig2.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig2.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig2.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/PropertiesReloadIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/PropertiesReloadIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/reloading/PropertiesReloadIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/PropertiesReloadIntegrationTest.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/SpringBootPropertiesTestApplication.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/SpringBootPropertiesTestApplication.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/reloading/SpringBootPropertiesTestApplication.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/SpringBootPropertiesTestApplication.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/ConfigurationPropertiesRefreshConfigBean.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/ConfigurationPropertiesRefreshConfigBean.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/ConfigurationPropertiesRefreshConfigBean.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/ConfigurationPropertiesRefreshConfigBean.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/EnvironmentConfigBean.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/EnvironmentConfigBean.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/EnvironmentConfigBean.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/EnvironmentConfigBean.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/PropertiesConfigBean.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/PropertiesConfigBean.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/PropertiesConfigBean.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/PropertiesConfigBean.java diff --git a/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/ValueRefreshConfigBean.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/ValueRefreshConfigBean.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/ValueRefreshConfigBean.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/reloading/beans/ValueRefreshConfigBean.java diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/testproperty/FilePropertyInjectionUnitTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/testproperty/FilePropertyInjectionUnitTest.java new file mode 100644 index 0000000000..874f632401 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/testproperty/FilePropertyInjectionUnitTest.java @@ -0,0 +1,24 @@ +package com.baeldung.properties.testproperty; + +import org.assertj.core.api.Assertions; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@TestPropertySource("/foo.properties") +public class FilePropertyInjectionUnitTest { + + @Value("${foo}") + private String foo; + + @Test + public void whenFilePropertyProvided_thenProperlyInjected() { + assertThat(foo).isEqualTo("bar"); + } +} diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/testproperty/PropertyInjectionUnitTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/testproperty/PropertyInjectionUnitTest.java new file mode 100644 index 0000000000..9492e18322 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/testproperty/PropertyInjectionUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.properties.testproperty; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@TestPropertySource(properties = {"foo=bar"}) +public class PropertyInjectionUnitTest { + + @Value("${foo}") + private String foo; + + @Test + public void whenPropertyProvided_thenProperlyInjected() { + assertThat(foo).isEqualTo("bar"); + } +} diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/testproperty/SpringBootPropertyInjectionIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/testproperty/SpringBootPropertyInjectionIntegrationTest.java new file mode 100644 index 0000000000..fdca7e814d --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/testproperty/SpringBootPropertyInjectionIntegrationTest.java @@ -0,0 +1,23 @@ +package com.baeldung.properties.testproperty; + +import com.baeldung.properties.reloading.SpringBootPropertiesTestApplication; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest(properties = {"foo=bar"}, classes = SpringBootPropertiesTestApplication.class) +public class SpringBootPropertyInjectionIntegrationTest { + + @Value("${foo}") + private String foo; + + @Test + public void whenSpringBootPropertyProvided_thenProperlyInjected() { + assertThat(foo).isEqualTo("bar"); + } +} diff --git a/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java similarity index 97% rename from spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java index 722c4fd1c4..d41d328867 100644 --- a/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java @@ -1,25 +1,25 @@ -package com.baeldung.test; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -import com.baeldung.properties.basic.ExtendedPropertiesWithJavaIntegrationTest; -import com.baeldung.properties.basic.PropertiesWithMultipleXmlsIntegrationTest; -import com.baeldung.properties.basic.PropertiesWithXmlIntegrationTest; -import com.baeldung.properties.external.ExternalPropertiesWithJavaIntegrationTest; -import com.baeldung.properties.external.ExternalPropertiesWithMultipleXmlsIntegrationTest; -import com.baeldung.properties.external.ExternalPropertiesWithXmlManualTest; - -@RunWith(Suite.class) -@SuiteClasses({ //@formatter:off - PropertiesWithXmlIntegrationTest.class, - ExternalPropertiesWithJavaIntegrationTest.class, - ExternalPropertiesWithMultipleXmlsIntegrationTest.class, - ExternalPropertiesWithXmlManualTest.class, - ExtendedPropertiesWithJavaIntegrationTest.class, - PropertiesWithMultipleXmlsIntegrationTest.class, -})// @formatter:on -public final class IntegrationTestSuite { - // -} +package com.baeldung.test; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +import com.baeldung.properties.basic.ExtendedPropertiesWithJavaIntegrationTest; +import com.baeldung.properties.basic.PropertiesWithMultipleXmlsIntegrationTest; +import com.baeldung.properties.basic.PropertiesWithXmlIntegrationTest; +import com.baeldung.properties.external.ExternalPropertiesWithJavaIntegrationTest; +import com.baeldung.properties.external.ExternalPropertiesWithMultipleXmlsIntegrationTest; +import com.baeldung.properties.external.ExternalPropertiesWithXmlManualTest; + +@RunWith(Suite.class) +@SuiteClasses({ //@formatter:off + PropertiesWithXmlIntegrationTest.class, + ExternalPropertiesWithJavaIntegrationTest.class, + ExternalPropertiesWithMultipleXmlsIntegrationTest.class, + ExternalPropertiesWithXmlManualTest.class, + ExtendedPropertiesWithJavaIntegrationTest.class, + PropertiesWithMultipleXmlsIntegrationTest.class, +})// @formatter:on +public final class IntegrationTestSuite { + // +} diff --git a/spring-boot-properties/src/test/java/com/baeldung/value/ClassNotManagedBySpringIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/value/ClassNotManagedBySpringIntegrationTest.java similarity index 100% rename from spring-boot-properties/src/test/java/com/baeldung/value/ClassNotManagedBySpringIntegrationTest.java rename to spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/value/ClassNotManagedBySpringIntegrationTest.java diff --git a/spring-boot-properties/src/test/resources/application.properties b/spring-boot-modules/spring-boot-properties/src/test/resources/application.properties similarity index 100% rename from spring-boot-properties/src/test/resources/application.properties rename to spring-boot-modules/spring-boot-properties/src/test/resources/application.properties diff --git a/spring-boot-properties/src/test/resources/configprops-test.properties b/spring-boot-modules/spring-boot-properties/src/test/resources/configprops-test.properties similarity index 96% rename from spring-boot-properties/src/test/resources/configprops-test.properties rename to spring-boot-modules/spring-boot-properties/src/test/resources/configprops-test.properties index 5eed93a22b..3fc1195b98 100644 --- a/spring-boot-properties/src/test/resources/configprops-test.properties +++ b/spring-boot-modules/spring-boot-properties/src/test/resources/configprops-test.properties @@ -24,3 +24,5 @@ item.size=21 #Additional properties additional.unit=km additional.max=100 + +key.something=val \ No newline at end of file diff --git a/spring-boot-properties/src/test/resources/conversion.properties b/spring-boot-modules/spring-boot-properties/src/test/resources/conversion.properties similarity index 100% rename from spring-boot-properties/src/test/resources/conversion.properties rename to spring-boot-modules/spring-boot-properties/src/test/resources/conversion.properties diff --git a/spring-boot-modules/spring-boot-properties/src/test/resources/foo.properties b/spring-boot-modules/spring-boot-properties/src/test/resources/foo.properties new file mode 100644 index 0000000000..b5ae2aedd4 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/resources/foo.properties @@ -0,0 +1,2 @@ +foo=bar +key.something=val \ No newline at end of file diff --git a/spring-boot-property-exp/README.md b/spring-boot-modules/spring-boot-property-exp/README.md similarity index 100% rename from spring-boot-property-exp/README.md rename to spring-boot-modules/spring-boot-property-exp/README.md diff --git a/spring-boot-property-exp/pom.xml b/spring-boot-modules/spring-boot-property-exp/pom.xml similarity index 85% rename from spring-boot-property-exp/pom.xml rename to spring-boot-modules/spring-boot-property-exp/pom.xml index b16fcd1c22..2da25fca31 100644 --- a/spring-boot-property-exp/pom.xml +++ b/spring-boot-modules/spring-boot-property-exp/pom.xml @@ -8,8 +8,8 @@ pom - com.baeldung - parent-modules + com.baeldung.spring-boot-modules + spring-boot-modules 1.0.0-SNAPSHOT diff --git a/spring-boot-property-exp/property-exp-custom-config/pom.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml similarity index 90% rename from spring-boot-property-exp/property-exp-custom-config/pom.xml rename to spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml index f9c3d6ef62..8ea9c8366d 100644 --- a/spring-boot-property-exp/property-exp-custom-config/pom.xml +++ b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml @@ -8,7 +8,7 @@ jar - com.baeldung + com.baeldung.spring-boot-modules spring-boot-property-exp 0.0.1-SNAPSHOT @@ -52,7 +52,7 @@ org.apache.maven.plugins maven-resources-plugin - 2.7 + ${apache-maven.version} @ @@ -63,7 +63,7 @@ org.codehaus.mojo exec-maven-plugin - 1.6.0 + ${exec-maven-plugin.version} com.baeldung.propertyexpansion.SpringBootPropertyExpansionApp @@ -74,6 +74,8 @@ 1.5.10.RELEASE Custom Property Value + 2.7 + 1.6.0 diff --git a/spring-boot-property-exp/property-exp-custom-config/src/main/java/com/baeldung/propertyexpansion/SpringBootPropertyExpansionApp.java b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/java/com/baeldung/propertyexpansion/SpringBootPropertyExpansionApp.java similarity index 100% rename from spring-boot-property-exp/property-exp-custom-config/src/main/java/com/baeldung/propertyexpansion/SpringBootPropertyExpansionApp.java rename to spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/java/com/baeldung/propertyexpansion/SpringBootPropertyExpansionApp.java diff --git a/spring-boot-property-exp/property-exp-custom-config/src/main/java/com/baeldung/propertyexpansion/components/PropertyLoggerBean.java b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/java/com/baeldung/propertyexpansion/components/PropertyLoggerBean.java similarity index 100% rename from spring-boot-property-exp/property-exp-custom-config/src/main/java/com/baeldung/propertyexpansion/components/PropertyLoggerBean.java rename to spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/java/com/baeldung/propertyexpansion/components/PropertyLoggerBean.java diff --git a/spring-boot-property-exp/property-exp-custom-config/src/main/resources/application.properties b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/resources/application.properties similarity index 100% rename from spring-boot-property-exp/property-exp-custom-config/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/resources/application.properties diff --git a/spring-boot-property-exp/property-exp-custom-config/src/main/resources/banner.txt b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/resources/banner.txt similarity index 100% rename from spring-boot-property-exp/property-exp-custom-config/src/main/resources/banner.txt rename to spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/resources/banner.txt diff --git a/spring-boot-mvc-2/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/resources/logback.xml similarity index 100% rename from spring-boot-mvc-2/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/main/resources/logback.xml diff --git a/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-property-exp/property-exp-default-config/build.gradle b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/build.gradle similarity index 100% rename from spring-boot-property-exp/property-exp-default-config/build.gradle rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/build.gradle diff --git a/spring-boot-property-exp/property-exp-default-config/gradle.properties b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/gradle.properties similarity index 100% rename from spring-boot-property-exp/property-exp-default-config/gradle.properties rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/gradle.properties diff --git a/spring-boot-property-exp/property-exp-default-config/pom.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml similarity index 95% rename from spring-boot-property-exp/property-exp-default-config/pom.xml rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml index 9cb1de33f6..aa5b8ef34a 100644 --- a/spring-boot-property-exp/property-exp-default-config/pom.xml +++ b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-1 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../../parent-boot-1 diff --git a/spring-boot-property-exp/property-exp-default-config/settings.gradle b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/settings.gradle similarity index 100% rename from spring-boot-property-exp/property-exp-default-config/settings.gradle rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/settings.gradle diff --git a/spring-boot-property-exp/property-exp-default-config/src/main/java/com/baeldung/propertyexpansion/SpringBootPropertyExpansionApp.java b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/java/com/baeldung/propertyexpansion/SpringBootPropertyExpansionApp.java similarity index 100% rename from spring-boot-property-exp/property-exp-default-config/src/main/java/com/baeldung/propertyexpansion/SpringBootPropertyExpansionApp.java rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/java/com/baeldung/propertyexpansion/SpringBootPropertyExpansionApp.java diff --git a/spring-boot-property-exp/property-exp-default-config/src/main/java/com/baeldung/propertyexpansion/components/PropertyLoggerBean.java b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/java/com/baeldung/propertyexpansion/components/PropertyLoggerBean.java similarity index 100% rename from spring-boot-property-exp/property-exp-default-config/src/main/java/com/baeldung/propertyexpansion/components/PropertyLoggerBean.java rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/java/com/baeldung/propertyexpansion/components/PropertyLoggerBean.java diff --git a/spring-boot-property-exp/property-exp-default-config/src/main/resources/application.properties b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/resources/application.properties similarity index 100% rename from spring-boot-property-exp/property-exp-default-config/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/resources/application.properties diff --git a/spring-boot-property-exp/property-exp-default-config/src/main/resources/banner.txt b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/resources/banner.txt similarity index 100% rename from spring-boot-property-exp/property-exp-default-config/src/main/resources/banner.txt rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/resources/banner.txt diff --git a/spring-boot-mvc/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/resources/logback.xml similarity index 100% rename from spring-boot-mvc/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/main/resources/logback.xml diff --git a/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-runtime/README.md b/spring-boot-modules/spring-boot-runtime/README.md similarity index 100% rename from spring-boot-runtime/README.md rename to spring-boot-modules/spring-boot-runtime/README.md diff --git a/spring-boot-runtime/disabling-console-jul/.gitignore b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/.gitignore similarity index 100% rename from spring-boot-runtime/disabling-console-jul/.gitignore rename to spring-boot-modules/spring-boot-runtime/disabling-console-jul/.gitignore diff --git a/spring-boot-runtime/disabling-console-jul/README.md b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/README.md similarity index 100% rename from spring-boot-runtime/disabling-console-jul/README.md rename to spring-boot-modules/spring-boot-runtime/disabling-console-jul/README.md diff --git a/spring-boot-runtime/disabling-console-jul/pom.xml b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/pom.xml similarity index 91% rename from spring-boot-runtime/disabling-console-jul/pom.xml rename to spring-boot-modules/spring-boot-runtime/disabling-console-jul/pom.xml index 2dc1a834b6..2f1c9c2add 100644 --- a/spring-boot-runtime/disabling-console-jul/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/pom.xml @@ -7,9 +7,9 @@ - org.springframework.boot - spring-boot-starter-parent - 2.1.1.RELEASE + com.baeldung + spring-boot-runtime + 0.0.1-SNAPSHOT diff --git a/spring-boot-runtime/disabling-console-jul/src/main/java/com/baeldung/springbootlogging/disablingconsole/jul/properties/DisablingConsoleJulApp.java b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/src/main/java/com/baeldung/springbootlogging/disablingconsole/jul/properties/DisablingConsoleJulApp.java similarity index 100% rename from spring-boot-runtime/disabling-console-jul/src/main/java/com/baeldung/springbootlogging/disablingconsole/jul/properties/DisablingConsoleJulApp.java rename to spring-boot-modules/spring-boot-runtime/disabling-console-jul/src/main/java/com/baeldung/springbootlogging/disablingconsole/jul/properties/DisablingConsoleJulApp.java diff --git a/spring-boot-runtime/disabling-console-jul/src/main/java/com/baeldung/springbootlogging/disablingconsole/jul/properties/controllers/DisabledConsoleRestController.java b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/src/main/java/com/baeldung/springbootlogging/disablingconsole/jul/properties/controllers/DisabledConsoleRestController.java similarity index 100% rename from spring-boot-runtime/disabling-console-jul/src/main/java/com/baeldung/springbootlogging/disablingconsole/jul/properties/controllers/DisabledConsoleRestController.java rename to spring-boot-modules/spring-boot-runtime/disabling-console-jul/src/main/java/com/baeldung/springbootlogging/disablingconsole/jul/properties/controllers/DisabledConsoleRestController.java diff --git a/spring-boot-runtime/disabling-console-jul/src/main/resources/application.properties b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/src/main/resources/application.properties similarity index 100% rename from spring-boot-runtime/disabling-console-jul/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-runtime/disabling-console-jul/src/main/resources/application.properties diff --git a/spring-boot-runtime/disabling-console-jul/src/main/resources/logging.properties b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/src/main/resources/logging.properties similarity index 100% rename from spring-boot-runtime/disabling-console-jul/src/main/resources/logging.properties rename to spring-boot-modules/spring-boot-runtime/disabling-console-jul/src/main/resources/logging.properties diff --git a/spring-boot-runtime/disabling-console-log4j2/.gitignore b/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/.gitignore similarity index 100% rename from spring-boot-runtime/disabling-console-log4j2/.gitignore rename to spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/.gitignore diff --git a/spring-boot-runtime/disabling-console-log4j2/README.md b/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/README.md similarity index 100% rename from spring-boot-runtime/disabling-console-log4j2/README.md rename to spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/README.md diff --git a/spring-boot-runtime/disabling-console-log4j2/pom.xml b/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/pom.xml similarity index 90% rename from spring-boot-runtime/disabling-console-log4j2/pom.xml rename to spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/pom.xml index b743c4bdac..35f54999ec 100644 --- a/spring-boot-runtime/disabling-console-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/pom.xml @@ -7,9 +7,9 @@ - org.springframework.boot - spring-boot-starter-parent - 2.1.1.RELEASE + com.baeldung + spring-boot-runtime + 0.0.1-SNAPSHOT diff --git a/spring-boot-runtime/disabling-console-log4j2/src/main/java/com/baeldung/springbootlogging/disablingconsole/log4j2/xml/DisablingConsoleLog4j2App.java b/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/src/main/java/com/baeldung/springbootlogging/disablingconsole/log4j2/xml/DisablingConsoleLog4j2App.java similarity index 100% rename from spring-boot-runtime/disabling-console-log4j2/src/main/java/com/baeldung/springbootlogging/disablingconsole/log4j2/xml/DisablingConsoleLog4j2App.java rename to spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/src/main/java/com/baeldung/springbootlogging/disablingconsole/log4j2/xml/DisablingConsoleLog4j2App.java diff --git a/spring-boot-runtime/disabling-console-log4j2/src/main/java/com/baeldung/springbootlogging/disablingconsole/log4j2/xml/controllers/DisabledConsoleRestController.java b/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/src/main/java/com/baeldung/springbootlogging/disablingconsole/log4j2/xml/controllers/DisabledConsoleRestController.java similarity index 100% rename from spring-boot-runtime/disabling-console-log4j2/src/main/java/com/baeldung/springbootlogging/disablingconsole/log4j2/xml/controllers/DisabledConsoleRestController.java rename to spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/src/main/java/com/baeldung/springbootlogging/disablingconsole/log4j2/xml/controllers/DisabledConsoleRestController.java diff --git a/spring-boot-runtime/disabling-console-log4j2/src/main/resources/log4j2.xml b/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/src/main/resources/log4j2.xml similarity index 100% rename from spring-boot-runtime/disabling-console-log4j2/src/main/resources/log4j2.xml rename to spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/src/main/resources/log4j2.xml diff --git a/spring-boot-runtime/disabling-console-logback/.gitignore b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/.gitignore similarity index 100% rename from spring-boot-runtime/disabling-console-logback/.gitignore rename to spring-boot-modules/spring-boot-runtime/disabling-console-logback/.gitignore diff --git a/spring-boot-runtime/disabling-console-logback/README.md b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/README.md similarity index 100% rename from spring-boot-runtime/disabling-console-logback/README.md rename to spring-boot-modules/spring-boot-runtime/disabling-console-logback/README.md diff --git a/spring-boot-runtime/disabling-console-logback/pom.xml b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/pom.xml similarity index 86% rename from spring-boot-runtime/disabling-console-logback/pom.xml rename to spring-boot-modules/spring-boot-runtime/disabling-console-logback/pom.xml index 1a415328b6..c96dfb6a2f 100644 --- a/spring-boot-runtime/disabling-console-logback/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/pom.xml @@ -8,9 +8,8 @@ com.baeldung - spring-boot-disable-console-logging + spring-boot-runtime 0.0.1-SNAPSHOT - ../ diff --git a/spring-boot-runtime/disabling-console-logback/src/main/java/com/baeldung/springbootlogging/disablingconsole/logback/xml/DisablingConsoleLogbackApp.java b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/src/main/java/com/baeldung/springbootlogging/disablingconsole/logback/xml/DisablingConsoleLogbackApp.java similarity index 100% rename from spring-boot-runtime/disabling-console-logback/src/main/java/com/baeldung/springbootlogging/disablingconsole/logback/xml/DisablingConsoleLogbackApp.java rename to spring-boot-modules/spring-boot-runtime/disabling-console-logback/src/main/java/com/baeldung/springbootlogging/disablingconsole/logback/xml/DisablingConsoleLogbackApp.java diff --git a/spring-boot-runtime/disabling-console-logback/src/main/java/com/baeldung/springbootlogging/disablingconsole/logback/xml/controllers/DisabledConsoleRestController.java b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/src/main/java/com/baeldung/springbootlogging/disablingconsole/logback/xml/controllers/DisabledConsoleRestController.java similarity index 100% rename from spring-boot-runtime/disabling-console-logback/src/main/java/com/baeldung/springbootlogging/disablingconsole/logback/xml/controllers/DisabledConsoleRestController.java rename to spring-boot-modules/spring-boot-runtime/disabling-console-logback/src/main/java/com/baeldung/springbootlogging/disablingconsole/logback/xml/controllers/DisabledConsoleRestController.java diff --git a/spring-boot-runtime/disabling-console-logback/src/main/resources/application.properties b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/src/main/resources/application.properties similarity index 100% rename from spring-boot-runtime/disabling-console-logback/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-runtime/disabling-console-logback/src/main/resources/application.properties diff --git a/spring-boot-runtime/disabling-console-logback/src/main/resources/logback-spring.xml b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/src/main/resources/logback-spring.xml similarity index 100% rename from spring-boot-runtime/disabling-console-logback/src/main/resources/logback-spring.xml rename to spring-boot-modules/spring-boot-runtime/disabling-console-logback/src/main/resources/logback-spring.xml diff --git a/spring-boot-runtime/docker/Dockerfile b/spring-boot-modules/spring-boot-runtime/docker/Dockerfile similarity index 100% rename from spring-boot-runtime/docker/Dockerfile rename to spring-boot-modules/spring-boot-runtime/docker/Dockerfile diff --git a/spring-boot-runtime/docker/logback.xml b/spring-boot-modules/spring-boot-runtime/docker/logback.xml similarity index 100% rename from spring-boot-runtime/docker/logback.xml rename to spring-boot-modules/spring-boot-runtime/docker/logback.xml diff --git a/spring-boot-runtime/docker/run.sh b/spring-boot-modules/spring-boot-runtime/docker/run.sh similarity index 100% rename from spring-boot-runtime/docker/run.sh rename to spring-boot-modules/spring-boot-runtime/docker/run.sh diff --git a/spring-boot-runtime/pom.xml b/spring-boot-modules/spring-boot-runtime/pom.xml similarity index 95% rename from spring-boot-runtime/pom.xml rename to spring-boot-modules/spring-boot-runtime/pom.xml index baa7faebf8..df45537940 100644 --- a/spring-boot-runtime/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/pom.xml @@ -4,16 +4,22 @@ 4.0.0 spring-boot-runtime spring-boot-runtime - war + pom Demo project for Spring Boot com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 + + disabling-console-jul + disabling-console-log4j2 + disabling-console-logback + + diff --git a/spring-boot-runtime/src/main/java/com/baeldung/changeport/CustomApplication.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/CustomApplication.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/changeport/CustomApplication.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/CustomApplication.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/changeport/ServerPortCustomizer.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/ServerPortCustomizer.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/changeport/ServerPortCustomizer.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/changeport/ServerPortCustomizer.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/cors/Account.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/Account.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/cors/Account.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/Account.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/cors/AccountController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/AccountController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/cors/AccountController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/cors/AccountController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/restart/Application.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/restart/Application.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/restart/Application.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/restart/Application.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/restart/RestartController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/restart/RestartController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/restart/RestartController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/restart/RestartController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/restart/RestartService.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/restart/RestartService.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/restart/RestartService.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/restart/RestartService.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/MainApplication.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/MainApplication.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/MainApplication.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/MainApplication.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/WebConfig.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/WebConfig.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/WebConfig.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/config/WebConfig.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/repository/HeavyResourceRepository.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/repository/HeavyResourceRepository.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/repository/HeavyResourceRepository.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/repository/HeavyResourceRepository.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/BarMappingExamplesController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/BarMappingExamplesController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/BarMappingExamplesController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/BarMappingExamplesController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/CompanyController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/CompanyController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/CompanyController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/CompanyController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/DeferredResultController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/DeferredResultController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/DeferredResultController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/DeferredResultController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/HeavyResourceController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/HeavyResourceController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/HeavyResourceController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/HeavyResourceController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/ItemController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/ItemController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/ItemController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/ItemController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/MyFooController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/MyFooController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/MyFooController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/MyFooController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/PactController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/PactController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/PactController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/PactController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/SimplePostController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/SimplePostController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/SimplePostController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/SimplePostController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Company.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Company.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Company.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Company.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Foo.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Foo.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Foo.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Foo.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Item.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Item.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Item.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Item.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/ItemManager.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/ItemManager.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/ItemManager.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/ItemManager.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Views.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Views.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Views.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/dto/Views.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/exception/ResourceNotFoundException.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/exception/ResourceNotFoundException.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/exception/ResourceNotFoundException.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/sampleapp/web/exception/ResourceNotFoundException.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/shutdown/Application.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/shutdown/Application.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/shutdown/Application.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/shutdown/Application.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/shutdown/ShutdownConfig.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/shutdown/ShutdownConfig.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/shutdown/ShutdownConfig.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/shutdown/ShutdownConfig.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/shutdown/TerminateBean.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/shutdown/TerminateBean.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/shutdown/TerminateBean.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/shutdown/TerminateBean.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/shutdown/shutdown/ShutdownController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/shutdown/shutdown/ShutdownController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/shutdown/shutdown/ShutdownController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/shutdown/shutdown/ShutdownController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/LoggingApplication.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/LoggingApplication.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/LoggingApplication.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/LoggingApplication.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/LoggingController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/LoggingController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/LoggingController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/LoggingController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/SecurityConfig.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/SecurityConfig.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/SecurityConfig.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/logging/SecurityConfig.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/App.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/App.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/App.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/App.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/CustomTraceRepository.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/CustomTraceRepository.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/CustomTraceRepository.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/CustomTraceRepository.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/EchoController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/EchoController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/EchoController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/EchoController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/TraceRequestFilter.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/TraceRequestFilter.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/TraceRequestFilter.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/spring/boot/management/trace/TraceRequestFilter.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/Application.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/Application.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/app/Application.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/Application.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/CustomeRequestLoggingFilter.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/CustomeRequestLoggingFilter.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/config/CustomeRequestLoggingFilter.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/CustomeRequestLoggingFilter.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/RequestLoggingFilterConfig.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/RequestLoggingFilterConfig.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/config/RequestLoggingFilterConfig.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/RequestLoggingFilterConfig.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/data/RateCard.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/data/RateCard.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/data/RateCard.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/data/RateCard.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/data/TaxiRide.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/data/TaxiRide.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/data/TaxiRide.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/data/TaxiRide.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java diff --git a/spring-boot-runtime/src/main/java/com/baeldung/web/log/util/RequestLoggingUtil.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/util/RequestLoggingUtil.java similarity index 100% rename from spring-boot-runtime/src/main/java/com/baeldung/web/log/util/RequestLoggingUtil.java rename to spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/util/RequestLoggingUtil.java diff --git a/spring-boot-runtime/src/main/resources/application-log.properties b/spring-boot-modules/spring-boot-runtime/src/main/resources/application-log.properties similarity index 100% rename from spring-boot-runtime/src/main/resources/application-log.properties rename to spring-boot-modules/spring-boot-runtime/src/main/resources/application-log.properties diff --git a/spring-boot-runtime/src/main/resources/application-logging.properties b/spring-boot-modules/spring-boot-runtime/src/main/resources/application-logging.properties similarity index 100% rename from spring-boot-runtime/src/main/resources/application-logging.properties rename to spring-boot-modules/spring-boot-runtime/src/main/resources/application-logging.properties diff --git a/spring-boot-runtime/src/main/resources/application-tomcat.properties b/spring-boot-modules/spring-boot-runtime/src/main/resources/application-tomcat.properties similarity index 100% rename from spring-boot-runtime/src/main/resources/application-tomcat.properties rename to spring-boot-modules/spring-boot-runtime/src/main/resources/application-tomcat.properties diff --git a/spring-boot-runtime/src/main/resources/application.properties b/spring-boot-modules/spring-boot-runtime/src/main/resources/application.properties similarity index 100% rename from spring-boot-runtime/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-runtime/src/main/resources/application.properties diff --git a/spring-boot-property-exp/property-exp-custom-config/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-runtime/src/main/resources/logback.xml similarity index 100% rename from spring-boot-property-exp/property-exp-custom-config/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-runtime/src/main/resources/logback.xml diff --git a/spring-boot-runtime/src/main/webapp/WEB-INF/api-servlet.xml b/spring-boot-modules/spring-boot-runtime/src/main/webapp/WEB-INF/api-servlet.xml similarity index 100% rename from spring-boot-runtime/src/main/webapp/WEB-INF/api-servlet.xml rename to spring-boot-modules/spring-boot-runtime/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-boot-runtime/src/main/webapp/WEB-INF/company.html b/spring-boot-modules/spring-boot-runtime/src/main/webapp/WEB-INF/company.html similarity index 100% rename from spring-boot-runtime/src/main/webapp/WEB-INF/company.html rename to spring-boot-modules/spring-boot-runtime/src/main/webapp/WEB-INF/company.html diff --git a/spring-boot-runtime/src/main/webapp/WEB-INF/spring-views.xml b/spring-boot-modules/spring-boot-runtime/src/main/webapp/WEB-INF/spring-views.xml similarity index 100% rename from spring-boot-runtime/src/main/webapp/WEB-INF/spring-views.xml rename to spring-boot-modules/spring-boot-runtime/src/main/webapp/WEB-INF/spring-views.xml diff --git a/spring-boot-runtime/src/main/webapp/WEB-INF/web.xml b/spring-boot-modules/spring-boot-runtime/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-boot-runtime/src/main/webapp/WEB-INF/web.xml rename to spring-boot-modules/spring-boot-runtime/src/main/webapp/WEB-INF/web.xml diff --git a/spring-boot-runtime/src/test/java/com/baeldung/restart/RestartApplicationManualTest.java b/spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/restart/RestartApplicationManualTest.java similarity index 100% rename from spring-boot-runtime/src/test/java/com/baeldung/restart/RestartApplicationManualTest.java rename to spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/restart/RestartApplicationManualTest.java diff --git a/spring-boot-runtime/src/test/java/com/baeldung/shutdown/ShutdownApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/shutdown/ShutdownApplicationIntegrationTest.java similarity index 100% rename from spring-boot-runtime/src/test/java/com/baeldung/shutdown/ShutdownApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/shutdown/ShutdownApplicationIntegrationTest.java diff --git a/spring-boot-runtime/src/test/java/com/baeldung/web/controller/HeavyResourceControllerIntegrationTest.java b/spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/web/controller/HeavyResourceControllerIntegrationTest.java similarity index 100% rename from spring-boot-runtime/src/test/java/com/baeldung/web/controller/HeavyResourceControllerIntegrationTest.java rename to spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/web/controller/HeavyResourceControllerIntegrationTest.java diff --git a/spring-boot-runtime/src/test/java/com/baeldung/web/controller/TaxiFareControllerIntegrationTest.java b/spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/web/controller/TaxiFareControllerIntegrationTest.java similarity index 100% rename from spring-boot-runtime/src/test/java/com/baeldung/web/controller/TaxiFareControllerIntegrationTest.java rename to spring-boot-modules/spring-boot-runtime/src/test/java/com/baeldung/web/controller/TaxiFareControllerIntegrationTest.java diff --git a/spring-boot-runtime/src/test/resources/application-integrationtest.properties b/spring-boot-modules/spring-boot-runtime/src/test/resources/application-integrationtest.properties similarity index 100% rename from spring-boot-runtime/src/test/resources/application-integrationtest.properties rename to spring-boot-modules/spring-boot-runtime/src/test/resources/application-integrationtest.properties diff --git a/spring-boot-runtime/src/test/resources/application.properties b/spring-boot-modules/spring-boot-runtime/src/test/resources/application.properties similarity index 100% rename from spring-boot-runtime/src/test/resources/application.properties rename to spring-boot-modules/spring-boot-runtime/src/test/resources/application.properties diff --git a/spring-boot-springdoc/README.md b/spring-boot-modules/spring-boot-springdoc/README.md similarity index 100% rename from spring-boot-springdoc/README.md rename to spring-boot-modules/spring-boot-springdoc/README.md diff --git a/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml similarity index 84% rename from spring-boot-springdoc/pom.xml rename to spring-boot-modules/spring-boot-springdoc/pom.xml index 8c35e38ae6..9212e56c5a 100644 --- a/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -13,10 +13,11 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 + 1.8 @@ -36,12 +37,23 @@ org.springdoc springdoc-openapi-core - 1.1.45 + 1.1.49 + + + io.github.classgraph + classgraph + + org.springdoc springdoc-openapi-ui - 1.1.45 + 1.1.49 + + + io.github.classgraph + classgraph + 4.8.44 @@ -62,7 +74,7 @@ org.springframework.boot spring-boot-maven-plugin - 2.1.8.RELEASE + 2.2.2.RELEASE pre-integration-test diff --git a/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/SpringdocApplication.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/SpringdocApplication.java similarity index 100% rename from spring-boot-springdoc/src/main/java/com/baeldung/springdoc/SpringdocApplication.java rename to spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/SpringdocApplication.java diff --git a/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java similarity index 100% rename from spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java rename to spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java diff --git a/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/exception/BookNotFoundException.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/exception/BookNotFoundException.java similarity index 100% rename from spring-boot-springdoc/src/main/java/com/baeldung/springdoc/exception/BookNotFoundException.java rename to spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/exception/BookNotFoundException.java diff --git a/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/exception/GlobalControllerExceptionHandler.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/exception/GlobalControllerExceptionHandler.java similarity index 100% rename from spring-boot-springdoc/src/main/java/com/baeldung/springdoc/exception/GlobalControllerExceptionHandler.java rename to spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/exception/GlobalControllerExceptionHandler.java diff --git a/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/model/Book.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/model/Book.java similarity index 100% rename from spring-boot-springdoc/src/main/java/com/baeldung/springdoc/model/Book.java rename to spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/model/Book.java diff --git a/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/repository/BookRepository.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/repository/BookRepository.java similarity index 100% rename from spring-boot-springdoc/src/main/java/com/baeldung/springdoc/repository/BookRepository.java rename to spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/repository/BookRepository.java diff --git a/spring-boot-springdoc/src/main/resources/application.properties b/spring-boot-modules/spring-boot-springdoc/src/main/resources/application.properties similarity index 100% rename from spring-boot-springdoc/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-springdoc/src/main/resources/application.properties diff --git a/spring-boot-springdoc/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-springdoc/src/main/resources/logback.xml similarity index 100% rename from spring-boot-springdoc/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-springdoc/src/main/resources/logback.xml diff --git a/spring-boot-springdoc/src/test/java/com/baeldung/springdoc/SpringContextTest.java b/spring-boot-modules/spring-boot-springdoc/src/test/java/com/baeldung/springdoc/SpringContextTest.java similarity index 100% rename from spring-boot-springdoc/src/test/java/com/baeldung/springdoc/SpringContextTest.java rename to spring-boot-modules/spring-boot-springdoc/src/test/java/com/baeldung/springdoc/SpringContextTest.java diff --git a/spring-boot-testing/.gitignore b/spring-boot-modules/spring-boot-testing/.gitignore similarity index 100% rename from spring-boot-testing/.gitignore rename to spring-boot-modules/spring-boot-testing/.gitignore diff --git a/spring-boot-testing/.mvn/wrapper/maven-wrapper.properties b/spring-boot-modules/spring-boot-testing/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from spring-boot-testing/.mvn/wrapper/maven-wrapper.properties rename to spring-boot-modules/spring-boot-testing/.mvn/wrapper/maven-wrapper.properties diff --git a/spring-boot-testing/README.md b/spring-boot-modules/spring-boot-testing/README.md similarity index 100% rename from spring-boot-testing/README.md rename to spring-boot-modules/spring-boot-testing/README.md diff --git a/spring-boot-testing/mvnw b/spring-boot-modules/spring-boot-testing/mvnw similarity index 100% rename from spring-boot-testing/mvnw rename to spring-boot-modules/spring-boot-testing/mvnw diff --git a/spring-boot-testing/mvnw.cmd b/spring-boot-modules/spring-boot-testing/mvnw.cmd similarity index 100% rename from spring-boot-testing/mvnw.cmd rename to spring-boot-modules/spring-boot-testing/mvnw.cmd diff --git a/spring-boot-testing/pom.xml b/spring-boot-modules/spring-boot-testing/pom.xml similarity index 95% rename from spring-boot-testing/pom.xml rename to spring-boot-modules/spring-boot-testing/pom.xml index ebe87fdd70..8b16b13733 100644 --- a/spring-boot-testing/pom.xml +++ b/spring-boot-modules/spring-boot-testing/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 @@ -42,7 +42,7 @@ it.ozimov embedded-redis - 0.7.2 + ${redis.version} test @@ -131,6 +131,8 @@ 2.2.4 1.2-groovy-2.4 1.6 + 0.7.2 + 2.1.9.RELEASE diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/Application.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/Application.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/boot/Application.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/Application.java diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/controller/rest/HomeController.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/controller/rest/HomeController.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/boot/controller/rest/HomeController.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/controller/rest/HomeController.java diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/controller/rest/WebController.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/controller/rest/WebController.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/boot/controller/rest/WebController.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/controller/rest/WebController.java diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisConfiguration.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisConfiguration.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisConfiguration.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisConfiguration.java diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisProperties.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisProperties.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisProperties.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisProperties.java diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/User.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/User.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/User.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/User.java diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepository.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepository.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepository.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepository.java diff --git a/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/component/OtherComponent.java diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelApplication.java diff --git a/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java similarity index 100% rename from spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java rename to spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/testloglevel/TestLogLevelController.java diff --git a/spring-boot-testing/src/main/resources/application-test.properties b/spring-boot-modules/spring-boot-testing/src/main/resources/application-test.properties similarity index 100% rename from spring-boot-testing/src/main/resources/application-test.properties rename to spring-boot-modules/spring-boot-testing/src/main/resources/application-test.properties diff --git a/spring-boot-testing/src/main/resources/application.properties b/spring-boot-modules/spring-boot-testing/src/main/resources/application.properties similarity index 100% rename from spring-boot-testing/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-testing/src/main/resources/application.properties diff --git a/spring-boot-testing/src/test/groovy/com/baeldung/boot/LoadContextTest.groovy b/spring-boot-modules/spring-boot-testing/src/test/groovy/com/baeldung/boot/LoadContextTest.groovy similarity index 100% rename from spring-boot-testing/src/test/groovy/com/baeldung/boot/LoadContextTest.groovy rename to spring-boot-modules/spring-boot-testing/src/test/groovy/com/baeldung/boot/LoadContextTest.groovy diff --git a/spring-boot-testing/src/test/groovy/com/baeldung/boot/WebControllerTest.groovy b/spring-boot-modules/spring-boot-testing/src/test/groovy/com/baeldung/boot/WebControllerTest.groovy similarity index 100% rename from spring-boot-testing/src/test/groovy/com/baeldung/boot/WebControllerTest.groovy rename to spring-boot-modules/spring-boot-testing/src/test/groovy/com/baeldung/boot/WebControllerTest.groovy diff --git a/spring-boot-testing/src/test/groovy/com/baeldung/boot/WebControllerTest.groovy alias b/spring-boot-modules/spring-boot-testing/src/test/groovy/com/baeldung/boot/WebControllerTest.groovy alias similarity index 100% rename from spring-boot-testing/src/test/groovy/com/baeldung/boot/WebControllerTest.groovy alias rename to spring-boot-modules/spring-boot-testing/src/test/groovy/com/baeldung/boot/WebControllerTest.groovy alias diff --git a/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig1IntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig1IntegrationTest.java similarity index 76% rename from spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig1IntegrationTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig1IntegrationTest.java index a4a29cddf3..2ca0c74901 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig1IntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig1IntegrationTest.java @@ -1,26 +1,32 @@ package com.baeldung.autoconfig.exclude; -import static org.junit.Assert.assertEquals; +import com.baeldung.boot.Application; import io.restassured.RestAssured; - import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.boot.Application; +import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.DEFINED_PORT) +@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT) @TestPropertySource(properties = "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration") public class ExcludeAutoConfig1IntegrationTest { + /** + * Encapsulates the random port the test server is listening on. + */ + @LocalServerPort + private int port; + @Test public void givenSecurityConfigExcluded_whenAccessHome_thenNoAuthenticationRequired() { - int statusCode = RestAssured.get("http://localhost:8080/").statusCode(); + int statusCode = RestAssured.get("http://localhost:" + port).statusCode(); assertEquals(HttpStatus.OK.value(), statusCode); } } diff --git a/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig2IntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig2IntegrationTest.java similarity index 74% rename from spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig2IntegrationTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig2IntegrationTest.java index cdf79b159c..c0bd6570a1 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig2IntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig2IntegrationTest.java @@ -1,26 +1,32 @@ package com.baeldung.autoconfig.exclude; -import static org.junit.Assert.assertEquals; +import com.baeldung.boot.Application; import io.restassured.RestAssured; - import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.boot.Application; +import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.DEFINED_PORT) +@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class ExcludeAutoConfig2IntegrationTest { + /** + * Encapsulates the random port the test server is listening on. + */ + @LocalServerPort + private int port; + @Test public void givenSecurityConfigExcluded_whenAccessHome_thenNoAuthenticationRequired() { - int statusCode = RestAssured.get("http://localhost:8080/").statusCode(); + int statusCode = RestAssured.get("http://localhost:" + port).statusCode(); assertEquals(HttpStatus.OK.value(), statusCode); } } diff --git a/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig3IntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig3IntegrationTest.java similarity index 77% rename from spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig3IntegrationTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig3IntegrationTest.java index 0e45d1e9e5..1642d4b932 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig3IntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig3IntegrationTest.java @@ -1,27 +1,33 @@ package com.baeldung.autoconfig.exclude; -import static org.junit.Assert.assertEquals; +import com.baeldung.boot.Application; import io.restassured.RestAssured; - import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.boot.Application; +import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.DEFINED_PORT) +@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT) @EnableAutoConfiguration(exclude=SecurityAutoConfiguration.class) public class ExcludeAutoConfig3IntegrationTest { + /** + * Encapsulates the random port the test server is listening on. + */ + @LocalServerPort + private int port; + @Test public void givenSecurityConfigExcluded_whenAccessHome_thenNoAuthenticationRequired() { - int statusCode = RestAssured.get("http://localhost:8080/").statusCode(); + int statusCode = RestAssured.get("http://localhost:" + port).statusCode(); assertEquals(HttpStatus.OK.value(), statusCode); } } diff --git a/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig4IntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig4IntegrationTest.java similarity index 70% rename from spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig4IntegrationTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig4IntegrationTest.java index 8429aed6cd..1aa453348b 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig4IntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/ExcludeAutoConfig4IntegrationTest.java @@ -1,22 +1,29 @@ package com.baeldung.autoconfig.exclude; -import static org.junit.Assert.assertEquals; import io.restassured.RestAssured; - import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.assertEquals; + @RunWith(SpringRunner.class) -@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.DEFINED_PORT) +@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class ExcludeAutoConfig4IntegrationTest { + /** + * Encapsulates the random port the test server is listening on. + */ + @LocalServerPort + private int port; + @Test public void givenSecurityConfigExcluded_whenAccessHome_thenNoAuthenticationRequired() { - int statusCode = RestAssured.get("http://localhost:8080/").statusCode(); + int statusCode = RestAssured.get("http://localhost:" + port).statusCode(); assertEquals(HttpStatus.OK.value(), statusCode); } } diff --git a/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/TestApplication.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/TestApplication.java similarity index 100% rename from spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/TestApplication.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/autoconfig/exclude/TestApplication.java diff --git a/spring-boot-testing/src/test/java/com/baeldung/boot/SpringContextTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/SpringContextTest.java similarity index 100% rename from spring-boot-testing/src/test/java/com/baeldung/boot/SpringContextTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/SpringContextTest.java diff --git a/spring-boot-testing/src/test/java/com/baeldung/boot/autoconfig/AutoConfigIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/autoconfig/AutoConfigIntegrationTest.java similarity index 73% rename from spring-boot-testing/src/test/java/com/baeldung/boot/autoconfig/AutoConfigIntegrationTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/autoconfig/AutoConfigIntegrationTest.java index fe71f44ddf..44a02c0c80 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/boot/autoconfig/AutoConfigIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/autoconfig/AutoConfigIntegrationTest.java @@ -1,30 +1,36 @@ package com.baeldung.boot.autoconfig; -import static org.junit.Assert.assertEquals; +import com.baeldung.boot.Application; import io.restassured.RestAssured; - import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.boot.Application; +import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.DEFINED_PORT) +@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class AutoConfigIntegrationTest { + /** + * Encapsulates the random port the test server is listening on. + */ + @LocalServerPort + private int port; + @Test public void givenNoAuthentication_whenAccessHome_thenUnauthorized() { - int statusCode = RestAssured.get("http://localhost:8080/").statusCode(); + int statusCode = RestAssured.get("http://localhost:" + port).statusCode(); assertEquals(HttpStatus.UNAUTHORIZED.value(), statusCode); } @Test public void givenAuthentication_whenAccessHome_thenOK() { - int statusCode = RestAssured.given().auth().basic("john", "123").get("http://localhost:8080/").statusCode(); + int statusCode = RestAssured.given().auth().basic("john", "123").get("http://localhost:" + port).statusCode(); assertEquals(HttpStatus.OK.value(), statusCode); } } diff --git a/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java similarity index 100% rename from spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java diff --git a/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepositoryIntegrationTest.java similarity index 100% rename from spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepositoryIntegrationTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepositoryIntegrationTest.java diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java similarity index 94% rename from spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java index 7a1eb4adbe..f8bd61e5c7 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackMultiProfileTestLogLevelIntegrationTest.java @@ -1,7 +1,5 @@ package com.baeldung.testloglevel; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -13,9 +11,14 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.rule.OutputCapture; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.ResponseEntity; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_CLASS; + +@DirtiesContext(classMode = AFTER_CLASS) @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class) @EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java similarity index 94% rename from spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java index af3bafdc2e..ffe9d400ed 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/LogbackTestLogLevelIntegrationTest.java @@ -1,7 +1,5 @@ package com.baeldung.testloglevel; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -13,9 +11,14 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.rule.OutputCapture; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.ResponseEntity; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_CLASS; + +@DirtiesContext(classMode = AFTER_CLASS) @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class) @EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) diff --git a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java similarity index 94% rename from spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java rename to spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java index 5609ce6c01..6e80f50c00 100644 --- a/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/testloglevel/TestLogLevelWithProfileIntegrationTest.java @@ -11,12 +11,15 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.rule.OutputCapture; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.ResponseEntity; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_CLASS; @RunWith(SpringRunner.class) +@DirtiesContext(classMode = AFTER_CLASS) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = TestLogLevelApplication.class) @EnableAutoConfiguration(exclude = SecurityAutoConfiguration.class) @ActiveProfiles("logging-test") diff --git a/spring-boot-testing/src/test/resources/application-logback-test.properties b/spring-boot-modules/spring-boot-testing/src/test/resources/application-logback-test.properties similarity index 100% rename from spring-boot-testing/src/test/resources/application-logback-test.properties rename to spring-boot-modules/spring-boot-testing/src/test/resources/application-logback-test.properties diff --git a/spring-boot-testing/src/test/resources/application-logback-test2.properties b/spring-boot-modules/spring-boot-testing/src/test/resources/application-logback-test2.properties similarity index 100% rename from spring-boot-testing/src/test/resources/application-logback-test2.properties rename to spring-boot-modules/spring-boot-testing/src/test/resources/application-logback-test2.properties diff --git a/spring-boot-testing/src/test/resources/application-logging-test.properties b/spring-boot-modules/spring-boot-testing/src/test/resources/application-logging-test.properties similarity index 100% rename from spring-boot-testing/src/test/resources/application-logging-test.properties rename to spring-boot-modules/spring-boot-testing/src/test/resources/application-logging-test.properties diff --git a/spring-boot-testing/src/test/resources/application-test.properties b/spring-boot-modules/spring-boot-testing/src/test/resources/application-test.properties similarity index 100% rename from spring-boot-testing/src/test/resources/application-test.properties rename to spring-boot-modules/spring-boot-testing/src/test/resources/application-test.properties diff --git a/spring-boot-testing/src/test/resources/application.properties b/spring-boot-modules/spring-boot-testing/src/test/resources/application.properties similarity index 100% rename from spring-boot-testing/src/test/resources/application.properties rename to spring-boot-modules/spring-boot-testing/src/test/resources/application.properties diff --git a/spring-boot-testing/src/test/resources/logback-multiprofile.xml b/spring-boot-modules/spring-boot-testing/src/test/resources/logback-multiprofile.xml similarity index 100% rename from spring-boot-testing/src/test/resources/logback-multiprofile.xml rename to spring-boot-modules/spring-boot-testing/src/test/resources/logback-multiprofile.xml diff --git a/spring-boot-testing/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot-testing/src/test/resources/logback-test.xml similarity index 100% rename from spring-boot-testing/src/test/resources/logback-test.xml rename to spring-boot-modules/spring-boot-testing/src/test/resources/logback-test.xml diff --git a/spring-boot-vue/.gitignore b/spring-boot-modules/spring-boot-vue/.gitignore similarity index 100% rename from spring-boot-vue/.gitignore rename to spring-boot-modules/spring-boot-vue/.gitignore diff --git a/spring-boot-vue/README.md b/spring-boot-modules/spring-boot-vue/README.md similarity index 100% rename from spring-boot-vue/README.md rename to spring-boot-modules/spring-boot-vue/README.md diff --git a/spring-boot-vue/pom.xml b/spring-boot-modules/spring-boot-vue/pom.xml similarity index 96% rename from spring-boot-vue/pom.xml rename to spring-boot-modules/spring-boot-vue/pom.xml index 98bba784d2..0a6307e46b 100644 --- a/spring-boot-vue/pom.xml +++ b/spring-boot-modules/spring-boot-vue/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-boot-vue/src/main/java/com/baeldung/springbootmvc/SpringBootMvcApplication.java b/spring-boot-modules/spring-boot-vue/src/main/java/com/baeldung/springbootmvc/SpringBootMvcApplication.java similarity index 100% rename from spring-boot-vue/src/main/java/com/baeldung/springbootmvc/SpringBootMvcApplication.java rename to spring-boot-modules/spring-boot-vue/src/main/java/com/baeldung/springbootmvc/SpringBootMvcApplication.java diff --git a/spring-boot-vue/src/main/java/com/baeldung/springbootmvc/controllers/MainController.java b/spring-boot-modules/spring-boot-vue/src/main/java/com/baeldung/springbootmvc/controllers/MainController.java similarity index 100% rename from spring-boot-vue/src/main/java/com/baeldung/springbootmvc/controllers/MainController.java rename to spring-boot-modules/spring-boot-vue/src/main/java/com/baeldung/springbootmvc/controllers/MainController.java diff --git a/spring-boot-vue/src/main/resources/application.properties b/spring-boot-modules/spring-boot-vue/src/main/resources/application.properties similarity index 100% rename from spring-boot-vue/src/main/resources/application.properties rename to spring-boot-modules/spring-boot-vue/src/main/resources/application.properties diff --git a/spring-boot-property-exp/property-exp-default-config/src/main/resources/logback.xml b/spring-boot-modules/spring-boot-vue/src/main/resources/logback.xml similarity index 100% rename from spring-boot-property-exp/property-exp-default-config/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot-vue/src/main/resources/logback.xml diff --git a/spring-boot-vue/src/main/resources/static/favicon.ico b/spring-boot-modules/spring-boot-vue/src/main/resources/static/favicon.ico similarity index 100% rename from spring-boot-vue/src/main/resources/static/favicon.ico rename to spring-boot-modules/spring-boot-vue/src/main/resources/static/favicon.ico diff --git a/spring-boot-vue/src/main/resources/templates/index.html b/spring-boot-modules/spring-boot-vue/src/main/resources/templates/index.html similarity index 100% rename from spring-boot-vue/src/main/resources/templates/index.html rename to spring-boot-modules/spring-boot-vue/src/main/resources/templates/index.html diff --git a/spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationIntegrationTest.java similarity index 100% rename from spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationIntegrationTest.java diff --git a/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot/.gitignore b/spring-boot-modules/spring-boot/.gitignore similarity index 89% rename from spring-boot/.gitignore rename to spring-boot-modules/spring-boot/.gitignore index 88e3308e9d..da7c2c5c0a 100644 --- a/spring-boot/.gitignore +++ b/spring-boot-modules/spring-boot/.gitignore @@ -1,5 +1,5 @@ -/target/ -.settings/ -.classpath -.project - +/target/ +.settings/ +.classpath +.project + diff --git a/spring-boot/.mvn/wrapper/maven-wrapper.properties b/spring-boot-modules/spring-boot/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from spring-boot/.mvn/wrapper/maven-wrapper.properties rename to spring-boot-modules/spring-boot/.mvn/wrapper/maven-wrapper.properties diff --git a/spring-boot/README.MD b/spring-boot-modules/spring-boot/README.MD similarity index 100% rename from spring-boot/README.MD rename to spring-boot-modules/spring-boot/README.MD diff --git a/spring-boot/mvnw b/spring-boot-modules/spring-boot/mvnw similarity index 100% rename from spring-boot/mvnw rename to spring-boot-modules/spring-boot/mvnw diff --git a/spring-boot/mvnw.cmd b/spring-boot-modules/spring-boot/mvnw.cmd similarity index 97% rename from spring-boot/mvnw.cmd rename to spring-boot-modules/spring-boot/mvnw.cmd index 4f0b068a03..6a6eec39ba 100755 --- a/spring-boot/mvnw.cmd +++ b/spring-boot-modules/spring-boot/mvnw.cmd @@ -1,145 +1,145 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/spring-boot/pom.xml b/spring-boot-modules/spring-boot/pom.xml similarity index 94% rename from spring-boot/pom.xml rename to spring-boot-modules/spring-boot/pom.xml index 2152a0a00d..3fb1ec9acc 100644 --- a/spring-boot/pom.xml +++ b/spring-boot-modules/spring-boot/pom.xml @@ -1,256 +1,268 @@ - - - 4.0.0 - spring-boot - spring-boot - war - This is simple boot application for Spring boot actuator test - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 - - - - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - - - org.junit.platform - junit-platform-launcher - ${junit-platform.version} - test - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.ehcache - ehcache - - - org.hibernate - hibernate-ehcache - - - org.springframework.boot - spring-boot-starter-actuator - - - - com.graphql-java - graphql-spring-boot-starter - ${graphql-spring-boot-starter.version} - - - com.graphql-java - graphql-java-tools - ${graphql-java-tools.version} - - - com.graphql-java - graphiql-spring-boot-starter - ${graphiql-spring-boot-starter.version} - - - - org.springframework.boot - spring-boot-starter-tomcat - - - - org.springframework.boot - spring-boot-starter-test - test - - - - io.dropwizard.metrics - metrics-core - - - - com.h2database - h2 - - - - org.springframework.boot - spring-boot-starter - - - com.jayway.jsonpath - json-path - test - - - - com.google.guava - guava - ${guava.version} - - - - org.apache.tomcat - tomcat-servlet-api - ${tomee-servlet-api.version} - provided - - - - org.togglz - togglz-spring-boot-starter - ${togglz.version} - - - - org.togglz - togglz-spring-security - ${togglz.version} - - - - org.apache.activemq - artemis-server - - - - com.rometools - rome - ${rome.version} - - - - de.codecentric - chaos-monkey-spring-boot - ${chaos.monkey.version} - - - - javax.validation - validation-api - - - - - spring-boot - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-war-plugin - - - - pl.project13.maven - git-commit-id-plugin - ${git-commit-id-plugin.version} - - - get-the-git-infos - - revision - - initialize - - - validate-the-git-infos - - validateRevision - - package - - - - true - ${project.build.outputDirectory}/git.properties - - - - - - - - - - autoconfiguration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*LiveTest.java - **/*IntegrationTest.java - **/*IntTest.java - - - **/AutoconfigurationTest.java - - - - - - - json - - - - - - - - - - - com.baeldung.intro.App - 8.5.11 - 2.4.1.Final - 1.9.0 - 2.0.0 - 5.0.2 - 5.0.2 - 5.2.4 - 18.0 - 2.2.4 - - - + + + 4.0.0 + spring-boot + spring-boot + war + This is simple boot application for Spring boot actuator test + 0.0.1-SNAPSHOT + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + + + org.junit.platform + junit-platform-launcher + ${junit-platform.version} + test + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.ehcache + ehcache + + + org.hibernate + hibernate-ehcache + + + org.springframework.boot + spring-boot-starter-actuator + + + + com.graphql-java + graphql-spring-boot-starter + ${graphql-spring-boot-starter.version} + + + com.graphql-java + graphql-java-tools + ${graphql-java-tools.version} + + + com.graphql-java + graphiql-spring-boot-starter + ${graphiql-spring-boot-starter.version} + + + + org.springframework.boot + spring-boot-starter-tomcat + + + + org.springframework.boot + spring-boot-starter-test + test + + + + io.dropwizard.metrics + metrics-core + + + + com.h2database + h2 + + + + org.springframework.boot + spring-boot-starter + + + com.jayway.jsonpath + json-path + test + + + + com.google.guava + guava + ${guava.version} + + + + org.apache.tomcat + tomcat-servlet-api + ${tomee-servlet-api.version} + provided + + + + org.togglz + togglz-spring-boot-starter + ${togglz.version} + + + + org.togglz + togglz-spring-security + ${togglz.version} + + + + org.apache.activemq + artemis-server + + + + com.rometools + rome + ${rome.version} + + + + de.codecentric + chaos-monkey-spring-boot + ${chaos.monkey.version} + + + + javax.validation + validation-api + + + + + spring-boot + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-war-plugin + + + + pl.project13.maven + git-commit-id-plugin + ${git-commit-id-plugin.version} + + + get-the-git-infos + + revision + + initialize + + + validate-the-git-infos + + validateRevision + + package + + + + true + ${project.build.outputDirectory}/git.properties + + + + + org.apache.maven.plugins + maven-resources-plugin + + + @ + + false + + + + + + + + + autoconfiguration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + **/*IntegrationTest.java + **/*IntTest.java + + + **/AutoconfigurationTest.java + + + + + + + json + + + + + + + + + + + com.baeldung.intro.App + 8.5.11 + 2.4.1.Final + 1.9.0 + 2.0.0 + 5.0.2 + 5.0.2 + 5.2.4 + 18.0 + 2.2.4 + @ + + + diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootAnnotatedApp.java diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/SpringBootPlainApp.java diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/AttrListener.java diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/EchoServlet.java diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloFilter.java diff --git a/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/annotation/servletcomponentscan/components/HelloServlet.java diff --git a/spring-boot/src/main/java/com/baeldung/beanvalidation/application/Application.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/Application.java similarity index 97% rename from spring-boot/src/main/java/com/baeldung/beanvalidation/application/Application.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/Application.java index b37eec9da0..e2b933a67e 100644 --- a/spring-boot/src/main/java/com/baeldung/beanvalidation/application/Application.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/Application.java @@ -1,28 +1,28 @@ -package com.baeldung.beanvalidation.application; - -import com.baeldung.beanvalidation.application.entities.User; -import com.baeldung.beanvalidation.application.repositories.UserRepository; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - - @Bean - public CommandLineRunner run(UserRepository userRepository) throws Exception { - return (String[] args) -> { - User user1 = new User("Bob", "bob@domain.com"); - User user2 = new User("Jenny", "jenny@domain.com"); - userRepository.save(user1); - userRepository.save(user2); - userRepository.findAll().forEach(System.out::println); - }; - } -} +package com.baeldung.beanvalidation.application; + +import com.baeldung.beanvalidation.application.entities.User; +import com.baeldung.beanvalidation.application.repositories.UserRepository; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + @Bean + public CommandLineRunner run(UserRepository userRepository) throws Exception { + return (String[] args) -> { + User user1 = new User("Bob", "bob@domain.com"); + User user2 = new User("Jenny", "jenny@domain.com"); + userRepository.save(user1); + userRepository.save(user2); + userRepository.findAll().forEach(System.out::println); + }; + } +} diff --git a/spring-boot/src/main/java/com/baeldung/beanvalidation/application/controllers/UserController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/controllers/UserController.java similarity index 97% rename from spring-boot/src/main/java/com/baeldung/beanvalidation/application/controllers/UserController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/controllers/UserController.java index 0c47e27e25..abda9a9449 100644 --- a/spring-boot/src/main/java/com/baeldung/beanvalidation/application/controllers/UserController.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/controllers/UserController.java @@ -1,53 +1,53 @@ -package com.baeldung.beanvalidation.application.controllers; - -import com.baeldung.beanvalidation.application.entities.User; -import com.baeldung.beanvalidation.application.repositories.UserRepository; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.validation.Valid; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.FieldError; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class UserController { - - private final UserRepository userRepository; - - @Autowired - public UserController(UserRepository userRepository) { - this.userRepository = userRepository; - } - - @GetMapping("/users") - public List getUsers() { - return (List) userRepository.findAll(); - } - - @PostMapping("/users") - ResponseEntity addUser(@Valid @RequestBody User user) { - return ResponseEntity.ok("User is valid"); - } - - @ResponseStatus(HttpStatus.BAD_REQUEST) - @ExceptionHandler(MethodArgumentNotValidException.class) - public Map handleValidationExceptions(MethodArgumentNotValidException ex) { - Map errors = new HashMap<>(); - ex.getBindingResult().getAllErrors().forEach((error) -> { - String fieldName = ((FieldError) error).getField(); - String errorMessage = error.getDefaultMessage(); - errors.put(fieldName, errorMessage); - }); - return errors; - } -} +package com.baeldung.beanvalidation.application.controllers; + +import com.baeldung.beanvalidation.application.entities.User; +import com.baeldung.beanvalidation.application.repositories.UserRepository; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.FieldError; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UserController { + + private final UserRepository userRepository; + + @Autowired + public UserController(UserRepository userRepository) { + this.userRepository = userRepository; + } + + @GetMapping("/users") + public List getUsers() { + return (List) userRepository.findAll(); + } + + @PostMapping("/users") + ResponseEntity addUser(@Valid @RequestBody User user) { + return ResponseEntity.ok("User is valid"); + } + + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ExceptionHandler(MethodArgumentNotValidException.class) + public Map handleValidationExceptions(MethodArgumentNotValidException ex) { + Map errors = new HashMap<>(); + ex.getBindingResult().getAllErrors().forEach((error) -> { + String fieldName = ((FieldError) error).getField(); + String errorMessage = error.getDefaultMessage(); + errors.put(fieldName, errorMessage); + }); + return errors; + } +} diff --git a/spring-boot/src/main/java/com/baeldung/beanvalidation/application/entities/User.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/entities/User.java similarity index 95% rename from spring-boot/src/main/java/com/baeldung/beanvalidation/application/entities/User.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/entities/User.java index 8233d08f4e..511ce47775 100644 --- a/spring-boot/src/main/java/com/baeldung/beanvalidation/application/entities/User.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/entities/User.java @@ -1,50 +1,50 @@ -package com.baeldung.beanvalidation.application.entities; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotBlank; - -@Entity -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - @NotBlank(message = "Name is mandatory") - private String name; - - @NotBlank(message = "Email is mandatory") - private String email; - - public User(){} - - public User(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; - } - - @Override - public String toString() { - return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; - } -} +package com.baeldung.beanvalidation.application.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.validation.constraints.NotBlank; + +@Entity +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @NotBlank(message = "Name is mandatory") + private String name; + + @NotBlank(message = "Email is mandatory") + private String email; + + public User(){} + + public User(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; + } + + @Override + public String toString() { + return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; + } +} diff --git a/spring-boot/src/main/java/com/baeldung/beanvalidation/application/repositories/UserRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/repositories/UserRepository.java similarity index 97% rename from spring-boot/src/main/java/com/baeldung/beanvalidation/application/repositories/UserRepository.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/repositories/UserRepository.java index 8bf7a9f8b2..7b55d15a01 100644 --- a/spring-boot/src/main/java/com/baeldung/beanvalidation/application/repositories/UserRepository.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/beanvalidation/application/repositories/UserRepository.java @@ -1,9 +1,9 @@ -package com.baeldung.beanvalidation.application.repositories; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -import com.baeldung.beanvalidation.application.entities.User; - -@Repository -public interface UserRepository extends CrudRepository {} +package com.baeldung.beanvalidation.application.repositories; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import com.baeldung.beanvalidation.application.entities.User; + +@Repository +public interface UserRepository extends CrudRepository {} diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/FilterConfig.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/FilterConfig.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/bootcustomfilters/FilterConfig.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/FilterConfig.java diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/buildproperties/Application.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/buildproperties/Application.java new file mode 100644 index 0000000000..405cec3eac --- /dev/null +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/buildproperties/Application.java @@ -0,0 +1,18 @@ +package com.baeldung.buildproperties; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.PropertySource; + +@SpringBootApplication +@ComponentScan(basePackages = "com.baeldung.buildproperties") +@PropertySource("classpath:build.properties") +//@PropertySource("classpath:build.yml") +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/buildproperties/BuildInfoService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/buildproperties/BuildInfoService.java new file mode 100644 index 0000000000..2a0d27188e --- /dev/null +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/buildproperties/BuildInfoService.java @@ -0,0 +1,21 @@ +package com.baeldung.buildproperties; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +@Service +public class BuildInfoService { + @Value("${application-description}") + private String applicationDescription; + + @Value("${application-version}") + private String applicationVersion; + + public String getApplicationDescription() { + return applicationDescription; + } + + public String getApplicationVersion() { + return applicationVersion; + } +} diff --git a/spring-boot/src/main/java/com/baeldung/chaosmonkey/SpringBootChaosMonkeyApp.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/chaosmonkey/SpringBootChaosMonkeyApp.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/chaosmonkey/SpringBootChaosMonkeyApp.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/chaosmonkey/SpringBootChaosMonkeyApp.java diff --git a/spring-boot/src/main/java/com/baeldung/chaosmonkey/controller/PermissionsController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/chaosmonkey/controller/PermissionsController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/chaosmonkey/controller/PermissionsController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/chaosmonkey/controller/PermissionsController.java diff --git a/spring-boot/src/main/java/com/baeldung/chaosmonkey/service/PermissionsService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/chaosmonkey/service/PermissionsService.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/chaosmonkey/service/PermissionsService.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/chaosmonkey/service/PermissionsService.java diff --git a/spring-boot/src/main/java/com/baeldung/displayallbeans/Application.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/displayallbeans/Application.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/displayallbeans/Application.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/displayallbeans/Application.java diff --git a/spring-boot/src/main/java/com/baeldung/displayallbeans/controller/FooController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/displayallbeans/controller/FooController.java similarity index 96% rename from spring-boot/src/main/java/com/baeldung/displayallbeans/controller/FooController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/displayallbeans/controller/FooController.java index 630820ff9f..5b5b4ae834 100644 --- a/spring-boot/src/main/java/com/baeldung/displayallbeans/controller/FooController.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/displayallbeans/controller/FooController.java @@ -1,23 +1,23 @@ -package com.baeldung.displayallbeans.controller; - -import java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -import com.baeldung.displayallbeans.service.FooService; - -@Controller -public class FooController { - @Autowired - private FooService fooService; - - @GetMapping(value = "/displayallbeans") - public ResponseEntity getHeaderAndBody(Map model) { - model.put("header", fooService.getHeader()); - model.put("message", fooService.getBody()); - return ResponseEntity.ok("displayallbeans"); - } -} +package com.baeldung.displayallbeans.controller; + +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import com.baeldung.displayallbeans.service.FooService; + +@Controller +public class FooController { + @Autowired + private FooService fooService; + + @GetMapping(value = "/displayallbeans") + public ResponseEntity getHeaderAndBody(Map model) { + model.put("header", fooService.getHeader()); + model.put("message", fooService.getBody()); + return ResponseEntity.ok("displayallbeans"); + } +} diff --git a/spring-boot/src/main/java/com/baeldung/displayallbeans/service/FooService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/displayallbeans/service/FooService.java similarity index 96% rename from spring-boot/src/main/java/com/baeldung/displayallbeans/service/FooService.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/displayallbeans/service/FooService.java index 1f3c15ee0e..d3f1ea294e 100644 --- a/spring-boot/src/main/java/com/baeldung/displayallbeans/service/FooService.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/displayallbeans/service/FooService.java @@ -1,16 +1,16 @@ -package com.baeldung.displayallbeans.service; - -import org.springframework.stereotype.Service; - -@Service -public class FooService { - - public String getHeader() { - return "Display All Beans"; - } - - public String getBody() { - return "This is a sample application that displays all beans " + "in Spring IoC container using ListableBeanFactory interface " + "and Spring Boot Actuators."; - } - -} +package com.baeldung.displayallbeans.service; + +import org.springframework.stereotype.Service; + +@Service +public class FooService { + + public String getHeader() { + return "Display All Beans"; + } + + public String getBody() { + return "This is a sample application that displays all beans " + "in Spring IoC container using ListableBeanFactory interface " + "and Spring Boot Actuators."; + } + +} diff --git a/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfo.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfo.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfo.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfo.java diff --git a/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfoValidator.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfoValidator.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfoValidator.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/ContactInfoValidator.java diff --git a/spring-boot/src/main/java/com/baeldung/dynamicvalidation/DynamicValidationApp.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/DynamicValidationApp.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/dynamicvalidation/DynamicValidationApp.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/DynamicValidationApp.java diff --git a/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/CustomerController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/CustomerController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/CustomerController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/CustomerController.java diff --git a/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/PersistenceConfig.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/PersistenceConfig.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/PersistenceConfig.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/config/PersistenceConfig.java diff --git a/spring-boot/src/main/java/com/baeldung/dynamicvalidation/dao/ContactInfoExpressionRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/dao/ContactInfoExpressionRepository.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/dynamicvalidation/dao/ContactInfoExpressionRepository.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/dao/ContactInfoExpressionRepository.java diff --git a/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/ContactInfoExpression.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/ContactInfoExpression.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/ContactInfoExpression.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/ContactInfoExpression.java diff --git a/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/Customer.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/Customer.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/Customer.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/dynamicvalidation/model/Customer.java diff --git a/spring-boot/src/main/java/com/baeldung/errorhandling/ErrorHandlingApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/ErrorHandlingApplication.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/errorhandling/ErrorHandlingApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/ErrorHandlingApplication.java diff --git a/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/IndexController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/IndexController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/errorhandling/controllers/IndexController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/IndexController.java diff --git a/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java diff --git a/spring-boot/src/main/java/com/baeldung/failureanalyzer/FailureAnalyzerApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/FailureAnalyzerApplication.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/failureanalyzer/FailureAnalyzerApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/FailureAnalyzerApplication.java diff --git a/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyBeanNotOfRequiredTypeFailureAnalyzer.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyBeanNotOfRequiredTypeFailureAnalyzer.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/failureanalyzer/MyBeanNotOfRequiredTypeFailureAnalyzer.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyBeanNotOfRequiredTypeFailureAnalyzer.java diff --git a/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyDAO.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyDAO.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/failureanalyzer/MyDAO.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyDAO.java diff --git a/spring-boot/src/main/java/com/baeldung/failureanalyzer/MySecondDAO.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MySecondDAO.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/failureanalyzer/MySecondDAO.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MySecondDAO.java diff --git a/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyService.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/failureanalyzer/MyService.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/failureanalyzer/MyService.java diff --git a/spring-boot/src/main/java/com/baeldung/git/CommitIdApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/git/CommitIdApplication.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/git/CommitIdApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/git/CommitIdApplication.java diff --git a/spring-boot/src/main/java/com/baeldung/git/CommitInfoController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/git/CommitInfoController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/git/CommitInfoController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/git/CommitInfoController.java diff --git a/spring-boot/src/main/java/com/baeldung/git/README.md b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/git/README.md similarity index 100% rename from spring-boot/src/main/java/com/baeldung/git/README.md rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/git/README.md diff --git a/spring-boot/src/main/java/com/baeldung/graphql/Author.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/Author.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/graphql/Author.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/Author.java diff --git a/spring-boot/src/main/java/com/baeldung/graphql/AuthorDao.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/AuthorDao.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/graphql/AuthorDao.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/AuthorDao.java diff --git a/spring-boot/src/main/java/com/baeldung/graphql/AuthorResolver.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/AuthorResolver.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/graphql/AuthorResolver.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/AuthorResolver.java diff --git a/spring-boot/src/main/java/com/baeldung/graphql/GraphqlConfiguration.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/GraphqlConfiguration.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/graphql/GraphqlConfiguration.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/GraphqlConfiguration.java diff --git a/spring-boot/src/main/java/com/baeldung/graphql/Mutation.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/Mutation.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/graphql/Mutation.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/Mutation.java diff --git a/spring-boot/src/main/java/com/baeldung/graphql/Post.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/Post.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/graphql/Post.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/Post.java diff --git a/spring-boot/src/main/java/com/baeldung/graphql/PostDao.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/PostDao.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/graphql/PostDao.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/PostDao.java diff --git a/spring-boot/src/main/java/com/baeldung/graphql/PostResolver.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/PostResolver.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/graphql/PostResolver.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/PostResolver.java diff --git a/spring-boot/src/main/java/com/baeldung/graphql/Query.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/Query.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/graphql/Query.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/graphql/Query.java diff --git a/spring-boot/src/main/java/com/baeldung/internationalization/InternationalizationApp.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/InternationalizationApp.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/internationalization/InternationalizationApp.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/InternationalizationApp.java diff --git a/spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java diff --git a/spring-boot/src/main/java/com/baeldung/internationalization/config/PageController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/config/PageController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/internationalization/config/PageController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/internationalization/config/PageController.java diff --git a/spring-boot/src/main/java/com/baeldung/intro/App.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/intro/App.java similarity index 96% rename from spring-boot/src/main/java/com/baeldung/intro/App.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/intro/App.java index b5d53f0da3..77cdf4ddb9 100644 --- a/spring-boot/src/main/java/com/baeldung/intro/App.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/intro/App.java @@ -1,11 +1,11 @@ -package com.baeldung.intro; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class App { - public static void main(String[] args) { - SpringApplication.run(App.class, args); - } -} +package com.baeldung.intro; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class App { + public static void main(String[] args) { + SpringApplication.run(App.class, args); + } +} diff --git a/spring-boot/src/main/java/com/baeldung/intro/controller/HomeController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/intro/controller/HomeController.java similarity index 95% rename from spring-boot/src/main/java/com/baeldung/intro/controller/HomeController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/intro/controller/HomeController.java index 32f22f2cae..4797d6e593 100644 --- a/spring-boot/src/main/java/com/baeldung/intro/controller/HomeController.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/intro/controller/HomeController.java @@ -1,18 +1,18 @@ -package com.baeldung.intro.controller; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HomeController { - - @GetMapping("/") - public String root() { - return "Index Page"; - } - - @GetMapping("/local") - public String local() { - return "/local"; - } -} +package com.baeldung.intro.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HomeController { + + @GetMapping("/") + public String root() { + return "Index Page"; + } + + @GetMapping("/local") + public String local() { + return "/local"; + } +} diff --git a/spring-boot/src/main/java/com/baeldung/jsondateformat/Contact.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/Contact.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/jsondateformat/Contact.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/Contact.java diff --git a/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactApp.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactApp.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/jsondateformat/ContactApp.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactApp.java diff --git a/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactAppConfig.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactAppConfig.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/jsondateformat/ContactAppConfig.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactAppConfig.java diff --git a/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/jsondateformat/ContactController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactController.java diff --git a/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactWithJavaUtilDate.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactWithJavaUtilDate.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/jsondateformat/ContactWithJavaUtilDate.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/ContactWithJavaUtilDate.java diff --git a/spring-boot/src/main/java/com/baeldung/jsondateformat/PlainContact.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/PlainContact.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/jsondateformat/PlainContact.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/PlainContact.java diff --git a/spring-boot/src/main/java/com/baeldung/jsondateformat/PlainContactWithJavaUtilDate.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/PlainContactWithJavaUtilDate.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/jsondateformat/PlainContactWithJavaUtilDate.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/jsondateformat/PlainContactWithJavaUtilDate.java diff --git a/spring-boot/src/main/java/com/baeldung/kong/QueryController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/kong/QueryController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/kong/QueryController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/kong/QueryController.java diff --git a/spring-boot/src/main/java/com/baeldung/kong/StockApp.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/kong/StockApp.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/kong/StockApp.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/kong/StockApp.java diff --git a/spring-boot/src/main/java/com/baeldung/rss/ArticleFeedView.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/rss/ArticleFeedView.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/rss/ArticleFeedView.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/rss/ArticleFeedView.java diff --git a/spring-boot/src/main/java/com/baeldung/rss/ArticleRssController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/rss/ArticleRssController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/rss/ArticleRssController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/rss/ArticleRssController.java diff --git a/spring-boot/src/main/java/com/baeldung/rss/CustomContainer.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/rss/CustomContainer.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/rss/CustomContainer.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/rss/CustomContainer.java diff --git a/spring-boot/src/main/java/com/baeldung/rss/RssApp.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/rss/RssApp.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/rss/RssApp.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/rss/RssApp.java diff --git a/spring-boot/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servletinitializer/WarInitializerApplication.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/ApplicationMain.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/ApplicationMain.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/ApplicationMain.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/ApplicationMain.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/configuration/WebAppInitializer.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/configuration/WebAppInitializer.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/configuration/WebAppInitializer.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/configuration/WebAppInitializer.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/configuration/WebMvcConfigure.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/configuration/WebMvcConfigure.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/configuration/WebMvcConfigure.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/configuration/WebMvcConfigure.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/props/Constants.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/props/Constants.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/props/Constants.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/props/Constants.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/props/PropertyLoader.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/props/PropertyLoader.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/props/PropertyLoader.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/props/PropertyLoader.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/props/PropertySourcesLoader.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/props/PropertySourcesLoader.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/props/PropertySourcesLoader.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/props/PropertySourcesLoader.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/servlets/GenericCustomServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/GenericCustomServlet.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/servlets/GenericCustomServlet.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/GenericCustomServlet.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/servlets/javaee/AnnotationServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/javaee/AnnotationServlet.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/servlets/javaee/AnnotationServlet.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/javaee/AnnotationServlet.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/servlets/javaee/EEWebXmlServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/javaee/EEWebXmlServlet.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/servlets/javaee/EEWebXmlServlet.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/javaee/EEWebXmlServlet.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/servlets/springboot/SpringRegistrationBeanServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/springboot/SpringRegistrationBeanServlet.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/servlets/springboot/SpringRegistrationBeanServlet.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/springboot/SpringRegistrationBeanServlet.java diff --git a/spring-boot/src/main/java/com/baeldung/servlets/servlets/springboot/embedded/EmbeddedTomcatExample.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/springboot/embedded/EmbeddedTomcatExample.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/servlets/servlets/springboot/embedded/EmbeddedTomcatExample.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/servlets/servlets/springboot/embedded/EmbeddedTomcatExample.java diff --git a/spring-boot/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java similarity index 96% rename from spring-boot/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java index 7cce34a06c..44ec9e25ab 100644 --- a/spring-boot/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/ShutdownHookApplication.java @@ -1,14 +1,14 @@ -package com.baeldung.shutdownhooks; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -@EnableAutoConfiguration -public class ShutdownHookApplication { - - public static void main(String args[]) { - SpringApplication.run(ShutdownHookApplication.class, args); - } -} +package com.baeldung.shutdownhooks; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@EnableAutoConfiguration +public class ShutdownHookApplication { + + public static void main(String args[]) { + SpringApplication.run(ShutdownHookApplication.class, args); + } +} diff --git a/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java similarity index 95% rename from spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java index e85b9395d3..545599ce25 100644 --- a/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean1.java @@ -1,14 +1,14 @@ -package com.baeldung.shutdownhooks.beans; - -import javax.annotation.PreDestroy; - -import org.springframework.stereotype.Component; - -@Component -public class Bean1 { - - @PreDestroy - public void destroy() { - System.out.println("Shutdown triggered using @PreDestroy."); - } -} +package com.baeldung.shutdownhooks.beans; + +import javax.annotation.PreDestroy; + +import org.springframework.stereotype.Component; + +@Component +public class Bean1 { + + @PreDestroy + public void destroy() { + System.out.println("Shutdown triggered using @PreDestroy."); + } +} diff --git a/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java similarity index 96% rename from spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java index e85d12e791..b586c1430a 100644 --- a/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean2.java @@ -1,14 +1,14 @@ -package com.baeldung.shutdownhooks.beans; - -import org.springframework.beans.factory.DisposableBean; -import org.springframework.stereotype.Component; - -@Component -public class Bean2 implements DisposableBean { - - @Override - public void destroy() throws Exception { - System.out.println("Shutdown triggered using DisposableBean."); - } - -} +package com.baeldung.shutdownhooks.beans; + +import org.springframework.beans.factory.DisposableBean; +import org.springframework.stereotype.Component; + +@Component +public class Bean2 implements DisposableBean { + + @Override + public void destroy() throws Exception { + System.out.println("Shutdown triggered using DisposableBean."); + } + +} diff --git a/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java similarity index 95% rename from spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java index bed1d50ee7..25a56e2859 100644 --- a/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/beans/Bean3.java @@ -1,8 +1,8 @@ -package com.baeldung.shutdownhooks.beans; - -public class Bean3 { - - public void destroy() { - System.out.println("Shutdown triggered using bean destroy method."); - } -} +package com.baeldung.shutdownhooks.beans; + +public class Bean3 { + + public void destroy() { + System.out.println("Shutdown triggered using bean destroy method."); + } +} diff --git a/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java similarity index 96% rename from spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java index 07d729cb83..03ad5524b6 100644 --- a/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ExampleServletContextListener.java @@ -1,18 +1,18 @@ -package com.baeldung.shutdownhooks.config; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - -public class ExampleServletContextListener implements ServletContextListener { - - @Override - public void contextDestroyed(ServletContextEvent event) { - System.out.println("Shutdown triggered using ServletContextListener."); - } - - @Override - public void contextInitialized(ServletContextEvent event) { - // Triggers when context initializes - } - -} +package com.baeldung.shutdownhooks.config; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +public class ExampleServletContextListener implements ServletContextListener { + + @Override + public void contextDestroyed(ServletContextEvent event) { + System.out.println("Shutdown triggered using ServletContextListener."); + } + + @Override + public void contextInitialized(ServletContextEvent event) { + // Triggers when context initializes + } + +} diff --git a/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java similarity index 96% rename from spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java index 2d0712e19b..7d487dfc21 100644 --- a/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/shutdownhooks/config/ShutdownHookConfiguration.java @@ -1,25 +1,25 @@ -package com.baeldung.shutdownhooks.config; - -import javax.servlet.ServletContextListener; - -import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.baeldung.shutdownhooks.beans.Bean3; - -@Configuration -public class ShutdownHookConfiguration { - - @Bean(destroyMethod = "destroy") - public Bean3 initializeBean3() { - return new Bean3(); - } - - @Bean - ServletListenerRegistrationBean servletListener() { - ServletListenerRegistrationBean srb = new ServletListenerRegistrationBean<>(); - srb.setListener(new ExampleServletContextListener()); - return srb; - } -} +package com.baeldung.shutdownhooks.config; + +import javax.servlet.ServletContextListener; + +import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.baeldung.shutdownhooks.beans.Bean3; + +@Configuration +public class ShutdownHookConfiguration { + + @Bean(destroyMethod = "destroy") + public Bean3 initializeBean3() { + return new Bean3(); + } + + @Bean + ServletListenerRegistrationBean servletListener() { + ServletListenerRegistrationBean srb = new ServletListenerRegistrationBean<>(); + srb.setListener(new ExampleServletContextListener()); + return srb; + } +} diff --git a/spring-boot/src/main/java/com/baeldung/toggle/Employee.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/Employee.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/toggle/Employee.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/Employee.java diff --git a/spring-boot/src/main/java/com/baeldung/toggle/EmployeeRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/EmployeeRepository.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/toggle/EmployeeRepository.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/EmployeeRepository.java diff --git a/spring-boot/src/main/java/com/baeldung/toggle/FeatureAssociation.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/FeatureAssociation.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/toggle/FeatureAssociation.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/FeatureAssociation.java diff --git a/spring-boot/src/main/java/com/baeldung/toggle/FeaturesAspect.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/FeaturesAspect.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/toggle/FeaturesAspect.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/FeaturesAspect.java diff --git a/spring-boot/src/main/java/com/baeldung/toggle/MyFeatures.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/MyFeatures.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/toggle/MyFeatures.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/MyFeatures.java diff --git a/spring-boot/src/main/java/com/baeldung/toggle/SalaryController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/SalaryController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/toggle/SalaryController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/SalaryController.java diff --git a/spring-boot/src/main/java/com/baeldung/toggle/SalaryService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/SalaryService.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/toggle/SalaryService.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/SalaryService.java diff --git a/spring-boot/src/main/java/com/baeldung/toggle/ToggleApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/ToggleApplication.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/toggle/ToggleApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/ToggleApplication.java diff --git a/spring-boot/src/main/java/com/baeldung/toggle/ToggleConfiguration.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/ToggleConfiguration.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/toggle/ToggleConfiguration.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/toggle/ToggleConfiguration.java diff --git a/spring-boot/src/main/java/com/baeldung/utils/UtilsApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/utils/UtilsApplication.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/utils/UtilsApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/utils/UtilsApplication.java diff --git a/spring-boot/src/main/java/com/baeldung/utils/controller/UtilsController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/utils/controller/UtilsController.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/utils/controller/UtilsController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/utils/controller/UtilsController.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/Application.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/Application.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/Application.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/Application.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/User.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/User.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/User.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/User.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserCombinedSerializer.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserCombinedSerializer.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserCombinedSerializer.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserCombinedSerializer.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserJsonDeserializer.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserJsonDeserializer.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserJsonDeserializer.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserJsonDeserializer.java diff --git a/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserJsonSerializer.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserJsonSerializer.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserJsonSerializer.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/jsoncomponent/UserJsonSerializer.java diff --git a/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java similarity index 95% rename from spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java index 6b342a1bfb..df0e3ec0b2 100644 --- a/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java +++ b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java @@ -1,24 +1,24 @@ -package org.baeldung.common.error; - -import org.springframework.boot.web.servlet.error.ErrorController; -import org.springframework.web.bind.annotation.GetMapping; - -public class MyCustomErrorController implements ErrorController { - - private static final String PATH = "/error"; - - public MyCustomErrorController() { - // TODO Auto-generated constructor stub - } - - @GetMapping(value = PATH) - public String error() { - return "Error haven"; - } - - @Override - public String getErrorPath() { - return PATH; - } - -} +package org.baeldung.common.error; + +import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.web.bind.annotation.GetMapping; + +public class MyCustomErrorController implements ErrorController { + + private static final String PATH = "/error"; + + public MyCustomErrorController() { + // TODO Auto-generated constructor stub + } + + @GetMapping(value = PATH) + public String error() { + return "Error haven"; + } + + @Override + public String getErrorPath() { + return PATH; + } + +} diff --git a/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java similarity index 96% rename from spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java index 723afddd06..774cf1b970 100644 --- a/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java +++ b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java @@ -1,15 +1,15 @@ -package org.baeldung.common.error; - -import org.springframework.boot.web.servlet.ServletRegistrationBean; - -import javax.servlet.Servlet; - -public class SpringHelloServletRegistrationBean extends ServletRegistrationBean { - - public SpringHelloServletRegistrationBean() { - } - - public SpringHelloServletRegistrationBean(Servlet servlet, String... urlMappings) { - super(servlet, urlMappings); - } -} +package org.baeldung.common.error; + +import org.springframework.boot.web.servlet.ServletRegistrationBean; + +import javax.servlet.Servlet; + +public class SpringHelloServletRegistrationBean extends ServletRegistrationBean { + + public SpringHelloServletRegistrationBean() { + } + + public SpringHelloServletRegistrationBean(Servlet servlet, String... urlMappings) { + super(servlet, urlMappings); + } +} diff --git a/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java similarity index 95% rename from spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java index 3e26f8c9d8..ac5f92e9c9 100644 --- a/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java +++ b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java @@ -1,22 +1,22 @@ -package org.baeldung.common.error.controller; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class ErrorController { - - public ErrorController() { - } - - @GetMapping("/400") - String error400() { - return "Error Code: 400 occured."; - } - - @GetMapping("/errorHaven") - String errorHeaven() { - return "You have reached the haven of errors!!!"; - } - -} +package org.baeldung.common.error.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ErrorController { + + public ErrorController() { + } + + @GetMapping("/400") + String error400() { + return "Error Code: 400 occured."; + } + + @GetMapping("/errorHaven") + String errorHeaven() { + return "You have reached the haven of errors!!!"; + } + +} diff --git a/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java similarity index 97% rename from spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java index f6ab017298..d553d44769 100644 --- a/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java +++ b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java @@ -1,25 +1,25 @@ -package org.baeldung.common.properties; - -import org.springframework.boot.web.server.ErrorPage; -import org.springframework.boot.web.server.WebServerFactoryCustomizer; -import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Component; - -@Component -public class MyServletContainerCustomizationBean implements WebServerFactoryCustomizer { - - public MyServletContainerCustomizationBean() { - - } - - @Override - public void customize(ConfigurableServletWebServerFactory container) { - container.setPort(8084); - container.setContextPath("/springbootapp"); - - container.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400")); - container.addErrorPages(new ErrorPage("/errorHaven")); - } - -} +package org.baeldung.common.properties; + +import org.springframework.boot.web.server.ErrorPage; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; +import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +@Component +public class MyServletContainerCustomizationBean implements WebServerFactoryCustomizer { + + public MyServletContainerCustomizationBean() { + + } + + @Override + public void customize(ConfigurableServletWebServerFactory container) { + container.setPort(8084); + container.setContextPath("/springbootapp"); + + container.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400")); + container.addErrorPages(new ErrorPage("/errorHaven")); + } + +} diff --git a/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java similarity index 96% rename from spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java index be33d64c5d..64853a9941 100644 --- a/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java +++ b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java @@ -1,28 +1,28 @@ -package org.baeldung.common.resources; - -import org.springframework.boot.ExitCodeGenerator; - -import java.util.Objects; -import java.util.concurrent.ExecutorService; - -public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator { - - private ExecutorService executorService; - - public ExecutorServiceExitCodeGenerator(ExecutorService executorService) { - } - - @Override - public int getExitCode() { - try { - if (!Objects.isNull(executorService)) { - executorService.shutdownNow(); - return 1; - } - - return 0; - } catch (SecurityException ex) { - return 0; - } - } -} +package org.baeldung.common.resources; + +import org.springframework.boot.ExitCodeGenerator; + +import java.util.Objects; +import java.util.concurrent.ExecutorService; + +public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator { + + private ExecutorService executorService; + + public ExecutorServiceExitCodeGenerator(ExecutorService executorService) { + } + + @Override + public int getExitCode() { + try { + if (!Objects.isNull(executorService)) { + executorService.shutdownNow(); + return 1; + } + + return 0; + } catch (SecurityException ex) { + return 0; + } + } +} diff --git a/spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/components/FooService.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/components/FooService.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/components/FooService.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/components/FooService.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/model/Foo.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/model/Foo.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/model/Foo.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/model/Foo.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java diff --git a/spring-boot/src/main/java/org/baeldung/demo/service/FooController.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/service/FooController.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/demo/service/FooController.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/service/FooController.java diff --git a/spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java diff --git a/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java similarity index 97% rename from spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java index 30ac94221b..a203659d63 100644 --- a/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java +++ b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java @@ -1,63 +1,63 @@ -package org.baeldung.main; - -import org.baeldung.boot.controller.servlet.HelloWorldServlet; -import org.baeldung.boot.controller.servlet.SpringHelloWorldServlet; -import org.baeldung.common.error.SpringHelloServletRegistrationBean; -import org.baeldung.common.resources.ExecutorServiceExitCodeGenerator; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -@RestController -@EnableAutoConfiguration -@ComponentScan({ "org.baeldung.common.error", "org.baeldung.common.error.controller", "org.baeldung.common.properties", "org.baeldung.common.resources", "org.baeldung.endpoints", "org.baeldung.service", "org.baeldung.monitor.jmx", "org.baeldung.boot.config" }) -public class SpringBootApplication { - - private static ApplicationContext applicationContext; - - @GetMapping("/") - String home() { - return "TADA!!! You are in Spring Boot Actuator test application."; - } - - public static void main(String[] args) { - applicationContext = SpringApplication.run(SpringBootApplication.class, args); - } - - @Bean - public ExecutorService executorService() { - return Executors.newFixedThreadPool(10); - } - - @Bean - public HelloWorldServlet helloWorldServlet() { - return new HelloWorldServlet(); - } - - @Bean - public SpringHelloServletRegistrationBean servletRegistrationBean() { - SpringHelloServletRegistrationBean bean = new SpringHelloServletRegistrationBean(new SpringHelloWorldServlet(), "/springHelloWorld/*"); - bean.setLoadOnStartup(1); - bean.addInitParameter("message", "SpringHelloWorldServlet special message"); - return bean; - } - - @Bean - @Autowired - public ExecutorServiceExitCodeGenerator executorServiceExitCodeGenerator(ExecutorService executorService) { - return new ExecutorServiceExitCodeGenerator(executorService); - } - - public void shutDown(ExecutorServiceExitCodeGenerator executorServiceExitCodeGenerator) { - SpringApplication.exit(applicationContext, executorServiceExitCodeGenerator); - } - -} +package org.baeldung.main; + +import org.baeldung.boot.controller.servlet.HelloWorldServlet; +import org.baeldung.boot.controller.servlet.SpringHelloWorldServlet; +import org.baeldung.common.error.SpringHelloServletRegistrationBean; +import org.baeldung.common.resources.ExecutorServiceExitCodeGenerator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +@RestController +@EnableAutoConfiguration +@ComponentScan({ "org.baeldung.common.error", "org.baeldung.common.error.controller", "org.baeldung.common.properties", "org.baeldung.common.resources", "org.baeldung.endpoints", "org.baeldung.service", "org.baeldung.monitor.jmx", "org.baeldung.boot.config" }) +public class SpringBootApplication { + + private static ApplicationContext applicationContext; + + @GetMapping("/") + String home() { + return "TADA!!! You are in Spring Boot Actuator test application."; + } + + public static void main(String[] args) { + applicationContext = SpringApplication.run(SpringBootApplication.class, args); + } + + @Bean + public ExecutorService executorService() { + return Executors.newFixedThreadPool(10); + } + + @Bean + public HelloWorldServlet helloWorldServlet() { + return new HelloWorldServlet(); + } + + @Bean + public SpringHelloServletRegistrationBean servletRegistrationBean() { + SpringHelloServletRegistrationBean bean = new SpringHelloServletRegistrationBean(new SpringHelloWorldServlet(), "/springHelloWorld/*"); + bean.setLoadOnStartup(1); + bean.addInitParameter("message", "SpringHelloWorldServlet special message"); + return bean; + } + + @Bean + @Autowired + public ExecutorServiceExitCodeGenerator executorServiceExitCodeGenerator(ExecutorService executorService) { + return new ExecutorServiceExitCodeGenerator(executorService); + } + + public void shutDown(ExecutorServiceExitCodeGenerator executorServiceExitCodeGenerator) { + SpringApplication.exit(applicationContext, executorServiceExitCodeGenerator); + } + +} diff --git a/spring-boot/src/main/java/org/baeldung/model/User.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/model/User.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/model/User.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/model/User.java diff --git a/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/repository/UserRepository.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java diff --git a/spring-boot/src/main/java/org/baeldung/session/exception/Application.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/Application.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/session/exception/Application.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/Application.java diff --git a/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java diff --git a/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java diff --git a/spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java diff --git a/spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java b/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java similarity index 100% rename from spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java rename to spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java diff --git a/spring-boot/src/main/resources/META-INF/spring.factories b/spring-boot-modules/spring-boot/src/main/resources/META-INF/spring.factories similarity index 100% rename from spring-boot/src/main/resources/META-INF/spring.factories rename to spring-boot-modules/spring-boot/src/main/resources/META-INF/spring.factories diff --git a/spring-boot/src/main/resources/application-errorhandling.properties b/spring-boot-modules/spring-boot/src/main/resources/application-errorhandling.properties similarity index 100% rename from spring-boot/src/main/resources/application-errorhandling.properties rename to spring-boot-modules/spring-boot/src/main/resources/application-errorhandling.properties diff --git a/spring-boot/src/main/resources/application.properties b/spring-boot-modules/spring-boot/src/main/resources/application.properties similarity index 96% rename from spring-boot/src/main/resources/application.properties rename to spring-boot-modules/spring-boot/src/main/resources/application.properties index 918fe5ea67..c322fb0573 100644 --- a/spring-boot/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot/src/main/resources/application.properties @@ -1,74 +1,74 @@ -server.port=9090 -server.servlet.contextPath=/springbootapp -management.server.port=8081 -management.server.address=127.0.0.1 -#debug=true -spring.jpa.show-sql=true -spring.jpa.hibernate.ddl-auto = update - -management.endpoints.jmx.domain=Spring Sample Application -spring.jmx.unique-names=true - -management.endpoints.web.exposure.include=* -management.endpoint.shutdown.enabled=true - -##jolokia.config.debug=true -##endpoints.jolokia.enabled=true -##endpoints.jolokia.path=jolokia - -spring.jmx.enabled=true - -## for pretty printing of json when endpoints accessed over HTTP -http.mappers.jsonPrettyPrint=true - -## Configuring info endpoint -info.app.name=Spring Sample Application -info.app.description=This is my first spring boot application G1 -info.app.version=1.0.0 -info.java-vendor = ${java.specification.vendor} - -logging.level.org.springframework=INFO - -#Servlet Configuration -servlet.name=dispatcherExample -servlet.mapping=/dispatcherExampleURL - -#spring.banner.charset=UTF-8 -#spring.banner.location=classpath:banner.txt -#spring.banner.image.location=classpath:banner.gif -#spring.banner.image.width= //TODO -#spring.banner.image.height= //TODO -#spring.banner.image.margin= //TODO -#spring.banner.image.invert= //TODO - -contactInfoType=email - -#chaos monkey for spring boot props -management.endpoint.chaosmonkey.enabled=true -management.endpoint.chaosmonkeyjmx.enabled=true - -spring.profiles.active=chaos-monkey -#Determine whether should execute or not -chaos.monkey.enabled=true -#How many requests are to be attacked. 1: attack each request; 5: each 5th request is attacked -chaos.monkey.assaults.level=1 -#Minimum latency in ms added to the request -chaos.monkey.assaults.latencyRangeStart=3000 -#Maximum latency in ms added to the request -chaos.monkey.assaults.latencyRangeEnd=15000 -#Latency assault active -chaos.monkey.assaults.latencyActive=true -#Exception assault active -chaos.monkey.assaults.exceptionsActive=false -#AppKiller assault active -chaos.monkey.assaults.killApplicationActive=false -#Controller watcher active -chaos.monkey.watcher.controller=false -#RestController watcher active -chaos.monkey.watcher.restController=false -#Service watcher active -chaos.monkey.watcher.service=true -#Repository watcher active -chaos.monkey.watcher.repository=false -#Component watcher active -chaos.monkey.watcher.component=false +server.port=9090 +server.servlet.contextPath=/springbootapp +management.server.port=8081 +management.server.address=127.0.0.1 +#debug=true +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto = update + +management.endpoints.jmx.domain=Spring Sample Application +spring.jmx.unique-names=true + +management.endpoints.web.exposure.include=* +management.endpoint.shutdown.enabled=true + +##jolokia.config.debug=true +##endpoints.jolokia.enabled=true +##endpoints.jolokia.path=jolokia + +spring.jmx.enabled=true + +## for pretty printing of json when endpoints accessed over HTTP +http.mappers.jsonPrettyPrint=true + +## Configuring info endpoint +info.app.name=Spring Sample Application +info.app.description=This is my first spring boot application G1 +info.app.version=1.0.0 +info.java-vendor = ${java.specification.vendor} + +logging.level.org.springframework=INFO + +#Servlet Configuration +servlet.name=dispatcherExample +servlet.mapping=/dispatcherExampleURL + +#spring.banner.charset=UTF-8 +#spring.banner.location=classpath:banner.txt +#spring.banner.image.location=classpath:banner.gif +#spring.banner.image.width= //TODO +#spring.banner.image.height= //TODO +#spring.banner.image.margin= //TODO +#spring.banner.image.invert= //TODO + +contactInfoType=email + +#chaos monkey for spring boot props +management.endpoint.chaosmonkey.enabled=true +management.endpoint.chaosmonkeyjmx.enabled=true + +spring.profiles.active=chaos-monkey +#Determine whether should execute or not +chaos.monkey.enabled=true +#How many requests are to be attacked. 1: attack each request; 5: each 5th request is attacked +chaos.monkey.assaults.level=1 +#Minimum latency in ms added to the request +chaos.monkey.assaults.latencyRangeStart=3000 +#Maximum latency in ms added to the request +chaos.monkey.assaults.latencyRangeEnd=15000 +#Latency assault active +chaos.monkey.assaults.latencyActive=true +#Exception assault active +chaos.monkey.assaults.exceptionsActive=false +#AppKiller assault active +chaos.monkey.assaults.killApplicationActive=false +#Controller watcher active +chaos.monkey.watcher.controller=false +#RestController watcher active +chaos.monkey.watcher.restController=false +#Service watcher active +chaos.monkey.watcher.service=true +#Repository watcher active +chaos.monkey.watcher.repository=false +#Component watcher active +chaos.monkey.watcher.component=false diff --git a/spring-boot/src/main/resources/banner.txt b/spring-boot-modules/spring-boot/src/main/resources/banner.txt similarity index 100% rename from spring-boot/src/main/resources/banner.txt rename to spring-boot-modules/spring-boot/src/main/resources/banner.txt diff --git a/spring-boot-modules/spring-boot/src/main/resources/build.properties b/spring-boot-modules/spring-boot/src/main/resources/build.properties new file mode 100644 index 0000000000..1612b8086d --- /dev/null +++ b/spring-boot-modules/spring-boot/src/main/resources/build.properties @@ -0,0 +1,2 @@ +application-description=@project.description@ +application-version=@project.version@ \ No newline at end of file diff --git a/spring-boot-modules/spring-boot/src/main/resources/build.yml b/spring-boot-modules/spring-boot/src/main/resources/build.yml new file mode 100644 index 0000000000..528d2e3440 --- /dev/null +++ b/spring-boot-modules/spring-boot/src/main/resources/build.yml @@ -0,0 +1,2 @@ +application-description: ^project.description^ +application-version: ^project.version^ \ No newline at end of file diff --git a/spring-boot/src/main/resources/custom.properties b/spring-boot-modules/spring-boot/src/main/resources/custom.properties similarity index 100% rename from spring-boot/src/main/resources/custom.properties rename to spring-boot-modules/spring-boot/src/main/resources/custom.properties diff --git a/spring-boot/src/main/resources/data-expressions.sql b/spring-boot-modules/spring-boot/src/main/resources/data-expressions.sql similarity index 100% rename from spring-boot/src/main/resources/data-expressions.sql rename to spring-boot-modules/spring-boot/src/main/resources/data-expressions.sql diff --git a/spring-boot/src/main/resources/data.sql b/spring-boot-modules/spring-boot/src/main/resources/data.sql similarity index 100% rename from spring-boot/src/main/resources/data.sql rename to spring-boot-modules/spring-boot/src/main/resources/data.sql diff --git a/spring-boot/src/main/resources/demo.properties b/spring-boot-modules/spring-boot/src/main/resources/demo.properties similarity index 100% rename from spring-boot/src/main/resources/demo.properties rename to spring-boot-modules/spring-boot/src/main/resources/demo.properties diff --git a/spring-boot/src/main/resources/graphql/blog.graphqls b/spring-boot-modules/spring-boot/src/main/resources/graphql/blog.graphqls similarity index 100% rename from spring-boot/src/main/resources/graphql/blog.graphqls rename to spring-boot-modules/spring-boot/src/main/resources/graphql/blog.graphqls diff --git a/spring-boot/src/main/resources/logback.xml b/spring-boot-modules/spring-boot/src/main/resources/logback.xml similarity index 100% rename from spring-boot/src/main/resources/logback.xml rename to spring-boot-modules/spring-boot/src/main/resources/logback.xml diff --git a/spring-boot/src/main/resources/messages.properties b/spring-boot-modules/spring-boot/src/main/resources/messages.properties similarity index 100% rename from spring-boot/src/main/resources/messages.properties rename to spring-boot-modules/spring-boot/src/main/resources/messages.properties diff --git a/spring-boot/src/main/resources/messages_fr.properties b/spring-boot-modules/spring-boot/src/main/resources/messages_fr.properties similarity index 100% rename from spring-boot/src/main/resources/messages_fr.properties rename to spring-boot-modules/spring-boot/src/main/resources/messages_fr.properties diff --git a/spring-boot/src/main/resources/persistence-generic-entity.properties b/spring-boot-modules/spring-boot/src/main/resources/persistence-generic-entity.properties similarity index 100% rename from spring-boot/src/main/resources/persistence-generic-entity.properties rename to spring-boot-modules/spring-boot/src/main/resources/persistence-generic-entity.properties diff --git a/spring-boot/src/main/resources/templates/error/404.html b/spring-boot-modules/spring-boot/src/main/resources/public/error/404.html similarity index 100% rename from spring-boot/src/main/resources/templates/error/404.html rename to spring-boot-modules/spring-boot/src/main/resources/public/error/404.html diff --git a/spring-boot/src/main/resources/schema-expressions.sql b/spring-boot-modules/spring-boot/src/main/resources/schema-expressions.sql similarity index 100% rename from spring-boot/src/main/resources/schema-expressions.sql rename to spring-boot-modules/spring-boot/src/main/resources/schema-expressions.sql diff --git a/spring-boot/src/main/resources/schema.sql b/spring-boot-modules/spring-boot/src/main/resources/schema.sql similarity index 100% rename from spring-boot/src/main/resources/schema.sql rename to spring-boot-modules/spring-boot/src/main/resources/schema.sql diff --git a/spring-boot/src/main/resources/shutdown/shutdown.bat b/spring-boot-modules/spring-boot/src/main/resources/shutdown/shutdown.bat similarity index 100% rename from spring-boot/src/main/resources/shutdown/shutdown.bat rename to spring-boot-modules/spring-boot/src/main/resources/shutdown/shutdown.bat diff --git a/spring-boot/src/main/resources/static/internationalization.js b/spring-boot-modules/spring-boot/src/main/resources/static/internationalization.js similarity index 100% rename from spring-boot/src/main/resources/static/internationalization.js rename to spring-boot-modules/spring-boot/src/main/resources/static/internationalization.js diff --git a/spring-boot/src/main/resources/templates/customer.html b/spring-boot-modules/spring-boot/src/main/resources/templates/customer.html similarity index 100% rename from spring-boot/src/main/resources/templates/customer.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/customer.html diff --git a/spring-boot/src/main/resources/templates/customers.html b/spring-boot-modules/spring-boot/src/main/resources/templates/customers.html similarity index 100% rename from spring-boot/src/main/resources/templates/customers.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/customers.html diff --git a/spring-boot/src/main/resources/templates/displayallbeans.html b/spring-boot-modules/spring-boot/src/main/resources/templates/displayallbeans.html similarity index 100% rename from spring-boot/src/main/resources/templates/displayallbeans.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/displayallbeans.html diff --git a/spring-boot/src/main/resources/templates/error-404.html b/spring-boot-modules/spring-boot/src/main/resources/templates/error-404.html similarity index 100% rename from spring-boot/src/main/resources/templates/error-404.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/error-404.html diff --git a/spring-boot/src/main/resources/templates/error-500.html b/spring-boot-modules/spring-boot/src/main/resources/templates/error-500.html similarity index 100% rename from spring-boot/src/main/resources/templates/error-500.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/error-500.html diff --git a/spring-boot/src/main/resources/templates/error.html b/spring-boot-modules/spring-boot/src/main/resources/templates/error.html similarity index 100% rename from spring-boot/src/main/resources/templates/error.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/error.html diff --git a/spring-boot/src/main/resources/public/error/404.html b/spring-boot-modules/spring-boot/src/main/resources/templates/error/404.html similarity index 94% rename from spring-boot/src/main/resources/public/error/404.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/error/404.html index 02d6092bee..df83ce219b 100644 --- a/spring-boot/src/main/resources/public/error/404.html +++ b/spring-boot-modules/spring-boot/src/main/resources/templates/error/404.html @@ -1,8 +1,8 @@ - - - RESOURCE NOT FOUND - - -

404 RESOURCE NOT FOUND

- + + + RESOURCE NOT FOUND + + +

404 RESOURCE NOT FOUND

+ \ No newline at end of file diff --git a/spring-boot/src/main/resources/templates/external.html b/spring-boot-modules/spring-boot/src/main/resources/templates/external.html similarity index 100% rename from spring-boot/src/main/resources/templates/external.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/external.html diff --git a/spring-boot/src/main/resources/templates/index.html b/spring-boot-modules/spring-boot/src/main/resources/templates/index.html similarity index 100% rename from spring-boot/src/main/resources/templates/index.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/index.html diff --git a/spring-boot/src/main/resources/templates/international.html b/spring-boot-modules/spring-boot/src/main/resources/templates/international.html similarity index 100% rename from spring-boot/src/main/resources/templates/international.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/international.html diff --git a/spring-boot/src/main/resources/templates/layout.html b/spring-boot-modules/spring-boot/src/main/resources/templates/layout.html similarity index 100% rename from spring-boot/src/main/resources/templates/layout.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/layout.html diff --git a/spring-boot/src/main/resources/templates/other.html b/spring-boot-modules/spring-boot/src/main/resources/templates/other.html similarity index 100% rename from spring-boot/src/main/resources/templates/other.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/other.html diff --git a/spring-boot/src/main/resources/templates/utils.html b/spring-boot-modules/spring-boot/src/main/resources/templates/utils.html similarity index 100% rename from spring-boot/src/main/resources/templates/utils.html rename to spring-boot-modules/spring-boot/src/main/resources/templates/utils.html diff --git a/spring-boot/src/main/webapp/WEB-INF/context.xml b/spring-boot-modules/spring-boot/src/main/webapp/WEB-INF/context.xml similarity index 100% rename from spring-boot/src/main/webapp/WEB-INF/context.xml rename to spring-boot-modules/spring-boot/src/main/webapp/WEB-INF/context.xml diff --git a/spring-boot/src/main/webapp/WEB-INF/dispatcher.xml b/spring-boot-modules/spring-boot/src/main/webapp/WEB-INF/dispatcher.xml similarity index 100% rename from spring-boot/src/main/webapp/WEB-INF/dispatcher.xml rename to spring-boot-modules/spring-boot/src/main/webapp/WEB-INF/dispatcher.xml diff --git a/spring-boot/src/main/webapp/WEB-INF/web.xml b/spring-boot-modules/spring-boot/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-boot/src/main/webapp/WEB-INF/web.xml rename to spring-boot-modules/spring-boot/src/main/webapp/WEB-INF/web.xml diff --git a/spring-boot/src/main/webapp/annotationservlet.jsp b/spring-boot-modules/spring-boot/src/main/webapp/annotationservlet.jsp similarity index 100% rename from spring-boot/src/main/webapp/annotationservlet.jsp rename to spring-boot-modules/spring-boot/src/main/webapp/annotationservlet.jsp diff --git a/spring-boot/src/main/webapp/index.jsp b/spring-boot-modules/spring-boot/src/main/webapp/index.jsp similarity index 100% rename from spring-boot/src/main/webapp/index.jsp rename to spring-boot-modules/spring-boot/src/main/webapp/index.jsp diff --git a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java diff --git a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java diff --git a/spring-boot/src/test/java/com/baeldung/beanvalidation/application/UserControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/beanvalidation/application/UserControllerIntegrationTest.java similarity index 88% rename from spring-boot/src/test/java/com/baeldung/beanvalidation/application/UserControllerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/beanvalidation/application/UserControllerIntegrationTest.java index 07d9b0807e..21fcaf922c 100644 --- a/spring-boot/src/test/java/com/baeldung/beanvalidation/application/UserControllerIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/beanvalidation/application/UserControllerIntegrationTest.java @@ -1,70 +1,71 @@ -package com.baeldung.beanvalidation.application; - -import com.baeldung.beanvalidation.application.controllers.UserController; -import com.baeldung.beanvalidation.application.repositories.UserRepository; - -import java.nio.charset.Charset; -import static org.assertj.core.api.Assertions.assertThat; -import org.hamcrest.core.Is; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.result.MockMvcResultMatchers; - -@RunWith(SpringRunner.class) -@WebMvcTest -@AutoConfigureMockMvc -public class UserControllerIntegrationTest { - - @MockBean - private UserRepository userRepository; - - @Autowired - UserController userController; - - @Autowired - private MockMvc mockMvc; - - @Test - public void whenUserControllerInjected_thenNotNull() throws Exception { - assertThat(userController).isNotNull(); - } - - @Test - public void whenGetRequestToUsers_thenCorrectResponse() throws Exception { - mockMvc.perform(MockMvcRequestBuilders.get("/users") - .contentType(MediaType.APPLICATION_JSON_UTF8)) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)); - - } - - @Test - public void whenPostRequestToUsersAndValidUser_thenCorrectResponse() throws Exception { - MediaType textPlainUtf8 = new MediaType(MediaType.TEXT_PLAIN, Charset.forName("UTF-8")); - String user = "{\"name\": \"bob\", \"email\" : \"bob@domain.com\"}"; - mockMvc.perform(MockMvcRequestBuilders.post("/users") - .content(user) - .contentType(MediaType.APPLICATION_JSON_UTF8)) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andExpect(MockMvcResultMatchers.content().contentType(textPlainUtf8)); - } - - @Test - public void whenPostRequestToUsersAndInValidUser_thenCorrectReponse() throws Exception { - String user = "{\"name\": \"\", \"email\" : \"bob@domain.com\"}"; - mockMvc.perform(MockMvcRequestBuilders.post("/users") - .content(user) - .contentType(MediaType.APPLICATION_JSON_UTF8)) - .andExpect(MockMvcResultMatchers.status().isBadRequest()) - .andExpect(MockMvcResultMatchers.jsonPath("$.name", Is.is("Name is mandatory"))) - .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)); - } -} +package com.baeldung.beanvalidation.application; + +import com.baeldung.beanvalidation.application.controllers.UserController; +import com.baeldung.beanvalidation.application.repositories.UserRepository; +import org.hamcrest.core.Is; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +import java.nio.charset.Charset; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@WebMvcTest +@AutoConfigureMockMvc +public class UserControllerIntegrationTest { + + @MockBean + private UserRepository userRepository; + + @Autowired + UserController userController; + + @Autowired + private MockMvc mockMvc; + + @Test + public void whenUserControllerInjected_thenNotNull() throws Exception { + assertThat(userController).isNotNull(); + } + + @Test + public void whenGetRequestToUsers_thenCorrectResponse() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/users") + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON)); + + } + + @Test + public void whenPostRequestToUsersAndValidUser_thenCorrectResponse() throws Exception { + MediaType textPlainUtf8 = new MediaType(MediaType.TEXT_PLAIN, Charset.forName("UTF-8")); + String user = "{\"name\": \"bob\", \"email\" : \"bob@domain.com\"}"; + mockMvc.perform(MockMvcRequestBuilders.post("/users") + .content(user) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().contentType(textPlainUtf8)); + } + + @Test + public void whenPostRequestToUsersAndInValidUser_thenCorrectReponse() throws Exception { + String user = "{\"name\": \"\", \"email\" : \"bob@domain.com\"}"; + mockMvc.perform(MockMvcRequestBuilders.post("/users") + .content(user) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(MockMvcResultMatchers.status().isBadRequest()) + .andExpect(MockMvcResultMatchers.jsonPath("$.name", Is.is("Name is mandatory"))) + .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON)); + } +} diff --git a/spring-boot-modules/spring-boot/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java new file mode 100644 index 0000000000..cb056fe56d --- /dev/null +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java @@ -0,0 +1,24 @@ +package com.baeldung.buildproperties; + +import static org.junit.Assert.assertThat; + +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class) +class BuildInfoServiceIntegrationTest { + + @Autowired + private BuildInfoService service; + + @Test + void whenGetApplicationDescription_thenSuccess() { + assertThat(service.getApplicationDescription(), Matchers.is("This is simple boot application for Spring boot actuator test")); + assertThat(service.getApplicationVersion(), Matchers.is("0.0.1-SNAPSHOT")); + } +} diff --git a/spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java similarity index 97% rename from spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java index e933920a96..f08a755fc7 100644 --- a/spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java @@ -1,101 +1,101 @@ -package com.baeldung.displayallbeans; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.BDDAssertions.then; - -import java.net.URI; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.actuate.beans.BeansEndpoint.ContextBeans; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.RequestEntity; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.web.context.WebApplicationContext; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@TestPropertySource(properties = { "management.port=0", "management.endpoints.web.exposure.include=*" }) -public class DisplayBeanIntegrationTest { - - @LocalServerPort - private int port; - - @Value("${local.management.port}") - private int mgt; - - @Autowired - private TestRestTemplate testRestTemplate; - - @Autowired - private WebApplicationContext context; - - private static final String ACTUATOR_PATH = "/actuator"; - - @Test - public void givenRestTemplate_whenAccessServerUrl_thenHttpStatusOK() throws Exception { - ResponseEntity entity = this.testRestTemplate.getForEntity("http://localhost:" + this.port + "/displayallbeans", String.class); - - then(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - public void givenRestTemplate_whenAccessEndpointUrl_thenHttpStatusOK() throws Exception { - ParameterizedTypeReference> responseType = new ParameterizedTypeReference>() { - }; - RequestEntity requestEntity = RequestEntity.get(new URI("http://localhost:" + this.mgt + ACTUATOR_PATH + "/beans")) - .accept(MediaType.APPLICATION_JSON) - .build(); - ResponseEntity> entity = this.testRestTemplate.exchange(requestEntity, responseType); - - then(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - public void givenRestTemplate_whenAccessEndpointUrl_thenReturnsBeanNames() throws Exception { - RequestEntity requestEntity = RequestEntity.get(new URI("http://localhost:" + this.mgt + ACTUATOR_PATH + "/beans")) - .accept(MediaType.APPLICATION_JSON) - .build(); - ResponseEntity entity = this.testRestTemplate.exchange(requestEntity, BeanActuatorResponse.class); - - Collection beanNamesList = entity.getBody() - .getBeans(); - - assertThat(beanNamesList).contains("fooController", "fooService"); - } - - @Test - public void givenWebApplicationContext_whenAccessGetBeanDefinitionNames_thenReturnsBeanNames() throws Exception { - String[] beanNames = context.getBeanDefinitionNames(); - - List beanNamesList = Arrays.asList(beanNames); - assertThat(beanNamesList).contains("fooController", "fooService"); - } - - private static class BeanActuatorResponse { - private Map>>> contexts; - - public Collection getBeans() { - return this.contexts.get("application") - .get("beans") - .keySet(); - } - - public Map>>> getContexts() { - return contexts; - } - } -} +package com.baeldung.displayallbeans; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.BDDAssertions.then; + +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.actuate.beans.BeansEndpoint.ContextBeans; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.RequestEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.context.WebApplicationContext; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@TestPropertySource(properties = { "management.port=0", "management.endpoints.web.exposure.include=*" }) +public class DisplayBeanIntegrationTest { + + @LocalServerPort + private int port; + + @Value("${local.management.port}") + private int mgt; + + @Autowired + private TestRestTemplate testRestTemplate; + + @Autowired + private WebApplicationContext context; + + private static final String ACTUATOR_PATH = "/actuator"; + + @Test + public void givenRestTemplate_whenAccessServerUrl_thenHttpStatusOK() throws Exception { + ResponseEntity entity = this.testRestTemplate.getForEntity("http://localhost:" + this.port + "/displayallbeans", String.class); + + then(entity.getStatusCode()).isEqualTo(HttpStatus.OK); + } + + @Test + public void givenRestTemplate_whenAccessEndpointUrl_thenHttpStatusOK() throws Exception { + ParameterizedTypeReference> responseType = new ParameterizedTypeReference>() { + }; + RequestEntity requestEntity = RequestEntity.get(new URI("http://localhost:" + this.mgt + ACTUATOR_PATH + "/beans")) + .accept(MediaType.APPLICATION_JSON) + .build(); + ResponseEntity> entity = this.testRestTemplate.exchange(requestEntity, responseType); + + then(entity.getStatusCode()).isEqualTo(HttpStatus.OK); + } + + @Test + public void givenRestTemplate_whenAccessEndpointUrl_thenReturnsBeanNames() throws Exception { + RequestEntity requestEntity = RequestEntity.get(new URI("http://localhost:" + this.mgt + ACTUATOR_PATH + "/beans")) + .accept(MediaType.APPLICATION_JSON) + .build(); + ResponseEntity entity = this.testRestTemplate.exchange(requestEntity, BeanActuatorResponse.class); + + Collection beanNamesList = entity.getBody() + .getBeans(); + + assertThat(beanNamesList).contains("fooController", "fooService"); + } + + @Test + public void givenWebApplicationContext_whenAccessGetBeanDefinitionNames_thenReturnsBeanNames() throws Exception { + String[] beanNames = context.getBeanDefinitionNames(); + + List beanNamesList = Arrays.asList(beanNames); + assertThat(beanNamesList).contains("fooController", "fooService"); + } + + private static class BeanActuatorResponse { + private Map>>> contexts; + + public Collection getBeans() { + return this.contexts.get("application") + .get("beans") + .keySet(); + } + + public Map>>> getContexts() { + return contexts; + } + } +} diff --git a/spring-boot/src/test/java/com/baeldung/failureanalyzer/FailureAnalyzerAppIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/FailureAnalyzerAppIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/failureanalyzer/FailureAnalyzerAppIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/FailureAnalyzerAppIntegrationTest.java diff --git a/spring-boot/src/test/java/com/baeldung/failureanalyzer/utils/ListAppender.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/utils/ListAppender.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/failureanalyzer/utils/ListAppender.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/failureanalyzer/utils/ListAppender.java diff --git a/spring-boot/src/test/java/com/baeldung/git/CommitIdIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/git/CommitIdIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/git/CommitIdIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/git/CommitIdIntegrationTest.java diff --git a/spring-boot/src/test/java/com/baeldung/intro/AppLiveTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/intro/AppLiveTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/intro/AppLiveTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/intro/AppLiveTest.java diff --git a/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppUnitTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppUnitTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppUnitTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppUnitTest.java diff --git a/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerUnitTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerUnitTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerUnitTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/jsondateformat/ContactAppWithObjectMapperCustomizerUnitTest.java diff --git a/spring-boot/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java diff --git a/spring-boot/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java diff --git a/spring-boot/src/test/java/com/baeldung/kong/domain/APIObject.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/APIObject.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/kong/domain/APIObject.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/APIObject.java diff --git a/spring-boot/src/test/java/com/baeldung/kong/domain/ConsumerObject.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/ConsumerObject.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/kong/domain/ConsumerObject.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/ConsumerObject.java diff --git a/spring-boot/src/test/java/com/baeldung/kong/domain/KeyAuthObject.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/KeyAuthObject.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/kong/domain/KeyAuthObject.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/KeyAuthObject.java diff --git a/spring-boot/src/test/java/com/baeldung/kong/domain/PluginObject.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/PluginObject.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/kong/domain/PluginObject.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/PluginObject.java diff --git a/spring-boot/src/test/java/com/baeldung/kong/domain/TargetObject.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/TargetObject.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/kong/domain/TargetObject.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/TargetObject.java diff --git a/spring-boot/src/test/java/com/baeldung/kong/domain/UpstreamObject.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/UpstreamObject.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/kong/domain/UpstreamObject.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/kong/domain/UpstreamObject.java diff --git a/spring-boot/src/test/java/com/baeldung/servletinitializer/WarInitializerApplicationIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/servletinitializer/WarInitializerApplicationIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/servletinitializer/WarInitializerApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/servletinitializer/WarInitializerApplicationIntegrationTest.java diff --git a/spring-boot/src/test/java/com/baeldung/toggle/ToggleIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/toggle/ToggleIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/toggle/ToggleIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/toggle/ToggleIntegrationTest.java diff --git a/spring-boot/src/test/java/com/baeldung/utils/UtilsControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/utils/UtilsControllerIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/com/baeldung/utils/UtilsControllerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/utils/UtilsControllerIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/boot/jsoncomponent/UserJsonDeserializerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/jsoncomponent/UserJsonDeserializerIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/boot/jsoncomponent/UserJsonDeserializerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/jsoncomponent/UserJsonDeserializerIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/boot/jsoncomponent/UserJsonSerializerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/jsoncomponent/UserJsonSerializerIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/boot/jsoncomponent/UserJsonSerializerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/jsoncomponent/UserJsonSerializerIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java similarity index 90% rename from spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java index 5d02d34f53..c32e36d7e3 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java @@ -1,19 +1,17 @@ package org.baeldung.boot.repository; -import static org.junit.Assert.assertThat; - import org.baeldung.boot.DemoApplicationIntegrationTest; import org.baeldung.demo.model.Foo; import org.baeldung.demo.repository.FooRepository; - -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.is; - import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertThat; + @Transactional public class FooRepositoryIntegrationTest extends DemoApplicationIntegrationTest { @Autowired @@ -28,8 +26,10 @@ public class FooRepositoryIntegrationTest extends DemoApplicationIntegrationTest @Test public void testFindByName() { Foo foo = fooRepository.findByName("Bar"); + assertThat(foo, notNullValue()); - assertThat(foo.getId(), is(2)); + assertThat(foo.getId(), notNullValue()); + assertThat(foo.getName(), is("Bar")); } } diff --git a/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java similarity index 80% rename from spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java index baa4f70e83..b22282e896 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java @@ -1,9 +1,5 @@ package org.baeldung.boot.repository; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - import org.baeldung.boot.DemoApplicationIntegrationTest; import org.baeldung.demo.model.Foo; import org.baeldung.demo.repository.FooRepository; @@ -11,6 +7,10 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + @Transactional public class HibernateSessionIntegrationTest extends DemoApplicationIntegrationTest { @Autowired @@ -18,13 +18,12 @@ public class HibernateSessionIntegrationTest extends DemoApplicationIntegrationT @Test public void whenSavingWithCurrentSession_thenThrowNoException() { - Foo foo = new Foo("Exception Solved"); - fooRepository.save(foo); - foo = null; - foo = fooRepository.findByName("Exception Solved"); + fooRepository.save(new Foo("Exception Solved")); + + Foo foo = fooRepository.findByName("Exception Solved"); assertThat(foo, notNullValue()); - assertThat(foo.getId(), is(1)); + assertThat(foo.getId(), notNullValue()); assertThat(foo.getName(), is("Exception Solved")); } } diff --git a/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java diff --git a/spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java diff --git a/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java similarity index 100% rename from spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java diff --git a/spring-boot/src/test/resources/application-integrationtest.properties b/spring-boot-modules/spring-boot/src/test/resources/application-integrationtest.properties similarity index 100% rename from spring-boot/src/test/resources/application-integrationtest.properties rename to spring-boot-modules/spring-boot/src/test/resources/application-integrationtest.properties diff --git a/spring-boot/src/test/resources/application.properties b/spring-boot-modules/spring-boot/src/test/resources/application.properties similarity index 100% rename from spring-boot/src/test/resources/application.properties rename to spring-boot-modules/spring-boot/src/test/resources/application.properties diff --git a/spring-boot/src/test/resources/conversion.properties b/spring-boot-modules/spring-boot/src/test/resources/conversion.properties similarity index 100% rename from spring-boot/src/test/resources/conversion.properties rename to spring-boot-modules/spring-boot/src/test/resources/conversion.properties diff --git a/spring-boot/src/test/resources/exception-hibernate.properties b/spring-boot-modules/spring-boot/src/test/resources/exception-hibernate.properties similarity index 100% rename from spring-boot/src/test/resources/exception-hibernate.properties rename to spring-boot-modules/spring-boot/src/test/resources/exception-hibernate.properties diff --git a/spring-boot/src/test/resources/exception.properties b/spring-boot-modules/spring-boot/src/test/resources/exception.properties similarity index 100% rename from spring-boot/src/test/resources/exception.properties rename to spring-boot-modules/spring-boot/src/test/resources/exception.properties diff --git a/spring-boot/src/test/resources/import.sql b/spring-boot-modules/spring-boot/src/test/resources/import.sql similarity index 100% rename from spring-boot/src/test/resources/import.sql rename to spring-boot-modules/spring-boot/src/test/resources/import.sql diff --git a/spring-boot/src/test/resources/logback-test.xml b/spring-boot-modules/spring-boot/src/test/resources/logback-test.xml similarity index 100% rename from spring-boot/src/test/resources/logback-test.xml rename to spring-boot-modules/spring-boot/src/test/resources/logback-test.xml diff --git a/spring-boot/src/test/resources/org/baeldung/boot/expected.json b/spring-boot-modules/spring-boot/src/test/resources/org/baeldung/boot/expected.json similarity index 100% rename from spring-boot/src/test/resources/org/baeldung/boot/expected.json rename to spring-boot-modules/spring-boot/src/test/resources/org/baeldung/boot/expected.json diff --git a/spring-boot-parent/spring-boot-with-custom-parent/pom.xml b/spring-boot-parent/spring-boot-with-custom-parent/pom.xml index 8a55f252d6..1eb4255c7e 100644 --- a/spring-boot-parent/spring-boot-with-custom-parent/pom.xml +++ b/spring-boot-parent/spring-boot-with-custom-parent/pom.xml @@ -11,6 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT + ../../parent-boot-2 diff --git a/spring-boot-parent/spring-boot-with-starter-parent/pom.xml b/spring-boot-parent/spring-boot-with-starter-parent/pom.xml index 9ea26e49fe..05c61fc4cc 100644 --- a/spring-boot-parent/spring-boot-with-starter-parent/pom.xml +++ b/spring-boot-parent/spring-boot-with-starter-parent/pom.xml @@ -9,10 +9,10 @@ spring-boot-with-starter-parent - org.springframework.boot - spring-boot-starter-parent - 2.1.5.RELEASE - + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 @@ -20,7 +20,7 @@ org.springframework.boot spring-boot-starter-data-jpa - 2.1.1.RELEASE + ${spring-boot.version}
@@ -38,6 +38,7 @@ 1.8 + 2.1.5.RELEASE 4.11 diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index 3909a99c65..f78c88d30b 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -10,7 +10,6 @@ This module contains articles about Spring Boot RESTful APIs. - [Testing REST with multiple MIME types](https://www.baeldung.com/testing-rest-api-with-multiple-media-types) - [Testing Web APIs with Postman Collections](https://www.baeldung.com/postman-testing-collections) - [Spring Boot Consuming and Producing JSON](https://www.baeldung.com/spring-boot-json) -- [Error Handling for REST with Spring](https://www.baeldung.com/exception-handling-for-rest-with-spring) ### E-book @@ -26,3 +25,6 @@ These articles are part of the Spring REST E-book: 8. [An Intro to Spring HATEOAS](https://www.baeldung.com/spring-hateoas-tutorial) 9. [REST Pagination in Spring](https://www.baeldung.com/rest-api-pagination-in-spring) 10. [Test a REST API with Java](https://www.baeldung.com/integration-testing-a-rest-api) + +NOTE: +Since this is a module tied to an e-book, it should not be moved or used to store the code for any further article. diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index 3787e21493..2483aab6be 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -45,6 +45,11 @@ spring-boot-starter-data-jpa + + org.springframework.boot + spring-boot-starter-data-rest + + org.springframework.boot @@ -90,6 +95,7 @@ 27.0.1-jre 1.4.11.1 2.3.5 + 2.1.9.RELEASE diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IUserService.java b/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IUserService.java deleted file mode 100644 index 79934114c1..0000000000 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IUserService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.modelmapper.service; - -import com.baeldung.modelmapper.model.User; - -public interface IUserService { - - User getCurrentUser(); - -} diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java index 2e967751ad..8887510eca 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -24,8 +24,8 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-${envTarget:h2}.properties" }) -@ComponentScan(basePackages = { "com.baeldung.persistence", "com.baeldung.modelmapper" }) -@EnableJpaRepositories(basePackages = {"com.baeldung.persistence.dao", "com.baeldung.modelmapper.repository"}) +@ComponentScan(basePackages = { "com.baeldung.persistence", "com.baeldung.springpagination" }) +@EnableJpaRepositories(basePackages = {"com.baeldung.persistence.dao", "com.baeldung.springpagination.repository"}) public class PersistenceConfig { @Autowired @@ -39,7 +39,7 @@ public class PersistenceConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "com.baeldung.persistence.model", "com.baeldung.modelmapper.model" }); + em.setPackagesToScan(new String[] { "com.baeldung.persistence.model", "com.baeldung.springpagination.model" }); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); // vendorAdapter.set diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java index ab16b61e1d..13a9933fa6 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java +++ b/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java @@ -14,8 +14,6 @@ import org.springframework.web.filter.ShallowEtagHeaderFilter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -// If we want to enable xml configurations for message-converter: -// @ImportResource("classpath:WEB-INF/api-servlet.xml") public class WebConfig implements WebMvcConfigurer { // @Override diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/controller/PostRestController.java similarity index 91% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/controller/PostRestController.java index e2def62466..c52960b365 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/controller/PostRestController.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/controller/PostRestController.java @@ -1,9 +1,9 @@ -package com.baeldung.modelmapper.controller; +package com.baeldung.springpagination.controller; -import com.baeldung.modelmapper.dto.PostDto; -import com.baeldung.modelmapper.model.Post; -import com.baeldung.modelmapper.service.IPostService; -import com.baeldung.modelmapper.service.IUserService; +import com.baeldung.springpagination.dto.PostDto; +import com.baeldung.springpagination.model.Post; +import com.baeldung.springpagination.service.IPostService; +import com.baeldung.springpagination.service.IUserService; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/PostDto.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/dto/PostDto.java similarity index 96% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/PostDto.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/dto/PostDto.java index 6fe2b23888..81cec5ed8c 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/PostDto.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/dto/PostDto.java @@ -1,4 +1,4 @@ -package com.baeldung.modelmapper.dto; +package com.baeldung.springpagination.dto; import java.text.ParseException; import java.text.SimpleDateFormat; diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/UserDto.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/dto/UserDto.java similarity index 80% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/UserDto.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/dto/UserDto.java index 23110ecbaa..2e4f667b30 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/dto/UserDto.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/dto/UserDto.java @@ -1,4 +1,4 @@ -package com.baeldung.modelmapper.dto; +package com.baeldung.springpagination.dto; public class UserDto { diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Post.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/model/Post.java similarity index 97% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Post.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/model/Post.java index be65ce34a2..88e9ef67bb 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Post.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/model/Post.java @@ -1,4 +1,4 @@ -package com.baeldung.modelmapper.model; +package com.baeldung.springpagination.model; import java.util.Date; diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Preference.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/model/Preference.java similarity index 92% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Preference.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/model/Preference.java index 0ab5b1eddf..44f8f41aff 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/Preference.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/model/Preference.java @@ -1,4 +1,4 @@ -package com.baeldung.modelmapper.model; +package com.baeldung.springpagination.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-boot-rest/src/main/java/com/baeldung/springpagination/model/Subject.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/model/Subject.java new file mode 100644 index 0000000000..80598ae07d --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/model/Subject.java @@ -0,0 +1,37 @@ +package com.baeldung.springpagination.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Subject { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + @Column(nullable = false) + private String name; + + public Subject() { + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/User.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/model/User.java similarity index 94% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/User.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/model/User.java index a458b26f4a..4d33834b28 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/model/User.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/model/User.java @@ -1,4 +1,4 @@ -package com.baeldung.modelmapper.model; +package com.baeldung.springpagination.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/repository/PostRepository.java similarity index 82% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/repository/PostRepository.java index fc3f5733c3..acdc01df94 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/repository/PostRepository.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/repository/PostRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.modelmapper.repository; +package com.baeldung.springpagination.repository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -7,8 +7,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; -import com.baeldung.modelmapper.model.Post; -import com.baeldung.modelmapper.model.User; +import com.baeldung.springpagination.model.Post; +import com.baeldung.springpagination.model.User; public interface PostRepository extends JpaRepository, PagingAndSortingRepository { diff --git a/spring-boot-rest/src/main/java/com/baeldung/springpagination/repository/SubjectRepository.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/repository/SubjectRepository.java new file mode 100644 index 0000000000..03c66f8d72 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/repository/SubjectRepository.java @@ -0,0 +1,16 @@ +package com.baeldung.springpagination.repository; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RestResource; + +import com.baeldung.springpagination.model.Subject; + +public interface SubjectRepository extends PagingAndSortingRepository { + + @RestResource(path = "nameContains") + public Page findByNameContaining(@Param("name") String name, Pageable p); + +} \ No newline at end of file diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IPostService.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/service/IPostService.java similarity index 71% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IPostService.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/service/IPostService.java index 0182a0da41..d1d9bee2c6 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/IPostService.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/service/IPostService.java @@ -1,8 +1,8 @@ -package com.baeldung.modelmapper.service; +package com.baeldung.springpagination.service; import java.util.List; -import com.baeldung.modelmapper.model.Post; +import com.baeldung.springpagination.model.Post; public interface IPostService { diff --git a/spring-boot-rest/src/main/java/com/baeldung/springpagination/service/IUserService.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/service/IUserService.java new file mode 100644 index 0000000000..92dce3ed78 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/service/IUserService.java @@ -0,0 +1,9 @@ +package com.baeldung.springpagination.service; + +import com.baeldung.springpagination.model.User; + +public interface IUserService { + + User getCurrentUser(); + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/PostService.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/service/PostService.java similarity index 87% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/PostService.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/service/PostService.java index 5980c30837..bb4869dd33 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/PostService.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/service/PostService.java @@ -1,4 +1,4 @@ -package com.baeldung.modelmapper.service; +package com.baeldung.springpagination.service; import java.util.List; @@ -8,8 +8,8 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; -import com.baeldung.modelmapper.model.Post; -import com.baeldung.modelmapper.repository.PostRepository; +import com.baeldung.springpagination.model.Post; +import com.baeldung.springpagination.repository.PostRepository; @Service public class PostService implements IPostService { diff --git a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/UserService.java b/spring-boot-rest/src/main/java/com/baeldung/springpagination/service/UserService.java similarity index 76% rename from spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/UserService.java rename to spring-boot-rest/src/main/java/com/baeldung/springpagination/service/UserService.java index e445f836a4..0694450f44 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/modelmapper/service/UserService.java +++ b/spring-boot-rest/src/main/java/com/baeldung/springpagination/service/UserService.java @@ -1,9 +1,9 @@ -package com.baeldung.modelmapper.service; +package com.baeldung.springpagination.service; import org.springframework.stereotype.Service; -import com.baeldung.modelmapper.model.Preference; -import com.baeldung.modelmapper.model.User; +import com.baeldung.springpagination.model.Preference; +import com.baeldung.springpagination.model.User; @Service public class UserService implements IUserService { diff --git a/spring-boot-rest/src/main/resources/WEB-INF/api-servlet.xml b/spring-boot-rest/src/main/resources/WEB-INF/api-servlet.xml deleted file mode 100644 index 78e38e1448..0000000000 --- a/spring-boot-rest/src/main/resources/WEB-INF/api-servlet.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-boot-rest/src/test/java/com/baeldung/springhateoas/CustomerControllerIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/springhateoas/CustomerControllerIntegrationTest.java index b08da6d2cd..644ce5132a 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/springhateoas/CustomerControllerIntegrationTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/springhateoas/CustomerControllerIntegrationTest.java @@ -70,7 +70,7 @@ public class CustomerControllerIntegrationTest { this.mvc.perform(get("/customers/" + DEFAULT_CUSTOMER_ID + "/orders").accept(MediaTypes.HAL_JSON_VALUE)) .andExpect(status().isOk()) - .andExpect(jsonPath("$._embedded.orderList[0]._links.self.href", + .andExpect(jsonPath("$._embedded.orders[0]._links.self.href", is("http://localhost/customers/customer1/order1"))) .andExpect(jsonPath("$._links.self.href", is("http://localhost/customers/customer1/orders"))); } @@ -89,8 +89,8 @@ public class CustomerControllerIntegrationTest { this.mvc.perform(get("/customers/").accept(MediaTypes.HAL_JSON_VALUE)) .andExpect(status().isOk()) .andExpect( - jsonPath("$._embedded.customerList[0]._links.self.href", is("http://localhost/customers/customer1"))) - .andExpect(jsonPath("$._embedded.customerList[0]._links.allOrders.href", + jsonPath("$._embedded.customers[0]._links.self.href", is("http://localhost/customers/customer1"))) + .andExpect(jsonPath("$._embedded.customers[0]._links.allOrders.href", is("http://localhost/customers/customer1/orders"))) .andExpect(jsonPath("$._links.self.href", is("http://localhost/customers"))); } diff --git a/spring-boot-rest/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java b/spring-boot-rest/src/test/java/com/baeldung/springpagination/PostDtoUnitTest.java similarity index 89% rename from spring-boot-rest/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java rename to spring-boot-rest/src/test/java/com/baeldung/springpagination/PostDtoUnitTest.java index 6e94cc4289..948247e166 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/modelmapper/PostDtoUnitTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/springpagination/PostDtoUnitTest.java @@ -1,12 +1,12 @@ -package com.baeldung.modelmapper; +package com.baeldung.springpagination; import static org.junit.Assert.assertEquals; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import org.junit.Test; import org.modelmapper.ModelMapper; -import com.baeldung.modelmapper.dto.PostDto; -import com.baeldung.modelmapper.model.Post; +import com.baeldung.springpagination.dto.PostDto; +import com.baeldung.springpagination.model.Post; public class PostDtoUnitTest { diff --git a/spring-boot-security/pom.xml b/spring-boot-security/pom.xml index 62c04b4dc3..92397d42f8 100644 --- a/spring-boot-security/pom.xml +++ b/spring-boot-security/pom.xml @@ -22,12 +22,22 @@ org.springframework.security.oauth spring-security-oauth2 - 2.3.3.RELEASE + 2.4.0.RELEASE + + + org.springframework.security + spring-security-core + 5.2.1.RELEASE + + + commons-io + commons-io + 2.6 org.springframework.security.oauth.boot spring-security-oauth2-autoconfigure - 2.1.2.RELEASE + 2.2.2.RELEASE org.springframework.boot @@ -64,7 +74,7 @@ org.springframework.boot spring-boot-autoconfigure - 2.1.1.RELEASE +
diff --git a/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/oauth2server/SpringBootAuthorizationServerApplication.java b/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/oauth2server/SpringBootAuthorizationServerApplication.java index 44dabefbb8..04f046ff78 100644 --- a/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/oauth2server/SpringBootAuthorizationServerApplication.java +++ b/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/oauth2server/SpringBootAuthorizationServerApplication.java @@ -1,7 +1,11 @@ package com.baeldung.springbootsecurity.oauth2server; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.annotation.CurrentSecurityContext; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; import org.springframework.web.bind.annotation.GetMapping; @@ -14,6 +18,8 @@ import java.security.Principal; @SpringBootApplication(scanBasePackages = "com.baeldung.springbootsecurity.oauth2server") public class SpringBootAuthorizationServerApplication { + private static final Logger logger = LoggerFactory.getLogger(SpringBootAuthorizationServerApplication.class); + public static void main(String[] args) { SpringApplication.run(SpringBootAuthorizationServerApplication.class, args); } @@ -26,5 +32,16 @@ public class SpringBootAuthorizationServerApplication { return user; } + @GetMapping("/authentication") + public Object getAuthentication(@CurrentSecurityContext(expression = "authentication") Authentication authentication) { + logger.info("authentication -> {}", authentication); + return authentication.getDetails(); + } + + @GetMapping("/principal") + public String getPrincipal(@CurrentSecurityContext(expression = "authentication.principal") Principal principal) { + logger.info("principal -> {}", principal); + return principal.getName(); + } } } diff --git a/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/oauth2server/CustomConfigAuthorizationServerIntegrationTest.java b/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/oauth2server/CustomConfigAuthorizationServerIntegrationTest.java index cc953eef5a..104e115b18 100644 --- a/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/oauth2server/CustomConfigAuthorizationServerIntegrationTest.java +++ b/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/oauth2server/CustomConfigAuthorizationServerIntegrationTest.java @@ -1,8 +1,10 @@ package com.baeldung.springbootsecurity.oauth2server; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException; import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; @@ -10,8 +12,13 @@ import org.springframework.security.oauth2.common.OAuth2AccessToken; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import java.net.URL; +import java.util.regex.Pattern; + import static java.util.Collections.singletonList; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @RunWith(SpringRunner.class) @@ -19,6 +26,14 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen @ActiveProfiles("authz") public class CustomConfigAuthorizationServerIntegrationTest extends OAuth2IntegrationTestSupport { + @LocalServerPort + private int port; + + @Before + public void setUp() throws Exception { + base = new URL("http://localhost:" + port); + } + @Test public void givenOAuth2Context_whenAccessTokenIsRequested_ThenAccessTokenValueIsNotNull() { ClientCredentialsResourceDetails resourceDetails = getClientCredentialsResourceDetails("baeldung", singletonList("read")); @@ -27,7 +42,29 @@ public class CustomConfigAuthorizationServerIntegrationTest extends OAuth2Integr OAuth2AccessToken accessToken = restTemplate.getAccessToken(); assertNotNull(accessToken); + } + @Test + public void givenOAuth2Context_whenAccessingAuthentication_ThenRespondTokenDetails() { + ClientCredentialsResourceDetails resourceDetails = getClientCredentialsResourceDetails("baeldung", singletonList("read")); + OAuth2RestTemplate restTemplate = getOAuth2RestTemplate(resourceDetails); + + String authentication = executeGetRequest(restTemplate, "/authentication"); + + Pattern pattern = Pattern.compile("\\{\"remoteAddress\":\".*" + + "\",\"sessionId\":null,\"tokenValue\":\".*" + + "\",\"tokenType\":\"Bearer\",\"decodedDetails\":null}"); + assertTrue("authentication", pattern.matcher(authentication).matches()); + } + + @Test + public void givenOAuth2Context_whenAccessingPrincipal_ThenRespondBaeldung() { + ClientCredentialsResourceDetails resourceDetails = getClientCredentialsResourceDetails("baeldung", singletonList("read")); + OAuth2RestTemplate restTemplate = getOAuth2RestTemplate(resourceDetails); + + String principal = executeGetRequest(restTemplate, "/principal"); + + assertEquals("baeldung", principal); } @Test(expected = OAuth2AccessDeniedException.class) diff --git a/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/oauth2server/OAuth2IntegrationTestSupport.java b/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/oauth2server/OAuth2IntegrationTestSupport.java index 3eef206c7d..a005965998 100644 --- a/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/oauth2server/OAuth2IntegrationTestSupport.java +++ b/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/oauth2server/OAuth2IntegrationTestSupport.java @@ -1,19 +1,33 @@ package com.baeldung.springbootsecurity.oauth2server; +import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; +import org.springframework.web.client.RequestCallback; +import org.springframework.web.client.ResponseExtractor; +import java.net.URL; +import java.nio.charset.Charset; import java.util.List; import static java.lang.String.format; import static java.util.Collections.singletonList; +import static org.springframework.http.HttpMethod.GET; public class OAuth2IntegrationTestSupport { - @Value("${local.server.port}") protected int port; + public static final ResponseExtractor EXTRACT_BODY_AS_STRING = clientHttpResponse -> + IOUtils.toString(clientHttpResponse.getBody(), Charset.defaultCharset()); + private static final RequestCallback DO_NOTHING_CALLBACK = request -> { + }; + + @Value("${local.server.port}") + protected int port; + + protected URL base; protected ClientCredentialsResourceDetails getClientCredentialsResourceDetails(final String clientId, final List scopes) { ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails(); @@ -31,4 +45,9 @@ public class OAuth2IntegrationTestSupport { restTemplate.setMessageConverters(singletonList(new MappingJackson2HttpMessageConverter())); return restTemplate; } + + protected String executeGetRequest(OAuth2RestTemplate restTemplate, String path) { + return restTemplate.execute(base.toString() + path, GET, DO_NOTHING_CALLBACK, EXTRACT_BODY_AS_STRING); + } + } diff --git a/spring-boot-testing/.mvn/wrapper/maven-wrapper.jar b/spring-boot-testing/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 9cc84ea9b4..0000000000 Binary files a/spring-boot-testing/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/spring-boot-vue/src/main/resources/logback.xml b/spring-boot-vue/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/spring-boot-vue/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/spring-boot/.factorypath b/spring-boot/.factorypath deleted file mode 100644 index 22b8a1ce95..0000000000 --- a/spring-boot/.factorypath +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-caching/src/main/java/org/baeldung/caching/config/ApplicationCacheConfig.java b/spring-caching/src/main/java/com/baeldung/caching/config/ApplicationCacheConfig.java similarity index 96% rename from spring-caching/src/main/java/org/baeldung/caching/config/ApplicationCacheConfig.java rename to spring-caching/src/main/java/com/baeldung/caching/config/ApplicationCacheConfig.java index 8bf23de2cc..9a8759cbff 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/config/ApplicationCacheConfig.java +++ b/spring-caching/src/main/java/com/baeldung/caching/config/ApplicationCacheConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.config; +package com.baeldung.caching.config; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; diff --git a/spring-caching/src/main/java/org/baeldung/caching/config/CachingConfig.java b/spring-caching/src/main/java/com/baeldung/caching/config/CachingConfig.java similarity index 90% rename from spring-caching/src/main/java/org/baeldung/caching/config/CachingConfig.java rename to spring-caching/src/main/java/com/baeldung/caching/config/CachingConfig.java index c995bca68d..d245b05502 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/config/CachingConfig.java +++ b/spring-caching/src/main/java/com/baeldung/caching/config/CachingConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.config; +package com.baeldung.caching.config; import java.util.Arrays; @@ -12,7 +12,7 @@ import org.springframework.context.annotation.Configuration; @Configuration @EnableCaching -@ComponentScan("org.baeldung.caching.example") +@ComponentScan("com.baeldung.caching.example") public class CachingConfig { @Bean diff --git a/spring-caching/src/main/java/org/baeldung/caching/config/CustomKeyGenerator.java b/spring-caching/src/main/java/com/baeldung/caching/config/CustomKeyGenerator.java similarity index 92% rename from spring-caching/src/main/java/org/baeldung/caching/config/CustomKeyGenerator.java rename to spring-caching/src/main/java/com/baeldung/caching/config/CustomKeyGenerator.java index c1da9493e0..173f44bfbc 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/config/CustomKeyGenerator.java +++ b/spring-caching/src/main/java/com/baeldung/caching/config/CustomKeyGenerator.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.config; +package com.baeldung.caching.config; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.util.StringUtils; diff --git a/spring-caching/src/main/java/org/baeldung/caching/eviction/controllers/CachingController.java b/spring-caching/src/main/java/com/baeldung/caching/eviction/controllers/CachingController.java similarity index 78% rename from spring-caching/src/main/java/org/baeldung/caching/eviction/controllers/CachingController.java rename to spring-caching/src/main/java/com/baeldung/caching/eviction/controllers/CachingController.java index aaaf8a5918..2980e32763 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/eviction/controllers/CachingController.java +++ b/spring-caching/src/main/java/com/baeldung/caching/eviction/controllers/CachingController.java @@ -1,6 +1,6 @@ -package org.baeldung.caching.eviction.controllers; +package com.baeldung.caching.eviction.controllers; -import org.baeldung.caching.eviction.service.CachingService; +import com.baeldung.caching.eviction.service.CachingService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/spring-caching/src/main/java/org/baeldung/caching/eviction/service/CachingService.java b/spring-caching/src/main/java/com/baeldung/caching/eviction/service/CachingService.java similarity index 97% rename from spring-caching/src/main/java/org/baeldung/caching/eviction/service/CachingService.java rename to spring-caching/src/main/java/com/baeldung/caching/eviction/service/CachingService.java index a0dd30c329..d44da332d4 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/eviction/service/CachingService.java +++ b/spring-caching/src/main/java/com/baeldung/caching/eviction/service/CachingService.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.eviction.service; +package com.baeldung.caching.eviction.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.CacheManager; diff --git a/spring-caching/src/main/java/org/baeldung/caching/example/AbstractService.java b/spring-caching/src/main/java/com/baeldung/caching/example/AbstractService.java similarity index 98% rename from spring-caching/src/main/java/org/baeldung/caching/example/AbstractService.java rename to spring-caching/src/main/java/com/baeldung/caching/example/AbstractService.java index 02b8c3c159..5893ffdfcf 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/example/AbstractService.java +++ b/spring-caching/src/main/java/com/baeldung/caching/example/AbstractService.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.example; +package com.baeldung.caching.example; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CachePut; diff --git a/spring-caching/src/main/java/org/baeldung/caching/example/BookService.java b/spring-caching/src/main/java/com/baeldung/caching/example/BookService.java similarity index 87% rename from spring-caching/src/main/java/org/baeldung/caching/example/BookService.java rename to spring-caching/src/main/java/com/baeldung/caching/example/BookService.java index 9f3aaf89cf..2b335ac10d 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/example/BookService.java +++ b/spring-caching/src/main/java/com/baeldung/caching/example/BookService.java @@ -1,6 +1,6 @@ -package org.baeldung.caching.example; +package com.baeldung.caching.example; -import org.baeldung.caching.model.Book; +import com.baeldung.caching.model.Book; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Component; diff --git a/spring-caching/src/main/java/org/baeldung/caching/example/Customer.java b/spring-caching/src/main/java/com/baeldung/caching/example/Customer.java similarity index 95% rename from spring-caching/src/main/java/org/baeldung/caching/example/Customer.java rename to spring-caching/src/main/java/com/baeldung/caching/example/Customer.java index a57f08e35b..52de4bc1cc 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/example/Customer.java +++ b/spring-caching/src/main/java/com/baeldung/caching/example/Customer.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.example; +package com.baeldung.caching.example; public class Customer { diff --git a/spring-caching/src/main/java/org/baeldung/caching/example/CustomerDataService.java b/spring-caching/src/main/java/com/baeldung/caching/example/CustomerDataService.java similarity index 98% rename from spring-caching/src/main/java/org/baeldung/caching/example/CustomerDataService.java rename to spring-caching/src/main/java/com/baeldung/caching/example/CustomerDataService.java index 1c595057a8..005a85fcb4 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/example/CustomerDataService.java +++ b/spring-caching/src/main/java/com/baeldung/caching/example/CustomerDataService.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.example; +package com.baeldung.caching.example; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; diff --git a/spring-caching/src/main/java/org/baeldung/caching/example/CustomerServiceWithParent.java b/spring-caching/src/main/java/com/baeldung/caching/example/CustomerServiceWithParent.java similarity index 86% rename from spring-caching/src/main/java/org/baeldung/caching/example/CustomerServiceWithParent.java rename to spring-caching/src/main/java/com/baeldung/caching/example/CustomerServiceWithParent.java index a5ded7daf9..be201413b4 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/example/CustomerServiceWithParent.java +++ b/spring-caching/src/main/java/com/baeldung/caching/example/CustomerServiceWithParent.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.example; +package com.baeldung.caching.example; import org.springframework.cache.annotation.CacheConfig; import org.springframework.stereotype.Component; diff --git a/spring-caching/src/main/java/org/baeldung/caching/model/Book.java b/spring-caching/src/main/java/com/baeldung/caching/model/Book.java similarity index 94% rename from spring-caching/src/main/java/org/baeldung/caching/model/Book.java rename to spring-caching/src/main/java/com/baeldung/caching/model/Book.java index c110c79db0..fd8abf1816 100644 --- a/spring-caching/src/main/java/org/baeldung/caching/model/Book.java +++ b/spring-caching/src/main/java/com/baeldung/caching/model/Book.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.model; +package com.baeldung.caching.model; public class Book { diff --git a/spring-caching/src/main/java/org/baeldung/ehcache/calculator/SquaredCalculator.java b/spring-caching/src/main/java/com/baeldung/ehcache/calculator/SquaredCalculator.java similarity index 86% rename from spring-caching/src/main/java/org/baeldung/ehcache/calculator/SquaredCalculator.java rename to spring-caching/src/main/java/com/baeldung/ehcache/calculator/SquaredCalculator.java index 25957539df..caf1df2a1b 100644 --- a/spring-caching/src/main/java/org/baeldung/ehcache/calculator/SquaredCalculator.java +++ b/spring-caching/src/main/java/com/baeldung/ehcache/calculator/SquaredCalculator.java @@ -1,6 +1,6 @@ -package org.baeldung.ehcache.calculator; +package com.baeldung.ehcache.calculator; -import org.baeldung.ehcache.config.CacheHelper; +import com.baeldung.ehcache.config.CacheHelper; public class SquaredCalculator { private CacheHelper cache; diff --git a/spring-caching/src/main/java/org/baeldung/ehcache/config/CacheHelper.java b/spring-caching/src/main/java/com/baeldung/ehcache/config/CacheHelper.java similarity index 96% rename from spring-caching/src/main/java/org/baeldung/ehcache/config/CacheHelper.java rename to spring-caching/src/main/java/com/baeldung/ehcache/config/CacheHelper.java index 7f59ad8cfb..d138f6e84c 100644 --- a/spring-caching/src/main/java/org/baeldung/ehcache/config/CacheHelper.java +++ b/spring-caching/src/main/java/com/baeldung/ehcache/config/CacheHelper.java @@ -1,4 +1,4 @@ -package org.baeldung.ehcache.config; +package com.baeldung.ehcache.config; import org.ehcache.Cache; import org.ehcache.CacheManager; diff --git a/spring-caching/src/main/resources/config.xml b/spring-caching/src/main/resources/config.xml index 23458539b0..666e91e173 100644 --- a/spring-caching/src/main/resources/config.xml +++ b/spring-caching/src/main/resources/config.xml @@ -13,7 +13,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/spring-caching/src/test/java/org/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java b/spring-caching/src/test/java/com/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java similarity index 96% rename from spring-caching/src/test/java/org/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java rename to spring-caching/src/test/java/com/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java index 28b0d26bed..7363022268 100644 --- a/spring-caching/src/test/java/org/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java +++ b/spring-caching/src/test/java/com/baeldung/caching/test/CacheEvictAnnotationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.test; +package com.baeldung.caching.test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; @@ -7,7 +7,7 @@ import static org.junit.Assert.assertThat; import java.util.ArrayList; import java.util.List; -import org.baeldung.caching.eviction.service.CachingService; +import com.baeldung.caching.eviction.service.CachingService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-caching/src/test/java/org/baeldung/caching/test/CacheManagerEvictIntegrationTest.java b/spring-caching/src/test/java/com/baeldung/caching/test/CacheManagerEvictIntegrationTest.java similarity index 97% rename from spring-caching/src/test/java/org/baeldung/caching/test/CacheManagerEvictIntegrationTest.java rename to spring-caching/src/test/java/com/baeldung/caching/test/CacheManagerEvictIntegrationTest.java index ffcc88febc..fa3168fc62 100644 --- a/spring-caching/src/test/java/org/baeldung/caching/test/CacheManagerEvictIntegrationTest.java +++ b/spring-caching/src/test/java/com/baeldung/caching/test/CacheManagerEvictIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.caching.test; +package com.baeldung.caching.test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; @@ -7,7 +7,7 @@ import static org.junit.Assert.assertThat; import java.util.ArrayList; import java.util.List; -import org.baeldung.caching.eviction.service.CachingService; +import com.baeldung.caching.eviction.service.CachingService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-caching/src/test/java/org/baeldung/caching/test/SpringCachingIntegrationTest.java b/spring-caching/src/test/java/com/baeldung/caching/test/SpringCachingIntegrationTest.java similarity index 88% rename from spring-caching/src/test/java/org/baeldung/caching/test/SpringCachingIntegrationTest.java rename to spring-caching/src/test/java/com/baeldung/caching/test/SpringCachingIntegrationTest.java index 8c4ebaa7ec..080044f359 100644 --- a/spring-caching/src/test/java/org/baeldung/caching/test/SpringCachingIntegrationTest.java +++ b/spring-caching/src/test/java/com/baeldung/caching/test/SpringCachingIntegrationTest.java @@ -1,9 +1,9 @@ -package org.baeldung.caching.test; +package com.baeldung.caching.test; -import org.baeldung.caching.config.CachingConfig; -import org.baeldung.caching.example.Customer; -import org.baeldung.caching.example.CustomerDataService; -import org.baeldung.caching.example.CustomerServiceWithParent; +import com.baeldung.caching.config.CachingConfig; +import com.baeldung.caching.example.Customer; +import com.baeldung.caching.example.CustomerDataService; +import com.baeldung.caching.example.CustomerServiceWithParent; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-caching/src/test/java/org/baeldung/ehcache/SquareCalculatorUnitTest.java b/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java similarity index 90% rename from spring-caching/src/test/java/org/baeldung/ehcache/SquareCalculatorUnitTest.java rename to spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java index 0e6ac6fd8e..37df749bab 100644 --- a/spring-caching/src/test/java/org/baeldung/ehcache/SquareCalculatorUnitTest.java +++ b/spring-caching/src/test/java/com/baeldung/ehcache/SquareCalculatorUnitTest.java @@ -1,7 +1,7 @@ -package org.baeldung.ehcache; +package com.baeldung.ehcache; -import org.baeldung.ehcache.calculator.SquaredCalculator; -import org.baeldung.ehcache.config.CacheHelper; +import com.baeldung.ehcache.calculator.SquaredCalculator; +import com.baeldung.ehcache.config.CacheHelper; import org.junit.Before; import org.junit.Test; diff --git a/spring-cloud/spring-cloud-aws/pom.xml b/spring-cloud/spring-cloud-aws/pom.xml index c1fc458a24..abf9363288 100644 --- a/spring-cloud/spring-cloud-aws/pom.xml +++ b/spring-cloud/spring-cloud-aws/pom.xml @@ -50,7 +50,7 @@ org.springframework.cloud spring-cloud-aws - 2.0.1.RELEASE + ${spring-cloud} pom import @@ -60,6 +60,7 @@ com.baeldung.spring.cloud.aws.SpringCloudAwsApplication Dalston.SR4 + 2.0.1.RELEASE diff --git a/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml index c41ad687ed..e909dbc253 100644 --- a/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml +++ b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml @@ -36,7 +36,7 @@ org.springframework.cloud spring-cloud-contract-maven-plugin - 2.1.1.RELEASE + ${spring-cloud.version} true com.baeldung.spring.cloud.springcloudcontractproducer.BaseTestClass @@ -45,4 +45,8 @@ + + + 2.1.1.RELEASE + diff --git a/spring-cloud/spring-cloud-functions/pom.xml b/spring-cloud/spring-cloud-functions/pom.xml index 2e1b747c2e..03510d0504 100644 --- a/spring-cloud/spring-cloud-functions/pom.xml +++ b/spring-cloud/spring-cloud-functions/pom.xml @@ -65,7 +65,7 @@ org.springframework.boot.experimental spring-boot-thin-layout - 1.0.10.RELEASE + ${spring-boot-thin.version}
@@ -88,6 +88,7 @@ 2.0.2 1.1.0 2.0.4.RELEASE + 1.0.10.RELEASE diff --git a/spring-cloud/spring-cloud-gateway/README.md b/spring-cloud/spring-cloud-gateway/README.md index e87bc547e1..d3323947e8 100644 --- a/spring-cloud/spring-cloud-gateway/README.md +++ b/spring-cloud/spring-cloud-gateway/README.md @@ -4,3 +4,4 @@ This module contains articles about Spring Cloud Gateway ### Relevant Articles: - [Exploring the new Spring Cloud Gateway](http://www.baeldung.com/spring-cloud-gateway) +- [Writing Custom Spring Cloud Gateway Filters](https://www.baeldung.com/spring-cloud-custom-gateway-filters) diff --git a/spring-cloud/spring-cloud-gateway/pom.xml b/spring-cloud/spring-cloud-gateway/pom.xml index 10cd49cc04..0f62c031cf 100644 --- a/spring-cloud/spring-cloud-gateway/pom.xml +++ b/spring-cloud/spring-cloud-gateway/pom.xml @@ -68,6 +68,10 @@ spring-boot-starter-test test + + org.springframework.boot + spring-boot-devtools +
diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/CustomPredicatesApplication.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/CustomPredicatesApplication.java new file mode 100644 index 0000000000..e209b6cdf0 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/CustomPredicatesApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.springcloudgateway.custompredicates; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; + +@SpringBootApplication +public class CustomPredicatesApplication { + + public static void main(String[] args) { + new SpringApplicationBuilder(CustomPredicatesApplication.class) + .profiles("customroutes") + .run(args); + } + +} \ No newline at end of file diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/config/CustomPredicatesConfig.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/config/CustomPredicatesConfig.java new file mode 100644 index 0000000000..0e88b29bcf --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/config/CustomPredicatesConfig.java @@ -0,0 +1,38 @@ +package com.baeldung.springcloudgateway.custompredicates.config; + +import org.springframework.cloud.gateway.filter.GatewayFilter; +import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.baeldung.springcloudgateway.custompredicates.factories.GoldenCustomerRoutePredicateFactory; +import com.baeldung.springcloudgateway.custompredicates.factories.GoldenCustomerRoutePredicateFactory.Config; +import com.baeldung.springcloudgateway.custompredicates.service.GoldenCustomerService; + +@Configuration +public class CustomPredicatesConfig { + + + @Bean + public GoldenCustomerRoutePredicateFactory goldenCustomer(GoldenCustomerService goldenCustomerService) { + return new GoldenCustomerRoutePredicateFactory(goldenCustomerService); + } + + + //@Bean + public RouteLocator routes(RouteLocatorBuilder builder, GoldenCustomerRoutePredicateFactory gf ) { + + return builder.routes() + .route("dsl_golden_route", r -> r.path("/dsl_api/**") + .filters(f -> f.stripPrefix(1)) + .uri("https://httpbin.org") + .predicate(gf.apply(new Config(true, "customerId")))) + .route("dsl_common_route", r -> r.path("/dsl_api/**") + .filters(f -> f.stripPrefix(1)) + .uri("https://httpbin.org") + .predicate(gf.apply(new Config(false, "customerId")))) + .build(); + } + +} diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/factories/GoldenCustomerRoutePredicateFactory.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/factories/GoldenCustomerRoutePredicateFactory.java new file mode 100644 index 0000000000..cb5c3a0b50 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/factories/GoldenCustomerRoutePredicateFactory.java @@ -0,0 +1,102 @@ +/** + * + */ +package com.baeldung.springcloudgateway.custompredicates.factories; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +import javax.validation.constraints.NotEmpty; + +import org.springframework.cloud.gateway.handler.predicate.AbstractRoutePredicateFactory; +import org.springframework.http.HttpCookie; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.server.ServerWebExchange; + +import com.baeldung.springcloudgateway.custompredicates.service.GoldenCustomerService; + +/** + * @author Philippe + * + */ +public class GoldenCustomerRoutePredicateFactory extends AbstractRoutePredicateFactory { + + private final GoldenCustomerService goldenCustomerService; + + public GoldenCustomerRoutePredicateFactory(GoldenCustomerService goldenCustomerService ) { + super(Config.class); + this.goldenCustomerService = goldenCustomerService; + } + + + @Override + public List shortcutFieldOrder() { + return Arrays.asList("isGolden","customerIdCookie"); + } + + + @Override + public Predicate apply(Config config) { + + return (ServerWebExchange t) -> { + List cookies = t.getRequest() + .getCookies() + .get(config.getCustomerIdCookie()); + + boolean isGolden; + if ( cookies == null || cookies.isEmpty()) { + isGolden = false; + } + else { + String customerId = cookies.get(0).getValue(); + isGolden = goldenCustomerService.isGoldenCustomer(customerId); + } + + return config.isGolden()?isGolden:!isGolden; + }; + } + + + @Validated + public static class Config { + boolean isGolden = true; + + @NotEmpty + String customerIdCookie = "customerId"; + + + public Config() {} + + public Config( boolean isGolden, String customerIdCookie) { + this.isGolden = isGolden; + this.customerIdCookie = customerIdCookie; + } + + public boolean isGolden() { + return isGolden; + } + + public void setGolden(boolean value) { + this.isGolden = value; + } + + /** + * @return the customerIdCookie + */ + public String getCustomerIdCookie() { + return customerIdCookie; + } + + /** + * @param customerIdCookie the customerIdCookie to set + */ + public void setCustomerIdCookie(String customerIdCookie) { + this.customerIdCookie = customerIdCookie; + } + + + + } + +} diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/service/GoldenCustomerService.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/service/GoldenCustomerService.java new file mode 100644 index 0000000000..82bf2e6ae9 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/custompredicates/service/GoldenCustomerService.java @@ -0,0 +1,26 @@ +/** + * + */ +package com.baeldung.springcloudgateway.custompredicates.service; + +import org.springframework.stereotype.Component; + +/** + * @author Philippe + * + */ +@Component +public class GoldenCustomerService { + + public boolean isGoldenCustomer(String customerId) { + + // TODO: Add some AI logic to check is this customer deserves a "golden" status ;^) + if ( "baeldung".equalsIgnoreCase(customerId)) { + return true; + } + else { + return false; + } + } + +} diff --git a/spring-cloud/spring-cloud-gateway/src/main/resources/application-customroutes.yml b/spring-cloud/spring-cloud-gateway/src/main/resources/application-customroutes.yml new file mode 100644 index 0000000000..859aa60bda --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/main/resources/application-customroutes.yml @@ -0,0 +1,26 @@ +spring: + cloud: + gateway: + routes: + - id: golden_route + uri: https://httpbin.org + predicates: + - Path=/api/** + - GoldenCustomer=true + filters: + - StripPrefix=1 + - AddRequestHeader=GoldenCustomer,true + - id: common_route + uri: https://httpbin.org + predicates: + - Path=/api/** + - name: GoldenCustomer + args: + golden: false + customerIdCookie: customerId + filters: + - StripPrefix=1 + - AddRequestHeader=GoldenCustomer,false + + + \ No newline at end of file diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/gatewayapp/CustomFiltersLiveTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/gatewayapp/CustomFiltersLiveTest.java index a4bb3f8068..f49f8c68b6 100644 --- a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/gatewayapp/CustomFiltersLiveTest.java +++ b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/customfilters/gatewayapp/CustomFiltersLiveTest.java @@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.assertj.core.api.Condition; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.LocalServerPort; @@ -27,6 +28,7 @@ public class CustomFiltersLiveTest { @LocalServerPort String port; + @Autowired private WebTestClient client; @BeforeEach diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/custompredicates/CustomPredicatesApplicationLiveTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/custompredicates/CustomPredicatesApplicationLiveTest.java new file mode 100644 index 0000000000..d9988ceb5e --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/custompredicates/CustomPredicatesApplicationLiveTest.java @@ -0,0 +1,67 @@ +package com.baeldung.springcloudgateway.custompredicates; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; + +import java.net.URI; + +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.junit.Before; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.RequestEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; + +/** + * This test requires + */ +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@ActiveProfiles("customroutes") +public class CustomPredicatesApplicationLiveTest { + + @LocalServerPort + String serverPort; + + @Autowired + private TestRestTemplate restTemplate; + + @Test + void givenNormalCustomer_whenCallHeadersApi_thenResponseForNormalCustomer() throws JSONException { + + String url = "http://localhost:" + serverPort + "/api/headers"; + ResponseEntity response = restTemplate.getForEntity(url, String.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + + JSONObject json = new JSONObject(response.getBody()); + JSONObject headers = json.getJSONObject("headers"); + assertThat(headers.getString("Goldencustomer")).isEqualTo("false"); + + } + + @Test + void givenGoldenCustomer_whenCallHeadersApi_thenResponseForGoldenCustomer() throws JSONException { + + String url = "http://localhost:" + serverPort + "/api/headers"; + RequestEntity request = RequestEntity + .get(URI.create(url)) + .header("Cookie", "customerId=baeldung") + .build(); + + ResponseEntity response = restTemplate.exchange(request, String.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + + JSONObject json = new JSONObject(response.getBody()); + JSONObject headers = json.getJSONObject("headers"); + assertThat(headers.getString("Goldencustomer")).isEqualTo("true"); + + } + +} diff --git a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml index e5f76d5d9c..07de78a92e 100644 --- a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/client-service/pom.xml @@ -89,7 +89,7 @@ - Finchley.SR2 + Hoxton.SR1 1.0.0.RELEASE diff --git a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/pom.xml b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/pom.xml index 93734a19a7..5459b77682 100644 --- a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/pom.xml @@ -24,7 +24,7 @@ ch.qos.logback logback-classic - 1.2.3 + ${logback.version}
@@ -71,6 +71,7 @@ Finchley.SR2 + 1.2.3 \ No newline at end of file diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 0ed303162d..1fb591f693 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -16,5 +16,5 @@ This module contains articles about core Spring functionality - [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations) - [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class) - [Guide to the Spring BeanFactory](https://www.baeldung.com/spring-beanfactory) -- [Read HttpServletRequest Multiple Times](https://www.baeldung.com/spring-reading-httpservletrequest-multiple-times) -- More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) \ No newline at end of file +- [Reading HttpServletRequest Multiple Times in Spring](https://www.baeldung.com/spring-reading-httpservletrequest-multiple-times) +- More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml index f89a093f30..4d474d8b2c 100644 --- a/spring-core-2/pom.xml +++ b/spring-core-2/pom.xml @@ -174,7 +174,7 @@ org.apache.maven.plugins maven-war-plugin - 3.2.2 + ${maven.version} false @@ -201,9 +201,9 @@ - org.baeldung.sample.App + com.baeldung.sample.App - 5.0.6.RELEASE + 5.2.2.RELEASE 1.3.2 5.2.5.Final @@ -214,6 +214,7 @@ 3.6.1 2.1.0 3.22.0-GA + 3.2.2 diff --git a/spring-core-2/src/main/java/org/baeldung/autowire/sample/App.java b/spring-core-2/src/main/java/com/baeldung/autowire/sample/App.java similarity index 90% rename from spring-core-2/src/main/java/org/baeldung/autowire/sample/App.java rename to spring-core-2/src/main/java/com/baeldung/autowire/sample/App.java index ed0c90d5b1..18ff11a49c 100644 --- a/spring-core-2/src/main/java/org/baeldung/autowire/sample/App.java +++ b/spring-core-2/src/main/java/com/baeldung/autowire/sample/App.java @@ -1,4 +1,4 @@ -package org.baeldung.autowire.sample; +package com.baeldung.autowire.sample; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-core-2/src/main/java/org/baeldung/autowire/sample/AppConfig.java b/spring-core-2/src/main/java/com/baeldung/autowire/sample/AppConfig.java similarity index 66% rename from spring-core-2/src/main/java/org/baeldung/autowire/sample/AppConfig.java rename to spring-core-2/src/main/java/com/baeldung/autowire/sample/AppConfig.java index 117dfe1027..f948e2bf8e 100644 --- a/spring-core-2/src/main/java/org/baeldung/autowire/sample/AppConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/autowire/sample/AppConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.autowire.sample; +package com.baeldung.autowire.sample; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.autowire.sample") +@ComponentScan("com.baeldung.autowire.sample") public class AppConfig { } diff --git a/spring-core-2/src/main/java/org/baeldung/autowire/sample/BarFormatter.java b/spring-core-2/src/main/java/com/baeldung/autowire/sample/BarFormatter.java similarity index 83% rename from spring-core-2/src/main/java/org/baeldung/autowire/sample/BarFormatter.java rename to spring-core-2/src/main/java/com/baeldung/autowire/sample/BarFormatter.java index f7e730fdc6..e67a376d25 100644 --- a/spring-core-2/src/main/java/org/baeldung/autowire/sample/BarFormatter.java +++ b/spring-core-2/src/main/java/com/baeldung/autowire/sample/BarFormatter.java @@ -1,4 +1,4 @@ -package org.baeldung.autowire.sample; +package com.baeldung.autowire.sample; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/com/baeldung/autowire/sample/FooDAO.java b/spring-core-2/src/main/java/com/baeldung/autowire/sample/FooDAO.java new file mode 100644 index 0000000000..aec26202ab --- /dev/null +++ b/spring-core-2/src/main/java/com/baeldung/autowire/sample/FooDAO.java @@ -0,0 +1,5 @@ +package com.baeldung.autowire.sample; + +public class FooDAO { + +} diff --git a/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooFormatter.java b/spring-core-2/src/main/java/com/baeldung/autowire/sample/FooFormatter.java similarity index 83% rename from spring-core-2/src/main/java/org/baeldung/autowire/sample/FooFormatter.java rename to spring-core-2/src/main/java/com/baeldung/autowire/sample/FooFormatter.java index 5fdacbadd4..57f93a53d7 100644 --- a/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooFormatter.java +++ b/spring-core-2/src/main/java/com/baeldung/autowire/sample/FooFormatter.java @@ -1,4 +1,4 @@ -package org.baeldung.autowire.sample; +package com.baeldung.autowire.sample; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/com/baeldung/autowire/sample/FooService.java b/spring-core-2/src/main/java/com/baeldung/autowire/sample/FooService.java new file mode 100644 index 0000000000..8a073279bc --- /dev/null +++ b/spring-core-2/src/main/java/com/baeldung/autowire/sample/FooService.java @@ -0,0 +1,31 @@ +package com.baeldung.autowire.sample; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class presents a field, a constructor, and a setter injection type. + * Usually, we'd stick with a single approach for a given property. This is just an educational code. + */ +@Component +public class FooService { + + @Autowired + @FormatterType("Foo") + private Formatter formatter; + + @Autowired + public FooService(@FormatterType("Foo") Formatter formatter) { + this.formatter = formatter; + } + + @Autowired + public void setFormatter(@FormatterType("Foo") Formatter formatter) { + this.formatter = formatter; + } + + public String doStuff() { + return formatter.format(); + } + +} diff --git a/spring-core-2/src/main/java/org/baeldung/autowire/sample/Formatter.java b/spring-core-2/src/main/java/com/baeldung/autowire/sample/Formatter.java similarity index 59% rename from spring-core-2/src/main/java/org/baeldung/autowire/sample/Formatter.java rename to spring-core-2/src/main/java/com/baeldung/autowire/sample/Formatter.java index 05cd5f1c26..59d718050a 100644 --- a/spring-core-2/src/main/java/org/baeldung/autowire/sample/Formatter.java +++ b/spring-core-2/src/main/java/com/baeldung/autowire/sample/Formatter.java @@ -1,4 +1,4 @@ -package org.baeldung.autowire.sample; +package com.baeldung.autowire.sample; public interface Formatter { diff --git a/spring-core-2/src/main/java/org/baeldung/autowire/sample/FormatterType.java b/spring-core-2/src/main/java/com/baeldung/autowire/sample/FormatterType.java similarity index 91% rename from spring-core-2/src/main/java/org/baeldung/autowire/sample/FormatterType.java rename to spring-core-2/src/main/java/com/baeldung/autowire/sample/FormatterType.java index ea1eec055a..f2961745b5 100644 --- a/spring-core-2/src/main/java/org/baeldung/autowire/sample/FormatterType.java +++ b/spring-core-2/src/main/java/com/baeldung/autowire/sample/FormatterType.java @@ -1,4 +1,4 @@ -package org.baeldung.autowire.sample; +package com.baeldung.autowire.sample; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-core-2/src/main/java/org/baeldung/bean/config/ConstructorBasedShipConfig.java b/spring-core-2/src/main/java/com/baeldung/bean/config/ConstructorBasedShipConfig.java similarity index 73% rename from spring-core-2/src/main/java/org/baeldung/bean/config/ConstructorBasedShipConfig.java rename to spring-core-2/src/main/java/com/baeldung/bean/config/ConstructorBasedShipConfig.java index f0e6e8868e..f9f23ee304 100644 --- a/spring-core-2/src/main/java/org/baeldung/bean/config/ConstructorBasedShipConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/bean/config/ConstructorBasedShipConfig.java @@ -1,7 +1,7 @@ -package org.baeldung.bean.config; +package com.baeldung.bean.config; -import org.baeldung.bean.injection.Helm; -import org.baeldung.bean.injection.Ship; +import com.baeldung.bean.injection.Helm; +import com.baeldung.bean.injection.Ship; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-core-2/src/main/java/org/baeldung/bean/config/SetterBasedShipConfig.java b/spring-core-2/src/main/java/com/baeldung/bean/config/SetterBasedShipConfig.java similarity index 66% rename from spring-core-2/src/main/java/org/baeldung/bean/config/SetterBasedShipConfig.java rename to spring-core-2/src/main/java/com/baeldung/bean/config/SetterBasedShipConfig.java index 7cd6de1c74..cea6385fd9 100644 --- a/spring-core-2/src/main/java/org/baeldung/bean/config/SetterBasedShipConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/bean/config/SetterBasedShipConfig.java @@ -1,7 +1,7 @@ -package org.baeldung.bean.config; +package com.baeldung.bean.config; -import org.baeldung.bean.injection.Helm; -import org.baeldung.bean.injection.Ship; +import com.baeldung.bean.injection.Helm; +import com.baeldung.bean.injection.Ship; import org.springframework.context.annotation.Bean; public class SetterBasedShipConfig { diff --git a/spring-core-2/src/main/java/org/baeldung/bean/injection/Helm.java b/spring-core-2/src/main/java/com/baeldung/bean/injection/Helm.java similarity index 86% rename from spring-core-2/src/main/java/org/baeldung/bean/injection/Helm.java rename to spring-core-2/src/main/java/com/baeldung/bean/injection/Helm.java index 86f71ce795..e1477bd0d9 100644 --- a/spring-core-2/src/main/java/org/baeldung/bean/injection/Helm.java +++ b/spring-core-2/src/main/java/com/baeldung/bean/injection/Helm.java @@ -1,4 +1,4 @@ -package org.baeldung.bean.injection; +package com.baeldung.bean.injection; public class Helm { diff --git a/spring-core-2/src/main/java/org/baeldung/bean/injection/Ship.java b/spring-core-2/src/main/java/com/baeldung/bean/injection/Ship.java similarity index 91% rename from spring-core-2/src/main/java/org/baeldung/bean/injection/Ship.java rename to spring-core-2/src/main/java/com/baeldung/bean/injection/Ship.java index 69d9fa1276..f69a3a51ca 100644 --- a/spring-core-2/src/main/java/org/baeldung/bean/injection/Ship.java +++ b/spring-core-2/src/main/java/com/baeldung/bean/injection/Ship.java @@ -1,4 +1,4 @@ -package org.baeldung.bean.injection; +package com.baeldung.bean.injection; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-core-2/src/main/java/org/baeldung/customannotation/CustomAnnotationConfiguration.java b/spring-core-2/src/main/java/com/baeldung/customannotation/CustomAnnotationConfiguration.java similarity index 68% rename from spring-core-2/src/main/java/org/baeldung/customannotation/CustomAnnotationConfiguration.java rename to spring-core-2/src/main/java/com/baeldung/customannotation/CustomAnnotationConfiguration.java index b8f312d778..2e42a3f744 100644 --- a/spring-core-2/src/main/java/org/baeldung/customannotation/CustomAnnotationConfiguration.java +++ b/spring-core-2/src/main/java/com/baeldung/customannotation/CustomAnnotationConfiguration.java @@ -1,9 +1,9 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.customannotation") +@ComponentScan("com.baeldung.customannotation") public class CustomAnnotationConfiguration { } diff --git a/spring-core-2/src/main/java/org/baeldung/customannotation/DataAccess.java b/spring-core-2/src/main/java/com/baeldung/customannotation/DataAccess.java similarity index 90% rename from spring-core-2/src/main/java/org/baeldung/customannotation/DataAccess.java rename to spring-core-2/src/main/java/com/baeldung/customannotation/DataAccess.java index 9a8a493a6d..4160bad16d 100644 --- a/spring-core-2/src/main/java/org/baeldung/customannotation/DataAccess.java +++ b/spring-core-2/src/main/java/com/baeldung/customannotation/DataAccess.java @@ -1,4 +1,4 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java b/spring-core-2/src/main/java/com/baeldung/customannotation/DataAccessAnnotationProcessor.java similarity index 97% rename from spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java rename to spring-core-2/src/main/java/com/baeldung/customannotation/DataAccessAnnotationProcessor.java index c792073745..27008176a8 100644 --- a/spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessAnnotationProcessor.java +++ b/spring-core-2/src/main/java/com/baeldung/customannotation/DataAccessAnnotationProcessor.java @@ -1,4 +1,4 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java b/spring-core-2/src/main/java/com/baeldung/customannotation/DataAccessFieldCallback.java similarity index 99% rename from spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java rename to spring-core-2/src/main/java/com/baeldung/customannotation/DataAccessFieldCallback.java index 8cb62affc4..07b5298ea9 100644 --- a/spring-core-2/src/main/java/org/baeldung/customannotation/DataAccessFieldCallback.java +++ b/spring-core-2/src/main/java/com/baeldung/customannotation/DataAccessFieldCallback.java @@ -1,4 +1,4 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import java.lang.reflect.Constructor; import java.lang.reflect.Field; diff --git a/spring-core-2/src/main/java/org/baeldung/customannotation/GenericDAO.java b/spring-core-2/src/main/java/com/baeldung/customannotation/GenericDAO.java similarity index 94% rename from spring-core-2/src/main/java/org/baeldung/customannotation/GenericDAO.java rename to spring-core-2/src/main/java/com/baeldung/customannotation/GenericDAO.java index 1916b7de6e..0edd33b049 100644 --- a/spring-core-2/src/main/java/org/baeldung/customannotation/GenericDAO.java +++ b/spring-core-2/src/main/java/com/baeldung/customannotation/GenericDAO.java @@ -1,4 +1,4 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import java.util.Collections; import java.util.List; diff --git a/spring-core-2/src/main/java/org/baeldung/customscope/TenantBean.java b/spring-core-2/src/main/java/com/baeldung/customscope/TenantBean.java similarity index 89% rename from spring-core-2/src/main/java/org/baeldung/customscope/TenantBean.java rename to spring-core-2/src/main/java/com/baeldung/customscope/TenantBean.java index 874fcda9f2..e892ae9d9b 100644 --- a/spring-core-2/src/main/java/org/baeldung/customscope/TenantBean.java +++ b/spring-core-2/src/main/java/com/baeldung/customscope/TenantBean.java @@ -1,4 +1,4 @@ -package org.baeldung.customscope; +package com.baeldung.customscope; public class TenantBean { diff --git a/spring-core-2/src/main/java/org/baeldung/customscope/TenantBeanFactoryPostProcessor.java b/spring-core-2/src/main/java/com/baeldung/customscope/TenantBeanFactoryPostProcessor.java similarity index 93% rename from spring-core-2/src/main/java/org/baeldung/customscope/TenantBeanFactoryPostProcessor.java rename to spring-core-2/src/main/java/com/baeldung/customscope/TenantBeanFactoryPostProcessor.java index 2757399fa6..84ed0b46d7 100644 --- a/spring-core-2/src/main/java/org/baeldung/customscope/TenantBeanFactoryPostProcessor.java +++ b/spring-core-2/src/main/java/com/baeldung/customscope/TenantBeanFactoryPostProcessor.java @@ -1,4 +1,4 @@ -package org.baeldung.customscope; +package com.baeldung.customscope; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; diff --git a/spring-core-2/src/main/java/org/baeldung/customscope/TenantBeansConfig.java b/spring-core-2/src/main/java/com/baeldung/customscope/TenantBeansConfig.java similarity index 93% rename from spring-core-2/src/main/java/org/baeldung/customscope/TenantBeansConfig.java rename to spring-core-2/src/main/java/com/baeldung/customscope/TenantBeansConfig.java index be3ac001fb..c219000fe6 100644 --- a/spring-core-2/src/main/java/org/baeldung/customscope/TenantBeansConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/customscope/TenantBeansConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.customscope; +package com.baeldung.customscope; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-core-2/src/main/java/org/baeldung/customscope/TenantScope.java b/spring-core-2/src/main/java/com/baeldung/customscope/TenantScope.java similarity index 97% rename from spring-core-2/src/main/java/org/baeldung/customscope/TenantScope.java rename to spring-core-2/src/main/java/com/baeldung/customscope/TenantScope.java index 144d092be6..f3077bc4c2 100644 --- a/spring-core-2/src/main/java/org/baeldung/customscope/TenantScope.java +++ b/spring-core-2/src/main/java/com/baeldung/customscope/TenantScope.java @@ -1,4 +1,4 @@ -package org.baeldung.customscope; +package com.baeldung.customscope; import java.util.Collections; import java.util.HashMap; diff --git a/spring-core-2/src/main/java/org/baeldung/customscope/TenantScopeConfig.java b/spring-core-2/src/main/java/com/baeldung/customscope/TenantScopeConfig.java similarity index 91% rename from spring-core-2/src/main/java/org/baeldung/customscope/TenantScopeConfig.java rename to spring-core-2/src/main/java/com/baeldung/customscope/TenantScopeConfig.java index d1159b0f60..1829e1e8c4 100644 --- a/spring-core-2/src/main/java/org/baeldung/customscope/TenantScopeConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/customscope/TenantScopeConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.customscope; +package com.baeldung.customscope; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.context.annotation.Bean; diff --git a/spring-core-2/src/main/java/org/baeldung/nullibility/Person.java b/spring-core-2/src/main/java/com/baeldung/nullibility/Person.java similarity index 95% rename from spring-core-2/src/main/java/org/baeldung/nullibility/Person.java rename to spring-core-2/src/main/java/com/baeldung/nullibility/Person.java index 08c77c9e9c..8fb60fb7a7 100644 --- a/spring-core-2/src/main/java/org/baeldung/nullibility/Person.java +++ b/spring-core-2/src/main/java/com/baeldung/nullibility/Person.java @@ -1,4 +1,4 @@ -package org.baeldung.nullibility; +package com.baeldung.nullibility; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; diff --git a/spring-core-2/src/main/java/org/baeldung/nullibility/package-info.java b/spring-core-2/src/main/java/com/baeldung/nullibility/package-info.java similarity index 77% rename from spring-core-2/src/main/java/org/baeldung/nullibility/package-info.java rename to spring-core-2/src/main/java/com/baeldung/nullibility/package-info.java index 446f2e316e..11a3f7c7aa 100644 --- a/spring-core-2/src/main/java/org/baeldung/nullibility/package-info.java +++ b/spring-core-2/src/main/java/com/baeldung/nullibility/package-info.java @@ -1,6 +1,6 @@ @NonNullApi @NonNullFields -package org.baeldung.nullibility; +package com.baeldung.nullibility; import org.springframework.lang.NonNullApi; import org.springframework.lang.NonNullFields; \ No newline at end of file diff --git a/spring-core-2/src/main/java/org/baeldung/order/Average.java b/spring-core-2/src/main/java/com/baeldung/order/Average.java similarity index 91% rename from spring-core-2/src/main/java/org/baeldung/order/Average.java rename to spring-core-2/src/main/java/com/baeldung/order/Average.java index 3deffaf1ae..0f84f1b436 100644 --- a/spring-core-2/src/main/java/org/baeldung/order/Average.java +++ b/spring-core-2/src/main/java/com/baeldung/order/Average.java @@ -1,4 +1,4 @@ -package org.baeldung.order; +package com.baeldung.order; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; diff --git a/spring-core-2/src/main/java/org/baeldung/order/Excellent.java b/spring-core-2/src/main/java/com/baeldung/order/Excellent.java similarity index 89% rename from spring-core-2/src/main/java/org/baeldung/order/Excellent.java rename to spring-core-2/src/main/java/com/baeldung/order/Excellent.java index 96fea4ac9b..5fd1d18796 100644 --- a/spring-core-2/src/main/java/org/baeldung/order/Excellent.java +++ b/spring-core-2/src/main/java/com/baeldung/order/Excellent.java @@ -1,4 +1,4 @@ -package org.baeldung.order; +package com.baeldung.order; import org.springframework.stereotype.Component; import org.springframework.core.annotation.Order; diff --git a/spring-core-2/src/main/java/org/baeldung/order/Good.java b/spring-core-2/src/main/java/com/baeldung/order/Good.java similarity index 89% rename from spring-core-2/src/main/java/org/baeldung/order/Good.java rename to spring-core-2/src/main/java/com/baeldung/order/Good.java index 4b3e268504..a176904c64 100644 --- a/spring-core-2/src/main/java/org/baeldung/order/Good.java +++ b/spring-core-2/src/main/java/com/baeldung/order/Good.java @@ -1,4 +1,4 @@ -package org.baeldung.order; +package com.baeldung.order; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/org/baeldung/order/Rating.java b/spring-core-2/src/main/java/com/baeldung/order/Rating.java similarity index 66% rename from spring-core-2/src/main/java/org/baeldung/order/Rating.java rename to spring-core-2/src/main/java/com/baeldung/order/Rating.java index 10f2780522..9125019b5c 100644 --- a/spring-core-2/src/main/java/org/baeldung/order/Rating.java +++ b/spring-core-2/src/main/java/com/baeldung/order/Rating.java @@ -1,4 +1,4 @@ -package org.baeldung.order; +package com.baeldung.order; public interface Rating { diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/Setup.java b/spring-core-2/src/main/java/com/baeldung/persistence/Setup.java similarity index 94% rename from spring-exceptions/src/main/java/org/baeldung/persistence/Setup.java rename to spring-core-2/src/main/java/com/baeldung/persistence/Setup.java index 5cba4e70fb..251ea4654c 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/Setup.java +++ b/spring-core-2/src/main/java/com/baeldung/persistence/Setup.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence; +package com.baeldung.persistence; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; diff --git a/spring-core-2/src/main/java/org/baeldung/primary/Config.java b/spring-core-2/src/main/java/com/baeldung/primary/Config.java similarity index 84% rename from spring-core-2/src/main/java/org/baeldung/primary/Config.java rename to spring-core-2/src/main/java/com/baeldung/primary/Config.java index bdcfe019e6..eec9fb2ceb 100644 --- a/spring-core-2/src/main/java/org/baeldung/primary/Config.java +++ b/spring-core-2/src/main/java/com/baeldung/primary/Config.java @@ -1,4 +1,4 @@ -package org.baeldung.primary; +package com.baeldung.primary; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -6,7 +6,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @Configuration -@ComponentScan(basePackages="org.baeldung.primary") +@ComponentScan(basePackages="com.baeldung.primary") public class Config { @Bean diff --git a/spring-core-2/src/main/java/org/baeldung/primary/DepartmentManager.java b/spring-core-2/src/main/java/com/baeldung/primary/DepartmentManager.java similarity index 87% rename from spring-core-2/src/main/java/org/baeldung/primary/DepartmentManager.java rename to spring-core-2/src/main/java/com/baeldung/primary/DepartmentManager.java index 2603951b4e..161b39337b 100644 --- a/spring-core-2/src/main/java/org/baeldung/primary/DepartmentManager.java +++ b/spring-core-2/src/main/java/com/baeldung/primary/DepartmentManager.java @@ -1,4 +1,4 @@ -package org.baeldung.primary; +package com.baeldung.primary; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/org/baeldung/primary/Employee.java b/spring-core-2/src/main/java/com/baeldung/primary/Employee.java similarity index 91% rename from spring-core-2/src/main/java/org/baeldung/primary/Employee.java rename to spring-core-2/src/main/java/com/baeldung/primary/Employee.java index 9168387613..48c5502921 100644 --- a/spring-core-2/src/main/java/org/baeldung/primary/Employee.java +++ b/spring-core-2/src/main/java/com/baeldung/primary/Employee.java @@ -1,4 +1,4 @@ -package org.baeldung.primary; +package com.baeldung.primary; /** * Created by Gebruiker on 7/17/2018. diff --git a/spring-core-2/src/main/java/org/baeldung/primary/GeneralManager.java b/spring-core-2/src/main/java/com/baeldung/primary/GeneralManager.java similarity index 89% rename from spring-core-2/src/main/java/org/baeldung/primary/GeneralManager.java rename to spring-core-2/src/main/java/com/baeldung/primary/GeneralManager.java index 0a94f0f96a..80b5a79471 100644 --- a/spring-core-2/src/main/java/org/baeldung/primary/GeneralManager.java +++ b/spring-core-2/src/main/java/com/baeldung/primary/GeneralManager.java @@ -1,4 +1,4 @@ -package org.baeldung.primary; +package com.baeldung.primary; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/org/baeldung/primary/Manager.java b/spring-core-2/src/main/java/com/baeldung/primary/Manager.java similarity index 77% rename from spring-core-2/src/main/java/org/baeldung/primary/Manager.java rename to spring-core-2/src/main/java/com/baeldung/primary/Manager.java index 4666a1babf..45e02b2b05 100644 --- a/spring-core-2/src/main/java/org/baeldung/primary/Manager.java +++ b/spring-core-2/src/main/java/com/baeldung/primary/Manager.java @@ -1,4 +1,4 @@ -package org.baeldung.primary; +package com.baeldung.primary; /** * Created by Gebruiker on 7/19/2018. diff --git a/spring-core-2/src/main/java/org/baeldung/primary/ManagerService.java b/spring-core-2/src/main/java/com/baeldung/primary/ManagerService.java similarity index 91% rename from spring-core-2/src/main/java/org/baeldung/primary/ManagerService.java rename to spring-core-2/src/main/java/com/baeldung/primary/ManagerService.java index 94ea6785c9..86390327c2 100644 --- a/spring-core-2/src/main/java/org/baeldung/primary/ManagerService.java +++ b/spring-core-2/src/main/java/com/baeldung/primary/ManagerService.java @@ -1,4 +1,4 @@ -package org.baeldung.primary; +package com.baeldung.primary; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/spring-core-2/src/main/java/org/baeldung/primary/PrimaryApplication.java b/spring-core-2/src/main/java/com/baeldung/primary/PrimaryApplication.java similarity index 95% rename from spring-core-2/src/main/java/org/baeldung/primary/PrimaryApplication.java rename to spring-core-2/src/main/java/com/baeldung/primary/PrimaryApplication.java index ffa2a4028d..f66bf8285b 100644 --- a/spring-core-2/src/main/java/org/baeldung/primary/PrimaryApplication.java +++ b/spring-core-2/src/main/java/com/baeldung/primary/PrimaryApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.primary; +package com.baeldung.primary; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-core-2/src/main/java/org/baeldung/profiles/DatasourceConfig.java b/spring-core-2/src/main/java/com/baeldung/profiles/DatasourceConfig.java similarity index 64% rename from spring-core-2/src/main/java/org/baeldung/profiles/DatasourceConfig.java rename to spring-core-2/src/main/java/com/baeldung/profiles/DatasourceConfig.java index 8fde925fd8..9724477666 100644 --- a/spring-core-2/src/main/java/org/baeldung/profiles/DatasourceConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/profiles/DatasourceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.profiles; +package com.baeldung.profiles; public interface DatasourceConfig { void setup(); diff --git a/spring-core-2/src/main/java/org/baeldung/profiles/DevDatasourceConfig.java b/spring-core-2/src/main/java/com/baeldung/profiles/DevDatasourceConfig.java similarity index 91% rename from spring-core-2/src/main/java/org/baeldung/profiles/DevDatasourceConfig.java rename to spring-core-2/src/main/java/com/baeldung/profiles/DevDatasourceConfig.java index e357280c43..b4b14eaf50 100644 --- a/spring-core-2/src/main/java/org/baeldung/profiles/DevDatasourceConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/profiles/DevDatasourceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.profiles; +package com.baeldung.profiles; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/org/baeldung/profiles/ProductionDatasourceConfig.java b/spring-core-2/src/main/java/com/baeldung/profiles/ProductionDatasourceConfig.java similarity index 91% rename from spring-core-2/src/main/java/org/baeldung/profiles/ProductionDatasourceConfig.java rename to spring-core-2/src/main/java/com/baeldung/profiles/ProductionDatasourceConfig.java index f1adff9c96..57943d1b17 100644 --- a/spring-core-2/src/main/java/org/baeldung/profiles/ProductionDatasourceConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/profiles/ProductionDatasourceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.profiles; +package com.baeldung.profiles; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/org/baeldung/profiles/ProfileManager.java b/spring-core-2/src/main/java/com/baeldung/profiles/ProfileManager.java similarity index 93% rename from spring-core-2/src/main/java/org/baeldung/profiles/ProfileManager.java rename to spring-core-2/src/main/java/com/baeldung/profiles/ProfileManager.java index b4cb10e690..81d4592782 100644 --- a/spring-core-2/src/main/java/org/baeldung/profiles/ProfileManager.java +++ b/spring-core-2/src/main/java/com/baeldung/profiles/ProfileManager.java @@ -1,4 +1,4 @@ -package org.baeldung.profiles; +package com.baeldung.profiles; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; diff --git a/spring-core-2/src/main/java/org/baeldung/profiles/SpringProfilesConfig.java b/spring-core-2/src/main/java/com/baeldung/profiles/SpringProfilesConfig.java similarity index 80% rename from spring-core-2/src/main/java/org/baeldung/profiles/SpringProfilesConfig.java rename to spring-core-2/src/main/java/com/baeldung/profiles/SpringProfilesConfig.java index 2d1905ee9c..cdd96ad953 100644 --- a/spring-core-2/src/main/java/org/baeldung/profiles/SpringProfilesConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/profiles/SpringProfilesConfig.java @@ -1,11 +1,11 @@ -package org.baeldung.profiles; +package com.baeldung.profiles; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; @Configuration -@ComponentScan("org.baeldung.profiles") +@ComponentScan("com.baeldung.profiles") @PropertySource(value = "classpath:application.properties") public class SpringProfilesConfig { diff --git a/spring-core-2/src/main/java/com/baeldung/sample/Bar.java b/spring-core-2/src/main/java/com/baeldung/sample/Bar.java new file mode 100644 index 0000000000..42302b5563 --- /dev/null +++ b/spring-core-2/src/main/java/com/baeldung/sample/Bar.java @@ -0,0 +1,5 @@ +package com.baeldung.sample; + +public class Bar { + +} diff --git a/spring-core-2/src/main/java/com/baeldung/sample/Foo.java b/spring-core-2/src/main/java/com/baeldung/sample/Foo.java new file mode 100644 index 0000000000..b25c9ecfb5 --- /dev/null +++ b/spring-core-2/src/main/java/com/baeldung/sample/Foo.java @@ -0,0 +1,5 @@ +package com.baeldung.sample; + +public class Foo { + +} diff --git a/spring-core-2/src/main/java/org/baeldung/sampleabstract/BallService.java b/spring-core-2/src/main/java/com/baeldung/sampleabstract/BallService.java similarity index 94% rename from spring-core-2/src/main/java/org/baeldung/sampleabstract/BallService.java rename to spring-core-2/src/main/java/com/baeldung/sampleabstract/BallService.java index 9a75de7fa1..0d951aac8b 100644 --- a/spring-core-2/src/main/java/org/baeldung/sampleabstract/BallService.java +++ b/spring-core-2/src/main/java/com/baeldung/sampleabstract/BallService.java @@ -1,4 +1,4 @@ -package org.baeldung.sampleabstract; +package com.baeldung.sampleabstract; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-core-2/src/main/java/org/baeldung/sampleabstract/BasketballService.java b/spring-core-2/src/main/java/com/baeldung/sampleabstract/BasketballService.java similarity index 88% rename from spring-core-2/src/main/java/org/baeldung/sampleabstract/BasketballService.java rename to spring-core-2/src/main/java/com/baeldung/sampleabstract/BasketballService.java index c117231d3c..4d6345b069 100644 --- a/spring-core-2/src/main/java/org/baeldung/sampleabstract/BasketballService.java +++ b/spring-core-2/src/main/java/com/baeldung/sampleabstract/BasketballService.java @@ -1,4 +1,4 @@ -package org.baeldung.sampleabstract; +package com.baeldung.sampleabstract; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/org/baeldung/sampleabstract/DemoApp.java b/spring-core-2/src/main/java/com/baeldung/sampleabstract/DemoApp.java similarity index 82% rename from spring-core-2/src/main/java/org/baeldung/sampleabstract/DemoApp.java rename to spring-core-2/src/main/java/com/baeldung/sampleabstract/DemoApp.java index 615d354ecf..5a308b2671 100644 --- a/spring-core-2/src/main/java/org/baeldung/sampleabstract/DemoApp.java +++ b/spring-core-2/src/main/java/com/baeldung/sampleabstract/DemoApp.java @@ -1,4 +1,4 @@ -package org.baeldung.sampleabstract; +package com.baeldung.sampleabstract; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -6,7 +6,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan(basePackages = "org.baeldung.sampleabstract") +@ComponentScan(basePackages = "com.baeldung.sampleabstract") public class DemoApp { diff --git a/spring-core-2/src/main/java/org/baeldung/sampleabstract/LogRepository.java b/spring-core-2/src/main/java/com/baeldung/sampleabstract/LogRepository.java similarity index 82% rename from spring-core-2/src/main/java/org/baeldung/sampleabstract/LogRepository.java rename to spring-core-2/src/main/java/com/baeldung/sampleabstract/LogRepository.java index 3a65671493..84979768b5 100644 --- a/spring-core-2/src/main/java/org/baeldung/sampleabstract/LogRepository.java +++ b/spring-core-2/src/main/java/com/baeldung/sampleabstract/LogRepository.java @@ -1,4 +1,4 @@ -package org.baeldung.sampleabstract; +package com.baeldung.sampleabstract; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/org/baeldung/sampleabstract/RuleRepository.java b/spring-core-2/src/main/java/com/baeldung/sampleabstract/RuleRepository.java similarity index 82% rename from spring-core-2/src/main/java/org/baeldung/sampleabstract/RuleRepository.java rename to spring-core-2/src/main/java/com/baeldung/sampleabstract/RuleRepository.java index fd42178ab6..a1c5b5067f 100644 --- a/spring-core-2/src/main/java/org/baeldung/sampleabstract/RuleRepository.java +++ b/spring-core-2/src/main/java/com/baeldung/sampleabstract/RuleRepository.java @@ -1,4 +1,4 @@ -package org.baeldung.sampleabstract; +package com.baeldung.sampleabstract; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/org/baeldung/scopes/HelloMessageGenerator.java b/spring-core-2/src/main/java/com/baeldung/scopes/HelloMessageGenerator.java similarity index 88% rename from spring-core-2/src/main/java/org/baeldung/scopes/HelloMessageGenerator.java rename to spring-core-2/src/main/java/com/baeldung/scopes/HelloMessageGenerator.java index 562069bc9a..9b912fc04e 100644 --- a/spring-core-2/src/main/java/org/baeldung/scopes/HelloMessageGenerator.java +++ b/spring-core-2/src/main/java/com/baeldung/scopes/HelloMessageGenerator.java @@ -1,4 +1,4 @@ -package org.baeldung.scopes; +package com.baeldung.scopes; public class HelloMessageGenerator { diff --git a/spring-core-2/src/main/java/org/baeldung/scopes/Person.java b/spring-core-2/src/main/java/com/baeldung/scopes/Person.java similarity index 93% rename from spring-core-2/src/main/java/org/baeldung/scopes/Person.java rename to spring-core-2/src/main/java/com/baeldung/scopes/Person.java index b070007a5c..e2ea2ce1d7 100644 --- a/spring-core-2/src/main/java/org/baeldung/scopes/Person.java +++ b/spring-core-2/src/main/java/com/baeldung/scopes/Person.java @@ -1,4 +1,4 @@ -package org.baeldung.scopes; +package com.baeldung.scopes; public class Person { private String name; diff --git a/spring-core-2/src/main/java/com/baeldung/scopes/ScopesConfig.java b/spring-core-2/src/main/java/com/baeldung/scopes/ScopesConfig.java new file mode 100644 index 0000000000..2291baa62d --- /dev/null +++ b/spring-core-2/src/main/java/com/baeldung/scopes/ScopesConfig.java @@ -0,0 +1,49 @@ +package com.baeldung.scopes; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.ScopedProxyMode; +import org.springframework.web.context.annotation.ApplicationScope; +import org.springframework.web.context.annotation.RequestScope; +import org.springframework.web.context.annotation.SessionScope; + +@Configuration +public class ScopesConfig { + + @Bean + @Scope("singleton") + public Person personSingleton() { + return new Person(); + } + + @Bean + @Scope("prototype") + public Person personPrototype() { + return new Person(); + } + + @Bean + @RequestScope + public HelloMessageGenerator requestScopedBean() { + return new HelloMessageGenerator(); + } + + @Bean + @SessionScope + public HelloMessageGenerator sessionScopedBean() { + return new HelloMessageGenerator(); + } + + @Bean + @ApplicationScope + public HelloMessageGenerator applicationScopedBean() { + return new HelloMessageGenerator(); + } + + @Bean + @Scope(scopeName = "websocket", proxyMode = ScopedProxyMode.TARGET_CLASS) + public HelloMessageGenerator websocketScopedBean() { + return new HelloMessageGenerator(); + } +} diff --git a/spring-core-2/src/main/java/org/baeldung/scopes/ScopesController.java b/spring-core-2/src/main/java/com/baeldung/scopes/ScopesController.java similarity index 98% rename from spring-core-2/src/main/java/org/baeldung/scopes/ScopesController.java rename to spring-core-2/src/main/java/com/baeldung/scopes/ScopesController.java index 9257a3aa3a..1ca4dc4050 100644 --- a/spring-core-2/src/main/java/org/baeldung/scopes/ScopesController.java +++ b/spring-core-2/src/main/java/com/baeldung/scopes/ScopesController.java @@ -1,4 +1,4 @@ -package org.baeldung.scopes; +package com.baeldung.scopes; import javax.annotation.Resource; diff --git a/spring-core-2/src/main/java/org/baeldung/spring/config/CleanupBean.java b/spring-core-2/src/main/java/com/baeldung/spring/config/CleanupBean.java similarity index 95% rename from spring-core-2/src/main/java/org/baeldung/spring/config/CleanupBean.java rename to spring-core-2/src/main/java/com/baeldung/spring/config/CleanupBean.java index ac90319745..155b8af9c4 100644 --- a/spring-core-2/src/main/java/org/baeldung/spring/config/CleanupBean.java +++ b/spring-core-2/src/main/java/com/baeldung/spring/config/CleanupBean.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package com.baeldung.spring.config; import java.util.concurrent.ExecutorService; diff --git a/spring-core-2/src/main/java/org/baeldung/spring/config/CoreConfig.java b/spring-core-2/src/main/java/com/baeldung/spring/config/CoreConfig.java similarity index 92% rename from spring-core-2/src/main/java/org/baeldung/spring/config/CoreConfig.java rename to spring-core-2/src/main/java/com/baeldung/spring/config/CoreConfig.java index 0d753dc447..35d245a17e 100644 --- a/spring-core-2/src/main/java/org/baeldung/spring/config/CoreConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/spring/config/CoreConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package com.baeldung.spring.config; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; @@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -@ComponentScan("org.baeldung.core") +@ComponentScan("com.baeldung.core") public class CoreConfig implements WebMvcConfigurer { public CoreConfig() { diff --git a/spring-core-2/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java b/spring-core-2/src/main/java/com/baeldung/spring/config/MainWebAppInitializer.java similarity index 95% rename from spring-core-2/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java rename to spring-core-2/src/main/java/com/baeldung/spring/config/MainWebAppInitializer.java index 9f4b73f609..dd396a653f 100644 --- a/spring-core-2/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java +++ b/spring-core-2/src/main/java/com/baeldung/spring/config/MainWebAppInitializer.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package com.baeldung.spring.config; import java.util.Set; @@ -26,7 +26,7 @@ public class MainWebAppInitializer implements WebApplicationInitializer // Create the 'root' Spring application context final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); - root.scan("org.baeldung.spring.config"); + root.scan("com.baeldung.spring.config"); // root.getEnvironment().setDefaultProfiles("embedded"); sc.addListener(new ContextLoaderListener(root)); diff --git a/spring-core-2/src/main/java/org/baeldung/spring/config/MvcConfig.java b/spring-core-2/src/main/java/com/baeldung/spring/config/MvcConfig.java similarity index 96% rename from spring-core-2/src/main/java/org/baeldung/spring/config/MvcConfig.java rename to spring-core-2/src/main/java/com/baeldung/spring/config/MvcConfig.java index e550733c47..cd31cd1128 100644 --- a/spring-core-2/src/main/java/org/baeldung/spring/config/MvcConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/spring/config/MvcConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package com.baeldung.spring.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-core-2/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-core-2/src/main/java/com/baeldung/spring/config/PersistenceConfig.java similarity index 94% rename from spring-core-2/src/main/java/org/baeldung/spring/config/PersistenceConfig.java rename to spring-core-2/src/main/java/com/baeldung/spring/config/PersistenceConfig.java index ffe88596fa..f27543af46 100644 --- a/spring-core-2/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/spring/config/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package com.baeldung.spring.config; import java.util.Properties; @@ -20,7 +20,7 @@ import com.google.common.base.Preconditions; // @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) +@ComponentScan({ "com.baeldung.persistence" }) public class PersistenceConfig { @Autowired @@ -34,7 +34,7 @@ public class PersistenceConfig { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.spring.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/spring-core-2/src/main/java/org/baeldung/spring/config/ScopesConfig.java b/spring-core-2/src/main/java/com/baeldung/spring/config/ScopesConfig.java similarity index 100% rename from spring-core-2/src/main/java/org/baeldung/spring/config/ScopesConfig.java rename to spring-core-2/src/main/java/com/baeldung/spring/config/ScopesConfig.java diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java b/spring-core-2/src/main/java/com/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java similarity index 89% rename from spring-core-2/src/main/java/org/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java rename to spring-core-2/src/main/java/com/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java index 082a986974..085f3b0706 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/asynchronous/AsynchronousSpringEventsConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.asynchronous; +package com.baeldung.springevents.asynchronous; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -8,7 +8,7 @@ import org.springframework.context.event.SimpleApplicationEventMulticaster; import org.springframework.core.task.SimpleAsyncTaskExecutor; @Configuration -@ComponentScan("org.baeldung.springevents.synchronous") +@ComponentScan("com.baeldung.springevents.synchronous") public class AsynchronousSpringEventsConfig { @Bean(name = "applicationEventMulticaster") diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java similarity index 97% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java index f750c40a6e..bbb2b5f008 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/AnnotationDrivenEventListener.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.springframework.context.event.ContextStartedEvent; import org.springframework.context.event.EventListener; diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/ContextRefreshedListener.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/ContextRefreshedListener.java similarity index 93% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/ContextRefreshedListener.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/ContextRefreshedListener.java index 9f8b2e6e83..31a6c78d00 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/ContextRefreshedListener.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/ContextRefreshedListener.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEvent.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/CustomSpringEvent.java similarity index 89% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEvent.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/CustomSpringEvent.java index 1631801ffe..3cf4980be3 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEvent.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/CustomSpringEvent.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.springframework.context.ApplicationEvent; diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventListener.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/CustomSpringEventListener.java similarity index 89% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventListener.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/CustomSpringEventListener.java index 69f96966ec..ff7ca7fe39 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventListener.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/CustomSpringEventListener.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventPublisher.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/CustomSpringEventPublisher.java similarity index 96% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventPublisher.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/CustomSpringEventPublisher.java index 3182090d5d..e4d7fcdc99 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/CustomSpringEventPublisher.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/CustomSpringEventPublisher.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringAppEvent.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericSpringAppEvent.java similarity index 87% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringAppEvent.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericSpringAppEvent.java index 6804312189..8a50a55f31 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringAppEvent.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericSpringAppEvent.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.springframework.context.ApplicationEvent; diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEvent.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericSpringEvent.java similarity index 88% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEvent.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericSpringEvent.java index ce2c223fec..86471221d2 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEvent.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericSpringEvent.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; public class GenericSpringEvent { diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEventListener.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericSpringEventListener.java similarity index 93% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEventListener.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericSpringEventListener.java index 1f5e3e7068..7b0a9727e4 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericSpringEventListener.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericSpringEventListener.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.springframework.context.ApplicationListener; import org.springframework.lang.NonNull; diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java similarity index 80% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java index fd214696e7..74839b4708 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericStringSpringAppEvent.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; class GenericStringSpringAppEvent extends GenericSpringAppEvent { diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringEvent.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericStringSpringEvent.java similarity index 80% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringEvent.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericStringSpringEvent.java index dd4e4e3ed4..70dda99aa3 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/GenericStringSpringEvent.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/GenericStringSpringEvent.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; public class GenericStringSpringEvent extends GenericSpringEvent { diff --git a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java similarity index 64% rename from spring-core-2/src/main/java/org/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java rename to spring-core-2/src/main/java/com/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java index fff8a7e4b5..58cb220ecb 100644 --- a/spring-core-2/src/main/java/org/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/springevents/synchronous/SynchronousSpringEventsConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.springevents.synchronous") +@ComponentScan("com.baeldung.springevents.synchronous") public class SynchronousSpringEventsConfig { } diff --git a/spring-core-2/src/main/java/org/baeldung/startup/AllStrategiesExampleBean.java b/spring-core-2/src/main/java/com/baeldung/startup/AllStrategiesExampleBean.java similarity index 96% rename from spring-core-2/src/main/java/org/baeldung/startup/AllStrategiesExampleBean.java rename to spring-core-2/src/main/java/com/baeldung/startup/AllStrategiesExampleBean.java index f36b8703ea..e08309d474 100644 --- a/spring-core-2/src/main/java/org/baeldung/startup/AllStrategiesExampleBean.java +++ b/spring-core-2/src/main/java/com/baeldung/startup/AllStrategiesExampleBean.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-core-2/src/main/java/org/baeldung/startup/EventListenerExampleBean.java b/spring-core-2/src/main/java/com/baeldung/startup/EventListenerExampleBean.java similarity index 94% rename from spring-core-2/src/main/java/org/baeldung/startup/EventListenerExampleBean.java rename to spring-core-2/src/main/java/com/baeldung/startup/EventListenerExampleBean.java index 58e42337cc..a76fc6a2b2 100644 --- a/spring-core-2/src/main/java/org/baeldung/startup/EventListenerExampleBean.java +++ b/spring-core-2/src/main/java/com/baeldung/startup/EventListenerExampleBean.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-core-2/src/main/java/org/baeldung/startup/InitMethodExampleBean.java b/spring-core-2/src/main/java/com/baeldung/startup/InitMethodExampleBean.java similarity index 95% rename from spring-core-2/src/main/java/org/baeldung/startup/InitMethodExampleBean.java rename to spring-core-2/src/main/java/com/baeldung/startup/InitMethodExampleBean.java index f3d30011f8..a3b12028d1 100644 --- a/spring-core-2/src/main/java/org/baeldung/startup/InitMethodExampleBean.java +++ b/spring-core-2/src/main/java/com/baeldung/startup/InitMethodExampleBean.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import java.util.Arrays; diff --git a/spring-core-2/src/main/java/org/baeldung/startup/InitializingBeanExampleBean.java b/spring-core-2/src/main/java/com/baeldung/startup/InitializingBeanExampleBean.java similarity index 96% rename from spring-core-2/src/main/java/org/baeldung/startup/InitializingBeanExampleBean.java rename to spring-core-2/src/main/java/com/baeldung/startup/InitializingBeanExampleBean.java index 5d6f8c9d88..c625a172fd 100644 --- a/spring-core-2/src/main/java/org/baeldung/startup/InitializingBeanExampleBean.java +++ b/spring-core-2/src/main/java/com/baeldung/startup/InitializingBeanExampleBean.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import java.util.Arrays; diff --git a/spring-core-2/src/main/java/org/baeldung/startup/InvalidInitExampleBean.java b/spring-core-2/src/main/java/com/baeldung/startup/InvalidInitExampleBean.java similarity index 93% rename from spring-core-2/src/main/java/org/baeldung/startup/InvalidInitExampleBean.java rename to spring-core-2/src/main/java/com/baeldung/startup/InvalidInitExampleBean.java index 0b9c6f0c7d..d31aee8acd 100644 --- a/spring-core-2/src/main/java/org/baeldung/startup/InvalidInitExampleBean.java +++ b/spring-core-2/src/main/java/com/baeldung/startup/InvalidInitExampleBean.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/spring-core-2/src/main/java/org/baeldung/startup/LogicInConstructorExampleBean.java b/spring-core-2/src/main/java/com/baeldung/startup/LogicInConstructorExampleBean.java similarity index 95% rename from spring-core-2/src/main/java/org/baeldung/startup/LogicInConstructorExampleBean.java rename to spring-core-2/src/main/java/com/baeldung/startup/LogicInConstructorExampleBean.java index d25a83942a..ade7573bbe 100644 --- a/spring-core-2/src/main/java/org/baeldung/startup/LogicInConstructorExampleBean.java +++ b/spring-core-2/src/main/java/com/baeldung/startup/LogicInConstructorExampleBean.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import java.util.Arrays; diff --git a/spring-core-2/src/main/java/org/baeldung/startup/PostConstructExampleBean.java b/spring-core-2/src/main/java/com/baeldung/startup/PostConstructExampleBean.java similarity index 95% rename from spring-core-2/src/main/java/org/baeldung/startup/PostConstructExampleBean.java rename to spring-core-2/src/main/java/com/baeldung/startup/PostConstructExampleBean.java index 2397c3a0a2..1001043d86 100644 --- a/spring-core-2/src/main/java/org/baeldung/startup/PostConstructExampleBean.java +++ b/spring-core-2/src/main/java/com/baeldung/startup/PostConstructExampleBean.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import java.util.Arrays; diff --git a/spring-core-2/src/main/java/org/baeldung/startup/SpringStartupConfig.java b/spring-core-2/src/main/java/com/baeldung/startup/SpringStartupConfig.java similarity index 71% rename from spring-core-2/src/main/java/org/baeldung/startup/SpringStartupConfig.java rename to spring-core-2/src/main/java/com/baeldung/startup/SpringStartupConfig.java index 12854e1be5..ad6492dadc 100644 --- a/spring-core-2/src/main/java/org/baeldung/startup/SpringStartupConfig.java +++ b/spring-core-2/src/main/java/com/baeldung/startup/SpringStartupConfig.java @@ -1,9 +1,9 @@ -package org.baeldung.startup; +package com.baeldung.startup; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.startup") +@ComponentScan("com.baeldung.startup") public class SpringStartupConfig { } \ No newline at end of file diff --git a/spring-core-2/src/main/java/org/baeldung/startup/StartupApplicationListenerExample.java b/spring-core-2/src/main/java/com/baeldung/startup/StartupApplicationListenerExample.java similarity index 95% rename from spring-core-2/src/main/java/org/baeldung/startup/StartupApplicationListenerExample.java rename to spring-core-2/src/main/java/com/baeldung/startup/StartupApplicationListenerExample.java index e02388dea3..2cc5e6abcb 100644 --- a/spring-core-2/src/main/java/org/baeldung/startup/StartupApplicationListenerExample.java +++ b/spring-core-2/src/main/java/com/baeldung/startup/StartupApplicationListenerExample.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooDAO.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooDAO.java deleted file mode 100644 index 3d3deaa077..0000000000 --- a/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooDAO.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.autowire.sample; - -public class FooDAO { - -} diff --git a/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooService.java b/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooService.java deleted file mode 100644 index a3638960cc..0000000000 --- a/spring-core-2/src/main/java/org/baeldung/autowire/sample/FooService.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.autowire.sample; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class FooService { - - @Autowired - @FormatterType("Foo") - private Formatter formatter; - - public String doStuff() { - return formatter.format(); - } - -} diff --git a/spring-core-2/src/main/java/org/baeldung/sample/Bar.java b/spring-core-2/src/main/java/org/baeldung/sample/Bar.java deleted file mode 100644 index 54e8d54418..0000000000 --- a/spring-core-2/src/main/java/org/baeldung/sample/Bar.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.sample; - -public class Bar { - -} diff --git a/spring-core-2/src/main/java/org/baeldung/sample/Foo.java b/spring-core-2/src/main/java/org/baeldung/sample/Foo.java deleted file mode 100644 index 562a00121a..0000000000 --- a/spring-core-2/src/main/java/org/baeldung/sample/Foo.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.sample; - -public class Foo { - -} diff --git a/spring-core-2/src/main/resources/beanInjection-constructor.xml b/spring-core-2/src/main/resources/beanInjection-constructor.xml index 5a2ffe767c..cbb8f98bb9 100644 --- a/spring-core-2/src/main/resources/beanInjection-constructor.xml +++ b/spring-core-2/src/main/resources/beanInjection-constructor.xml @@ -4,12 +4,12 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + \ No newline at end of file diff --git a/spring-core-2/src/main/resources/beanInjection-setter.xml b/spring-core-2/src/main/resources/beanInjection-setter.xml index 0e82e3be1c..1440df9702 100644 --- a/spring-core-2/src/main/resources/beanInjection-setter.xml +++ b/spring-core-2/src/main/resources/beanInjection-setter.xml @@ -4,11 +4,11 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + \ No newline at end of file diff --git a/spring-core-2/src/main/resources/jdbc/springJdbc-config.xml b/spring-core-2/src/main/resources/jdbc/springJdbc-config.xml index 5fd2699b41..e3d7452eb1 100644 --- a/spring-core-2/src/main/resources/jdbc/springJdbc-config.xml +++ b/spring-core-2/src/main/resources/jdbc/springJdbc-config.xml @@ -4,7 +4,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd" > - + diff --git a/spring-core-2/src/main/resources/scopes.xml b/spring-core-2/src/main/resources/scopes.xml index 8fdb186c28..f7b554ec49 100644 --- a/spring-core-2/src/main/resources/scopes.xml +++ b/spring-core-2/src/main/resources/scopes.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + - + diff --git a/spring-core-2/src/main/resources/springProfiles-config.xml b/spring-core-2/src/main/resources/springProfiles-config.xml index 985ab6ba86..5eb6bfcd7f 100644 --- a/spring-core-2/src/main/resources/springProfiles-config.xml +++ b/spring-core-2/src/main/resources/springProfiles-config.xml @@ -6,10 +6,10 @@ > - + - + \ No newline at end of file diff --git a/spring-core-2/src/main/resources/startupConfig.xml b/spring-core-2/src/main/resources/startupConfig.xml index 8226665a90..d42e0f6c2b 100644 --- a/spring-core-2/src/main/resources/startupConfig.xml +++ b/spring-core-2/src/main/resources/startupConfig.xml @@ -4,13 +4,13 @@ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> \ No newline at end of file diff --git a/spring-core-2/src/test/java/org/baeldung/autowire/sample/FooServiceIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/autowire/sample/FooServiceIntegrationTest.java similarity index 94% rename from spring-core-2/src/test/java/org/baeldung/autowire/sample/FooServiceIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/autowire/sample/FooServiceIntegrationTest.java index 941fc4baff..34ba7902ca 100644 --- a/spring-core-2/src/test/java/org/baeldung/autowire/sample/FooServiceIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/autowire/sample/FooServiceIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.autowire.sample; +package com.baeldung.autowire.sample; import org.junit.Assert; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java similarity index 87% rename from spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java index 447a09d69e..fb3f973f29 100644 --- a/spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/bean/injection/ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.bean.injection; +package com.baeldung.bean.injection; -import org.baeldung.bean.config.ConstructorBasedShipConfig; +import com.baeldung.bean.config.ConstructorBasedShipConfig; import org.junit.Assert; import org.junit.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java similarity index 95% rename from spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java index 9f6011d851..18ce5ce8ed 100644 --- a/spring-core-2/src/test/java/org/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/bean/injection/ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.bean.injection; +package com.baeldung.bean.injection; import org.junit.Assert; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java similarity index 87% rename from spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java index 1c15775093..1e2147d2bc 100644 --- a/spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/bean/injection/SetterBasedBeanInjectionWithJavaConfigIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.bean.injection; +package com.baeldung.bean.injection; -import org.baeldung.bean.config.SetterBasedShipConfig; +import com.baeldung.bean.config.SetterBasedShipConfig; import org.junit.Assert; import org.junit.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java similarity index 94% rename from spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java index bc17a08383..9c7526a7be 100644 --- a/spring-core-2/src/test/java/org/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/bean/injection/SetterBasedBeanInjectionWithXMLConfigIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.bean.injection; +package com.baeldung.bean.injection; import org.junit.Assert; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/customannotation/Account.java b/spring-core-2/src/test/java/com/baeldung/customannotation/Account.java similarity index 94% rename from spring-core-2/src/test/java/org/baeldung/customannotation/Account.java rename to spring-core-2/src/test/java/com/baeldung/customannotation/Account.java index 04545e5b83..cfdd8815e4 100644 --- a/spring-core-2/src/test/java/org/baeldung/customannotation/Account.java +++ b/spring-core-2/src/test/java/com/baeldung/customannotation/Account.java @@ -1,4 +1,4 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import java.io.Serializable; diff --git a/spring-core-2/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java b/spring-core-2/src/test/java/com/baeldung/customannotation/BeanWithGenericDAO.java similarity index 89% rename from spring-core-2/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java rename to spring-core-2/src/test/java/com/baeldung/customannotation/BeanWithGenericDAO.java index 9ba915f296..a0707f263b 100644 --- a/spring-core-2/src/test/java/org/baeldung/customannotation/BeanWithGenericDAO.java +++ b/spring-core-2/src/test/java/com/baeldung/customannotation/BeanWithGenericDAO.java @@ -1,4 +1,4 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import org.springframework.stereotype.Repository; diff --git a/spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java similarity index 98% rename from spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java index ae3d53fb9b..1baea4505b 100644 --- a/spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; diff --git a/spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java similarity index 98% rename from spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java index bab2574cd2..bc7a5f7246 100644 --- a/spring-core-2/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; diff --git a/spring-core-2/src/test/java/org/baeldung/customannotation/Person.java b/spring-core-2/src/test/java/com/baeldung/customannotation/Person.java similarity index 92% rename from spring-core-2/src/test/java/org/baeldung/customannotation/Person.java rename to spring-core-2/src/test/java/com/baeldung/customannotation/Person.java index 3babc8f0a2..4fa70e51af 100644 --- a/spring-core-2/src/test/java/org/baeldung/customannotation/Person.java +++ b/spring-core-2/src/test/java/com/baeldung/customannotation/Person.java @@ -1,4 +1,4 @@ -package org.baeldung.customannotation; +package com.baeldung.customannotation; import java.io.Serializable; diff --git a/spring-core-2/src/test/java/org/baeldung/customscope/TenantScopeIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/customscope/TenantScopeIntegrationTest.java similarity index 96% rename from spring-core-2/src/test/java/org/baeldung/customscope/TenantScopeIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/customscope/TenantScopeIntegrationTest.java index e873ac5065..1cd7357a09 100644 --- a/spring-core-2/src/test/java/org/baeldung/customscope/TenantScopeIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/customscope/TenantScopeIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.customscope; +package com.baeldung.customscope; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; @@ -46,7 +46,7 @@ public class TenantScopeIntegrationTest { public final void whenComponentScan_thenContextContainsFooAndBar() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); try { - ctx.scan("org.baeldung.customscope"); + ctx.scan("com.baeldung.customscope"); ctx.refresh(); TenantBean foo = (TenantBean) ctx.getBean("foo", TenantBean.class); diff --git a/spring-core-2/src/test/java/org/baeldung/order/RatingRetrieverUnitTest.java b/spring-core-2/src/test/java/com/baeldung/order/RatingRetrieverUnitTest.java similarity index 93% rename from spring-core-2/src/test/java/org/baeldung/order/RatingRetrieverUnitTest.java rename to spring-core-2/src/test/java/com/baeldung/order/RatingRetrieverUnitTest.java index 96993ccd7c..342a4c5f05 100644 --- a/spring-core-2/src/test/java/org/baeldung/order/RatingRetrieverUnitTest.java +++ b/spring-core-2/src/test/java/com/baeldung/order/RatingRetrieverUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.order; +package com.baeldung.order; import static org.hamcrest.CoreMatchers.equalTo; @@ -21,7 +21,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; public class RatingRetrieverUnitTest { @Configuration - @ComponentScan(basePackages = {"org.baeldung.order"}) + @ComponentScan(basePackages = {"com.baeldung.order"}) static class ContextConfiguration {} @Autowired diff --git a/spring-core-2/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java similarity index 96% rename from spring-core-2/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java index cf5ca132e6..81b136f5ba 100644 --- a/spring-core-2/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.profiles; +package com.baeldung.profiles; import org.junit.Assert; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java similarity index 97% rename from spring-core-2/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java index 5bacaef07b..b863fe30c1 100644 --- a/spring-core-2/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.profiles; +package com.baeldung.profiles; import org.junit.Assert; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java similarity index 96% rename from spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java index 929d088a14..60e9499d4b 100644 --- a/spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.profiles; +package com.baeldung.profiles; import org.junit.Assert; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java similarity index 98% rename from spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java index 2b46a50588..4fc90b2e7c 100644 --- a/spring-core-2/src/test/java/org/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithXMLIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.profiles; +package com.baeldung.profiles; import org.junit.Assert; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/scopes/ScopesIntegrationTest.java similarity index 98% rename from spring-core-2/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/scopes/ScopesIntegrationTest.java index 0ae99610f6..ae4df3b632 100644 --- a/spring-core-2/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/scopes/ScopesIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.scopes; +package com.baeldung.scopes; import org.junit.Assert; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java similarity index 88% rename from spring-core-2/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java index e12baed7e0..4f8035bcbe 100644 --- a/spring-core-2/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.springevents.asynchronous; +package com.baeldung.springevents.asynchronous; -import org.baeldung.springevents.synchronous.CustomSpringEventPublisher; +import com.baeldung.springevents.synchronous.CustomSpringEventPublisher; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-core-2/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java similarity index 87% rename from spring-core-2/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java index e8e6f91b06..0ba43cdcbb 100644 --- a/spring-core-2/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java @@ -1,6 +1,5 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; -import org.baeldung.springevents.synchronous.SynchronousSpringEventsConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-core-2/src/test/java/org/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java similarity index 95% rename from spring-core-2/src/test/java/org/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java index f183314b6d..7f5314b420 100644 --- a/spring-core-2/src/test/java/org/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/springevents/synchronous/GenericAppEventListenerIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-core-2/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java similarity index 97% rename from spring-core-2/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java index b169cfec36..1d624d2289 100644 --- a/spring-core-2/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.springevents.synchronous; +package com.baeldung.springevents.synchronous; import org.junit.Ignore; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/startup/SpringStartupIntegrationTest.java similarity index 98% rename from spring-core-2/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/startup/SpringStartupIntegrationTest.java index 6263482948..b58c093c31 100644 --- a/spring-core-2/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/startup/SpringStartupIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import org.assertj.core.api.Assertions; import org.junit.Test; diff --git a/spring-core-2/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java similarity index 96% rename from spring-core-2/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java rename to spring-core-2/src/test/java/com/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java index a46d24fa3b..3dfd4835df 100644 --- a/spring-core-2/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-data-rest-querydsl/pom.xml b/spring-data-rest-querydsl/pom.xml index 9f53f6b55f..c0ad43fe0b 100644 --- a/spring-data-rest-querydsl/pom.xml +++ b/spring-data-rest-querydsl/pom.xml @@ -72,8 +72,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${maven.source} + ${maven.target} -verbose -parameters @@ -83,7 +83,7 @@ com.mysema.maven apt-maven-plugin - 1.1.3 + ${mysema.version} generate-sources @@ -99,5 +99,10 @@ + + 1.8 + 1.8 + 1.1.3 + diff --git a/spring-data-rest/pom.xml b/spring-data-rest/pom.xml index 05f2ccbbae..bb592c08d5 100644 --- a/spring-data-rest/pom.xml +++ b/spring-data-rest/pom.xml @@ -66,7 +66,7 @@ com.mysema.maven maven-apt-plugin - 1.0 + ${maven.version} generate-sources @@ -90,6 +90,7 @@ UTF-8 com.baeldung.books.SpringDataRestApplication + 1.0 \ No newline at end of file diff --git a/spring-ejb/README.md b/spring-ejb/README.md index 423d55ea22..8f6522266c 100644 --- a/spring-ejb/README.md +++ b/spring-ejb/README.md @@ -8,5 +8,5 @@ This module contains articles about Spring with EJB - [Java EE Session Beans](https://www.baeldung.com/ejb-session-beans) - [A Guide to Message Driven Beans in EJB](https://www.baeldung.com/ejb-message-driven-beans) - [Integration Guide for Spring and EJB](https://www.baeldung.com/spring-ejb) -- [Singleton Session Bean in Java EE](https://www.baeldung.com/java-ee-singleton-session-bean) +- [Singleton Session Bean in Jakarta EE](https://www.baeldung.com/java-ee-singleton-session-bean) diff --git a/spring-ejb/wildfly/wildfly-ear/pom.xml b/spring-ejb/wildfly/wildfly-ear/pom.xml index 9393820b12..07f53358bf 100644 --- a/spring-ejb/wildfly/wildfly-ear/pom.xml +++ b/spring-ejb/wildfly/wildfly-ear/pom.xml @@ -45,7 +45,7 @@ ${maven-ear-plugin.version} lib/ - 7 + ${defaultLibBundleDir.version} com.baeldung.wildfly @@ -66,6 +66,7 @@ 2.10.1 1.2.0.Final + 7 \ No newline at end of file diff --git a/spring-exceptions/README.md b/spring-exceptions/README.md index f8c7553f05..2136402d49 100644 --- a/spring-exceptions/README.md +++ b/spring-exceptions/README.md @@ -1,4 +1,4 @@ -## Spring `Exception`s +## Spring Exceptions This module contains articles about Spring `Exception`s diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause1/BeanA.java similarity index 78% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause1/BeanA.java index 50d07c6d39..735b6936fe 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause1/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause1; +package com.baeldung.ex.beancreationexception.cause1; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause1/BeanB.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause1/BeanB.java new file mode 100644 index 0000000000..666389bb01 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause1/BeanB.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.beancreationexception.cause1; + +public class BeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/BeanA.java similarity index 78% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/BeanA.java index 352dd5f2db..ba139118b7 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause2; +package com.baeldung.ex.beancreationexception.cause2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB1.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/BeanB1.java similarity index 67% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB1.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/BeanB1.java index b9ec961d1e..b36dd1152f 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB1.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/BeanB1.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause2; +package com.baeldung.ex.beancreationexception.cause2; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB2.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/BeanB2.java similarity index 67% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB2.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/BeanB2.java index aa7fe8250a..4dc5a9a7f6 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/BeanB2.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/BeanB2.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause2; +package com.baeldung.ex.beancreationexception.cause2; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/IBeanB.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/IBeanB.java new file mode 100644 index 0000000000..f469af842c --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause2/IBeanB.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.beancreationexception.cause2; + +public interface IBeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause3/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause3/BeanA.java similarity index 76% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause3/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause3/BeanA.java index 2f2d1b2684..e169a267b6 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause3/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause3/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause3; +package com.baeldung.ex.beancreationexception.cause3; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause4/BeanA.java similarity index 68% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause4/BeanA.java index 7886f30f22..d1e7b157ee 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause4/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause4; +package com.baeldung.ex.beancreationexception.cause4; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause4/IBeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause4/IBeanA.java new file mode 100644 index 0000000000..495dec9180 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause4/IBeanA.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.beancreationexception.cause4; + +public interface IBeanA { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause5/BeanA.java similarity index 78% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause5/BeanA.java index b8f88125b2..85dc2a4c60 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause5/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause5; +package com.baeldung.ex.beancreationexception.cause5; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause5/IBeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause5/IBeanA.java new file mode 100644 index 0000000000..8429f7d5d7 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause5/IBeanA.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.beancreationexception.cause5; + +public interface IBeanA { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause6/BeanA.java similarity index 68% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause6/BeanA.java index 164b006340..82dcb6faf2 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause6/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause6; +package com.baeldung.ex.beancreationexception.cause6; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanB.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause6/BeanB.java similarity index 66% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanB.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause6/BeanB.java index 4a7bdab280..f37cc6f50d 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/BeanB.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause6/BeanB.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause6; +package com.baeldung.ex.beancreationexception.cause6; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause6/IBeanB.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause6/IBeanB.java new file mode 100644 index 0000000000..6515c7b467 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause6/IBeanB.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.beancreationexception.cause6; + +public interface IBeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/BeanA.java similarity index 84% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/BeanA.java index 2a0230fa3f..e301a1f13c 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause8; +package com.baeldung.ex.beancreationexception.cause8; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanB.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/BeanB.java similarity index 84% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanB.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/BeanB.java index 2e8a3eed07..3c3bd9f106 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/BeanB.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/BeanB.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause8; +package com.baeldung.ex.beancreationexception.cause8; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/IBeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/IBeanA.java new file mode 100644 index 0000000000..42b4c7390c --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/IBeanA.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.beancreationexception.cause8; + +public interface IBeanA { + // +} diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/IBeanB.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/IBeanB.java new file mode 100644 index 0000000000..6ecbddf617 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause8/IBeanB.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.beancreationexception.cause8; + +public interface IBeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause9/BeanA.java similarity index 51% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause9/BeanA.java index 28c39e2777..814c4f84ff 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause9/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception.cause9; +package com.baeldung.ex.beancreationexception.cause9; public abstract class BeanA implements IBeanA { // diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause9/BeanB.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause9/BeanB.java new file mode 100644 index 0000000000..327bbfd10e --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause9/BeanB.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.beancreationexception.cause9; + +public class BeanB { + // +} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause9/IBeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause9/IBeanA.java new file mode 100644 index 0000000000..a8abfd5ae0 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/cause9/IBeanA.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.beancreationexception.cause9; + +public interface IBeanA { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java similarity index 69% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java index cb74b96b67..fcc501f7e3 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause1ContextWithJavaConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.beancreationexception.spring; +package com.baeldung.ex.beancreationexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.ex.beancreationexception.cause1") +@ComponentScan("com.baeldung.ex.beancreationexception.cause1") public class Cause1ContextWithJavaConfig { public Cause1ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java similarity index 69% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java index 6b20439059..cd8b36f2db 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause2ContextWithJavaConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.beancreationexception.spring; +package com.baeldung.ex.beancreationexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.ex.beancreationexception.cause2") +@ComponentScan("com.baeldung.ex.beancreationexception.cause2") public class Cause2ContextWithJavaConfig { public Cause2ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java similarity index 69% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java index 437d2c4c20..205a9b6553 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause3ContextWithJavaConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.beancreationexception.spring; +package com.baeldung.ex.beancreationexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.ex.beancreationexception.cause3") +@ComponentScan("com.baeldung.ex.beancreationexception.cause3") public class Cause3ContextWithJavaConfig { public Cause3ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java similarity index 76% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java index b661ba4650..f2fb2b9a6d 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause4ContextWithJavaConfig.java @@ -1,11 +1,11 @@ -package org.baeldung.ex.beancreationexception.spring; +package com.baeldung.ex.beancreationexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration -@ComponentScan("org.baeldung.ex.beancreationexception.cause4") +@ComponentScan("com.baeldung.ex.beancreationexception.cause4") @ImportResource("classpath:beancreationexception_cause4.xml") public class Cause4ContextWithJavaConfig { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java similarity index 69% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java index 821041cb0c..3d45bd6896 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause5ContextWithJavaConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.beancreationexception.spring; +package com.baeldung.ex.beancreationexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.ex.beancreationexception.cause5") +@ComponentScan("com.baeldung.ex.beancreationexception.cause5") public class Cause5ContextWithJavaConfig { public Cause5ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java similarity index 76% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java index c76e34deec..ab4c590804 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause6ContextWithJavaConfig.java @@ -1,11 +1,11 @@ -package org.baeldung.ex.beancreationexception.spring; +package com.baeldung.ex.beancreationexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration -@ComponentScan("org.baeldung.ex.beancreationexception.cause6") +@ComponentScan("com.baeldung.ex.beancreationexception.cause6") @ImportResource("classpath:beancreationexception_cause6.xml") public class Cause6ContextWithJavaConfig { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java similarity index 76% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java index 6b56519c1a..63f9826d25 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause7ContextWithJavaConfig.java @@ -1,11 +1,11 @@ -package org.baeldung.ex.beancreationexception.spring; +package com.baeldung.ex.beancreationexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration -@ComponentScan("org.baeldung.ex.beancreationexception.cause7") +@ComponentScan("com.baeldung.ex.beancreationexception.cause7") @ImportResource("classpath:beancreationexception_cause7.xml") public class Cause7ContextWithJavaConfig { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java similarity index 69% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java index 084cf8d3af..c6a591df2b 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause8ContextWithJavaConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.beancreationexception.spring; +package com.baeldung.ex.beancreationexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.ex.beancreationexception.cause8") +@ComponentScan("com.baeldung.ex.beancreationexception.cause8") public class Cause8ContextWithJavaConfig { public Cause8ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java similarity index 80% rename from spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java index d64ec9ab3d..b9e3f4befd 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beancreationexception/spring/Cause9ContextWithJavaConfig.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception.spring; +package com.baeldung.ex.beancreationexception.spring; -import org.baeldung.ex.beancreationexception.cause9.BeanB; +import com.baeldung.ex.beancreationexception.cause9.BeanB; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration -@ComponentScan("org.baeldung.ex.beancreationexception.cause9") +@ComponentScan("com.baeldung.ex.beancreationexception.cause9") @ImportResource("classpath:beancreationexception_cause9.xml") public class Cause9ContextWithJavaConfig { @Autowired diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java similarity index 77% rename from spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java index a0aefda1cd..7de8a98f3b 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/cause2/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beandefinitionstoreexception.cause2; +package com.baeldung.ex.beandefinitionstoreexception.cause2; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java similarity index 74% rename from spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java index 3b6b4f2b8d..6684686b9a 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/spring/Cause1ContextWithJavaConfig.java @@ -1,11 +1,11 @@ -package org.baeldung.ex.beandefinitionstoreexception.spring; +package com.baeldung.ex.beandefinitionstoreexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration -@ComponentScan("org.baeldung.ex.beandefinitionstoreexception.cause1") +@ComponentScan("com.baeldung.ex.beandefinitionstoreexception.cause1") @ImportResource("beans.xml") public class Cause1ContextWithJavaConfig { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java similarity index 84% rename from spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java index d31890e0f3..35f69d3321 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/spring/Cause2ContextWithJavaConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beandefinitionstoreexception.spring; +package com.baeldung.ex.beandefinitionstoreexception.spring; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; @@ -7,7 +7,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; @Configuration -@ComponentScan("org.baeldung.ex.beandefinitionstoreexception.cause2") +@ComponentScan("com.baeldung.ex.beandefinitionstoreexception.cause2") public class Cause2ContextWithJavaConfig { @Value("${some.property}") diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java similarity index 68% rename from spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java index 11a00b1770..15a113ba79 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/beandefinitionstoreexception/spring/Cause3ContextWithJavaConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.beandefinitionstoreexception.spring; +package com.baeldung.ex.beandefinitionstoreexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.ex.beandefinitionstoreexception.cause3") +@ComponentScan("com.baeldung.ex.beandefinitionstoreexception.cause3") public class Cause3ContextWithJavaConfig { public Cause3ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/dataintegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java similarity index 78% rename from spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/dataintegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java index c4d98176c5..4034b45b24 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/dataintegrityviolationexception/spring/Cause1DataContextWithJavaConfig.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.dataintegrityviolationexception.spring; +package com.baeldung.ex.dataintegrityviolationexception.spring; -import org.baeldung.spring.config.PersistenceConfig; +import com.baeldung.spring.config.PersistenceConfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -8,7 +8,7 @@ import org.springframework.context.annotation.Import; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @Configuration -@ComponentScan("org.baeldung.ex.dataIntegrityviolationexception.cause1") +@ComponentScan("com.baeldung.ex.dataIntegrityviolationexception.cause1") @Import(PersistenceConfig.class) public class Cause1DataContextWithJavaConfig { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/dataintegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java similarity index 67% rename from spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/dataintegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java index 4dcae6282c..c4c0c4570d 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/dataintegrityviolationexception/spring/Cause2DataContextWithJavaConfig.java @@ -1,12 +1,12 @@ -package org.baeldung.ex.dataintegrityviolationexception.spring; +package com.baeldung.ex.dataintegrityviolationexception.spring; -import org.baeldung.spring.config.PersistenceConfig; +import com.baeldung.spring.config.PersistenceConfig; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @Configuration -@ComponentScan("org.baeldung.ex.dataIntegrityviolationexception.cause2") +@ComponentScan("com.baeldung.ex.dataIntegrityviolationexception.cause2") @Import(PersistenceConfig.class) public class Cause2DataContextWithJavaConfig { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/dataintegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java similarity index 67% rename from spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/dataintegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java index bb9b905854..b4426c9224 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/dataintegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/dataintegrityviolationexception/spring/Cause3DataContextWithJavaConfig.java @@ -1,12 +1,12 @@ -package org.baeldung.ex.dataintegrityviolationexception.spring; +package com.baeldung.ex.dataintegrityviolationexception.spring; -import org.baeldung.spring.config.PersistenceConfig; +import com.baeldung.spring.config.PersistenceConfig; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @Configuration -@ComponentScan("org.baeldung.ex.dataIntegrityviolationexception.cause3") +@ComponentScan("com.baeldung.ex.dataIntegrityviolationexception.cause3") @Import(PersistenceConfig.class) public class Cause3DataContextWithJavaConfig { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java similarity index 87% rename from spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java rename to spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java index 001c14d6d6..0eda0e7236 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause1/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.mappingexception.cause1.persistence.model; +package com.baeldung.ex.mappingexception.cause1.persistence.model; import java.io.Serializable; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java similarity index 88% rename from spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java rename to spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java index fa1200f710..602a8340df 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause2/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.mappingexception.cause2.persistence.model; +package com.baeldung.ex.mappingexception.cause2.persistence.model; import java.io.Serializable; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java similarity index 88% rename from spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java rename to spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java index 11e71edf01..58e80d3b51 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.mappingexception.cause4.persistence.model; +package com.baeldung.ex.mappingexception.cause3.persistence.model; import java.io.Serializable; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java similarity index 88% rename from spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java rename to spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java index 243196786c..82674514fc 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/cause3/persistence/model/Foo.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/cause4/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.mappingexception.cause3.persistence.model; +package com.baeldung.ex.mappingexception.cause4.persistence.model; import java.io.Serializable; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java similarity index 94% rename from spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java index 11dff24e48..d2929e3d91 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/spring/Cause1PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.mappingexception.spring; +package com.baeldung.ex.mappingexception.spring; import java.util.Properties; @@ -21,7 +21,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.ex.mappingexception.cause1.persistence" }) +@ComponentScan({ "com.baeldung.ex.mappingexception.cause1.persistence" }) public class Cause1PersistenceConfig { @Autowired @@ -35,7 +35,7 @@ public class Cause1PersistenceConfig { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause1.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.ex.mappingexception.cause1.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java similarity index 94% rename from spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java index d1d6408934..399238073c 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/spring/Cause2PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.mappingexception.spring; +package com.baeldung.ex.mappingexception.spring; import java.util.Properties; @@ -21,7 +21,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.ex.mappingexception.cause2.persistence" }) +@ComponentScan({ "com.baeldung.ex.mappingexception.cause2.persistence" }) public class Cause2PersistenceConfig { @Autowired @@ -37,7 +37,7 @@ public class Cause2PersistenceConfig { sessionFactory.setDataSource(restDataSource()); sessionFactory.setHibernateProperties(hibernateProperties()); - // sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model" }); + // sessionFactory.setPackagesToScan(new String[] { "com.baeldung.ex.mappingexception.cause2.persistence.model" }); // sessionFactory.setAnnotatedClasses(new Class[] { Foo.class }); return sessionFactory; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java similarity index 92% rename from spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java index d4245e8e45..f5191d52f2 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/mappingexception/spring/Cause3PersistenceConfig.java @@ -1,11 +1,11 @@ -package org.baeldung.ex.mappingexception.spring; +package com.baeldung.ex.mappingexception.spring; import java.util.Properties; import javax.sql.DataSource; import org.apache.tomcat.dbcp.dbcp.BasicDataSource; -import org.baeldung.ex.mappingexception.cause3.persistence.model.Foo; +import com.baeldung.ex.mappingexception.cause3.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -22,7 +22,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.ex.mappingexception.cause2.persistence" }) +@ComponentScan({ "com.baeldung.ex.mappingexception.cause2.persistence" }) public class Cause3PersistenceConfig { @Autowired @@ -38,7 +38,7 @@ public class Cause3PersistenceConfig { sessionFactory.setDataSource(restDataSource()); sessionFactory.setHibernateProperties(hibernateProperties()); - // sessionFactory.setPackagesToScan(new String[] { "org.baeldung.ex.mappingexception.cause2.persistence.model" }); + // sessionFactory.setPackagesToScan(new String[] { "com.baeldung.ex.mappingexception.cause2.persistence.model" }); sessionFactory.setAnnotatedClasses(new Class[] { Foo.class }); return sessionFactory; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nontransientexception/cause/Cause1NonTransientConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/nontransientexception/cause/Cause1NonTransientConfig.java similarity index 94% rename from spring-exceptions/src/main/java/org/baeldung/ex/nontransientexception/cause/Cause1NonTransientConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nontransientexception/cause/Cause1NonTransientConfig.java index 3337e4796d..118cb5da90 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nontransientexception/cause/Cause1NonTransientConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nontransientexception/cause/Cause1NonTransientConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.nontransientexception.cause; +package com.baeldung.ex.nontransientexception.cause; import java.util.Properties; @@ -21,7 +21,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-derby.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) +@ComponentScan({ "com.baeldung.persistence" }) public class Cause1NonTransientConfig { @Autowired @@ -35,7 +35,7 @@ public class Cause1NonTransientConfig { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nontransientexception/cause/Cause4NonTransientConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/nontransientexception/cause/Cause4NonTransientConfig.java similarity index 94% rename from spring-exceptions/src/main/java/org/baeldung/ex/nontransientexception/cause/Cause4NonTransientConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nontransientexception/cause/Cause4NonTransientConfig.java index 3543526f37..e79266e9ee 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nontransientexception/cause/Cause4NonTransientConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nontransientexception/cause/Cause4NonTransientConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.nontransientexception.cause; +package com.baeldung.ex.nontransientexception.cause; import java.util.Properties; @@ -21,7 +21,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-derby.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) +@ComponentScan({ "com.baeldung.persistence" }) public class Cause4NonTransientConfig { @Autowired @@ -35,7 +35,7 @@ public class Cause4NonTransientConfig { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nontransientexception/cause/Cause5NonTransientConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/nontransientexception/cause/Cause5NonTransientConfig.java similarity index 94% rename from spring-exceptions/src/main/java/org/baeldung/ex/nontransientexception/cause/Cause5NonTransientConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nontransientexception/cause/Cause5NonTransientConfig.java index 6d5d998c5b..784b36afbf 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nontransientexception/cause/Cause5NonTransientConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nontransientexception/cause/Cause5NonTransientConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.nontransientexception.cause; +package com.baeldung.ex.nontransientexception.cause; import java.util.Properties; @@ -21,7 +21,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql-incorrect.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) +@ComponentScan({ "com.baeldung.persistence" }) public class Cause5NonTransientConfig { @Autowired @@ -35,7 +35,7 @@ public class Cause5NonTransientConfig { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java similarity index 75% rename from spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java index c664309426..3832d6e61a 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause1; +package com.baeldung.ex.nosuchbeandefinitionexception.cause1; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java new file mode 100644 index 0000000000..49915c37d7 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.nosuchbeandefinitionexception.cause1; + +public class BeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java similarity index 75% rename from spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java index 2b454bfabb..19409820ea 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause2; +package com.baeldung.ex.nosuchbeandefinitionexception.cause2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java similarity index 63% rename from spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java index 877f400668..6b5fbb7c3e 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB1.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause2; +package com.baeldung.ex.nosuchbeandefinitionexception.cause2; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java similarity index 63% rename from spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java index 6bf4160966..0f0bcb8f7d 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/BeanB2.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause2; +package com.baeldung.ex.nosuchbeandefinitionexception.cause2; import org.springframework.stereotype.Component; diff --git a/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java new file mode 100644 index 0000000000..b8acb7faa6 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java @@ -0,0 +1,5 @@ +package com.baeldung.ex.nosuchbeandefinitionexception.cause2; + +public interface IBeanB { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java similarity index 87% rename from spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java index 091d3f1aa8..c094362629 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/cause3/BeanA.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause3; +package com.baeldung.ex.nosuchbeandefinitionexception.cause3; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java similarity index 68% rename from spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java index 5ba971baa9..026ccc532b 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/spring/Cause1ContextWithJavaConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.spring; +package com.baeldung.ex.nosuchbeandefinitionexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause1") +@ComponentScan("com.baeldung.ex.nosuchbeandefinitionexception.cause1") public class Cause1ContextWithJavaConfig { public Cause1ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java similarity index 68% rename from spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java index 9f4816ef7c..30da7f2119 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/spring/Cause2ContextWithJavaConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.spring; +package com.baeldung.ex.nosuchbeandefinitionexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause2") +@ComponentScan("com.baeldung.ex.nosuchbeandefinitionexception.cause2") public class Cause2ContextWithJavaConfig { public Cause2ContextWithJavaConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java similarity index 68% rename from spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java index a8d0fbe37b..e36c2e4eab 100644 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/ex/nosuchbeandefinitionexception/spring/Cause3ContextWithJavaConfig.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.spring; +package com.baeldung.ex.nosuchbeandefinitionexception.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan("org.baeldung.ex.nosuchbeandefinitionexception.cause3") +@ComponentScan("com.baeldung.ex.nosuchbeandefinitionexception.cause3") public class Cause3ContextWithJavaConfig { public Cause3ContextWithJavaConfig() { diff --git a/spring-core-2/src/main/java/org/baeldung/persistence/Setup.java b/spring-exceptions/src/main/java/com/baeldung/persistence/Setup.java similarity index 94% rename from spring-core-2/src/main/java/org/baeldung/persistence/Setup.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/Setup.java index 5cba4e70fb..251ea4654c 100644 --- a/spring-core-2/src/main/java/org/baeldung/persistence/Setup.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/Setup.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence; +package com.baeldung.persistence; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractHibernateDao.java b/spring-exceptions/src/main/java/com/baeldung/persistence/common/AbstractHibernateDao.java similarity index 97% rename from spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractHibernateDao.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/common/AbstractHibernateDao.java index cadb2ac061..90e4249c68 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractHibernateDao.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/common/AbstractHibernateDao.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.common; +package com.baeldung.persistence.common; import java.io.Serializable; import java.util.List; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractService.java b/spring-exceptions/src/main/java/com/baeldung/persistence/common/AbstractService.java similarity index 90% rename from spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractService.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/common/AbstractService.java index d2e162ad7b..5e1cdcba17 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/common/AbstractService.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/common/AbstractService.java @@ -1,9 +1,8 @@ -package org.baeldung.persistence.common; +package com.baeldung.persistence.common; import java.io.Serializable; import java.util.List; -import org.baeldung.persistence.common.IOperations; import org.springframework.transaction.annotation.Transactional; @Transactional diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/common/IOperations.java b/spring-exceptions/src/main/java/com/baeldung/persistence/common/IOperations.java similarity index 88% rename from spring-exceptions/src/main/java/org/baeldung/persistence/common/IOperations.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/common/IOperations.java index dee27950c7..feac025a6d 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/common/IOperations.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/common/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.common; +package com.baeldung.persistence.common; import java.io.Serializable; import java.util.List; diff --git a/spring-exceptions/src/main/java/com/baeldung/persistence/dao/IChildDao.java b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/IChildDao.java new file mode 100644 index 0000000000..b662be5da3 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/IChildDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.common.IOperations; +import com.baeldung.persistence.model.Child; + +public interface IChildDao extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/com/baeldung/persistence/dao/IFooDao.java b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 0000000000..131cd04768 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.common.IOperations; +import com.baeldung.persistence.model.Foo; + +public interface IFooDao extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/com/baeldung/persistence/dao/IParentDao.java b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/IParentDao.java new file mode 100644 index 0000000000..63b39c05c2 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/IParentDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.common.IOperations; +import com.baeldung.persistence.model.Parent; + +public interface IParentDao extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java similarity index 67% rename from spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java index e068573c5c..428189f522 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ChildDao.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/impl/ChildDao.java @@ -1,8 +1,8 @@ -package org.baeldung.persistence.dao.impl; +package com.baeldung.persistence.dao.impl; -import org.baeldung.persistence.common.AbstractHibernateDao; -import org.baeldung.persistence.dao.IChildDao; -import org.baeldung.persistence.model.Child; +import com.baeldung.persistence.common.AbstractHibernateDao; +import com.baeldung.persistence.model.Child; +import com.baeldung.persistence.dao.IChildDao; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java similarity index 66% rename from spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java index baf29c9ecd..2754a0e96d 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/FooDao.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/impl/FooDao.java @@ -1,8 +1,8 @@ -package org.baeldung.persistence.dao.impl; +package com.baeldung.persistence.dao.impl; -import org.baeldung.persistence.common.AbstractHibernateDao; -import org.baeldung.persistence.dao.IFooDao; -import org.baeldung.persistence.model.Foo; +import com.baeldung.persistence.common.AbstractHibernateDao; +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.model.Foo; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java similarity index 67% rename from spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java index 5634137b63..c1551b9f2e 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/impl/ParentDao.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/dao/impl/ParentDao.java @@ -1,8 +1,8 @@ -package org.baeldung.persistence.dao.impl; +package com.baeldung.persistence.dao.impl; -import org.baeldung.persistence.common.AbstractHibernateDao; -import org.baeldung.persistence.dao.IParentDao; -import org.baeldung.persistence.model.Parent; +import com.baeldung.persistence.common.AbstractHibernateDao; +import com.baeldung.persistence.model.Parent; +import com.baeldung.persistence.dao.IParentDao; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/model/Child.java b/spring-exceptions/src/main/java/com/baeldung/persistence/model/Child.java similarity index 95% rename from spring-exceptions/src/main/java/org/baeldung/persistence/model/Child.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/model/Child.java index 4eec4cf1d3..19cfb2e237 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/model/Child.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/model/Child.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import java.io.Serializable; diff --git a/spring-rest-testing/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-exceptions/src/main/java/com/baeldung/persistence/model/Foo.java similarity index 97% rename from spring-rest-testing/src/main/java/org/baeldung/persistence/model/Foo.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/model/Foo.java index 8e1dee33e8..9af3d07bed 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import java.io.Serializable; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/model/Parent.java b/spring-exceptions/src/main/java/com/baeldung/persistence/model/Parent.java similarity index 96% rename from spring-exceptions/src/main/java/org/baeldung/persistence/model/Parent.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/model/Parent.java index 19e405615d..fa6948990b 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/model/Parent.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/model/Parent.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import java.io.Serializable; diff --git a/spring-exceptions/src/main/java/com/baeldung/persistence/service/IChildService.java b/spring-exceptions/src/main/java/com/baeldung/persistence/service/IChildService.java new file mode 100644 index 0000000000..e7af073a4d --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/service/IChildService.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.common.IOperations; +import com.baeldung.persistence.model.Child; + +public interface IChildService extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/com/baeldung/persistence/service/IFooService.java b/spring-exceptions/src/main/java/com/baeldung/persistence/service/IFooService.java new file mode 100644 index 0000000000..f154391bb5 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/service/IFooService.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.common.IOperations; +import com.baeldung.persistence.model.Foo; + +public interface IFooService extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/com/baeldung/persistence/service/IParentService.java b/spring-exceptions/src/main/java/com/baeldung/persistence/service/IParentService.java new file mode 100644 index 0000000000..1c7ee45219 --- /dev/null +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/service/IParentService.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.common.IOperations; +import com.baeldung.persistence.model.Parent; + +public interface IParentService extends IOperations { + // +} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java b/spring-exceptions/src/main/java/com/baeldung/persistence/service/impl/ChildService.java similarity index 56% rename from spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/service/impl/ChildService.java index 89597313ea..ed913188f1 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ChildService.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/service/impl/ChildService.java @@ -1,10 +1,10 @@ -package org.baeldung.persistence.service.impl; +package com.baeldung.persistence.service.impl; -import org.baeldung.persistence.common.AbstractService; -import org.baeldung.persistence.common.IOperations; -import org.baeldung.persistence.dao.IChildDao; -import org.baeldung.persistence.model.Child; -import org.baeldung.persistence.service.IChildService; +import com.baeldung.persistence.common.AbstractService; +import com.baeldung.persistence.common.IOperations; +import com.baeldung.persistence.service.IChildService; +import com.baeldung.persistence.dao.IChildDao; +import com.baeldung.persistence.model.Child; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-exceptions/src/main/java/com/baeldung/persistence/service/impl/FooService.java similarity index 56% rename from spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/service/impl/FooService.java index f0a4d7a649..d3d7fe81c8 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/FooService.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/service/impl/FooService.java @@ -1,10 +1,10 @@ -package org.baeldung.persistence.service.impl; +package com.baeldung.persistence.service.impl; -import org.baeldung.persistence.common.AbstractService; -import org.baeldung.persistence.common.IOperations; -import org.baeldung.persistence.dao.IFooDao; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; +import com.baeldung.persistence.common.AbstractService; +import com.baeldung.persistence.common.IOperations; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java b/spring-exceptions/src/main/java/com/baeldung/persistence/service/impl/ParentService.java similarity index 57% rename from spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java rename to spring-exceptions/src/main/java/com/baeldung/persistence/service/impl/ParentService.java index 97c44f4a2f..b7fa75a716 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/impl/ParentService.java +++ b/spring-exceptions/src/main/java/com/baeldung/persistence/service/impl/ParentService.java @@ -1,10 +1,10 @@ -package org.baeldung.persistence.service.impl; +package com.baeldung.persistence.service.impl; -import org.baeldung.persistence.common.AbstractService; -import org.baeldung.persistence.common.IOperations; -import org.baeldung.persistence.dao.IParentDao; -import org.baeldung.persistence.model.Parent; -import org.baeldung.persistence.service.IParentService; +import com.baeldung.persistence.common.AbstractService; +import com.baeldung.persistence.common.IOperations; +import com.baeldung.persistence.model.Parent; +import com.baeldung.persistence.service.IParentService; +import com.baeldung.persistence.dao.IParentDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java b/spring-exceptions/src/main/java/com/baeldung/properties/core/ComponentInXmlUsingProperties.java similarity index 95% rename from spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java rename to spring-exceptions/src/main/java/com/baeldung/properties/core/ComponentInXmlUsingProperties.java index f695326cd6..35f54b90e5 100644 --- a/spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentInXmlUsingProperties.java +++ b/spring-exceptions/src/main/java/com/baeldung/properties/core/ComponentInXmlUsingProperties.java @@ -1,4 +1,4 @@ -package org.baeldung.properties.core; +package com.baeldung.properties.core; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java b/spring-exceptions/src/main/java/com/baeldung/properties/core/ComponentUsingProperties.java similarity index 95% rename from spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java rename to spring-exceptions/src/main/java/com/baeldung/properties/core/ComponentUsingProperties.java index 7e082702fe..ff6e11d453 100644 --- a/spring-exceptions/src/main/java/org/baeldung/properties/core/ComponentUsingProperties.java +++ b/spring-exceptions/src/main/java/com/baeldung/properties/core/ComponentUsingProperties.java @@ -1,4 +1,4 @@ -package org.baeldung.properties.core; +package com.baeldung.properties.core; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfig.java similarity index 88% rename from spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java rename to spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfig.java index 9b5d7ed047..80c17ef059 100644 --- a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.properties.spring; +package com.baeldung.properties.spring; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -7,7 +7,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; @Configuration -@ComponentScan("org.baeldung.properties.core") +@ComponentScan("com.baeldung.properties.core") @PropertySource("classpath:foo.properties") public class PropertiesWithJavaConfig { diff --git a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfigOther.java similarity index 88% rename from spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java rename to spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfigOther.java index 594ba0a09d..54d7814045 100644 --- a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithJavaConfigOther.java +++ b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithJavaConfigOther.java @@ -1,4 +1,4 @@ -package org.baeldung.properties.spring; +package com.baeldung.properties.spring; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; diff --git a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithXmlConfig.java similarity index 82% rename from spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java rename to spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithXmlConfig.java index 9ad7febcb0..2a774f449f 100644 --- a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithXmlConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.properties.spring; +package com.baeldung.properties.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -6,7 +6,7 @@ import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource("classpath:configForProperties.xml") -@ComponentScan("org.baeldung.core") +@ComponentScan("com.baeldung.core") public class PropertiesWithXmlConfig { public PropertiesWithXmlConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithXmlConfigOne.java similarity index 82% rename from spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java rename to spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithXmlConfigOne.java index 9061cc10d4..205741d22b 100644 --- a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigOne.java +++ b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithXmlConfigOne.java @@ -1,4 +1,4 @@ -package org.baeldung.properties.spring; +package com.baeldung.properties.spring; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -6,7 +6,7 @@ import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource("classpath:configForPropertiesOne.xml") -@ComponentScan("org.baeldung.core") +@ComponentScan("com.baeldung.core") public class PropertiesWithXmlConfigOne { public PropertiesWithXmlConfigOne() { diff --git a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java similarity index 88% rename from spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java rename to spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java index e4365cbc8b..98f64eb94d 100644 --- a/spring-exceptions/src/main/java/org/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java +++ b/spring-exceptions/src/main/java/com/baeldung/properties/spring/PropertiesWithXmlConfigTwo.java @@ -1,4 +1,4 @@ -package org.baeldung.properties.spring; +package com.baeldung.properties.spring; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; diff --git a/spring-exceptions/src/main/java/org/baeldung/spring/config/CoreConfig.java b/spring-exceptions/src/main/java/com/baeldung/spring/config/CoreConfig.java similarity index 82% rename from spring-exceptions/src/main/java/org/baeldung/spring/config/CoreConfig.java rename to spring-exceptions/src/main/java/com/baeldung/spring/config/CoreConfig.java index ff1742351b..8c51378ca9 100644 --- a/spring-exceptions/src/main/java/org/baeldung/spring/config/CoreConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/spring/config/CoreConfig.java @@ -1,11 +1,11 @@ -package org.baeldung.spring.config; +package com.baeldung.spring.config; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration -@ComponentScan("org.baeldung.core") +@ComponentScan("com.baeldung.core") public class CoreConfig extends WebMvcConfigurerAdapter { public CoreConfig() { diff --git a/spring-exceptions/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java b/spring-exceptions/src/main/java/com/baeldung/spring/config/MainWebAppInitializer.java similarity index 95% rename from spring-exceptions/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java rename to spring-exceptions/src/main/java/com/baeldung/spring/config/MainWebAppInitializer.java index 5ef83b8afd..3aaa1c8aee 100644 --- a/spring-exceptions/src/main/java/org/baeldung/spring/config/MainWebAppInitializer.java +++ b/spring-exceptions/src/main/java/com/baeldung/spring/config/MainWebAppInitializer.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package com.baeldung.spring.config; import java.util.Set; @@ -23,7 +23,7 @@ public class MainWebAppInitializer implements WebApplicationInitializer { // Create the 'root' Spring application context final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); - root.scan("org.baeldung.spring.config"); + root.scan("com.baeldung.spring.config"); // root.getEnvironment().setDefaultProfiles("embedded"); // Manages the lifecycle of the root application context diff --git a/spring-exceptions/src/main/java/org/baeldung/spring/config/MvcConfig.java b/spring-exceptions/src/main/java/com/baeldung/spring/config/MvcConfig.java similarity index 96% rename from spring-exceptions/src/main/java/org/baeldung/spring/config/MvcConfig.java rename to spring-exceptions/src/main/java/com/baeldung/spring/config/MvcConfig.java index f87e400fce..717e3c9356 100644 --- a/spring-exceptions/src/main/java/org/baeldung/spring/config/MvcConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/spring/config/MvcConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package com.baeldung.spring.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java b/spring-exceptions/src/main/java/com/baeldung/spring/config/PersistenceConfig.java similarity index 95% rename from spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java rename to spring-exceptions/src/main/java/com/baeldung/spring/config/PersistenceConfig.java index 4fb3fdacd5..0a31b158d9 100644 --- a/spring-exceptions/src/main/java/org/baeldung/spring/config/PersistenceConfig.java +++ b/spring-exceptions/src/main/java/com/baeldung/spring/config/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.config; +package com.baeldung.spring.config; import java.util.Properties; @@ -21,7 +21,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) +@ComponentScan({ "com.baeldung.persistence" }) public class PersistenceConfig { @Autowired @@ -35,7 +35,7 @@ public class PersistenceConfig { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanB.java deleted file mode 100644 index 8b4b17a0c6..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause1/BeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.beancreationexception.cause1; - -public class BeanB { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/IBeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/IBeanB.java deleted file mode 100644 index 60e8a0a429..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause2/IBeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.beancreationexception.cause2; - -public interface IBeanB { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/IBeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/IBeanA.java deleted file mode 100644 index 2f25c1c365..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause4/IBeanA.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.beancreationexception.cause4; - -public interface IBeanA { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/IBeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/IBeanA.java deleted file mode 100644 index 5c575e400c..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause5/IBeanA.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.beancreationexception.cause5; - -public interface IBeanA { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/IBeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/IBeanB.java deleted file mode 100644 index 36b436ce98..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause6/IBeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.beancreationexception.cause6; - -public interface IBeanB { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanA.java deleted file mode 100644 index 3d6c4eef28..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanA.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.beancreationexception.cause8; - -public interface IBeanA { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanB.java deleted file mode 100644 index 5f6f438968..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause8/IBeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.beancreationexception.cause8; - -public interface IBeanB { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java deleted file mode 100644 index 5e076023f0..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/BeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.beancreationexception.cause9; - -public class BeanB { - // -} \ No newline at end of file diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/IBeanA.java b/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/IBeanA.java deleted file mode 100644 index 82114b18da..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/beancreationexception/cause9/IBeanA.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.beancreationexception.cause9; - -public interface IBeanA { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java deleted file mode 100644 index 8a198422e8..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause1/BeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause1; - -public class BeanB { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java b/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java deleted file mode 100644 index 3e70126c1a..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/ex/nosuchbeandefinitionexception/cause2/IBeanB.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.baeldung.ex.nosuchbeandefinitionexception.cause2; - -public interface IBeanB { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IChildDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IChildDao.java deleted file mode 100644 index 25290554f3..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IChildDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.common.IOperations; -import org.baeldung.persistence.model.Child; - -public interface IChildDao extends IOperations { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IFooDao.java deleted file mode 100644 index b41cd9edde..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IFooDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.common.IOperations; -import org.baeldung.persistence.model.Foo; - -public interface IFooDao extends IOperations { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IParentDao.java b/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IParentDao.java deleted file mode 100644 index a047d97ef1..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/dao/IParentDao.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.common.IOperations; -import org.baeldung.persistence.model.Parent; - -public interface IParentDao extends IOperations { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/IChildService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/IChildService.java deleted file mode 100644 index e2c2055ca2..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/IChildService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.persistence.service; - -import org.baeldung.persistence.common.IOperations; -import org.baeldung.persistence.model.Child; - -public interface IChildService extends IOperations { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/IFooService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/IFooService.java deleted file mode 100644 index 64b826db02..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/IFooService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.persistence.service; - -import org.baeldung.persistence.common.IOperations; -import org.baeldung.persistence.model.Foo; - -public interface IFooService extends IOperations { - // -} diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/service/IParentService.java b/spring-exceptions/src/main/java/org/baeldung/persistence/service/IParentService.java deleted file mode 100644 index a05f07658f..0000000000 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/service/IParentService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.baeldung.persistence.service; - -import org.baeldung.persistence.common.IOperations; -import org.baeldung.persistence.model.Parent; - -public interface IParentService extends IOperations { - // -} diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause4.xml b/spring-exceptions/src/main/resources/beancreationexception_cause4.xml index ad7edc3763..47f55db2d7 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause4.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause4.xml @@ -6,6 +6,6 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"> - + \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause6.xml b/spring-exceptions/src/main/resources/beancreationexception_cause6.xml index fe60786151..fdfed069f0 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause6.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause6.xml @@ -6,7 +6,7 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"> - + diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause7.xml b/spring-exceptions/src/main/resources/beancreationexception_cause7.xml index d8ef7dd18c..29b7bab317 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause7.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause7.xml @@ -6,6 +6,6 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"> - + \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/beancreationexception_cause9.xml b/spring-exceptions/src/main/resources/beancreationexception_cause9.xml index 5d658f819f..b059ec67c3 100644 --- a/spring-exceptions/src/main/resources/beancreationexception_cause9.xml +++ b/spring-exceptions/src/main/resources/beancreationexception_cause9.xml @@ -6,6 +6,6 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"> - + \ No newline at end of file diff --git a/spring-exceptions/src/main/resources/configForProperties.xml b/spring-exceptions/src/main/resources/configForProperties.xml index 0f766665eb..e61d883c70 100644 --- a/spring-exceptions/src/main/resources/configForProperties.xml +++ b/spring-exceptions/src/main/resources/configForProperties.xml @@ -9,7 +9,7 @@ - + diff --git a/spring-exceptions/src/main/resources/configForPropertiesOne.xml b/spring-exceptions/src/main/resources/configForPropertiesOne.xml index 068c86a840..53072d89bb 100644 --- a/spring-exceptions/src/main/resources/configForPropertiesOne.xml +++ b/spring-exceptions/src/main/resources/configForPropertiesOne.xml @@ -9,7 +9,7 @@ - + diff --git a/spring-exceptions/src/main/webapp/WEB-INF/web_old.xml b/spring-exceptions/src/main/webapp/WEB-INF/web_old.xml index 016369ad27..c8b38fae30 100644 --- a/spring-exceptions/src/main/webapp/WEB-INF/web_old.xml +++ b/spring-exceptions/src/main/webapp/WEB-INF/web_old.xml @@ -16,7 +16,7 @@ contextConfigLocation - org.baeldung.spring.web.config + com.baeldung.spring.web.config diff --git a/spring-exceptions/src/test/java/org/baeldung/SpringContextLiveTest.java b/spring-exceptions/src/test/java/com/baeldung/SpringContextLiveTest.java similarity index 87% rename from spring-exceptions/src/test/java/org/baeldung/SpringContextLiveTest.java rename to spring-exceptions/src/test/java/com/baeldung/SpringContextLiveTest.java index ece7e0e730..a9ba0cf5c1 100644 --- a/spring-exceptions/src/test/java/org/baeldung/SpringContextLiveTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/SpringContextLiveTest.java @@ -1,6 +1,6 @@ -package org.baeldung; +package com.baeldung; -import org.baeldung.spring.config.PersistenceConfig; +import com.baeldung.spring.config.PersistenceConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java similarity index 93% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java index 9597c09568..81fb4770ac 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/BeanCreationExceptionTestSuite.java @@ -1,4 +1,4 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionManualTest.java index 350347bb19..441e17cf98 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause1BeanCreationExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; -import org.baeldung.ex.beancreationexception.spring.Cause1ContextWithJavaConfig; +import com.baeldung.ex.beancreationexception.spring.Cause1ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionManualTest.java index c2b9561848..6b760d4fbe 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause2BeanCreationExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; -import org.baeldung.ex.beancreationexception.spring.Cause2ContextWithJavaConfig; +import com.baeldung.ex.beancreationexception.spring.Cause2ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionManualTest.java index 7b9b49bf58..83935c2e2e 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause3BeanCreationExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; -import org.baeldung.ex.beancreationexception.spring.Cause3ContextWithJavaConfig; +import com.baeldung.ex.beancreationexception.spring.Cause3ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionManualTest.java index 3a6e30476c..0e4d83e929 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause4BeanCreationExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; -import org.baeldung.ex.beancreationexception.spring.Cause4ContextWithJavaConfig; +import com.baeldung.ex.beancreationexception.spring.Cause4ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionManualTest.java index e69a323f8d..828c200a3d 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause5BeanCreationExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; -import org.baeldung.ex.beancreationexception.spring.Cause5ContextWithJavaConfig; +import com.baeldung.ex.beancreationexception.spring.Cause5ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionManualTest.java index 30fbd47635..9bae716684 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause6BeanCreationExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; -import org.baeldung.ex.beancreationexception.spring.Cause6ContextWithJavaConfig; +import com.baeldung.ex.beancreationexception.spring.Cause6ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionManualTest.java index d832bddf72..35606d4339 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause7BeanCreationExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; -import org.baeldung.ex.beancreationexception.spring.Cause7ContextWithJavaConfig; +import com.baeldung.ex.beancreationexception.spring.Cause7ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionManualTest.java index a9f32b6d1a..51809af8bf 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause8BeanCreationExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; -import org.baeldung.ex.beancreationexception.spring.Cause8ContextWithJavaConfig; +import com.baeldung.ex.beancreationexception.spring.Cause8ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionManualTest.java index 6af5fb3712..9a6cee8192 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beancreationexception/Cause9BeanCreationExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beancreationexception; +package com.baeldung.ex.beancreationexception; -import org.baeldung.ex.beancreationexception.spring.Cause9ContextWithJavaConfig; +import com.baeldung.ex.beancreationexception.spring.Cause9ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionManualTest.java similarity index 83% rename from spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionManualTest.java index 1580546fa7..f5c3cc1ed8 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beandefinitionstoreexception/Cause1BeanDefinitionStoreExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beandefinitionstoreexception; +package com.baeldung.ex.beandefinitionstoreexception; -import org.baeldung.ex.beandefinitionstoreexception.spring.Cause1ContextWithJavaConfig; +import com.baeldung.ex.beandefinitionstoreexception.spring.Cause1ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionManualTest.java similarity index 83% rename from spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionManualTest.java index ce0db694dc..cddbb173ec 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beandefinitionstoreexception/Cause2BeanDefinitionStoreExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beandefinitionstoreexception; +package com.baeldung.ex.beandefinitionstoreexception; -import org.baeldung.ex.beandefinitionstoreexception.spring.Cause2ContextWithJavaConfig; +import com.baeldung.ex.beandefinitionstoreexception.spring.Cause2ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionManualTest.java similarity index 83% rename from spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionManualTest.java index c090ac7b5f..a5c458be9f 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/beandefinitionstoreexception/Cause3BeanDefinitionStoreExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.beandefinitionstoreexception; +package com.baeldung.ex.beandefinitionstoreexception; -import org.baeldung.ex.beandefinitionstoreexception.spring.Cause3ContextWithJavaConfig; +import com.baeldung.ex.beandefinitionstoreexception.spring.Cause3ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause1DataIntegrityViolationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/dataintegrityviolationexception/Cause1DataIntegrityViolationExceptionManualTest.java similarity index 82% rename from spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause1DataIntegrityViolationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/dataintegrityviolationexception/Cause1DataIntegrityViolationExceptionManualTest.java index 056e052359..e41f916000 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause1DataIntegrityViolationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/dataintegrityviolationexception/Cause1DataIntegrityViolationExceptionManualTest.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.dataintegrityviolationexception; +package com.baeldung.ex.dataintegrityviolationexception; -import org.baeldung.ex.dataintegrityviolationexception.spring.Cause1DataContextWithJavaConfig; -import org.baeldung.persistence.model.Child; -import org.baeldung.persistence.model.Parent; -import org.baeldung.persistence.service.IChildService; -import org.baeldung.persistence.service.IParentService; +import com.baeldung.ex.dataintegrityviolationexception.spring.Cause1DataContextWithJavaConfig; +import com.baeldung.persistence.model.Child; +import com.baeldung.persistence.model.Parent; +import com.baeldung.persistence.service.IChildService; +import com.baeldung.persistence.service.IParentService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause2DataIntegrityViolationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/dataintegrityviolationexception/Cause2DataIntegrityViolationExceptionManualTest.java similarity index 80% rename from spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause2DataIntegrityViolationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/dataintegrityviolationexception/Cause2DataIntegrityViolationExceptionManualTest.java index e36a027105..b41cead90d 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause2DataIntegrityViolationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/dataintegrityviolationexception/Cause2DataIntegrityViolationExceptionManualTest.java @@ -1,8 +1,8 @@ -package org.baeldung.ex.dataintegrityviolationexception; +package com.baeldung.ex.dataintegrityviolationexception; -import org.baeldung.ex.dataintegrityviolationexception.spring.Cause2DataContextWithJavaConfig; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; +import com.baeldung.ex.dataintegrityviolationexception.spring.Cause2DataContextWithJavaConfig; +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause3DataIntegrityViolationExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/dataintegrityviolationexception/Cause3DataIntegrityViolationExceptionManualTest.java similarity index 82% rename from spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause3DataIntegrityViolationExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/dataintegrityviolationexception/Cause3DataIntegrityViolationExceptionManualTest.java index 4194e1c9fe..c41321c144 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/dataintegrityviolationexception/Cause3DataIntegrityViolationExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/dataintegrityviolationexception/Cause3DataIntegrityViolationExceptionManualTest.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.dataintegrityviolationexception; +package com.baeldung.ex.dataintegrityviolationexception; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import org.baeldung.ex.dataintegrityviolationexception.spring.Cause3DataContextWithJavaConfig; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; +import com.baeldung.ex.dataintegrityviolationexception.spring.Cause3DataContextWithJavaConfig; +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause1MappingExceptionManualTest.java similarity index 85% rename from spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause1MappingExceptionManualTest.java index 7ba9618a77..b00b9d7257 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause1MappingExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause1MappingExceptionManualTest.java @@ -1,7 +1,7 @@ -package org.baeldung.ex.mappingexception; +package com.baeldung.ex.mappingexception; -import org.baeldung.ex.mappingexception.cause1.persistence.model.Foo; -import org.baeldung.ex.mappingexception.spring.Cause1PersistenceConfig; +import com.baeldung.ex.mappingexception.cause1.persistence.model.Foo; +import com.baeldung.ex.mappingexception.spring.Cause1PersistenceConfig; import org.hibernate.MappingException; import org.hibernate.SessionFactory; import org.junit.Test; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause2MappingExceptionManualTest.java similarity index 84% rename from spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause2MappingExceptionManualTest.java index 66923fc6a9..1ff4170276 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause2MappingExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause2MappingExceptionManualTest.java @@ -1,7 +1,7 @@ -package org.baeldung.ex.mappingexception; +package com.baeldung.ex.mappingexception; -import org.baeldung.ex.mappingexception.cause2.persistence.model.Foo; -import org.baeldung.ex.mappingexception.spring.Cause2PersistenceConfig; +import com.baeldung.ex.mappingexception.cause2.persistence.model.Foo; +import com.baeldung.ex.mappingexception.spring.Cause2PersistenceConfig; import org.hibernate.SessionFactory; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause3MappingExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause3MappingExceptionManualTest.java similarity index 85% rename from spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause3MappingExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause3MappingExceptionManualTest.java index e6888d1685..54a4c9cde3 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause3MappingExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause3MappingExceptionManualTest.java @@ -1,7 +1,7 @@ -package org.baeldung.ex.mappingexception; +package com.baeldung.ex.mappingexception; -import org.baeldung.ex.mappingexception.cause3.persistence.model.Foo; -import org.baeldung.ex.mappingexception.spring.Cause3PersistenceConfig; +import com.baeldung.ex.mappingexception.cause3.persistence.model.Foo; +import com.baeldung.ex.mappingexception.spring.Cause3PersistenceConfig; import org.hibernate.MappingException; import org.hibernate.SessionFactory; import org.junit.Test; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause4MappingExceptionManualTest.java similarity index 93% rename from spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause4MappingExceptionManualTest.java index ea90b3d6cc..7f6b765073 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/mappingexception/Cause4MappingExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/mappingexception/Cause4MappingExceptionManualTest.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.mappingexception; +package com.baeldung.ex.mappingexception; import java.io.IOException; import java.io.InputStream; import java.util.Properties; -import org.baeldung.ex.mappingexception.cause4.persistence.model.Foo; +import com.baeldung.ex.mappingexception.cause4.persistence.model.Foo; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/CannotGetJdbcConnectionExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/CannotGetJdbcConnectionExceptionManualTest.java similarity index 74% rename from spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/CannotGetJdbcConnectionExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/CannotGetJdbcConnectionExceptionManualTest.java index b7ed103394..2aebf6ff42 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/CannotGetJdbcConnectionExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/CannotGetJdbcConnectionExceptionManualTest.java @@ -1,15 +1,11 @@ -package org.baeldung.ex.nontransientdataaccessexception; +package com.baeldung.ex.nontransientdataaccessexception; import javax.sql.DataSource; -import org.baeldung.ex.nontransientexception.cause.Cause1NonTransientConfig; -import org.baeldung.ex.nontransientexception.cause.Cause5NonTransientConfig; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; +import com.baeldung.ex.nontransientexception.cause.Cause5NonTransientConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataIntegrityViolationException; import org.springframework.jdbc.CannotGetJdbcConnectionException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/DataIntegrityExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/DataIntegrityExceptionManualTest.java similarity index 87% rename from spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/DataIntegrityExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/DataIntegrityExceptionManualTest.java index b98a210125..2450554055 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/DataIntegrityExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/DataIntegrityExceptionManualTest.java @@ -1,10 +1,10 @@ -package org.baeldung.ex.nontransientdataaccessexception; +package com.baeldung.ex.nontransientdataaccessexception; import javax.sql.DataSource; -import org.baeldung.ex.nontransientexception.cause.Cause1NonTransientConfig; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; +import com.baeldung.ex.nontransientexception.cause.Cause1NonTransientConfig; +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/DataRetrievalExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/DataRetrievalExceptionManualTest.java similarity index 92% rename from spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/DataRetrievalExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/DataRetrievalExceptionManualTest.java index 122278580f..8f0d6d60cc 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/DataRetrievalExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/DataRetrievalExceptionManualTest.java @@ -1,9 +1,9 @@ -package org.baeldung.ex.nontransientdataaccessexception; +package com.baeldung.ex.nontransientdataaccessexception; import javax.sql.DataSource; -import org.baeldung.ex.nontransientexception.cause.Cause1NonTransientConfig; -import org.baeldung.persistence.model.Foo; +import com.baeldung.ex.nontransientexception.cause.Cause1NonTransientConfig; +import com.baeldung.persistence.model.Foo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/DataSourceLookupExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/DataSourceLookupExceptionManualTest.java similarity index 89% rename from spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/DataSourceLookupExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/DataSourceLookupExceptionManualTest.java index 4da5f94098..508fb77e61 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/DataSourceLookupExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/DataSourceLookupExceptionManualTest.java @@ -1,8 +1,8 @@ -package org.baeldung.ex.nontransientdataaccessexception; +package com.baeldung.ex.nontransientdataaccessexception; import javax.sql.DataSource; -import org.baeldung.ex.nontransientexception.cause.Cause4NonTransientConfig; +import com.baeldung.ex.nontransientexception.cause.Cause4NonTransientConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/InvalidResourceUsageExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/InvalidResourceUsageExceptionManualTest.java similarity index 90% rename from spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/InvalidResourceUsageExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/InvalidResourceUsageExceptionManualTest.java index fc420acfe9..3e64f69884 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nontransientdataaccessexception/InvalidResourceUsageExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/nontransientdataaccessexception/InvalidResourceUsageExceptionManualTest.java @@ -1,7 +1,7 @@ -package org.baeldung.ex.nontransientdataaccessexception; +package com.baeldung.ex.nontransientdataaccessexception; -import org.baeldung.ex.nontransientexception.cause.Cause1NonTransientConfig; -import org.baeldung.persistence.service.IFooService; +import com.baeldung.ex.nontransientexception.cause.Cause1NonTransientConfig; +import com.baeldung.persistence.service.IFooService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionManualTest.java similarity index 57% rename from spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionManualTest.java index 45ffdf9096..52cd2f31ea 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/nosuchbeandefinitionexception/Cause1NoSuchBeanDefinitionExceptionManualTest.java @@ -1,14 +1,8 @@ -package org.baeldung.ex.nosuchbeandefinitionexception; +package com.baeldung.ex.nosuchbeandefinitionexception; -import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause1ContextWithJavaConfig; -import org.baeldung.persistence.model.Child; -import org.baeldung.persistence.model.Parent; -import org.baeldung.persistence.service.IChildService; -import org.baeldung.persistence.service.IParentService; +import com.baeldung.ex.nosuchbeandefinitionexception.spring.Cause1ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataIntegrityViolationException; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionManualTest.java similarity index 83% rename from spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionManualTest.java index 09ed2b4435..b165482ea1 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/nosuchbeandefinitionexception/Cause2NoSuchBeanDefinitionExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.nosuchbeandefinitionexception; +package com.baeldung.ex.nosuchbeandefinitionexception; -import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause2ContextWithJavaConfig; +import com.baeldung.ex.nosuchbeandefinitionexception.spring.Cause2ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionManualTest.java b/spring-exceptions/src/test/java/com/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionManualTest.java similarity index 83% rename from spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionManualTest.java index 7dc016a568..ec0f8c8b1e 100644 --- a/spring-exceptions/src/test/java/org/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/ex/nosuchbeandefinitionexception/Cause3NoSuchBeanDefinitionExceptionManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.ex.nosuchbeandefinitionexception; +package com.baeldung.ex.nosuchbeandefinitionexception; -import org.baeldung.ex.nosuchbeandefinitionexception.spring.Cause3ContextWithJavaConfig; +import com.baeldung.ex.nosuchbeandefinitionexception.spring.Cause3ContextWithJavaConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithJavaManualTest.java b/spring-exceptions/src/test/java/com/baeldung/properties/core/PropertiesWithJavaManualTest.java similarity index 86% rename from spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithJavaManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/properties/core/PropertiesWithJavaManualTest.java index 91db8210b3..e3f360e6a5 100644 --- a/spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithJavaManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/properties/core/PropertiesWithJavaManualTest.java @@ -1,7 +1,7 @@ -package org.baeldung.properties.core; +package com.baeldung.properties.core; -import org.baeldung.properties.spring.PropertiesWithJavaConfig; -import org.baeldung.properties.spring.PropertiesWithJavaConfigOther; +import com.baeldung.properties.spring.PropertiesWithJavaConfig; +import com.baeldung.properties.spring.PropertiesWithJavaConfigOther; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsManualTest.java b/spring-exceptions/src/test/java/com/baeldung/properties/core/PropertiesWithMultipleXmlsManualTest.java similarity index 86% rename from spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/properties/core/PropertiesWithMultipleXmlsManualTest.java index 201e554381..b63cd74646 100644 --- a/spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithMultipleXmlsManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/properties/core/PropertiesWithMultipleXmlsManualTest.java @@ -1,7 +1,7 @@ -package org.baeldung.properties.core; +package com.baeldung.properties.core; -import org.baeldung.properties.spring.PropertiesWithXmlConfigOne; -import org.baeldung.properties.spring.PropertiesWithXmlConfigTwo; +import com.baeldung.properties.spring.PropertiesWithXmlConfigOne; +import com.baeldung.properties.spring.PropertiesWithXmlConfigTwo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithXmlManualTest.java b/spring-exceptions/src/test/java/com/baeldung/properties/core/PropertiesWithXmlManualTest.java similarity index 90% rename from spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithXmlManualTest.java rename to spring-exceptions/src/test/java/com/baeldung/properties/core/PropertiesWithXmlManualTest.java index a54dd8a3fb..b848dab75f 100644 --- a/spring-exceptions/src/test/java/org/baeldung/properties/core/PropertiesWithXmlManualTest.java +++ b/spring-exceptions/src/test/java/com/baeldung/properties/core/PropertiesWithXmlManualTest.java @@ -1,6 +1,6 @@ -package org.baeldung.properties.core; +package com.baeldung.properties.core; -import org.baeldung.properties.spring.PropertiesWithXmlConfig; +import com.baeldung.properties.spring.PropertiesWithXmlConfig; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-integration/pom.xml b/spring-integration/pom.xml index ebdde5a1ee..a985f55d89 100644 --- a/spring-integration/pom.xml +++ b/spring-integration/pom.xml @@ -85,7 +85,7 @@ com.h2database h2 - 1.4.197 + ${h2.version} @@ -124,6 +124,7 @@ 1.1.1 2.10 1.5.0 + 1.4.197 diff --git a/spring-jinq/pom.xml b/spring-jinq/pom.xml index 991401c4a1..29fc3605d7 100644 --- a/spring-jinq/pom.xml +++ b/spring-jinq/pom.xml @@ -11,6 +11,7 @@ com.baeldung parent-boot-1 0.0.1-SNAPSHOT + ../parent-boot-1 diff --git a/spring-jms/pom.xml b/spring-jms/pom.xml index a0d2625477..9cd9126fac 100644 --- a/spring-jms/pom.xml +++ b/spring-jms/pom.xml @@ -38,7 +38,7 @@ org.springframework.boot spring-boot-starter-test - 1.5.10.RELEASE + ${spring-boot-test.version} test @@ -64,6 +64,7 @@ 4.3.4.RELEASE 5.14.1 + 1.5.10.RELEASE diff --git a/spring-jooq/pom.xml b/spring-jooq/pom.xml index 620172f2a1..f3b8cce8dc 100644 --- a/spring-jooq/pom.xml +++ b/spring-jooq/pom.xml @@ -194,6 +194,7 @@ 1.5 1.0.0 org.jooq.example.spring.Application + 2.1.9.RELEASE \ No newline at end of file diff --git a/spring-mvc-basics-2/.gitignore b/spring-mvc-basics-2/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/spring-mvc-basics-2/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/spring-mvc-basics-2/README.md b/spring-mvc-basics-2/README.md index 4a5ea24283..9d1402a210 100644 --- a/spring-mvc-basics-2/README.md +++ b/spring-mvc-basics-2/README.md @@ -1,14 +1,15 @@ -## Spring MVC Basics +## Spring MVC Basics 2 -This module contains articles about the basics of Spring MVC. Articles about more specific areas of Spring MVC have -their own module. +This module contains articles about Spring MVC -### The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring - -### Relevant Articles: -- [Quick Guide to Spring Controllers](http://www.baeldung.com/spring-controllers) -- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller) -- [Model, ModelMap, and ModelView in Spring MVC](http://www.baeldung.com/spring-mvc-model-model-map-model-view) -- [Spring Web Contexts](http://www.baeldung.com/spring-web-contexts) -- [[<-- Prev]](/spring-mvc-basics) \ No newline at end of file +## Relevant articles: +- [HandlerAdapters in Spring MVC](https://www.baeldung.com/spring-mvc-handler-adapters) +- [Template Engines for Spring](https://www.baeldung.com/spring-template-engines) +- [Spring 5 and Servlet 4 – The PushBuilder](https://www.baeldung.com/spring-5-push) +- [Servlet Redirect vs Forward](https://www.baeldung.com/servlet-redirect-forward) +- [Apache Tiles Integration with Spring MVC](https://www.baeldung.com/spring-mvc-apache-tiles) +- [Guide to Spring Email](https://www.baeldung.com/spring-email) +- [Request Method Not Supported (405) in Spring](https://www.baeldung.com/spring-request-method-not-supported-405) +- [Spring @RequestParam Annotation](https://www.baeldung.com/spring-request-param) +- More articles: [[more -->]](/spring-mvc-basics-3) +- More articles: [[<-- prev]](/spring-mvc-basics) diff --git a/spring-mvc-basics-2/pom.xml b/spring-mvc-basics-2/pom.xml index 8e36eb38d8..4c3041a209 100644 --- a/spring-mvc-basics-2/pom.xml +++ b/spring-mvc-basics-2/pom.xml @@ -1,37 +1,185 @@ - + 4.0.0 spring-mvc-basics-2 + 0.0.1-SNAPSHOT spring-mvc-basics-2 war com.baeldung - parent-boot-2 + parent-spring-5 0.0.1-SNAPSHOT - ../parent-boot-2 + ../parent-spring-5 - com.fasterxml.jackson.core - jackson-databind + org.springframework + spring-oxm + ${spring.version} - org.springframework - spring-web + com.sun.mail + javax.mail + ${javax.mail.version} javax.servlet javax.servlet-api - provided + ${javax.servlet-api.version} + + + javax.servlet.jsp + javax.servlet.jsp-api + ${javax.servlet.jsp-api.version} + + + javax.servlet + jstl + ${jstl.version} + + + org.hibernate + hibernate-validator + ${hibernate-validator.version} + + + commons-fileupload + commons-fileupload + ${commons-fileupload.version} org.springframework spring-webmvc + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + + + + + org.thymeleaf + thymeleaf + ${org.thymeleaf-version} + + + org.thymeleaf + thymeleaf-spring4 + ${org.thymeleaf-version} + + + + + org.freemarker + freemarker + ${freemarker.version} + + + org.springframework + spring-context-support + ${spring.version} + + + + + org.codehaus.groovy + groovy-templates + ${groovy.version} + + + + + de.neuland-bfi + spring-jade4j + ${jade.version} + + + + org.apache.tiles + tiles-jsp + ${apache-tiles.version} + + + + + org.springframework + spring-test + ${spring.version} + test + + + com.rometools + rome + ${rome.version} + + + com.thoughtworks.xstream + xstream + ${xstream.version} + + + com.github.scribejava + scribejava-apis + ${scribejava.version} + + + org.json + json + ${json.version} + + + org.apache.maven.surefire + surefire-logger-api + ${maven-surefire-plugin.version} + + test + true - \ No newline at end of file + + spring-mvc-basics-2 + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + src/main/webapp + springMvcSimple + false + ${deploy-path} + + + + + + + + 1.8 + 1.8 + 2.21.0 + 2.3.2-b02 + 4.0.0 + 6.0.10.Final + enter-location-of-server + 1.3.2 + 3.0.7.RELEASE + 2.4.12 + 2.3.27-incubating + 1.2.5 + 1.9.0 + 1.4.9 + 5.1.0 + 20180130 + 3.0.8 + 1.6.1 + + + diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/FreemarkerConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/FreemarkerConfiguration.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/FreemarkerConfiguration.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/FreemarkerConfiguration.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/GroovyConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/GroovyConfiguration.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/GroovyConfiguration.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/GroovyConfiguration.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/JadeTemplateConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/JadeTemplateConfiguration.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/JadeTemplateConfiguration.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/JadeTemplateConfiguration.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/PushConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/PushConfiguration.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/PushConfiguration.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/PushConfiguration.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/TilesApplicationConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/TilesApplicationConfiguration.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/TilesApplicationConfiguration.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/TilesApplicationConfiguration.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/WebInitializer.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/configuration/WebInitializer.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java similarity index 97% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java index 89f5b2501b..30bda5c582 100644 --- a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java @@ -1,15 +1,15 @@ -package com.baeldung.spring.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.servlet.ModelAndView; - -@Controller -public class AnnotationMethodHandlerAdapterExample { - @RequestMapping("/annotedName") - public ModelAndView getEmployeeName() { - ModelAndView model = new ModelAndView("Greeting"); - model.addObject("message", "Dinesh"); - return model; - } +package com.baeldung.spring.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class AnnotationMethodHandlerAdapterExample { + @RequestMapping("/annotedName") + public ModelAndView getEmployeeName() { + ModelAndView model = new ModelAndView("Greeting"); + model.addObject("message", "Dinesh"); + return model; + } } \ No newline at end of file diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/CustomerController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/CustomerController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/CustomerController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/CustomerController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/EmployeeController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/EmployeeController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/EmployeeController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/EmployeeController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/FileUploadController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/FileUploadController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/FileUploadController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/FileUploadController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/MailController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/MailController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java similarity index 97% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java index 754bea79f1..628f853208 100644 --- a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java @@ -1,15 +1,15 @@ -package com.baeldung.spring.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.servlet.ModelAndView; - -@Controller -public class RequestMappingHandlerAdapterExample { - @RequestMapping("/requestName") - public ModelAndView getEmployeeName() { - ModelAndView model = new ModelAndView("Greeting"); - model.addObject("message", "Madhwal"); - return model; - } +package com.baeldung.spring.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class RequestMappingHandlerAdapterExample { + @RequestMapping("/requestName") + public ModelAndView getEmployeeName() { + ModelAndView model = new ModelAndView("Greeting"); + model.addObject("message", "Madhwal"); + return model; + } } \ No newline at end of file diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/RequestMethodController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMethodController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/RequestMethodController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMethodController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java similarity index 97% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java index 17c4ab689e..d3800d4e1c 100644 --- a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java @@ -1,16 +1,16 @@ -package com.baeldung.spring.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.AbstractController; - -public class SimpleControllerHandlerAdapterExample extends AbstractController { - @Override - protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { - ModelAndView model = new ModelAndView("Greeting"); - model.addObject("message", "Dinesh Madhwal"); - return model; - } +package com.baeldung.spring.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.AbstractController; + +public class SimpleControllerHandlerAdapterExample extends AbstractController { + @Override + protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { + ModelAndView model = new ModelAndView("Greeting"); + model.addObject("message", "Dinesh Madhwal"); + return model; + } } \ No newline at end of file diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/UserController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/UserController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/UserController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/UserController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/Article.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/Article.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/Article.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/Article.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/ArticleFeedView.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleFeedView.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/ArticleFeedView.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleFeedView.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/ArticleRssController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/ArticleRssController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/ArticleRssFeedViewResolver.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssFeedViewResolver.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/ArticleRssFeedViewResolver.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssFeedViewResolver.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/JsonChannelHttpMessageConverter.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/JsonChannelHttpMessageConverter.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/rss/JsonChannelHttpMessageConverter.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/JsonChannelHttpMessageConverter.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/scribe/GithubController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/GithubController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/scribe/GithubController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/GithubController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/scribe/TwitterController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/TwitterController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/scribe/TwitterController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/TwitterController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/controller/tiles/TilesController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/tiles/TilesController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/controller/tiles/TilesController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/tiles/TilesController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/domain/Customer.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Customer.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/domain/Customer.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Customer.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/domain/Employee.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Employee.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/domain/Employee.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Employee.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/domain/MailObject.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/domain/MailObject.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/domain/User.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/User.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/domain/User.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/User.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/exception/InvalidRequestException.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/exception/InvalidRequestException.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/exception/InvalidRequestException.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/exception/InvalidRequestException.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/interceptor/FileUploadExceptionAdvice.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/interceptor/FileUploadExceptionAdvice.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/interceptor/FileUploadExceptionAdvice.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/interceptor/FileUploadExceptionAdvice.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/mail/EmailService.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/mail/EmailService.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/push/controller/PushController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/push/controller/PushController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/push/controller/PushController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/push/controller/PushController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/requestparam/RequestParamController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/requestparam/RequestParamController.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/requestparam/RequestParamController.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/requestparam/RequestParamController.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/service/EmployeeService.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeService.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/service/EmployeeService.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeService.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/service/EmployeeServiceImpl.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeServiceImpl.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/service/EmployeeServiceImpl.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeServiceImpl.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/servlets/ForwardedServlet.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/ForwardedServlet.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/servlets/ForwardedServlet.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/ForwardedServlet.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/servlets/HelloServlet.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/HelloServlet.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/servlets/HelloServlet.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/HelloServlet.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/servlets/RedirectedServlet.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/RedirectedServlet.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/servlets/RedirectedServlet.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/RedirectedServlet.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/servlets/WelcomeServlet.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/WelcomeServlet.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/servlets/WelcomeServlet.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/WelcomeServlet.java diff --git a/spring-mvc-simple/src/main/java/com/baeldung/spring/validator/CustomerValidator.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/validator/CustomerValidator.java similarity index 100% rename from spring-mvc-simple/src/main/java/com/baeldung/spring/validator/CustomerValidator.java rename to spring-mvc-basics-2/src/main/java/com/baeldung/spring/validator/CustomerValidator.java diff --git a/spring-mvc-basics-2/src/main/resources/application.properties b/spring-mvc-basics-2/src/main/resources/application.properties index 709574239b..9a804c07d8 100644 --- a/spring-mvc-basics-2/src/main/resources/application.properties +++ b/spring-mvc-basics-2/src/main/resources/application.properties @@ -1 +1,22 @@ -spring.main.allow-bean-definition-overriding=true \ No newline at end of file +#this property file will have to be loaded explicitly as this is not a Spring Boot project + +# Gmail SMTP +spring.mail.host=smtp.gmail.com +spring.mail.port=587 +spring.mail.username=username +spring.mail.password=password +spring.mail.properties.mail.smtp.auth=true +spring.mail.properties.mail.smtp.starttls.enable=true + +# Amazon SES SMTP +#spring.mail.host=email-smtp.us-west-2.amazonaws.com +#spring.mail.username=username +#spring.mail.password=password +#spring.mail.properties.mail.transport.protocol=smtp +#spring.mail.properties.mail.smtp.port=25 +#spring.mail.properties.mail.smtp.auth=true +#spring.mail.properties.mail.smtp.starttls.enable=true +#spring.mail.properties.mail.smtp.starttls.required=true + +# path to attachment file +attachment.invoice=path_to_file \ No newline at end of file diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/Greeting.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/Greeting.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/Greeting.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/Greeting.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/Greeting.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/Greeting.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/Greeting.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/Greeting.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/customerHome.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerHome.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/customerHome.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerHome.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/customerView.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerView.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/customerView.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerView.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/demo.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/demo.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/demo.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/demo.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/emails.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/emails.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/employeeHome.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeHome.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/employeeHome.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeHome.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/employeeView.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeView.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/employeeView.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeView.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/error.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/error.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/error.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/error.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/file.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/file.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/file.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/file.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/mail/send.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/send.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/mail/send.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/send.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/pages/apachetiles.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/apachetiles.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/pages/apachetiles.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/apachetiles.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/pages/home.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/home.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/pages/home.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/home.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/pages/springmvc.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/springmvc.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/pages/springmvc.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/springmvc.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/registration-freemarker.ftl b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-freemarker.ftl similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/registration-freemarker.ftl rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-freemarker.ftl diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/registration-groovy.tpl b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-groovy.tpl similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/registration-groovy.tpl rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-groovy.tpl diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/registration-jade.jade b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-jade.jade similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/registration-jade.jade rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-jade.jade diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/registration-thymeleaf.html b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-thymeleaf.html similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/registration-thymeleaf.html rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-thymeleaf.html diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/registration.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/registration.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp diff --git a/spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/tiles.xml b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/tiles.xml similarity index 100% rename from spring-mvc-simple/src/main/webapp/WEB-INF/views/tiles/tiles.xml rename to spring-mvc-basics-2/src/main/webapp/WEB-INF/views/tiles/tiles.xml diff --git a/spring-mvc-simple/src/main/webapp/resources/logo.png b/spring-mvc-basics-2/src/main/webapp/resources/logo.png similarity index 100% rename from spring-mvc-simple/src/main/webapp/resources/logo.png rename to spring-mvc-basics-2/src/main/webapp/resources/logo.png diff --git a/spring-mvc-simple/src/main/webapp/static/css/app.css b/spring-mvc-basics-2/src/main/webapp/static/css/app.css similarity index 100% rename from spring-mvc-simple/src/main/webapp/static/css/app.css rename to spring-mvc-basics-2/src/main/webapp/static/css/app.css diff --git a/spring-mvc-simple/src/test/java/com/baeldung/SpringContextTest.java b/spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-mvc-simple/src/test/java/com/baeldung/SpringContextTest.java rename to spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-mvc-simple/src/test/java/com/baeldung/controller/push/PushControllerIntegrationTest.java b/spring-mvc-basics-2/src/test/java/com/baeldung/controller/push/PushControllerIntegrationTest.java similarity index 100% rename from spring-mvc-simple/src/test/java/com/baeldung/controller/push/PushControllerIntegrationTest.java rename to spring-mvc-basics-2/src/test/java/com/baeldung/controller/push/PushControllerIntegrationTest.java diff --git a/spring-mvc-simple/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java b/spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java similarity index 100% rename from spring-mvc-simple/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java rename to spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java diff --git a/spring-mvc-simple/src/test/java/com/baeldung/spring/servlets/HelloServletIntegrationTest.java b/spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/HelloServletIntegrationTest.java similarity index 100% rename from spring-mvc-simple/src/test/java/com/baeldung/spring/servlets/HelloServletIntegrationTest.java rename to spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/HelloServletIntegrationTest.java diff --git a/spring-mvc-simple/src/test/java/com/baeldung/spring/servlets/WelcomeServletIntegrationTest.java b/spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/WelcomeServletIntegrationTest.java similarity index 100% rename from spring-mvc-simple/src/test/java/com/baeldung/spring/servlets/WelcomeServletIntegrationTest.java rename to spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/WelcomeServletIntegrationTest.java diff --git a/spring-mvc-simple-2/README.md b/spring-mvc-basics-3/README.md similarity index 80% rename from spring-mvc-simple-2/README.md rename to spring-mvc-basics-3/README.md index 3d240531ae..180cee498b 100644 --- a/spring-mvc-simple-2/README.md +++ b/spring-mvc-basics-3/README.md @@ -1,4 +1,4 @@ -## Spring MVC Simple 2 +## Spring MVC Basics 3 This module contains articles about Spring MVC @@ -11,4 +11,5 @@ This module contains articles about Spring MVC - [Using Enums as Request Parameters in Spring](https://www.baeldung.com/spring-enum-request-param) - [Excluding URLs for a Filter in a Spring Web Application](https://www.baeldung.com/spring-exclude-filter) - [Guide to Flash Attributes in a Spring Web Application](https://www.baeldung.com/spring-web-flash-attributes) -- More articles: [[<-- prev]](/spring-mvc-simple) +- [Handling URL Encoded Form Data in Spring REST](https://www.baeldung.com/spring-url-encoded-form-data) +- More articles: [[<-- prev]](/spring-mvc-basics-2)[[more -->]](/spring-mvc-basics-4) diff --git a/spring-mvc-simple-2/pom.xml b/spring-mvc-basics-3/pom.xml similarity index 98% rename from spring-mvc-simple-2/pom.xml rename to spring-mvc-basics-3/pom.xml index 307e8bc94b..48b1e51dd3 100644 --- a/spring-mvc-simple-2/pom.xml +++ b/spring-mvc-basics-3/pom.xml @@ -2,8 +2,8 @@ 4.0.0 - spring-mvc-simple-2 - spring-mvc-simple-2 + spring-mvc-basics-3 + spring-mvc-basics-3 war Demo project for Spring Boot diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/Application.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/Application.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/Application.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/Application.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/config/WebConfig.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/config/WebConfig.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/config/WebConfig.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/config/WebConfig.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/controller/GenericEntityController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/controller/GenericEntityController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/controller/GenericEntityController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/controller/GenericEntityController.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/StringToAbstractEntityConverterFactory.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToAbstractEntityConverterFactory.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/StringToAbstractEntityConverterFactory.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToAbstractEntityConverterFactory.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/StringToEnumConverter.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEnumConverter.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/StringToEnumConverter.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEnumConverter.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/StringToLocalDateTimeConverter.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToLocalDateTimeConverter.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/StringToLocalDateTimeConverter.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToLocalDateTimeConverter.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/controller/AbstractEntityController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/AbstractEntityController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/controller/AbstractEntityController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/AbstractEntityController.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/AbstractEntity.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/AbstractEntity.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/AbstractEntity.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/AbstractEntity.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/Bar.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Bar.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/Bar.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Bar.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/Employee.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Employee.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/Employee.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Employee.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/Foo.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Foo.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/Foo.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Foo.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/GenericEntity.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/GenericEntity.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/GenericEntity.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/GenericEntity.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/Modes.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Modes.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/domain/Modes.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Modes.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/repository/GenericEntityRepository.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/repository/GenericEntityRepository.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/repository/GenericEntityRepository.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/repository/GenericEntityRepository.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/web/resolver/HeaderVersionArgumentResolver.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/HeaderVersionArgumentResolver.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/web/resolver/HeaderVersionArgumentResolver.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/HeaderVersionArgumentResolver.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/boot/web/resolver/Version.java b/spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/Version.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/boot/web/resolver/Version.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/Version.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/CachedBodyHttpServletRequest.java b/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequest.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/CachedBodyHttpServletRequest.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequest.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/CachedBodyServletInputStream.java b/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyServletInputStream.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/CachedBodyServletInputStream.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyServletInputStream.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/ContentCachingFilter.java b/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/ContentCachingFilter.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/ContentCachingFilter.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/ContentCachingFilter.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/HttpRequestDemoConfig.java b/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/HttpRequestDemoConfig.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/HttpRequestDemoConfig.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/HttpRequestDemoConfig.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/Person.java b/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/Person.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/Person.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/Person.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/PersonController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PersonController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/PersonController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PersonController.java diff --git a/spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/PrintRequestContentFilter.java b/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PrintRequestContentFilter.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/org/baeldung/cachedrequest/PrintRequestContentFilter.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PrintRequestContentFilter.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/Application.java b/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/Application.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/Application.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/Application.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java b/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java b/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java b/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java b/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java b/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java b/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/flash_attributes/Application.java b/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/Application.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/flash_attributes/Application.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/Application.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/flash_attributes/controllers/PoemSubmission.java b/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/controllers/PoemSubmission.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/flash_attributes/controllers/PoemSubmission.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/controllers/PoemSubmission.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/flash_attributes/model/Poem.java b/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/model/Poem.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/flash_attributes/model/Poem.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/model/Poem.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/form_submission/Application.java b/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/Application.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/form_submission/Application.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/Application.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java b/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/form_submission/model/Feedback.java b/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/model/Feedback.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/form_submission/model/Feedback.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/model/Feedback.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java b/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/NotNullRequest.java b/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/NotNullRequest.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/NotNullRequest.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/NotNullRequest.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationController.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationExamples.java b/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationExamples.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationExamples.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationExamples.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/Application.java b/spring-mvc-basics-3/src/main/java/com/baeldung/spring/Application.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/spring/Application.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/spring/Application.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/MvcConfig.java b/spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/MvcConfig.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/MvcConfig.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/MvcConfig.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java b/spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/enums/EnumController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/spring/enums/EnumController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/spring/enums/EnumController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/spring/enums/EnumController.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java b/spring-mvc-basics-3/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/headers/controller/ReadHeaderRestController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/spring/headers/controller/ReadHeaderRestController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/spring/headers/controller/ReadHeaderRestController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/spring/headers/controller/ReadHeaderRestController.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/model/Modes.java b/spring-mvc-basics-3/src/main/java/com/baeldung/spring/model/Modes.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/spring/model/Modes.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/spring/model/Modes.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/Application.java b/spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/Application.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/Application.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/Application.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/SlashParsingController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/SlashParsingController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/SlashParsingController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/SlashParsingController.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/SpringListValidationApplication.java b/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/SpringListValidationApplication.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/SpringListValidationApplication.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/SpringListValidationApplication.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraint.java b/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraint.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraint.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraint.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java b/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/controller/MovieController.java b/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/controller/MovieController.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/controller/MovieController.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/controller/MovieController.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/exception/ConstraintViolationExceptionHandler.java b/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/exception/ConstraintViolationExceptionHandler.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/exception/ConstraintViolationExceptionHandler.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/exception/ConstraintViolationExceptionHandler.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/model/Movie.java b/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/model/Movie.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/model/Movie.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/model/Movie.java diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/service/MovieService.java b/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/service/MovieService.java similarity index 100% rename from spring-mvc-simple-2/src/main/java/com/baeldung/validation/listvalidation/service/MovieService.java rename to spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/service/MovieService.java diff --git a/spring-mvc-simple-2/src/main/resources/application.properties b/spring-mvc-basics-3/src/main/resources/application.properties similarity index 100% rename from spring-mvc-simple-2/src/main/resources/application.properties rename to spring-mvc-basics-3/src/main/resources/application.properties diff --git a/spring-mvc-simple-2/src/main/resources/templates/feedback.html b/spring-mvc-basics-3/src/main/resources/templates/feedback.html similarity index 100% rename from spring-mvc-simple-2/src/main/resources/templates/feedback.html rename to spring-mvc-basics-3/src/main/resources/templates/feedback.html diff --git a/spring-mvc-simple-2/src/main/resources/templates/submit.html b/spring-mvc-basics-3/src/main/resources/templates/submit.html similarity index 100% rename from spring-mvc-simple-2/src/main/resources/templates/submit.html rename to spring-mvc-basics-3/src/main/resources/templates/submit.html diff --git a/spring-mvc-simple-2/src/main/resources/templates/success.html b/spring-mvc-basics-3/src/main/resources/templates/success.html similarity index 100% rename from spring-mvc-simple-2/src/main/resources/templates/success.html rename to spring-mvc-basics-3/src/main/resources/templates/success.html diff --git a/spring-mvc-simple-2/src/test/java/com/baeldung/AppContextIntegrationTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/AppContextIntegrationTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/com/baeldung/AppContextIntegrationTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/AppContextIntegrationTest.java diff --git a/spring-mvc-simple-2/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java similarity index 75% rename from spring-mvc-simple-2/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java index 7190c4f427..bccca58aea 100644 --- a/spring-mvc-simple-2/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java +++ b/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java @@ -16,8 +16,6 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import java.nio.charset.Charset; - import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; @@ -39,31 +37,23 @@ public class SpringBootApplicationIntegrationTest { @Test public void givenRequestHasBeenMade_whenMeetsAllOfGivenConditions_thenCorrect() throws Exception { - MediaType contentType = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8")); - - mockMvc.perform(MockMvcRequestBuilders.get("/entity/all")).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().contentType(contentType)).andExpect(jsonPath("$", hasSize(4))); + mockMvc.perform(MockMvcRequestBuilders.get("/entity/all")).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$", hasSize(4))); } @Test public void givenRequestHasBeenMade_whenMeetsFindByDateOfGivenConditions_thenCorrect() throws Exception { - MediaType contentType = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8")); - - mockMvc.perform(MockMvcRequestBuilders.get("/entity/findbydate/{date}", "2011-12-03T10:15:30")).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().contentType(contentType)) + mockMvc.perform(MockMvcRequestBuilders.get("/entity/findbydate/{date}", "2011-12-03T10:15:30")).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id", equalTo(1))); } @Test public void givenRequestHasBeenMade_whenMeetsFindByModeOfGivenConditions_thenCorrect() throws Exception { - MediaType contentType = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8")); - - mockMvc.perform(MockMvcRequestBuilders.get("/entity/findbymode/{mode}", Modes.ALPHA.name())).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().contentType(contentType)).andExpect(jsonPath("$.id", equalTo(1))); + mockMvc.perform(MockMvcRequestBuilders.get("/entity/findbymode/{mode}", Modes.ALPHA.name())).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$.id", equalTo(1))); } @Test public void givenRequestHasBeenMade_whenMeetsFindByVersionOfGivenConditions_thenCorrect() throws Exception { - MediaType contentType = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8")); - - mockMvc.perform(MockMvcRequestBuilders.get("/entity/findbyversion").header("Version", "1.0.0")).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().contentType(contentType)) + mockMvc.perform(MockMvcRequestBuilders.get("/entity/findbyversion").header("Version", "1.0.0")).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id", equalTo(1))); } } \ No newline at end of file diff --git a/spring-mvc-simple-2/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java diff --git a/spring-mvc-simple-2/src/test/java/com/baeldung/SpringBootMailIntegrationTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootMailIntegrationTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/com/baeldung/SpringBootMailIntegrationTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootMailIntegrationTest.java diff --git a/spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/CachedBodyHttpServletRequestUnitTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequestUnitTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/CachedBodyHttpServletRequestUnitTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequestUnitTest.java diff --git a/spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/CachedBodyServletInputStreamUnitTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyServletInputStreamUnitTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/CachedBodyServletInputStreamUnitTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyServletInputStreamUnitTest.java diff --git a/spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/ContentCachingFilterUnitTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/ContentCachingFilterUnitTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/ContentCachingFilterUnitTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/ContentCachingFilterUnitTest.java diff --git a/spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/PersonControllerIntegrationTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PersonControllerIntegrationTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/PersonControllerIntegrationTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PersonControllerIntegrationTest.java diff --git a/spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/PrintRequestContentFilterUnitTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PrintRequestContentFilterUnitTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/org/baeldung/cachedrequest/PrintRequestContentFilterUnitTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PrintRequestContentFilterUnitTest.java diff --git a/spring-mvc-simple-2/src/test/java/com/baeldung/headers/controller/ReadHeaderRestControllerIntegrationTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/headers/controller/ReadHeaderRestControllerIntegrationTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/com/baeldung/headers/controller/ReadHeaderRestControllerIntegrationTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/headers/controller/ReadHeaderRestControllerIntegrationTest.java diff --git a/spring-mvc-simple-2/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java diff --git a/spring-mvc-simple-2/src/test/java/com/baeldung/validation/listvalidation/MovieControllerIntegrationTest.java b/spring-mvc-basics-3/src/test/java/com/baeldung/validation/listvalidation/MovieControllerIntegrationTest.java similarity index 100% rename from spring-mvc-simple-2/src/test/java/com/baeldung/validation/listvalidation/MovieControllerIntegrationTest.java rename to spring-mvc-basics-3/src/test/java/com/baeldung/validation/listvalidation/MovieControllerIntegrationTest.java diff --git a/jackson-simple/.gitignore b/spring-mvc-basics-4/.gitignore similarity index 100% rename from jackson-simple/.gitignore rename to spring-mvc-basics-4/.gitignore diff --git a/spring-mvc-basics-4/README.md b/spring-mvc-basics-4/README.md new file mode 100644 index 0000000000..19cb9059ed --- /dev/null +++ b/spring-mvc-basics-4/README.md @@ -0,0 +1,11 @@ +## Spring MVC Basics with Java Configuration Example Project + +### The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + +### Relevant Articles: +- [Quick Guide to Spring Controllers](https://www.baeldung.com/spring-controllers) +- [Model, ModelMap, and ModelView in Spring MVC](https://www.baeldung.com/spring-mvc-model-model-map-model-view) +- [Spring Web Contexts](https://www.baeldung.com/spring-web-contexts) +- [Spring Optional Path variables](https://www.baeldung.com/spring-optional-path-variables) +- More articles: [[<-- prev]](/spring-mvc-basics-3) \ No newline at end of file diff --git a/spring-mvc-basics-4/pom.xml b/spring-mvc-basics-4/pom.xml new file mode 100644 index 0000000000..8382cd03b8 --- /dev/null +++ b/spring-mvc-basics-4/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + spring-mvc-basics-4 + spring-mvc-basics-4 + war + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + com.fasterxml.jackson.core + jackson-databind + + + org.springframework + spring-web + + + javax.servlet + javax.servlet-api + provided + + + org.springframework + spring-webmvc + + + + \ No newline at end of file diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/Greeting.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/Greeting.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/Greeting.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/Greeting.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/contexts/services/GreeterService.java b/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/GreeterService.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/contexts/services/GreeterService.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/GreeterService.java diff --git a/spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/StudentControllerConfig.java b/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/StudentControllerConfig.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/StudentControllerConfig.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/StudentControllerConfig.java diff --git a/spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/WebConfig.java b/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/org/baeldung/controller/config/WebConfig.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java diff --git a/spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/PassParametersController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/PassParametersController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/PassParametersController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/PassParametersController.java diff --git a/spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/RestAnnotatedController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestAnnotatedController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/RestAnnotatedController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestAnnotatedController.java diff --git a/spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/RestController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/RestController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestController.java diff --git a/spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/TestController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/TestController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/org/baeldung/controller/controller/TestController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/TestController.java diff --git a/spring-mvc-basics-2/src/main/java/org/baeldung/controller/student/Student.java b/spring-mvc-basics-4/src/main/java/com/baeldung/controller/student/Student.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/org/baeldung/controller/student/Student.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/controller/student/Student.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/Article.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/Article.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithMapParamController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithMapParamController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithOptionalParamController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithOptionalParamController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithRequiredAttributeController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithRequiredAttributeController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java b/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java rename to spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java diff --git a/spring-mvc-basics-4/src/main/resources/application.properties b/spring-mvc-basics-4/src/main/resources/application.properties new file mode 100644 index 0000000000..709574239b --- /dev/null +++ b/spring-mvc-basics-4/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.main.allow-bean-definition-overriding=true \ No newline at end of file diff --git a/spring-boot-runtime/src/main/resources/logback.xml b/spring-mvc-basics-4/src/main/resources/logback.xml similarity index 100% rename from spring-boot-runtime/src/main/resources/logback.xml rename to spring-mvc-basics-4/src/main/resources/logback.xml diff --git a/spring-mvc-basics-2/src/main/resources/test-mvc.xml b/spring-mvc-basics-4/src/main/resources/test-mvc.xml similarity index 100% rename from spring-mvc-basics-2/src/main/resources/test-mvc.xml rename to spring-mvc-basics-4/src/main/resources/test-mvc.xml diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/greeting.xml b/spring-mvc-basics-4/src/main/webapp/WEB-INF/greeting.xml similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/greeting.xml rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/greeting.xml diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/index.jsp b/spring-mvc-basics-4/src/main/webapp/WEB-INF/index.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/index.jsp rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/index.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/normal-webapp-servlet.xml b/spring-mvc-basics-4/src/main/webapp/WEB-INF/normal-webapp-servlet.xml similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/normal-webapp-servlet.xml rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/normal-webapp-servlet.xml diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/rootApplicationContext.xml b/spring-mvc-basics-4/src/main/webapp/WEB-INF/rootApplicationContext.xml similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/rootApplicationContext.xml rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/rootApplicationContext.xml diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/secure-webapp-servlet.xml b/spring-mvc-basics-4/src/main/webapp/WEB-INF/secure-webapp-servlet.xml similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/secure-webapp-servlet.xml rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/secure-webapp-servlet.xml diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/secure/view/welcome.jsp b/spring-mvc-basics-4/src/main/webapp/WEB-INF/secure/view/welcome.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/secure/view/welcome.jsp rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/secure/view/welcome.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/sample.jsp b/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/scopesExample.jsp b/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/scopesExample.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/view/scopesExample.jsp rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/view/scopesExample.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/viewPage.html b/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/viewPage.html similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/view/viewPage.html rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/view/viewPage.html diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/view/welcome.jsp b/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/welcome.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/view/welcome.jsp rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/view/welcome.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/web-old.xml b/spring-mvc-basics-4/src/main/webapp/WEB-INF/web-old.xml similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/web-old.xml rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/web-old.xml diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/welcome.jsp b/spring-mvc-basics-4/src/main/webapp/WEB-INF/welcome.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/welcome.jsp rename to spring-mvc-basics-4/src/main/webapp/WEB-INF/welcome.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/index.jsp b/spring-mvc-basics-4/src/main/webapp/index.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/index.jsp rename to spring-mvc-basics-4/src/main/webapp/index.jsp diff --git a/spring-mvc-basics-2/src/test/java/org/baeldung/controller/ControllerAnnotationIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerAnnotationIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/org/baeldung/controller/ControllerAnnotationIntegrationTest.java rename to spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerAnnotationIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/org/baeldung/controller/ControllerIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/org/baeldung/controller/ControllerIntegrationTest.java rename to spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/org/baeldung/controller/PassParametersControllerIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/controller/PassParametersControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/org/baeldung/controller/PassParametersControllerIntegrationTest.java rename to spring-mvc-basics-4/src/test/java/com/baeldung/controller/PassParametersControllerIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerControllerIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerControllerIntegrationTest.java rename to spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java rename to spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java rename to spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java rename to spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java b/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java rename to spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/resources/test-mvc.xml b/spring-mvc-basics-4/src/test/resources/test-mvc.xml similarity index 100% rename from spring-mvc-basics-2/src/test/resources/test-mvc.xml rename to spring-mvc-basics-4/src/test/resources/test-mvc.xml diff --git a/spring-mvc-basics/README.md b/spring-mvc-basics/README.md index a995c89a07..cd36ffd94a 100644 --- a/spring-mvc-basics/README.md +++ b/spring-mvc-basics/README.md @@ -17,4 +17,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Using Spring @ResponseStatus to Set HTTP Status Code](https://www.baeldung.com/spring-response-status) - [Spring MVC and the @ModelAttribute Annotation](https://www.baeldung.com/spring-mvc-and-the-modelattribute-annotation) - [The HttpMediaTypeNotAcceptableException in Spring MVC](https://www.baeldung.com/spring-httpmediatypenotacceptable) -- [[Next -->]](/spring-mvc-basics-2) \ No newline at end of file +- More articles: [[more -->]](/spring-mvc-basics-2) \ No newline at end of file diff --git a/spring-mvc-basics/pom.xml b/spring-mvc-basics/pom.xml index ab6d200e67..159dda955f 100644 --- a/spring-mvc-basics/pom.xml +++ b/spring-mvc-basics/pom.xml @@ -38,6 +38,7 @@ + spring-mvc-basics org.springframework.boot diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/userHome.jsp b/spring-mvc-basics/src/main/webapp/WEB-INF/view/userHome.jsp new file mode 100644 index 0000000000..38c08d5a18 --- /dev/null +++ b/spring-mvc-basics/src/main/webapp/WEB-INF/view/userHome.jsp @@ -0,0 +1,55 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> + + + + + User Form + + + +
+ +

New User

+
${message}
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+
+ + diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerContentNegotiationIntegrationTest.java b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerContentNegotiationIntegrationTest.java index 6500955d23..4ccba79f9c 100644 --- a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerContentNegotiationIntegrationTest.java +++ b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerContentNegotiationIntegrationTest.java @@ -1,9 +1,5 @@ package com.baeldung.web.controller; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -12,6 +8,10 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @SpringBootTest @AutoConfigureMockMvc public class EmployeeControllerContentNegotiationIntegrationTest { @@ -23,7 +23,7 @@ public class EmployeeControllerContentNegotiationIntegrationTest { public void whenEndpointUsingJsonSuffixCalled_thenJsonResponseObtained() throws Exception { this.mockMvc.perform(get("/employee/1.json")) .andExpect(status().isOk()) - .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)); } @Test @@ -37,7 +37,7 @@ public class EmployeeControllerContentNegotiationIntegrationTest { public void whenEndpointUsingJsonParameterCalled_thenJsonResponseObtained() throws Exception { this.mockMvc.perform(get("/employee/1?mediaType=json")) .andExpect(status().isOk()) - .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)); } @Test @@ -51,7 +51,7 @@ public class EmployeeControllerContentNegotiationIntegrationTest { public void whenEndpointUsingJsonAcceptHeaderCalled_thenJsonResponseObtained() throws Exception { this.mockMvc.perform(get("/employee/1").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)) .andExpect(status().isOk()) - .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)); } @Test diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java index 87d70c2d29..8071828fa3 100644 --- a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java +++ b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java @@ -1,19 +1,17 @@ package com.baeldung.web.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.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + public class SimpleBookControllerIntegrationTest { private MockMvc mockMvc; - private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; @BeforeEach public void setup() { @@ -25,7 +23,7 @@ public class SimpleBookControllerIntegrationTest { this.mockMvc .perform(get("/books/42")) .andExpect(status().isOk()) - .andExpect(content().contentType(CONTENT_TYPE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id").value(42)); } diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java index 294943f2e2..1062280f3b 100644 --- a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java +++ b/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java @@ -1,19 +1,17 @@ package com.baeldung.web.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.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + public class SimpleBookRestControllerIntegrationTest { private MockMvc mockMvc; - private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; @BeforeEach public void setup() { @@ -25,7 +23,7 @@ public class SimpleBookRestControllerIntegrationTest { this.mockMvc .perform(get("/books-rest/42")) .andExpect(status().isOk()) - .andExpect(content().contentType(CONTENT_TYPE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id").value(42)); } diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index 7088162496..ff1f7830b6 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -7,17 +7,12 @@ This module contains articles about Spring MVC with Java configuration The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Introduction to Pointcut Expressions in Spring](https://www.baeldung.com/spring-aop-pointcut-tutorial) -- [Introduction to Advice Types in Spring](https://www.baeldung.com/spring-aop-advice-tutorial) - [Integration Testing in Spring](https://www.baeldung.com/integration-testing-in-spring) - [A Quick Guide to Spring MVC Matrix Variables](https://www.baeldung.com/spring-mvc-matrix-variables) -- [Intro to WebSockets with Spring](https://www.baeldung.com/websockets-spring) - [File Upload with Spring MVC](https://www.baeldung.com/spring-file-upload) - [Introduction to HtmlUnit](https://www.baeldung.com/htmlunit) - [Upload and Display Excel Files with Spring MVC](https://www.baeldung.com/spring-mvc-excel-files) - [web.xml vs Initializer with Spring](https://www.baeldung.com/spring-xml-vs-java-config) - [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot) -- [A Quick Example of Spring Websockets’ @SendToUser Annotation](https://www.baeldung.com/spring-websockets-sendtouser) - [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters) - [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) -- [The HttpMediaTypeNotAcceptableException in Spring MVC](https://www.baeldung.com/spring-httpmediatypenotacceptable) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 7d0afd85ec..0f3a1d65b9 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -26,12 +26,12 @@ javax.servlet javax.servlet-api - 4.0.1 + ${javax.version} javax.servlet.jsp javax.servlet.jsp-api - 2.3.3 + ${javax-servlet-api.version} javax.servlet @@ -48,24 +48,11 @@ jackson-databind ${jackson.version} - - - - org.aspectj - aspectjrt - 1.9.1 - - - org.aspectj - aspectjweaver - 1.9.1 - - net.sourceforge.htmlunit htmlunit - 2.32 + ${htmlunit.version} commons-logging @@ -99,7 +86,7 @@ com.jayway.jsonpath json-path test - 2.4.0 + ${json-path.version} org.springframework.boot @@ -120,18 +107,6 @@ hibernate-validator ${hibernate-validator.version} - - - - - com.google.code.gson - gson - 2.8.5 - - - org.springframework.boot - spring-boot-starter-websocket - org.glassfish javax.el @@ -248,6 +223,8 @@ + 2.1.9.RELEASE + 3.0.9.RELEASE @@ -283,6 +260,10 @@ 3.16-beta1 3.0.1-b09 + 4.0.1 + 2.3.3 + 2.32 + 2.4.0 com.baeldung.SpringMVCApplication diff --git a/spring-mvc-java/src/test/java/com/baeldung/SpringContextTest.java b/spring-mvc-java/src/test/java/com/baeldung/SpringContextTest.java deleted file mode 100644 index 8943ecb548..0000000000 --- a/spring-mvc-java/src/test/java/com/baeldung/SpringContextTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import com.baeldung.config.TestConfig; - -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = {TestConfig.class}) -public class SpringContextTest { - - @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { - - } -} diff --git a/spring-mvc-java/src/test/java/com/baeldung/config/TestConfig.java b/spring-mvc-java/src/test/java/com/baeldung/config/TestConfig.java deleted file mode 100644 index 641513a24a..0000000000 --- a/spring-mvc-java/src/test/java/com/baeldung/config/TestConfig.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.EnableAspectJAutoProxy; - -@Configuration -@ComponentScan(basePackages = { "com.baeldung.dao", "com.baeldung.aop", "com.baeldung.events" }) -@EnableAspectJAutoProxy -public class TestConfig { -} diff --git a/spring-mvc-simple/README.md b/spring-mvc-simple/README.md deleted file mode 100644 index ae03fedf3c..0000000000 --- a/spring-mvc-simple/README.md +++ /dev/null @@ -1,15 +0,0 @@ -## Spring MVC Simple - -This module contains articles about Spring MVC - -## Relevant articles: - -- [HandlerAdapters in Spring MVC](https://www.baeldung.com/spring-mvc-handler-adapters) -- [Template Engines for Spring](https://www.baeldung.com/spring-template-engines) -- [Spring 5 and Servlet 4 – The PushBuilder](https://www.baeldung.com/spring-5-push) -- [Servlet Redirect vs Forward](https://www.baeldung.com/servlet-redirect-forward) -- [Apache Tiles Integration with Spring MVC](https://www.baeldung.com/spring-mvc-apache-tiles) -- [Guide to Spring Email](https://www.baeldung.com/spring-email) -- [Request Method Not Supported (405) in Spring](https://www.baeldung.com/spring-request-method-not-supported-405) -- [Spring @RequestParam Annotation](https://www.baeldung.com/spring-request-param) -- More articles: [[more -->]](/spring-mvc-simple-2) \ No newline at end of file diff --git a/spring-mvc-simple/pom.xml b/spring-mvc-simple/pom.xml deleted file mode 100644 index 539e81307a..0000000000 --- a/spring-mvc-simple/pom.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - 4.0.0 - spring-mvc-simple - 0.0.1-SNAPSHOT - spring-mvc-simple - war - - - com.baeldung - parent-spring-5 - 0.0.1-SNAPSHOT - ../parent-spring-5 - - - - - org.springframework - spring-oxm - ${spring.version} - - - com.sun.mail - javax.mail - ${javax.mail.version} - - - javax.servlet - javax.servlet-api - ${javax.servlet-api.version} - - - javax.servlet.jsp - javax.servlet.jsp-api - ${javax.servlet.jsp-api.version} - - - javax.servlet - jstl - ${jstl.version} - - - org.hibernate - hibernate-validator - ${hibernate-validator.version} - - - commons-fileupload - commons-fileupload - ${commons-fileupload.version} - - - org.springframework - spring-webmvc - ${spring.version} - - - org.springframework - spring-tx - ${spring.version} - - - - - org.thymeleaf - thymeleaf - ${org.thymeleaf-version} - - - org.thymeleaf - thymeleaf-spring4 - ${org.thymeleaf-version} - - - - - org.freemarker - freemarker - ${freemarker.version} - - - org.springframework - spring-context-support - ${spring.version} - - - - - org.codehaus.groovy - groovy-templates - ${groovy.version} - - - - - de.neuland-bfi - spring-jade4j - ${jade.version} - - - - org.apache.tiles - tiles-jsp - ${apache-tiles.version} - - - - - org.springframework - spring-test - ${spring.version} - test - - - com.rometools - rome - ${rome.version} - - - com.thoughtworks.xstream - xstream - ${xstream.version} - - - com.github.scribejava - scribejava-apis - ${scribejava.version} - - - org.json - json - ${json.version} - - - org.apache.maven.surefire - surefire-logger-api - ${maven-surefire-plugin.version} - - test - true - - - - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - src/main/webapp - springMvcSimple - false - ${deploy-path} - - - - - spring-mvc-simple - - - - 1.8 - 1.8 - 2.21.0 - 2.3.2-b02 - 4.0.0 - 6.0.10.Final - enter-location-of-server - 1.3.2 - 3.0.7.RELEASE - 2.4.12 - 2.3.27-incubating - 1.2.5 - 1.9.0 - 1.4.9 - 5.1.0 - 20180130 - 3.0.8 - 1.6.1 - - - diff --git a/spring-mvc-simple/src/main/resources/application.properties b/spring-mvc-simple/src/main/resources/application.properties deleted file mode 100644 index 9a804c07d8..0000000000 --- a/spring-mvc-simple/src/main/resources/application.properties +++ /dev/null @@ -1,22 +0,0 @@ -#this property file will have to be loaded explicitly as this is not a Spring Boot project - -# Gmail SMTP -spring.mail.host=smtp.gmail.com -spring.mail.port=587 -spring.mail.username=username -spring.mail.password=password -spring.mail.properties.mail.smtp.auth=true -spring.mail.properties.mail.smtp.starttls.enable=true - -# Amazon SES SMTP -#spring.mail.host=email-smtp.us-west-2.amazonaws.com -#spring.mail.username=username -#spring.mail.password=password -#spring.mail.properties.mail.transport.protocol=smtp -#spring.mail.properties.mail.smtp.port=25 -#spring.mail.properties.mail.smtp.auth=true -#spring.mail.properties.mail.smtp.starttls.enable=true -#spring.mail.properties.mail.smtp.starttls.required=true - -# path to attachment file -attachment.invoice=path_to_file \ No newline at end of file diff --git a/spring-mvc-views/README.md b/spring-mvc-views/README.md new file mode 100644 index 0000000000..7aa05699f3 --- /dev/null +++ b/spring-mvc-views/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Spring MVC Themes](https://www.baeldung.com/spring-mvc-themes) diff --git a/spring-mvc-views/src/main/java/com/baeldung/config/DataSourceConfig.java b/spring-mvc-views/src/main/java/com/baeldung/themes/config/DataSourceConfig.java similarity index 94% rename from spring-mvc-views/src/main/java/com/baeldung/config/DataSourceConfig.java rename to spring-mvc-views/src/main/java/com/baeldung/themes/config/DataSourceConfig.java index 803c30f29d..3b1abfd459 100644 --- a/spring-mvc-views/src/main/java/com/baeldung/config/DataSourceConfig.java +++ b/spring-mvc-views/src/main/java/com/baeldung/themes/config/DataSourceConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.themes.config; import org.springframework.context.annotation.Bean; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -27,7 +27,7 @@ public class DataSourceConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource); - em.setPackagesToScan("com.baeldung.domain"); + em.setPackagesToScan("com.baeldung.themes.domain"); em.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); return em; } diff --git a/spring-mvc-views/src/main/java/com/baeldung/config/InitSecurity.java b/spring-mvc-views/src/main/java/com/baeldung/themes/config/InitSecurity.java similarity index 82% rename from spring-mvc-views/src/main/java/com/baeldung/config/InitSecurity.java rename to spring-mvc-views/src/main/java/com/baeldung/themes/config/InitSecurity.java index 2bf659f476..929e49cb79 100644 --- a/spring-mvc-views/src/main/java/com/baeldung/config/InitSecurity.java +++ b/spring-mvc-views/src/main/java/com/baeldung/themes/config/InitSecurity.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.themes.config; import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; diff --git a/spring-mvc-views/src/main/java/com/baeldung/config/SecurityConfig.java b/spring-mvc-views/src/main/java/com/baeldung/themes/config/SecurityConfig.java similarity index 98% rename from spring-mvc-views/src/main/java/com/baeldung/config/SecurityConfig.java rename to spring-mvc-views/src/main/java/com/baeldung/themes/config/SecurityConfig.java index 2e0a413cf3..78a52d4f8b 100644 --- a/spring-mvc-views/src/main/java/com/baeldung/config/SecurityConfig.java +++ b/spring-mvc-views/src/main/java/com/baeldung/themes/config/SecurityConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.themes.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; diff --git a/spring-mvc-views/src/main/java/com/baeldung/config/ThemeMVCConfig.java b/spring-mvc-views/src/main/java/com/baeldung/themes/config/ThemeMVCConfig.java similarity index 94% rename from spring-mvc-views/src/main/java/com/baeldung/config/ThemeMVCConfig.java rename to spring-mvc-views/src/main/java/com/baeldung/themes/config/ThemeMVCConfig.java index 86f6f54195..1d3f94258e 100644 --- a/spring-mvc-views/src/main/java/com/baeldung/config/ThemeMVCConfig.java +++ b/spring-mvc-views/src/main/java/com/baeldung/themes/config/ThemeMVCConfig.java @@ -1,6 +1,6 @@ -package com.baeldung.config; +package com.baeldung.themes.config; -import com.baeldung.theme.resolver.UserPreferenceThemeResolver; +import com.baeldung.themes.resolver.UserPreferenceThemeResolver; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/spring-mvc-views/src/main/java/com/baeldung/config/WebInitializer.java b/spring-mvc-views/src/main/java/com/baeldung/themes/config/WebInitializer.java similarity index 96% rename from spring-mvc-views/src/main/java/com/baeldung/config/WebInitializer.java rename to spring-mvc-views/src/main/java/com/baeldung/themes/config/WebInitializer.java index 5516fb7b3c..3fbe8d043d 100644 --- a/spring-mvc-views/src/main/java/com/baeldung/config/WebInitializer.java +++ b/spring-mvc-views/src/main/java/com/baeldung/themes/config/WebInitializer.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.themes.config; import org.springframework.web.WebApplicationInitializer; import org.springframework.web.context.ContextLoaderListener; diff --git a/spring-mvc-views/src/main/java/com/baeldung/controllers/AppController.java b/spring-mvc-views/src/main/java/com/baeldung/themes/controllers/AppController.java similarity index 85% rename from spring-mvc-views/src/main/java/com/baeldung/controllers/AppController.java rename to spring-mvc-views/src/main/java/com/baeldung/themes/controllers/AppController.java index 31343492e1..ed398fa60a 100644 --- a/spring-mvc-views/src/main/java/com/baeldung/controllers/AppController.java +++ b/spring-mvc-views/src/main/java/com/baeldung/themes/controllers/AppController.java @@ -1,4 +1,4 @@ -package com.baeldung.controllers; +package com.baeldung.themes.controllers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-mvc-views/src/main/java/com/baeldung/domain/UserPreference.java b/spring-mvc-views/src/main/java/com/baeldung/themes/domain/UserPreference.java similarity index 93% rename from spring-mvc-views/src/main/java/com/baeldung/domain/UserPreference.java rename to spring-mvc-views/src/main/java/com/baeldung/themes/domain/UserPreference.java index 81034de947..89f8ea1a36 100644 --- a/spring-mvc-views/src/main/java/com/baeldung/domain/UserPreference.java +++ b/spring-mvc-views/src/main/java/com/baeldung/themes/domain/UserPreference.java @@ -1,4 +1,4 @@ -package com.baeldung.domain; +package com.baeldung.themes.domain; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/spring-mvc-views/src/main/java/com/baeldung/repository/UserPreferenceRepository.java b/spring-mvc-views/src/main/java/com/baeldung/themes/repository/UserPreferenceRepository.java similarity index 66% rename from spring-mvc-views/src/main/java/com/baeldung/repository/UserPreferenceRepository.java rename to spring-mvc-views/src/main/java/com/baeldung/themes/repository/UserPreferenceRepository.java index 77e5da0498..d4e4ff0a5e 100644 --- a/spring-mvc-views/src/main/java/com/baeldung/repository/UserPreferenceRepository.java +++ b/spring-mvc-views/src/main/java/com/baeldung/themes/repository/UserPreferenceRepository.java @@ -1,6 +1,6 @@ -package com.baeldung.repository; +package com.baeldung.themes.repository; -import com.baeldung.domain.UserPreference; +import com.baeldung.themes.domain.UserPreference; import org.springframework.data.repository.PagingAndSortingRepository; public interface UserPreferenceRepository extends PagingAndSortingRepository { diff --git a/spring-mvc-views/src/main/java/com/baeldung/theme/resolver/UserPreferenceThemeResolver.java b/spring-mvc-views/src/main/java/com/baeldung/themes/resolver/UserPreferenceThemeResolver.java similarity index 95% rename from spring-mvc-views/src/main/java/com/baeldung/theme/resolver/UserPreferenceThemeResolver.java rename to spring-mvc-views/src/main/java/com/baeldung/themes/resolver/UserPreferenceThemeResolver.java index 4c59734d41..ff160110fd 100644 --- a/spring-mvc-views/src/main/java/com/baeldung/theme/resolver/UserPreferenceThemeResolver.java +++ b/spring-mvc-views/src/main/java/com/baeldung/themes/resolver/UserPreferenceThemeResolver.java @@ -1,7 +1,7 @@ -package com.baeldung.theme.resolver; +package com.baeldung.themes.resolver; -import com.baeldung.domain.UserPreference; -import com.baeldung.repository.UserPreferenceRepository; +import com.baeldung.themes.domain.UserPreference; +import com.baeldung.themes.repository.UserPreferenceRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; diff --git a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/pom.xml b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/pom.xml index 1f6181a365..20680d5880 100644 --- a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/pom.xml +++ b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/pom.xml @@ -31,7 +31,7 @@ com.caucho hessian - 4.0.38 + ${hessian.version} @@ -58,5 +58,8 @@ + + 4.0.38 +
\ No newline at end of file diff --git a/spring-rest-angular/pom.xml b/spring-rest-angular/pom.xml index 1c6ab77a2d..1d50b4c76c 100644 --- a/spring-rest-angular/pom.xml +++ b/spring-rest-angular/pom.xml @@ -74,7 +74,7 @@ 19.0 - org.baeldung.web.main.Application + com.baeldung.web.main.Application diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/dao/StudentRepository.java b/spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java similarity index 66% rename from spring-rest-angular/src/main/java/org/baeldung/web/dao/StudentRepository.java rename to spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java index 566d95da00..b69cf6f552 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/dao/StudentRepository.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.web.dao; +package com.baeldung.web.dao; -import org.baeldung.web.entity.Student; +import com.baeldung.web.entity.Student; import org.springframework.data.jpa.repository.JpaRepository; public interface StudentRepository extends JpaRepository diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/entity/Student.java b/spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java similarity index 97% rename from spring-rest-angular/src/main/java/org/baeldung/web/entity/Student.java rename to spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java index 0a0b60d87d..849b35cf24 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/entity/Student.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java @@ -1,4 +1,4 @@ -package org.baeldung.web.entity; +package com.baeldung.web.entity; import java.io.Serializable; diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java b/spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java similarity index 93% rename from spring-rest-angular/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java rename to spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java index 740caec59e..ae9c4543ec 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java @@ -1,4 +1,4 @@ -package org.baeldung.web.exception; +package com.baeldung.web.exception; public class MyResourceNotFoundException extends RuntimeException { diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java b/spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java similarity index 96% rename from spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java rename to spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java index fd10643c53..1f3f0aec39 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java @@ -1,4 +1,4 @@ -package org.baeldung.web.main; +package com.baeldung.web.main; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/main/PersistenceConfig.java b/spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java similarity index 85% rename from spring-rest-angular/src/main/java/org/baeldung/web/main/PersistenceConfig.java rename to spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java index 0fc6b74892..b964c753d2 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/main/PersistenceConfig.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.web.main; +package com.baeldung.web.main; import javax.sql.DataSource; @@ -12,9 +12,9 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -@EnableJpaRepositories("org.baeldung.web.dao") -@ComponentScan(basePackages = { "org.baeldung.web" }) -@EntityScan("org.baeldung.web.entity") +@EnableJpaRepositories("com.baeldung.web.dao") +@ComponentScan(basePackages = { "com.baeldung.web" }) +@EntityScan("com.baeldung.web.entity") @Configuration public class PersistenceConfig { diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/rest/StudentDirectoryRestController.java b/spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java similarity index 83% rename from spring-rest-angular/src/main/java/org/baeldung/web/rest/StudentDirectoryRestController.java rename to spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java index dc295a3d97..6197279384 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/rest/StudentDirectoryRestController.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java @@ -1,8 +1,8 @@ -package org.baeldung.web.rest; +package com.baeldung.web.rest; -import org.baeldung.web.entity.Student; -import org.baeldung.web.exception.MyResourceNotFoundException; -import org.baeldung.web.service.StudentService; +import com.baeldung.web.entity.Student; +import com.baeldung.web.exception.MyResourceNotFoundException; +import com.baeldung.web.service.StudentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/service/IOperations.java b/spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java similarity index 81% rename from spring-rest-angular/src/main/java/org/baeldung/web/service/IOperations.java rename to spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java index 2176c0bb70..60cb4382f4 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/service/IOperations.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.web.service; +package com.baeldung.web.service; import org.springframework.data.domain.Page; diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java b/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java new file mode 100644 index 0000000000..65eb791904 --- /dev/null +++ b/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java @@ -0,0 +1,7 @@ +package com.baeldung.web.service; + +import com.baeldung.web.entity.Student; + +public interface StudentService extends IOperations { + +} diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentServiceImpl.java b/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java similarity index 69% rename from spring-rest-angular/src/main/java/org/baeldung/web/service/StudentServiceImpl.java rename to spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java index c7bcdc5bd5..cacb0e7840 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentServiceImpl.java +++ b/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java @@ -1,7 +1,7 @@ -package org.baeldung.web.service; +package com.baeldung.web.service; -import org.baeldung.web.dao.StudentRepository; -import org.baeldung.web.entity.Student; +import com.baeldung.web.dao.StudentRepository; +import com.baeldung.web.entity.Student; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -15,7 +15,7 @@ public class StudentServiceImpl implements StudentService { @Override public Page findPaginated(int page, int size) { - return dao.findAll(new PageRequest(page, size)); + return dao.findAll(PageRequest.of(page, size)); } } diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentService.java b/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentService.java deleted file mode 100644 index 1b194f76e2..0000000000 --- a/spring-rest-angular/src/main/java/org/baeldung/web/service/StudentService.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.baeldung.web.service; - -import org.baeldung.web.entity.Student; - -public interface StudentService extends IOperations { - -} diff --git a/spring-rest-angular/src/test/java/org/baeldung/SpringContextTest.java b/spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java similarity index 85% rename from spring-rest-angular/src/test/java/org/baeldung/SpringContextTest.java rename to spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java index 9136ce43eb..ee8c553c76 100644 --- a/spring-rest-angular/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java @@ -1,6 +1,6 @@ -package org.baeldung; +package com.baeldung; -import org.baeldung.web.main.Application; +import com.baeldung.web.main.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java b/spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java similarity index 97% rename from spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java rename to spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java index 1473d44b92..654c4ef647 100644 --- a/spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java +++ b/spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.web.service; +package com.baeldung.web.service; import static io.restassured.RestAssured.given; import static org.hamcrest.core.Is.is; @@ -6,7 +6,7 @@ import static org.hamcrest.core.IsCollectionContaining.hasItems; import static org.hamcrest.core.IsEqual.equalTo; import org.apache.commons.lang3.RandomStringUtils; -import org.baeldung.web.main.Application; +import com.baeldung.web.main.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java similarity index 96% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java index 7d5326246d..78b77256af 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/CompressingClientHttpRequestInterceptor.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/GzipUtils.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/GzipUtils.java similarity index 96% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/GzipUtils.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/GzipUtils.java index 75420ca6d8..b9731535b2 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/GzipUtils.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/GzipUtils.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.apache.commons.codec.Charsets; import org.apache.commons.io.IOUtils; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/JettyWebServerConfiguration.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/JettyWebServerConfiguration.java similarity index 96% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/JettyWebServerConfiguration.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/JettyWebServerConfiguration.java index 784814b04d..8de8e5b523 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/JettyWebServerConfiguration.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/JettyWebServerConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.gzip.GzipHandler; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/Message.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/Message.java similarity index 92% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/Message.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/Message.java index d3450b227c..24272a4fca 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/Message.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/Message.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; public class Message { diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/MessageController.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/MessageController.java similarity index 96% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/MessageController.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/MessageController.java index 657c3cfec8..2fc2ca8272 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/MessageController.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/MessageController.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/RestTemplateConfiguration.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/RestTemplateConfiguration.java similarity index 92% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/RestTemplateConfiguration.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/RestTemplateConfiguration.java index e1d0f985d9..c1e3c89ae9 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/RestTemplateConfiguration.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/RestTemplateConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/SpringCompressRequestApplication.java b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/SpringCompressRequestApplication.java similarity index 90% rename from spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/SpringCompressRequestApplication.java rename to spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/SpringCompressRequestApplication.java index 3082e3c277..9b1b71979d 100644 --- a/spring-rest-compress/src/main/java/org/baeldung/spring/rest/compress/SpringCompressRequestApplication.java +++ b/spring-rest-compress/src/main/java/com/baeldung/spring/rest/compress/SpringCompressRequestApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/GzipUtilsUnitTest.java b/spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/GzipUtilsUnitTest.java similarity index 92% rename from spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/GzipUtilsUnitTest.java rename to spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/GzipUtilsUnitTest.java index d238c9ec7c..431758d358 100644 --- a/spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/GzipUtilsUnitTest.java +++ b/spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/GzipUtilsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.junit.Test; diff --git a/spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/MessageControllerUnitTest.java b/spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/MessageControllerUnitTest.java similarity index 97% rename from spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/MessageControllerUnitTest.java rename to spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/MessageControllerUnitTest.java index 9658204917..50b2b7ccd7 100644 --- a/spring-rest-compress/src/test/java/org/baeldung/spring/rest/compress/MessageControllerUnitTest.java +++ b/spring-rest-compress/src/test/java/com/baeldung/spring/rest/compress/MessageControllerUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.rest.compress; +package com.baeldung.spring.rest.compress; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-rest-hal-browser/pom.xml b/spring-rest-hal-browser/pom.xml index 94ce837b27..adef8bf2b0 100644 --- a/spring-rest-hal-browser/pom.xml +++ b/spring-rest-hal-browser/pom.xml @@ -19,25 +19,25 @@ org.springframework.boot spring-boot-starter-web - 2.0.3.RELEASE + ${spring-boot.version} org.springframework.boot spring-boot-starter-data-jpa - 2.0.3.RELEASE + ${spring-boot.version} org.springframework.data spring-data-rest-hal-browser - 3.0.8.RELEASE + ${spring-data.version} com.h2database h2 - 1.4.197 + ${h2.version} @@ -47,11 +47,19 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${source.version} + ${target.version}
+ + 2.0.3.RELEASE + 3.0.8.RELEASE + 1.4.197 + 1.8 + 1.8 + + \ No newline at end of file diff --git a/spring-rest-http/README.md b/spring-rest-http/README.md index 51f5ed4000..54b31e80c4 100644 --- a/spring-rest-http/README.md +++ b/spring-rest-http/README.md @@ -10,5 +10,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Guide to UriComponentsBuilder in Spring](https://www.baeldung.com/spring-uricomponentsbuilder) - [How to Set a Header on a Response with Spring 5](https://www.baeldung.com/spring-response-header) - The tests contained for this article rely on the sample application within the [spring-resttemplate](/spring-resttemplate) module - [Returning Custom Status Codes from Spring Controllers](https://www.baeldung.com/spring-mvc-controller-custom-http-status-code) -- [Spring @RequestMapping](https://www.baeldung.com/spring-requestmapping) -- [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result) \ No newline at end of file +- [Spring RequestMapping](https://www.baeldung.com/spring-requestmapping) +- [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result) diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java b/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java index db7cb66f87..0e8f9caf03 100644 --- a/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java +++ b/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java @@ -331,7 +331,7 @@ public final class FooProtos { return com.baeldung.web.dto.FooProtos.internal_static_baeldung_Foo_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.web.dto.FooProtos.Foo.class, com.baeldung.web.dto.FooProtos.Foo.Builder.class); } - // Construct using org.baeldung.web.dto.FooProtos.Foo.newBuilder() + // Construct using com.baeldung.web.dto.FooProtos.Foo.newBuilder() private Builder() { maybeForceBuilderInitialization(); } @@ -581,7 +581,7 @@ public final class FooProtos { private static com.google.protobuf.Descriptors.FileDescriptor descriptor; static { - java.lang.String[] descriptorData = { "\n\017FooProtos.proto\022\010baeldung\"\037\n\003Foo\022\n\n\002id" + "\030\001 \002(\003\022\014\n\004name\030\002 \002(\tB!\n\024org.baeldung.web" + ".dtoB\tFooProtos" }; + java.lang.String[] descriptorData = { "\n\017FooProtos.proto\022\010baeldung\"\037\n\003Foo\022\n\n\002id" + "\030\001 \002(\003\022\014\n\004name\030\002 \002(\tB!\n\024com.baeldung.web" + ".dtoB\tFooProtos" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { public com.google.protobuf.ExtensionRegistry assignDescriptors(com.google.protobuf.Descriptors.FileDescriptor root) { descriptor = root; diff --git a/spring-rest-testing/src/main/java/org/baeldung/persistence/IOperations.java b/spring-rest-testing/src/main/java/com/baeldung/persistence/IOperations.java similarity index 89% rename from spring-rest-testing/src/main/java/org/baeldung/persistence/IOperations.java rename to spring-rest-testing/src/main/java/com/baeldung/persistence/IOperations.java index 0b617bf7ab..73100ec64f 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/persistence/IOperations.java +++ b/spring-rest-testing/src/main/java/com/baeldung/persistence/IOperations.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence; +package com.baeldung.persistence; import java.io.Serializable; import java.util.List; diff --git a/spring-rest-testing/src/main/java/org/baeldung/persistence/dao/IFooDao.java b/spring-rest-testing/src/main/java/com/baeldung/persistence/dao/IFooDao.java similarity index 81% rename from spring-rest-testing/src/main/java/org/baeldung/persistence/dao/IFooDao.java rename to spring-rest-testing/src/main/java/com/baeldung/persistence/dao/IFooDao.java index 230abd0d5f..8d47d2eb42 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/persistence/dao/IFooDao.java +++ b/spring-rest-testing/src/main/java/com/baeldung/persistence/dao/IFooDao.java @@ -1,6 +1,6 @@ -package org.baeldung.persistence.dao; +package com.baeldung.persistence.dao; -import org.baeldung.persistence.model.Foo; +import com.baeldung.persistence.model.Foo; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; diff --git a/spring-exceptions/src/main/java/org/baeldung/persistence/model/Foo.java b/spring-rest-testing/src/main/java/com/baeldung/persistence/model/Foo.java similarity index 97% rename from spring-exceptions/src/main/java/org/baeldung/persistence/model/Foo.java rename to spring-rest-testing/src/main/java/com/baeldung/persistence/model/Foo.java index 8e1dee33e8..9af3d07bed 100644 --- a/spring-exceptions/src/main/java/org/baeldung/persistence/model/Foo.java +++ b/spring-rest-testing/src/main/java/com/baeldung/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import java.io.Serializable; diff --git a/spring-rest-testing/src/main/java/org/baeldung/persistence/model/User.java b/spring-rest-testing/src/main/java/com/baeldung/persistence/model/User.java similarity index 97% rename from spring-rest-testing/src/main/java/org/baeldung/persistence/model/User.java rename to spring-rest-testing/src/main/java/com/baeldung/persistence/model/User.java index 670d4a2e74..dbc2b9360f 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/persistence/model/User.java +++ b/spring-rest-testing/src/main/java/com/baeldung/persistence/model/User.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package com.baeldung.persistence.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-rest-testing/src/main/java/com/baeldung/persistence/service/IFooService.java b/spring-rest-testing/src/main/java/com/baeldung/persistence/service/IFooService.java new file mode 100644 index 0000000000..15330550a1 --- /dev/null +++ b/spring-rest-testing/src/main/java/com/baeldung/persistence/service/IFooService.java @@ -0,0 +1,10 @@ +package com.baeldung.persistence.service; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.IOperations; + +public interface IFooService extends IOperations { + + Foo retrieveByName(String name); + +} diff --git a/spring-rest-testing/src/main/java/org/baeldung/persistence/service/common/AbstractService.java b/spring-rest-testing/src/main/java/com/baeldung/persistence/service/common/AbstractService.java similarity index 90% rename from spring-rest-testing/src/main/java/org/baeldung/persistence/service/common/AbstractService.java rename to spring-rest-testing/src/main/java/com/baeldung/persistence/service/common/AbstractService.java index ceefbbe0e3..5a5d9d6241 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/persistence/service/common/AbstractService.java +++ b/spring-rest-testing/src/main/java/com/baeldung/persistence/service/common/AbstractService.java @@ -1,9 +1,9 @@ -package org.baeldung.persistence.service.common; +package com.baeldung.persistence.service.common; import java.io.Serializable; import java.util.List; -import org.baeldung.persistence.IOperations; +import com.baeldung.persistence.IOperations; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-rest-testing/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-rest-testing/src/main/java/com/baeldung/persistence/service/impl/FooService.java similarity index 73% rename from spring-rest-testing/src/main/java/org/baeldung/persistence/service/impl/FooService.java rename to spring-rest-testing/src/main/java/com/baeldung/persistence/service/impl/FooService.java index 32fe1bd7e0..92fb6c28a0 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/persistence/service/impl/FooService.java +++ b/spring-rest-testing/src/main/java/com/baeldung/persistence/service/impl/FooService.java @@ -1,9 +1,9 @@ -package org.baeldung.persistence.service.impl; +package com.baeldung.persistence.service.impl; -import org.baeldung.persistence.dao.IFooDao; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; -import org.baeldung.persistence.service.common.AbstractService; +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.stereotype.Service; diff --git a/spring-rest-testing/src/main/java/org/baeldung/spring/Application.java b/spring-rest-testing/src/main/java/com/baeldung/spring/Application.java similarity index 95% rename from spring-rest-testing/src/main/java/org/baeldung/spring/Application.java rename to spring-rest-testing/src/main/java/com/baeldung/spring/Application.java index ca72a4ef56..c35c4d7e5e 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/spring/Application.java +++ b/spring-rest-testing/src/main/java/com/baeldung/spring/Application.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import javax.servlet.ServletContext; import javax.servlet.ServletException; @@ -19,7 +19,7 @@ import org.springframework.web.context.request.RequestContextListener; */ @EnableScheduling @EnableAutoConfiguration -@ComponentScan("org.baeldung") +@ComponentScan("com.baeldung") @SpringBootApplication public class Application extends SpringBootServletInitializer { diff --git a/spring-rest-testing/src/main/java/org/baeldung/spring/PersistenceConfig.java b/spring-rest-testing/src/main/java/com/baeldung/spring/PersistenceConfig.java similarity index 94% rename from spring-rest-testing/src/main/java/org/baeldung/spring/PersistenceConfig.java rename to spring-rest-testing/src/main/java/com/baeldung/spring/PersistenceConfig.java index f3a87b189e..4a4b9eee3f 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/spring/PersistenceConfig.java +++ b/spring-rest-testing/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import java.util.Properties; @@ -24,9 +24,9 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-${envTarget:h2}.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) +@ComponentScan({ "com.baeldung.persistence" }) // @ImportResource("classpath*:springDataPersistenceConfig.xml") -@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao") +@EnableJpaRepositories(basePackages = "com.baeldung.persistence.dao") public class PersistenceConfig { @Autowired @@ -40,7 +40,7 @@ public class PersistenceConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); // vendorAdapter.set diff --git a/spring-rest-testing/src/main/java/org/baeldung/spring/WebConfig.java b/spring-rest-testing/src/main/java/com/baeldung/spring/WebConfig.java similarity index 94% rename from spring-rest-testing/src/main/java/org/baeldung/spring/WebConfig.java rename to spring-rest-testing/src/main/java/com/baeldung/spring/WebConfig.java index a0db08d93d..e35acb0bf0 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/spring/WebConfig.java +++ b/spring-rest-testing/src/main/java/com/baeldung/spring/WebConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.spring; +package com.baeldung.spring; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -10,7 +10,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.view.InternalResourceViewResolver; @Configuration -@ComponentScan("org.baeldung.web") +@ComponentScan("com.baeldung.web") @EnableWebMvc public class WebConfig implements WebMvcConfigurer { diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/controller/FooController.java b/spring-rest-testing/src/main/java/com/baeldung/web/controller/FooController.java similarity index 92% rename from spring-rest-testing/src/main/java/org/baeldung/web/controller/FooController.java rename to spring-rest-testing/src/main/java/com/baeldung/web/controller/FooController.java index caaf422410..b5350c33c1 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/controller/FooController.java @@ -1,12 +1,12 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; -import org.baeldung.persistence.model.Foo; -import org.baeldung.persistence.service.IFooService; -import org.baeldung.web.util.RestPreconditions; +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.web.util.RestPreconditions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/controller/HomeController.java b/spring-rest-testing/src/main/java/com/baeldung/web/controller/HomeController.java similarity index 87% rename from spring-rest-testing/src/main/java/org/baeldung/web/controller/HomeController.java rename to spring-rest-testing/src/main/java/com/baeldung/web/controller/HomeController.java index 9c4d14cae3..c82911211a 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/controller/HomeController.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/controller/HomeController.java @@ -1,4 +1,4 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/controller/RootController.java b/spring-rest-testing/src/main/java/com/baeldung/web/controller/RootController.java similarity index 90% rename from spring-rest-testing/src/main/java/org/baeldung/web/controller/RootController.java rename to spring-rest-testing/src/main/java/com/baeldung/web/controller/RootController.java index a66f3d1893..005f6f023b 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/controller/RootController.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/controller/RootController.java @@ -1,9 +1,9 @@ -package org.baeldung.web.controller; +package com.baeldung.web.controller; import java.util.Map; -import org.baeldung.web.metric.IActuatorMetricService; -import org.baeldung.web.metric.IMetricService; +import com.baeldung.web.metric.IActuatorMetricService; +import com.baeldung.web.metric.IMetricService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java b/spring-rest-testing/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java similarity index 92% rename from spring-rest-testing/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java rename to spring-rest-testing/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java index 14b61f9832..fd002efc28 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java @@ -1,4 +1,4 @@ -package org.baeldung.web.exception; +package com.baeldung.web.exception; public final class MyResourceNotFoundException extends RuntimeException { diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/metric/ActuatorMetricService.java b/spring-rest-testing/src/main/java/com/baeldung/web/metric/ActuatorMetricService.java similarity index 99% rename from spring-rest-testing/src/main/java/org/baeldung/web/metric/ActuatorMetricService.java rename to spring-rest-testing/src/main/java/com/baeldung/web/metric/ActuatorMetricService.java index 4dcec17b9e..8c26fa04a0 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/metric/ActuatorMetricService.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/metric/ActuatorMetricService.java @@ -1,4 +1,4 @@ -package org.baeldung.web.metric; +package com.baeldung.web.metric; import java.text.SimpleDateFormat; import java.util.ArrayList; diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/metric/CustomActuatorMetricService.java b/spring-rest-testing/src/main/java/com/baeldung/web/metric/CustomActuatorMetricService.java similarity index 98% rename from spring-rest-testing/src/main/java/org/baeldung/web/metric/CustomActuatorMetricService.java rename to spring-rest-testing/src/main/java/com/baeldung/web/metric/CustomActuatorMetricService.java index cf30686e52..ee17825b7c 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/metric/CustomActuatorMetricService.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/metric/CustomActuatorMetricService.java @@ -1,4 +1,4 @@ -package org.baeldung.web.metric; +package com.baeldung.web.metric; import java.text.SimpleDateFormat; import java.util.ArrayList; diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/metric/IActuatorMetricService.java b/spring-rest-testing/src/main/java/com/baeldung/web/metric/IActuatorMetricService.java similarity index 69% rename from spring-rest-testing/src/main/java/org/baeldung/web/metric/IActuatorMetricService.java rename to spring-rest-testing/src/main/java/com/baeldung/web/metric/IActuatorMetricService.java index 191d347070..60bb43ee00 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/metric/IActuatorMetricService.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/metric/IActuatorMetricService.java @@ -1,4 +1,4 @@ -package org.baeldung.web.metric; +package com.baeldung.web.metric; public interface IActuatorMetricService { Object[][] getGraphData(); diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/metric/ICustomActuatorMetricService.java b/spring-rest-testing/src/main/java/com/baeldung/web/metric/ICustomActuatorMetricService.java similarity index 79% rename from spring-rest-testing/src/main/java/org/baeldung/web/metric/ICustomActuatorMetricService.java rename to spring-rest-testing/src/main/java/com/baeldung/web/metric/ICustomActuatorMetricService.java index 19ab7164ac..5126252e27 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/metric/ICustomActuatorMetricService.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/metric/ICustomActuatorMetricService.java @@ -1,4 +1,4 @@ -package org.baeldung.web.metric; +package com.baeldung.web.metric; public interface ICustomActuatorMetricService { diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/metric/IMetricService.java b/spring-rest-testing/src/main/java/com/baeldung/web/metric/IMetricService.java similarity index 86% rename from spring-rest-testing/src/main/java/org/baeldung/web/metric/IMetricService.java rename to spring-rest-testing/src/main/java/com/baeldung/web/metric/IMetricService.java index 902d6ac811..b8dfa60215 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/metric/IMetricService.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/metric/IMetricService.java @@ -1,4 +1,4 @@ -package org.baeldung.web.metric; +package com.baeldung.web.metric; import java.util.Map; diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/metric/MetricFilter.java b/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricFilter.java similarity index 98% rename from spring-rest-testing/src/main/java/org/baeldung/web/metric/MetricFilter.java rename to spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricFilter.java index 6c2fb0cb39..dee63b226f 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/metric/MetricFilter.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricFilter.java @@ -1,4 +1,4 @@ -package org.baeldung.web.metric; +package com.baeldung.web.metric; import javax.servlet.Filter; import javax.servlet.FilterChain; diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/metric/MetricService.java b/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricService.java similarity index 99% rename from spring-rest-testing/src/main/java/org/baeldung/web/metric/MetricService.java rename to spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricService.java index 086068ad8f..fd3cccab3e 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/metric/MetricService.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricService.java @@ -1,4 +1,4 @@ -package org.baeldung.web.metric; +package com.baeldung.web.metric; import java.text.SimpleDateFormat; import java.util.Date; diff --git a/spring-rest-testing/src/main/java/org/baeldung/web/util/RestPreconditions.java b/spring-rest-testing/src/main/java/com/baeldung/web/util/RestPreconditions.java similarity index 93% rename from spring-rest-testing/src/main/java/org/baeldung/web/util/RestPreconditions.java rename to spring-rest-testing/src/main/java/com/baeldung/web/util/RestPreconditions.java index 4f2dedcfa0..93a4ef6a33 100644 --- a/spring-rest-testing/src/main/java/org/baeldung/web/util/RestPreconditions.java +++ b/spring-rest-testing/src/main/java/com/baeldung/web/util/RestPreconditions.java @@ -1,9 +1,8 @@ -package org.baeldung.web.util; +package com.baeldung.web.util; +import com.baeldung.web.exception.MyResourceNotFoundException; import org.springframework.http.HttpStatus; -import org.baeldung.web.exception.MyResourceNotFoundException; - /** * Simple static methods to be called at the start of your own methods to verify correct arguments and state. If the Precondition fails, an {@link HttpStatus} code is thrown */ diff --git a/spring-rest-testing/src/main/java/org/baeldung/persistence/service/IFooService.java b/spring-rest-testing/src/main/java/org/baeldung/persistence/service/IFooService.java deleted file mode 100644 index 60d607b9ef..0000000000 --- a/spring-rest-testing/src/main/java/org/baeldung/persistence/service/IFooService.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.baeldung.persistence.service; - -import org.baeldung.persistence.IOperations; -import org.baeldung.persistence.model.Foo; - -public interface IFooService extends IOperations { - - Foo retrieveByName(String name); - -} diff --git a/spring-rest-testing/src/main/resources/springDataPersistenceConfig.xml b/spring-rest-testing/src/main/resources/springDataPersistenceConfig.xml index d6d0ec6e47..5ea2d9c05b 100644 --- a/spring-rest-testing/src/main/resources/springDataPersistenceConfig.xml +++ b/spring-rest-testing/src/main/resources/springDataPersistenceConfig.xml @@ -7,6 +7,6 @@ http://www.springframework.org/schema/data/jpa/spring-jpa.xsd" > - + \ No newline at end of file diff --git a/spring-rest-testing/src/main/webapp/WEB-INF/web.xml b/spring-rest-testing/src/main/webapp/WEB-INF/web.xml index 5f90c3519f..7129b6b4af 100644 --- a/spring-rest-testing/src/main/webapp/WEB-INF/web.xml +++ b/spring-rest-testing/src/main/webapp/WEB-INF/web.xml @@ -16,7 +16,7 @@ contextConfigLocation - org.baeldung.spring + com.baeldung.spring @@ -37,7 +37,7 @@ metricFilter - org.baeldung.web.metric.MetricFilter + com.baeldung.web.metric.MetricFilter diff --git a/spring-rest-testing/src/test/java/org/baeldung/Consts.java b/spring-rest-testing/src/test/java/com/baeldung/Consts.java similarity index 73% rename from spring-rest-testing/src/test/java/org/baeldung/Consts.java rename to spring-rest-testing/src/test/java/com/baeldung/Consts.java index e5f0be160f..e33efd589e 100644 --- a/spring-rest-testing/src/test/java/org/baeldung/Consts.java +++ b/spring-rest-testing/src/test/java/com/baeldung/Consts.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; public interface Consts { int APPLICATION_PORT = 8082; diff --git a/spring-rest-testing/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-rest-testing/src/test/java/com/baeldung/SpringContextIntegrationTest.java similarity index 86% rename from spring-rest-testing/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-rest-testing/src/test/java/com/baeldung/SpringContextIntegrationTest.java index 35939c992f..155e05b106 100644 --- a/spring-rest-testing/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-rest-testing/src/test/java/com/baeldung/SpringContextIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung; +package com.baeldung; -import org.baeldung.spring.Application; +import com.baeldung.spring.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-rest-simple/src/test/java/org/baeldung/SpringContextTest.java b/spring-rest-testing/src/test/java/com/baeldung/SpringContextTest.java similarity index 85% rename from spring-rest-simple/src/test/java/org/baeldung/SpringContextTest.java rename to spring-rest-testing/src/test/java/com/baeldung/SpringContextTest.java index 5e68a8e64f..e023254719 100644 --- a/spring-rest-simple/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-rest-testing/src/test/java/com/baeldung/SpringContextTest.java @@ -1,12 +1,11 @@ -package org.baeldung; +package com.baeldung; +import com.baeldung.spring.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.Application; - @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class SpringContextTest { diff --git a/spring-rest-testing/src/test/java/org/baeldung/persistence/PersistenceTestSuite.java b/spring-rest-testing/src/test/java/com/baeldung/persistence/PersistenceTestSuite.java similarity index 71% rename from spring-rest-testing/src/test/java/org/baeldung/persistence/PersistenceTestSuite.java rename to spring-rest-testing/src/test/java/com/baeldung/persistence/PersistenceTestSuite.java index fb0fd00bb5..77c74b15e4 100644 --- a/spring-rest-testing/src/test/java/org/baeldung/persistence/PersistenceTestSuite.java +++ b/spring-rest-testing/src/test/java/com/baeldung/persistence/PersistenceTestSuite.java @@ -1,6 +1,6 @@ -package org.baeldung.persistence; +package com.baeldung.persistence; -import org.baeldung.persistence.service.FooServicePersistenceIntegrationTest; +import com.baeldung.persistence.service.FooServicePersistenceIntegrationTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/spring-rest-testing/src/test/java/org/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java b/spring-rest-testing/src/test/java/com/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java similarity index 97% rename from spring-rest-testing/src/test/java/org/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java rename to spring-rest-testing/src/test/java/com/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java index 79889e0f9e..e66e9d49e2 100644 --- a/spring-rest-testing/src/test/java/org/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java +++ b/spring-rest-testing/src/test/java/com/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.service; +package com.baeldung.persistence.service; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.hamcrest.Matchers.hasItem; @@ -11,9 +11,9 @@ import static org.junit.Assert.assertThat; import java.io.Serializable; import java.util.List; -import org.baeldung.persistence.IOperations; -import org.baeldung.persistence.model.Foo; -import org.baeldung.util.IDUtil; +import com.baeldung.util.IDUtil; +import com.baeldung.persistence.IOperations; +import com.baeldung.persistence.model.Foo; import org.hamcrest.Matchers; import org.junit.Ignore; import org.junit.Test; diff --git a/spring-rest-testing/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-rest-testing/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java similarity index 93% rename from spring-rest-testing/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java rename to spring-rest-testing/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java index 089d2d13a2..24f46b9c8f 100644 --- a/spring-rest-testing/src/test/java/org/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java +++ b/spring-rest-testing/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java @@ -1,11 +1,11 @@ -package org.baeldung.persistence.service; +package com.baeldung.persistence.service; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.junit.Assert.assertNotNull; -import org.baeldung.persistence.IOperations; -import org.baeldung.persistence.model.Foo; -import org.baeldung.spring.PersistenceConfig; +import com.baeldung.persistence.IOperations; +import com.baeldung.persistence.model.Foo; +import com.baeldung.spring.PersistenceConfig; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-rest-testing/src/test/java/org/baeldung/util/IDUtil.java b/spring-rest-testing/src/test/java/com/baeldung/util/IDUtil.java similarity index 96% rename from spring-rest-testing/src/test/java/org/baeldung/util/IDUtil.java rename to spring-rest-testing/src/test/java/com/baeldung/util/IDUtil.java index 85ab623e5f..45e72e046d 100644 --- a/spring-rest-testing/src/test/java/org/baeldung/util/IDUtil.java +++ b/spring-rest-testing/src/test/java/com/baeldung/util/IDUtil.java @@ -1,4 +1,4 @@ -package org.baeldung.util; +package com.baeldung.util; import java.util.Random; diff --git a/spring-rest-testing/src/test/java/org/baeldung/SpringContextTest.java b/spring-rest-testing/src/test/java/org/baeldung/SpringContextTest.java deleted file mode 100644 index 8debddc40a..0000000000 --- a/spring-rest-testing/src/test/java/org/baeldung/SpringContextTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.baeldung; - -import org.baeldung.spring.Application; -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 = Application.class) -public class SpringContextTest { - - @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { - } -} diff --git a/spring-resttemplate/pom.xml b/spring-resttemplate/pom.xml index 0b5d0b20d0..138fde3b45 100644 --- a/spring-resttemplate/pom.xml +++ b/spring-resttemplate/pom.xml @@ -125,7 +125,7 @@ junit junit - 4.12 + ${junit.version} @@ -162,10 +162,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + ${maven.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -308,6 +308,10 @@ 3.4.1 3.5.11 + 1.8 + 1.8 + 4.12 + 3.7.0 diff --git a/spring-roo/pom.xml b/spring-roo/pom.xml index 456642b1f0..448574ed19 100644 --- a/spring-roo/pom.xml +++ b/spring-roo/pom.xml @@ -413,7 +413,7 @@ spring-roo-repository Spring Roo Repository - http://repo.spring.io/spring-roo + https://repo.spring.io/spring-roo diff --git a/spring-scheduling/pom.xml b/spring-scheduling/pom.xml index a337de39b7..8726fea438 100644 --- a/spring-scheduling/pom.xml +++ b/spring-scheduling/pom.xml @@ -5,7 +5,7 @@ spring-scheduling 0.1-SNAPSHOT spring-scheduling - war + jar com.baeldung diff --git a/spring-scheduling/src/main/java/org/baeldung/async/AsyncComponent.java b/spring-scheduling/src/main/java/com/baeldung/async/AsyncComponent.java similarity index 97% rename from spring-scheduling/src/main/java/org/baeldung/async/AsyncComponent.java rename to spring-scheduling/src/main/java/com/baeldung/async/AsyncComponent.java index 8503f75c8f..7d18b8b784 100644 --- a/spring-scheduling/src/main/java/org/baeldung/async/AsyncComponent.java +++ b/spring-scheduling/src/main/java/com/baeldung/async/AsyncComponent.java @@ -1,4 +1,4 @@ -package org.baeldung.async; +package com.baeldung.async; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; diff --git a/spring-scheduling/src/main/java/org/baeldung/async/CustomAsyncExceptionHandler.java b/spring-scheduling/src/main/java/com/baeldung/async/CustomAsyncExceptionHandler.java similarity index 95% rename from spring-scheduling/src/main/java/org/baeldung/async/CustomAsyncExceptionHandler.java rename to spring-scheduling/src/main/java/com/baeldung/async/CustomAsyncExceptionHandler.java index a7a177f8fe..ba95f000a2 100644 --- a/spring-scheduling/src/main/java/org/baeldung/async/CustomAsyncExceptionHandler.java +++ b/spring-scheduling/src/main/java/com/baeldung/async/CustomAsyncExceptionHandler.java @@ -1,4 +1,4 @@ -package org.baeldung.async; +package com.baeldung.async; import java.lang.reflect.Method; diff --git a/spring-scheduling/src/main/java/org/baeldung/async/config/SpringAsyncConfig.java b/spring-scheduling/src/main/java/com/baeldung/async/config/SpringAsyncConfig.java similarity index 89% rename from spring-scheduling/src/main/java/org/baeldung/async/config/SpringAsyncConfig.java rename to spring-scheduling/src/main/java/com/baeldung/async/config/SpringAsyncConfig.java index 0676258207..56fa643017 100644 --- a/spring-scheduling/src/main/java/org/baeldung/async/config/SpringAsyncConfig.java +++ b/spring-scheduling/src/main/java/com/baeldung/async/config/SpringAsyncConfig.java @@ -1,8 +1,8 @@ -package org.baeldung.async.config; +package com.baeldung.async.config; import java.util.concurrent.Executor; -import org.baeldung.async.CustomAsyncExceptionHandler; +import com.baeldung.async.CustomAsyncExceptionHandler; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -14,7 +14,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @Configuration @EnableAsync() -@ComponentScan("org.baeldung.async") +@ComponentScan("com.baeldung.async") public class SpringAsyncConfig implements AsyncConfigurer { @Bean(name = "threadPoolTaskExecutor") diff --git a/spring-scheduling/src/main/java/org/baeldung/scheduling/ScheduledAnnotationExample.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledAnnotationExample.java similarity index 98% rename from spring-scheduling/src/main/java/org/baeldung/scheduling/ScheduledAnnotationExample.java rename to spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledAnnotationExample.java index 23bbee3bc3..892347d615 100644 --- a/spring-scheduling/src/main/java/org/baeldung/scheduling/ScheduledAnnotationExample.java +++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledAnnotationExample.java @@ -1,4 +1,4 @@ -package org.baeldung.scheduling; +package com.baeldung.scheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; diff --git a/spring-scheduling/src/main/java/org/baeldung/scheduling/SchedulingWithXmlConfig.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/SchedulingWithXmlConfig.java similarity index 93% rename from spring-scheduling/src/main/java/org/baeldung/scheduling/SchedulingWithXmlConfig.java rename to spring-scheduling/src/main/java/com/baeldung/scheduling/SchedulingWithXmlConfig.java index d7da9ac19c..54856442f4 100644 --- a/spring-scheduling/src/main/java/org/baeldung/scheduling/SchedulingWithXmlConfig.java +++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/SchedulingWithXmlConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.scheduling; +package com.baeldung.scheduling; public class SchedulingWithXmlConfig { diff --git a/spring-scheduling/src/main/java/org/baeldung/scheduling/SpringSchedulingConfig.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/SpringSchedulingConfig.java similarity index 90% rename from spring-scheduling/src/main/java/org/baeldung/scheduling/SpringSchedulingConfig.java rename to spring-scheduling/src/main/java/com/baeldung/scheduling/SpringSchedulingConfig.java index 1d81fa0aa8..5d7f1cf88f 100644 --- a/spring-scheduling/src/main/java/org/baeldung/scheduling/SpringSchedulingConfig.java +++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/SpringSchedulingConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.scheduling; +package com.baeldung.scheduling; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -9,7 +9,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; @Configuration @EnableScheduling -@ComponentScan("org.baeldung.scheduling") +@ComponentScan("com.baeldung.scheduling") @PropertySource("classpath:springScheduled.properties") public class SpringSchedulingConfig { diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/SpringSchedulingFixedRateConfig.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/SpringSchedulingFixedRateConfig.java deleted file mode 100644 index 6000f75ec2..0000000000 --- a/spring-scheduling/src/main/java/com/baeldung/scheduling/SpringSchedulingFixedRateConfig.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baeldung.scheduling; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.EnableScheduling; - -@Configuration -@EnableScheduling -@ComponentScan("com.baeldung.scheduling") -public class SpringSchedulingFixedRateConfig { - -} \ No newline at end of file diff --git a/spring-scheduling/src/main/java/org/baeldung/springretry/AppConfig.java b/spring-scheduling/src/main/java/com/baeldung/springretry/AppConfig.java similarity index 92% rename from spring-scheduling/src/main/java/org/baeldung/springretry/AppConfig.java rename to spring-scheduling/src/main/java/com/baeldung/springretry/AppConfig.java index d9b081578c..e79beb370b 100644 --- a/spring-scheduling/src/main/java/org/baeldung/springretry/AppConfig.java +++ b/spring-scheduling/src/main/java/com/baeldung/springretry/AppConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.springretry; +package com.baeldung.springretry; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -9,7 +9,7 @@ import org.springframework.retry.policy.SimpleRetryPolicy; import org.springframework.retry.support.RetryTemplate; @Configuration -@ComponentScan(basePackages = "org.baeldung.springretry") +@ComponentScan(basePackages = "com.baeldung.springretry") @EnableRetry // Uncomment this two lines if we need XML configuration // @EnableAspectJAutoProxy diff --git a/spring-scheduling/src/main/java/org/baeldung/springretry/DefaultListenerSupport.java b/spring-scheduling/src/main/java/com/baeldung/springretry/DefaultListenerSupport.java similarity index 96% rename from spring-scheduling/src/main/java/org/baeldung/springretry/DefaultListenerSupport.java rename to spring-scheduling/src/main/java/com/baeldung/springretry/DefaultListenerSupport.java index bc251b4c2f..0f9f1b6f0d 100644 --- a/spring-scheduling/src/main/java/org/baeldung/springretry/DefaultListenerSupport.java +++ b/spring-scheduling/src/main/java/com/baeldung/springretry/DefaultListenerSupport.java @@ -1,4 +1,4 @@ -package org.baeldung.springretry; +package com.baeldung.springretry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-scheduling/src/main/java/org/baeldung/springretry/MyService.java b/spring-scheduling/src/main/java/com/baeldung/springretry/MyService.java similarity index 93% rename from spring-scheduling/src/main/java/org/baeldung/springretry/MyService.java rename to spring-scheduling/src/main/java/com/baeldung/springretry/MyService.java index 6306ff3c26..409bf25845 100644 --- a/spring-scheduling/src/main/java/org/baeldung/springretry/MyService.java +++ b/spring-scheduling/src/main/java/com/baeldung/springretry/MyService.java @@ -1,4 +1,4 @@ -package org.baeldung.springretry; +package com.baeldung.springretry; import java.sql.SQLException; diff --git a/spring-scheduling/src/main/java/org/baeldung/springretry/MyServiceImpl.java b/spring-scheduling/src/main/java/com/baeldung/springretry/MyServiceImpl.java similarity index 96% rename from spring-scheduling/src/main/java/org/baeldung/springretry/MyServiceImpl.java rename to spring-scheduling/src/main/java/com/baeldung/springretry/MyServiceImpl.java index 1b698f26c9..3e4b5ed00d 100644 --- a/spring-scheduling/src/main/java/org/baeldung/springretry/MyServiceImpl.java +++ b/spring-scheduling/src/main/java/com/baeldung/springretry/MyServiceImpl.java @@ -1,4 +1,4 @@ -package org.baeldung.springretry; +package com.baeldung.springretry; import java.sql.SQLException; diff --git a/spring-scheduling/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerConfig.java b/spring-scheduling/src/main/java/com/baeldung/taskscheduler/ThreadPoolTaskSchedulerConfig.java similarity index 93% rename from spring-scheduling/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerConfig.java rename to spring-scheduling/src/main/java/com/baeldung/taskscheduler/ThreadPoolTaskSchedulerConfig.java index 342a5fe3e6..c24c701df5 100644 --- a/spring-scheduling/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerConfig.java +++ b/spring-scheduling/src/main/java/com/baeldung/taskscheduler/ThreadPoolTaskSchedulerConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.taskscheduler; +package com.baeldung.taskscheduler; import java.util.concurrent.TimeUnit; @@ -10,7 +10,7 @@ import org.springframework.scheduling.support.CronTrigger; import org.springframework.scheduling.support.PeriodicTrigger; @Configuration -@ComponentScan(basePackages = "org.baeldung.taskscheduler", basePackageClasses = { ThreadPoolTaskSchedulerExamples.class }) +@ComponentScan(basePackages = "com.baeldung.taskscheduler", basePackageClasses = { ThreadPoolTaskSchedulerExamples.class }) public class ThreadPoolTaskSchedulerConfig { @Bean diff --git a/spring-scheduling/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java b/spring-scheduling/src/main/java/com/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java similarity index 97% rename from spring-scheduling/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java rename to spring-scheduling/src/main/java/com/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java index 5d72ed148a..c0c6f37507 100644 --- a/spring-scheduling/src/main/java/org/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java +++ b/spring-scheduling/src/main/java/com/baeldung/taskscheduler/ThreadPoolTaskSchedulerExamples.java @@ -1,4 +1,4 @@ -package org.baeldung.taskscheduler; +package com.baeldung.taskscheduler; import java.util.Date; diff --git a/spring-scheduling/src/main/resources/retryadvice.xml b/spring-scheduling/src/main/resources/retryadvice.xml index 79a9fc8660..8de7801a58 100644 --- a/spring-scheduling/src/main/resources/retryadvice.xml +++ b/spring-scheduling/src/main/resources/retryadvice.xml @@ -7,7 +7,7 @@ http://www.springframework.org/schema/beans/spring-beans.xsd"> + expression="execution(* com.baeldung.springretry..*MyService.defaultXmlRetryService(..))" /> diff --git a/spring-scheduling/src/main/resources/springAsync-config.xml b/spring-scheduling/src/main/resources/springAsync-config.xml index 40fc40c79f..48bfbb3f41 100644 --- a/spring-scheduling/src/main/resources/springAsync-config.xml +++ b/spring-scheduling/src/main/resources/springAsync-config.xml @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/spring-scheduling/src/main/resources/springScheduled-config.xml b/spring-scheduling/src/main/resources/springScheduled-config.xml index 4078f535da..1e42b118bd 100644 --- a/spring-scheduling/src/main/resources/springScheduled-config.xml +++ b/spring-scheduling/src/main/resources/springScheduled-config.xml @@ -16,7 +16,7 @@ - + + + 4.0.0 + spring-security-modules + 0.0.1-SNAPSHOT + spring-security-modules + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + spring-security-acl + spring-security-angular/server + spring-security-cache-control + spring-security-core + spring-security-cors + spring-security-kerberos + spring-security-mvc + spring-security-mvc-boot + spring-security-mvc-custom + spring-security-mvc-digest-auth + spring-security-mvc-jsonview + spring-security-mvc-ldap + spring-security-mvc-login + spring-security-mvc-persisted-remember-me + spring-security-mvc-socket + spring-security-oidc + spring-security-react + + spring-security-rest + spring-security-rest-basic-auth + spring-security-rest-custom + spring-security-sso + spring-security-stormpath + spring-security-thymeleaf + spring-security-x509 + + + diff --git a/spring-security-modules/spring-security-core/.gitignore b/spring-security-modules/spring-security-core/.gitignore index 83c05e60c8..9f970225ad 100644 --- a/spring-security-modules/spring-security-core/.gitignore +++ b/spring-security-modules/spring-security-core/.gitignore @@ -1,13 +1 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file +target/ \ No newline at end of file diff --git a/spring-security-modules/spring-security-core/README.md b/spring-security-modules/spring-security-core/README.md index 3579e5e759..6b1f236b7c 100644 --- a/spring-security-modules/spring-security-core/README.md +++ b/spring-security-modules/spring-security-core/README.md @@ -8,8 +8,6 @@ This module contains articles about core Spring Security - [Introduction to Spring Method Security](https://www.baeldung.com/spring-security-method-security) - [Overview and Need for DelegatingFilterProxy in Spring](https://www.baeldung.com/spring-delegating-filter-proxy) -### @PreFilter and @PostFilter annotations - -#### Build the Project +### Build the Project `mvn clean install` diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/App.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/App.java index d23df9adef..6e41a53967 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/App.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/App.java @@ -12,9 +12,6 @@ import org.springframework.web.filter.DelegatingFilterProxy; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; @SpringBootApplication -@EnableJpaRepositories("com.baeldung.repository") -@ComponentScan("com.baeldung") -@EntityScan("com.baeldung.entity") public class App extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(App.class, args); @@ -31,19 +28,16 @@ public class App extends SpringBootServletInitializer { @Override protected Class[] getRootConfigClasses() { - // TODO Auto-generated method stub return null; } @Override protected Class[] getServletConfigClasses() { - // TODO Auto-generated method stub return null; } @Override protected String[] getServletMappings() { - // TODO Auto-generated method stub return null; } } diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/auditing/ExposeAttemptedPathAuthorizationAuditListener.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/auditing/ExposeAttemptedPathAuthorizationAuditListener.java similarity index 97% rename from spring-security-modules/spring-security-core/src/main/java/com/baeldung/auditing/ExposeAttemptedPathAuthorizationAuditListener.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/auditing/ExposeAttemptedPathAuthorizationAuditListener.java index 615d14584f..d238c157df 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/auditing/ExposeAttemptedPathAuthorizationAuditListener.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/auditing/ExposeAttemptedPathAuthorizationAuditListener.java @@ -1,4 +1,4 @@ -package com.baeldung.auditing; +package com.baeldung.app.auditing; import org.springframework.boot.actuate.audit.AuditEvent; import org.springframework.boot.actuate.security.AbstractAuthorizationAuditListener; diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/auditing/LoginAttemptsLogger.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/auditing/LoginAttemptsLogger.java similarity index 96% rename from spring-security-modules/spring-security-core/src/main/java/com/baeldung/auditing/LoginAttemptsLogger.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/auditing/LoginAttemptsLogger.java index d06c3e24e1..e775006953 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/auditing/LoginAttemptsLogger.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/auditing/LoginAttemptsLogger.java @@ -1,4 +1,4 @@ -package com.baeldung.auditing; +package com.baeldung.app.auditing; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/config/DatabaseLoader.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/config/DatabaseLoader.java similarity index 85% rename from spring-security-modules/spring-security-core/src/main/java/com/baeldung/config/DatabaseLoader.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/config/DatabaseLoader.java index 7f22c3ec99..9d06d5f7ac 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/config/DatabaseLoader.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/config/DatabaseLoader.java @@ -1,11 +1,11 @@ -package com.baeldung.config; +package com.baeldung.app.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; -import com.baeldung.entity.Task; -import com.baeldung.repository.TaskRepository; +import com.baeldung.app.entity.Task; +import com.baeldung.app.repository.TaskRepository; @Component public class DatabaseLoader implements CommandLineRunner { diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/config/WebSecurityConfig.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/config/WebSecurityConfig.java similarity index 98% rename from spring-security-modules/spring-security-core/src/main/java/com/baeldung/config/WebSecurityConfig.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/config/WebSecurityConfig.java index be11a0fde5..15af160135 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/config/WebSecurityConfig.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/config/WebSecurityConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.config; +package com.baeldung.app.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/controller/TaskController.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java similarity index 89% rename from spring-security-modules/spring-security-core/src/main/java/com/baeldung/controller/TaskController.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java index 91156354b1..a084f14eca 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/controller/TaskController.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java @@ -1,4 +1,4 @@ -package com.baeldung.controller; +package com.baeldung.app.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -7,8 +7,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import com.baeldung.entity.Task; -import com.baeldung.service.TaskService; +import com.baeldung.app.entity.Task; +import com.baeldung.app.service.TaskService; @Controller @RequestMapping("api/tasks") diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/entity/Task.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/entity/Task.java similarity index 96% rename from spring-security-modules/spring-security-core/src/main/java/com/baeldung/entity/Task.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/entity/Task.java index 9103c342cc..d2a8a1383d 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/entity/Task.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/entity/Task.java @@ -1,4 +1,4 @@ -package com.baeldung.entity; +package com.baeldung.app.entity; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filter/CustomFilter.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/filter/CustomFilter.java similarity index 96% rename from spring-security-modules/spring-security-core/src/main/java/com/baeldung/filter/CustomFilter.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/filter/CustomFilter.java index e748b373b7..7229e4606f 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/filter/CustomFilter.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/filter/CustomFilter.java @@ -1,4 +1,4 @@ -package com.baeldung.filter; +package com.baeldung.app.filter; import java.io.IOException; diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/repository/TaskRepository.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/repository/TaskRepository.java similarity index 64% rename from spring-security-modules/spring-security-core/src/main/java/com/baeldung/repository/TaskRepository.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/repository/TaskRepository.java index afb999719c..ac0f850891 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/repository/TaskRepository.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/repository/TaskRepository.java @@ -1,8 +1,8 @@ -package com.baeldung.repository; +package com.baeldung.app.repository; import org.springframework.data.repository.CrudRepository; -import com.baeldung.entity.Task; +import com.baeldung.app.entity.Task; public interface TaskRepository extends CrudRepository { diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/service/TaskService.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/service/TaskService.java similarity index 85% rename from spring-security-modules/spring-security-core/src/main/java/com/baeldung/service/TaskService.java rename to spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/service/TaskService.java index 1269eb4fd0..20d53ac77a 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/service/TaskService.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/service/TaskService.java @@ -1,12 +1,12 @@ -package com.baeldung.service; +package com.baeldung.app.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PostFilter; import org.springframework.security.access.prepost.PreFilter; import org.springframework.stereotype.Service; -import com.baeldung.entity.Task; -import com.baeldung.repository.TaskRepository; +import com.baeldung.app.entity.Task; +import com.baeldung.app.repository.TaskRepository; @Service public class TaskService { diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/CustomPermissionAllowedMethodSecurityMetadataSource.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/CustomPermissionAllowedMethodSecurityMetadataSource.java new file mode 100644 index 0000000000..4bde3f5aa3 --- /dev/null +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/CustomPermissionAllowedMethodSecurityMetadataSource.java @@ -0,0 +1,49 @@ +package com.baeldung.denyonmissing; + +import static org.springframework.security.access.annotation.Jsr250SecurityConfig.DENY_ALL_ATTRIBUTE; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.security.access.ConfigAttribute; +import org.springframework.security.access.method.AbstractFallbackMethodSecurityMetadataSource; +import org.springframework.security.access.prepost.PostAuthorize; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; + +public class CustomPermissionAllowedMethodSecurityMetadataSource extends AbstractFallbackMethodSecurityMetadataSource { + @Override + protected Collection findAttributes(Class clazz) { + return null; + } + + @Override + protected Collection findAttributes(Method method, Class targetClass) { + Annotation[] annotations = AnnotationUtils.getAnnotations(method); + List attributes = new ArrayList<>(); + + // if the class is annotated as @Controller we should by default deny access to every method + if (AnnotationUtils.findAnnotation(targetClass, Controller.class) != null) { + attributes.add(DENY_ALL_ATTRIBUTE); + } + + if (annotations != null) { + for (Annotation a : annotations) { + // but not if the method has at least a PreAuthorize or PostAuthorize annotation + if (a instanceof PreAuthorize || a instanceof PostAuthorize) { + return null; + } + } + } + return attributes; + } + + @Override + public Collection getAllConfigAttributes() { + return null; + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/DenyApplication.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/DenyApplication.java new file mode 100644 index 0000000000..d5d28ae210 --- /dev/null +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/DenyApplication.java @@ -0,0 +1,11 @@ +package com.baeldung.denyonmissing; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DenyApplication { + public static void main(String[] args) { + SpringApplication.run(DenyApplication.class, args); + } +} diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/DenyMethodSecurityConfig.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/DenyMethodSecurityConfig.java new file mode 100644 index 0000000000..695f81eb54 --- /dev/null +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/DenyMethodSecurityConfig.java @@ -0,0 +1,29 @@ +package com.baeldung.denyonmissing; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.access.method.MethodSecurityMetadataSource; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.provisioning.InMemoryUserDetailsManager; + +@Configuration +@EnableWebSecurity +@EnableGlobalMethodSecurity(prePostEnabled = true) +public class DenyMethodSecurityConfig extends GlobalMethodSecurityConfiguration { + @Override + protected MethodSecurityMetadataSource customMethodSecurityMetadataSource() { + return new CustomPermissionAllowedMethodSecurityMetadataSource(); + } + + @Bean + public UserDetailsService userDetailsService() { + return new InMemoryUserDetailsManager( + User.withUsername("user").password("{noop}password").roles("USER").build(), + User.withUsername("guest").password("{noop}password").roles().build() + ); + } +} diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/DenyOnMissingController.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/DenyOnMissingController.java new file mode 100644 index 0000000000..ef8881d3b7 --- /dev/null +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/denyonmissing/DenyOnMissingController.java @@ -0,0 +1,19 @@ +package com.baeldung.denyonmissing; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class DenyOnMissingController { + @GetMapping(path = "hello") + @PreAuthorize("hasRole('USER')") + public String hello() { + return "Hello world!"; + } + + @GetMapping(path = "bye") + public String bye() { + return "Bye bye world!"; + } +} diff --git a/spring-security-modules/spring-security-core/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-core/src/test/java/com/baeldung/app/SpringContextTest.java similarity index 93% rename from spring-security-modules/spring-security-core/src/test/java/com/baeldung/SpringContextTest.java rename to spring-security-modules/spring-security-core/src/test/java/com/baeldung/app/SpringContextTest.java index bca6450fb1..b3c31a936a 100644 --- a/spring-security-modules/spring-security-core/src/test/java/com/baeldung/SpringContextTest.java +++ b/spring-security-modules/spring-security-core/src/test/java/com/baeldung/app/SpringContextTest.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.app; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-security-modules/spring-security-core/src/test/java/com/baeldung/test/LiveTest.java b/spring-security-modules/spring-security-core/src/test/java/com/baeldung/app/test/LiveTest.java similarity index 96% rename from spring-security-modules/spring-security-core/src/test/java/com/baeldung/test/LiveTest.java rename to spring-security-modules/spring-security-core/src/test/java/com/baeldung/app/test/LiveTest.java index 6bcb2e8f0f..d099173395 100644 --- a/spring-security-modules/spring-security-core/src/test/java/com/baeldung/test/LiveTest.java +++ b/spring-security-modules/spring-security-core/src/test/java/com/baeldung/app/test/LiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.test; +package com.baeldung.app.test; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -22,7 +22,7 @@ import org.springframework.web.context.WebApplicationContext; import com.baeldung.app.App; @RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = App.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = App.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class LiveTest { diff --git a/spring-security-modules/spring-security-core/src/test/java/com/baeldung/denyonmissing/DenyOnMissingControllerIntegrationTest.java b/spring-security-modules/spring-security-core/src/test/java/com/baeldung/denyonmissing/DenyOnMissingControllerIntegrationTest.java new file mode 100644 index 0000000000..b4e4154982 --- /dev/null +++ b/spring-security-modules/spring-security-core/src/test/java/com/baeldung/denyonmissing/DenyOnMissingControllerIntegrationTest.java @@ -0,0 +1,53 @@ +package com.baeldung.denyonmissing; + +import static org.hamcrest.core.Is.isA; +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.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(classes = DenyApplication.class) +public class DenyOnMissingControllerIntegrationTest { + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Autowired + private WebApplicationContext context; + private MockMvc mockMvc; + + @Before + public void setUp() { + mockMvc = MockMvcBuilders.webAppContextSetup(context) + .build(); + } + + @Test + @WithMockUser(username = "user") + public void givenANormalUser_whenCallingHello_thenAccessDenied() throws Exception { + mockMvc.perform(get("/hello")) + .andExpect(status().isOk()) + .andExpect(content().string("Hello world!")); + } + + @Test + @WithMockUser(username = "user") + public void givenANormalUser_whenCallingBye_thenAccessDenied() throws Exception { + expectedException.expectCause(isA(AccessDeniedException.class)); + + mockMvc.perform(get("/bye")); + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-core/src/test/resources/.gitignore b/spring-security-modules/spring-security-core/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/spring-security-modules/spring-security-core/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file diff --git a/spring-security-modules/spring-security-cors/pom.xml b/spring-security-modules/spring-security-cors/pom.xml index 91e8f5adb6..2acb99368f 100644 --- a/spring-security-modules/spring-security-cors/pom.xml +++ b/spring-security-modules/spring-security-cors/pom.xml @@ -3,15 +3,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-security-cors - 0.0.1-SNAPSHOT spring-security-cors jar Spring Security CORS com.baeldung - parent-modules - 1.0.0-SNAPSHOT + spring-security-modules + 0.0.1-SNAPSHOT diff --git a/spring-security-modules/spring-security-cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerTest.java b/spring-security-modules/spring-security-cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java similarity index 97% rename from spring-security-modules/spring-security-cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerTest.java rename to spring-security-modules/spring-security-cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java index a471eb922f..7567573040 100644 --- a/spring-security-modules/spring-security-cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerTest.java +++ b/spring-security-modules/spring-security-cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java @@ -18,7 +18,7 @@ import com.baeldung.springbootsecuritycors.basicauth.SpringBootSecurityApplicati @RunWith(SpringRunner.class) @SpringBootTest(classes = { SpringBootSecurityApplication.class }) -public class ResourceControllerTest { +public class ResourceControllerUnitTest { private MockMvc mockMvc; diff --git a/spring-security-modules/spring-security-mvc-boot/src/main/java/com/baeldung/models/Tweet.java b/spring-security-modules/spring-security-mvc-boot/src/main/java/com/baeldung/models/Tweet.java index b2e45009f6..54a96deaf3 100644 --- a/spring-security-modules/spring-security-mvc-boot/src/main/java/com/baeldung/models/Tweet.java +++ b/spring-security-modules/spring-security-mvc-boot/src/main/java/com/baeldung/models/Tweet.java @@ -3,14 +3,17 @@ package com.baeldung.models; import java.util.HashSet; import java.util.Set; +import javax.persistence.CollectionTable; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Table; @Entity +@Table(name = "Tweet") public class Tweet { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) @@ -18,7 +21,8 @@ public class Tweet { private String tweet; private String owner; @ElementCollection(targetClass = String.class, fetch = FetchType.EAGER) - private Set likes = new HashSet(); + @CollectionTable(name = "Tweet_Likes") + private Set likes = new HashSet<>(); public long getId() { return id; diff --git a/spring-security-modules/spring-security-mvc-boot/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java index bd0c14ca1f..b2def82c51 100644 --- a/spring-security-modules/spring-security-mvc-boot/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java +++ b/spring-security-modules/spring-security-mvc-boot/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java @@ -1,29 +1,5 @@ package com.baeldung.relationships; -import static org.springframework.util.Assert.isTrue; - -import java.util.Date; -import java.util.List; - -import javax.servlet.ServletContext; - -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; - import com.baeldung.AppConfig; import com.baeldung.data.repositories.TweetRepository; import com.baeldung.data.repositories.UserRepository; @@ -31,6 +7,30 @@ import com.baeldung.models.AppUser; import com.baeldung.models.Tweet; import com.baeldung.security.AppUserPrincipal; import com.baeldung.util.DummyContentUtil; +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.dao.InvalidDataAccessApiUsageException; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.jdbc.JdbcTestUtils; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; + +import javax.servlet.ServletContext; +import java.util.Date; +import java.util.List; + +import static org.springframework.util.Assert.isTrue; @RunWith(SpringRunner.class) @WebAppConfiguration @@ -54,10 +54,22 @@ public class SpringDataWithSecurityIntegrationTest { tweetRepository.saveAll(DummyContentUtil.generateDummyTweets(appUsers)); } - @AfterClass - public static void tearDown() { - tweetRepository.deleteAll(); - userRepository.deleteAll(); + /** + * This is to ensure the tables are dropped in proper order. + * After the Spring Boot 2.2.2 upgrade, DDL statements generated automatically try to drop Tweet table first. + * As a result we get org.h2.jdbc.JdbcSQLSyntaxErrorException because Tweet_Likes table depends on Tweet. + * + * @see + * StackOverflow#59364212 + * + * @see + * StackOverflow#59561551 + * + */ + @After + public void tearDown() { + JdbcTemplate jdbcTemplate = ctx.getBean(JdbcTemplate.class); + JdbcTestUtils.dropTables(jdbcTemplate, "Tweet_Likes", "Tweet"); } @Test @@ -82,7 +94,7 @@ public class SpringDataWithSecurityIntegrationTest { .setAuthentication(auth); Page page = null; do { - page = tweetRepository.getMyTweetsAndTheOnesILiked(new PageRequest(page != null ? page.getNumber() + 1 : 0, 5)); + page = tweetRepository.getMyTweetsAndTheOnesILiked(PageRequest.of(page != null ? page.getNumber() + 1 : 0, 5)); for (Tweet twt : page.getContent()) { isTrue((twt.getOwner() == appUser.getUsername()) || (twt.getLikes() .contains(appUser.getUsername())), "I do not have any Tweets"); @@ -94,7 +106,7 @@ public class SpringDataWithSecurityIntegrationTest { public void givenNoAppUser_whenPaginatedResultsRetrievalAttempted_shouldFail() { Page page = null; do { - page = tweetRepository.getMyTweetsAndTheOnesILiked(new PageRequest(page != null ? page.getNumber() + 1 : 0, 5)); + page = tweetRepository.getMyTweetsAndTheOnesILiked(PageRequest.of(page != null ? page.getNumber() + 1 : 0, 5)); } while (page != null && page.hasNext()); } } diff --git a/spring-security-modules/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml b/spring-security-modules/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml index 659347f610..6c0f24e2c4 100644 --- a/spring-security-modules/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml +++ b/spring-security-modules/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml @@ -2,9 +2,9 @@ diff --git a/spring-security-modules/spring-security-mvc-login/src/main/resources/channelWebSecurityConfig.xml b/spring-security-modules/spring-security-mvc-login/src/main/resources/channelWebSecurityConfig.xml index 516829f5eb..eff3e1a1a1 100644 --- a/spring-security-modules/spring-security-mvc-login/src/main/resources/channelWebSecurityConfig.xml +++ b/spring-security-modules/spring-security-mvc-login/src/main/resources/channelWebSecurityConfig.xml @@ -2,9 +2,9 @@ diff --git a/spring-security-modules/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml b/spring-security-modules/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml index 189522889f..8a83bf5e93 100644 --- a/spring-security-modules/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml +++ b/spring-security-modules/spring-security-mvc-login/src/main/resources/webSecurityConfig.xml @@ -2,9 +2,9 @@ diff --git a/spring-security-modules/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-modules/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml index 4ba9642448..fa2fae4148 100644 --- a/spring-security-modules/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-security-modules/spring-security-mvc-login/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd" > \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc-login/src/test/resources/mvc-servlet.xml b/spring-security-modules/spring-security-mvc-login/src/test/resources/mvc-servlet.xml index aa5488b116..4568d319b8 100644 --- a/spring-security-modules/spring-security-mvc-login/src/test/resources/mvc-servlet.xml +++ b/spring-security-modules/spring-security-mvc-login/src/test/resources/mvc-servlet.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> diff --git a/spring-security-modules/spring-security-oidc/README.md b/spring-security-modules/spring-security-oidc/README.md new file mode 100644 index 0000000000..92ba60cad9 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/README.md @@ -0,0 +1,23 @@ +## Spring Security OpenID + +This module contains articles about OpenID with Spring Security + +### Relevant articles + +- [Spring Security and OpenID Connect](https://www.baeldung.com/spring-security-openid-connect) + +### OpenID Connect with Spring Security + +### Run the Project + +``` +mvn spring-boot:run +``` + +### Obtain Google App - Client ID, Secret + +- We need to get client id and client secret by creating a new project at [Google Developer Console](https://console.developers.google.com/project/_/apiui/credential?pli=1) +- We can follow these instructions to register our client application on their platform + +- Once we have the client id and secret, we have to make sure we add them to the YAML files of the project + diff --git a/spring-security-modules/spring-security-oidc/pom.xml b/spring-security-modules/spring-security-oidc/pom.xml new file mode 100644 index 0000000000..91e4641450 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + spring-security-oidc + spring-security-oidc + war + Spring OpenID Connect sample project + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-oauth2-client + + + + + 2.2.1.RELEASE + + + diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/discovery/SpringOidcDiscoveryApplication.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/discovery/SpringOidcDiscoveryApplication.java new file mode 100644 index 0000000000..895fe676e1 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/discovery/SpringOidcDiscoveryApplication.java @@ -0,0 +1,20 @@ +package com.baeldung.openid.oidc.discovery; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; + +import com.baeldung.openid.oidc.utils.YamlLoaderInitializer; + +@SpringBootApplication +public class SpringOidcDiscoveryApplication { + + public static void main(String[] args) { + SpringApplication application = new SpringApplication(SpringOidcDiscoveryApplication.class); + ApplicationContextInitializer yamlInitializer = new YamlLoaderInitializer("discovery-application.yml"); + application.addInitializers(yamlInitializer); + application.run(args); + } + +} diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/discovery/web/controllers/UserRestController.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/discovery/web/controllers/UserRestController.java new file mode 100644 index 0000000000..984a23fea3 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/discovery/web/controllers/UserRestController.java @@ -0,0 +1,17 @@ +package com.baeldung.openid.oidc.discovery.web.controllers; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.oauth2.core.oidc.user.OidcUser; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/user") +public class UserRestController { + + @GetMapping("/oidc-principal") + public OidcUser getOidcUserPrincipal(@AuthenticationPrincipal OidcUser principal) { + return principal; + } +} diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/SpringOidcLoginApplication.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/SpringOidcLoginApplication.java new file mode 100644 index 0000000000..6ec87c4406 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/SpringOidcLoginApplication.java @@ -0,0 +1,20 @@ +package com.baeldung.openid.oidc.login; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; + +import com.baeldung.openid.oidc.utils.YamlLoaderInitializer; + +@SpringBootApplication +public class SpringOidcLoginApplication { + + public static void main(String[] args) { + SpringApplication application = new SpringApplication(SpringOidcLoginApplication.class); + ApplicationContextInitializer yamlInitializer = new YamlLoaderInitializer("login-application.yml"); + application.addInitializers(yamlInitializer); + application.run(args); + } + +} diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/config/OAuth2LoginSecurityConfig.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/config/OAuth2LoginSecurityConfig.java new file mode 100644 index 0000000000..5bb5cef58c --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/config/OAuth2LoginSecurityConfig.java @@ -0,0 +1,28 @@ +package com.baeldung.openid.oidc.login.config; + +import java.util.HashSet; +import java.util.Set; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService; + +@Configuration +public class OAuth2LoginSecurityConfig extends WebSecurityConfigurerAdapter {// @formatter:off + + @Override + protected void configure(HttpSecurity http) throws Exception { + Set googleScopes = new HashSet<>(); + googleScopes.add("https://www.googleapis.com/auth/userinfo.email"); + googleScopes.add("https://www.googleapis.com/auth/userinfo.profile"); + + OidcUserService googleUserService = new OidcUserService(); + googleUserService.setAccessibleScopes(googleScopes); + + http.authorizeRequests(authorizeRequests -> authorizeRequests.anyRequest() + .authenticated()) + .oauth2Login(oauthLogin -> oauthLogin.userInfoEndpoint() + .oidcUserService(googleUserService)); + }// @formatter:on +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/service/UserService.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/service/UserService.java new file mode 100644 index 0000000000..b6e35bd139 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/service/UserService.java @@ -0,0 +1,23 @@ +package com.baeldung.openid.oidc.login.service; + +import java.util.Collections; +import java.util.Map; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.oauth2.core.oidc.user.OidcUser; +import org.springframework.stereotype.Service; + +@Service +public class UserService { + + public Map getUserClaims() { + Authentication authentication = SecurityContextHolder.getContext() + .getAuthentication(); + if (authentication.getPrincipal() instanceof OidcUser) { + OidcUser principal = ((OidcUser) authentication.getPrincipal()); + return principal.getClaims(); + } + return Collections.emptyMap(); + } +} diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/web/controllers/UserRestController.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/web/controllers/UserRestController.java new file mode 100644 index 0000000000..a4715c9310 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/login/web/controllers/UserRestController.java @@ -0,0 +1,32 @@ +package com.baeldung.openid.oidc.login.web.controllers; + +import java.util.Map; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.oauth2.core.oidc.user.OidcUser; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.openid.oidc.login.service.UserService; + +@RestController +@RequestMapping("/user") +public class UserRestController { + + private UserService service; + + public UserRestController(UserService service) { + this.service = service; + } + + @GetMapping("/oidc-principal") + public OidcUser getOidcUserPrincipal(@AuthenticationPrincipal OidcUser principal) { + return principal; + } + + @GetMapping("/oidc-claims") + public Map getClaimsFromBean() { + return service.getUserClaims(); + } +} diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/SpringOidcSessionManagementApplication.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/SpringOidcSessionManagementApplication.java new file mode 100644 index 0000000000..700fc7fbe7 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/SpringOidcSessionManagementApplication.java @@ -0,0 +1,20 @@ +package com.baeldung.openid.oidc.sessionmanagement; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; + +import com.baeldung.openid.oidc.utils.YamlLoaderInitializer; + +@SpringBootApplication +public class SpringOidcSessionManagementApplication { + + public static void main(String[] args) { + SpringApplication application = new SpringApplication(SpringOidcSessionManagementApplication.class); + ApplicationContextInitializer yamlInitializer = new YamlLoaderInitializer("sessionmanagement-application.yml"); + application.addInitializers(yamlInitializer); + application.run(args); + } + +} diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/config/OAuth2SessionManagementSecurityConfig.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/config/OAuth2SessionManagementSecurityConfig.java new file mode 100644 index 0000000000..5a55c89b05 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/config/OAuth2SessionManagementSecurityConfig.java @@ -0,0 +1,37 @@ +package com.baeldung.openid.oidc.sessionmanagement.config; + +import java.net.URI; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler; +import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; +import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; + +@Configuration +public class OAuth2SessionManagementSecurityConfig extends WebSecurityConfigurerAdapter { + + @Autowired + private ClientRegistrationRepository clientRegistrationRepository; + + @Override + protected void configure(HttpSecurity http) throws Exception { // @formatter:off + http.authorizeRequests(authorizeRequests -> authorizeRequests.mvcMatchers("/home") + .permitAll() + .anyRequest() + .authenticated()) + .oauth2Login(oauthLogin -> oauthLogin.permitAll()) + .logout(logout -> logout.logoutSuccessHandler(oidcLogoutSuccessHandler())); + } // @formatter:on + + + private LogoutSuccessHandler oidcLogoutSuccessHandler() { + OidcClientInitiatedLogoutSuccessHandler oidcLogoutSuccessHandler = new OidcClientInitiatedLogoutSuccessHandler(this.clientRegistrationRepository); + + oidcLogoutSuccessHandler.setPostLogoutRedirectUri(URI.create("http://localhost:8081/home")); + + return oidcLogoutSuccessHandler; + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/web/controllers/HomeRestController.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/web/controllers/HomeRestController.java new file mode 100644 index 0000000000..88becc2456 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/web/controllers/HomeRestController.java @@ -0,0 +1,14 @@ +package com.baeldung.openid.oidc.sessionmanagement.web.controllers; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HomeRestController { + + @GetMapping("/home") + public String simpleHomepage() { + return "Welcome to this simple homepage!"; + } + +} diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/web/controllers/UserRestController.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/web/controllers/UserRestController.java new file mode 100644 index 0000000000..256d4bc389 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/sessionmanagement/web/controllers/UserRestController.java @@ -0,0 +1,17 @@ +package com.baeldung.openid.oidc.sessionmanagement.web.controllers; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.oauth2.core.oidc.user.OidcUser; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/user") +public class UserRestController { + + @GetMapping("/oidc-principal") + public OidcUser getOidcUserPrincipal(@AuthenticationPrincipal OidcUser principal) { + return principal; + } +} diff --git a/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/utils/YamlLoaderInitializer.java b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/utils/YamlLoaderInitializer.java new file mode 100644 index 0000000000..4d51dcb9a8 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/java/com/baeldung/openid/oidc/utils/YamlLoaderInitializer.java @@ -0,0 +1,48 @@ +package com.baeldung.openid.oidc.utils; + +import java.io.IOException; + +import org.springframework.boot.env.YamlPropertySourceLoader; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.env.PropertySource; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; + +public class YamlLoaderInitializer implements ApplicationContextInitializer { + + private final YamlPropertySourceLoader loader = new YamlPropertySourceLoader(); + private final String file; + + public YamlLoaderInitializer() { + this.file = null; + } + + public YamlLoaderInitializer(String file) { + this.file = file; + } + + @Override + public void initialize(ConfigurableApplicationContext applicationContext) { + String yamlFile = (this.file == null) ? applicationContext.getEnvironment() + .getProperty("custom.configyaml.file") : this.file; + Resource path = new ClassPathResource(yamlFile); + PropertySource propertySource = loadYaml(path); + applicationContext.getEnvironment() + .getPropertySources() + .addLast(propertySource); + } + + private PropertySource loadYaml(Resource path) { + if (!path.exists()) { + throw new IllegalArgumentException("Resource " + path + " does not exist"); + } + try { + return this.loader.load("custom-resource", path) + .get(0); + } catch (IOException ex) { + throw new IllegalStateException("Failed to load yaml configuration from" + path, ex); + } + } + +} diff --git a/spring-security-modules/spring-security-oidc/src/main/resources/application.yml b/spring-security-modules/spring-security-oidc/src/main/resources/application.yml new file mode 100644 index 0000000000..f303fcecd1 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/resources/application.yml @@ -0,0 +1,7 @@ +server: + port: 8081 + +logging: + level: + org.springframework.web.client.RestTemplate: DEBUG + \ No newline at end of file diff --git a/spring-security-modules/spring-security-oidc/src/main/resources/discovery-application.yml b/spring-security-modules/spring-security-oidc/src/main/resources/discovery-application.yml new file mode 100644 index 0000000000..1cbebbcb7b --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/resources/discovery-application.yml @@ -0,0 +1,11 @@ +spring: + security: + oauth2: + client: + registration: + custom-google: + client-id: + client-secret: + provider: + custom-google: + issuer-uri: https://accounts.google.com \ No newline at end of file diff --git a/spring-security-modules/spring-security-oidc/src/main/resources/login-application.yml b/spring-security-modules/spring-security-oidc/src/main/resources/login-application.yml new file mode 100644 index 0000000000..b3220a0550 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/resources/login-application.yml @@ -0,0 +1,8 @@ +spring: + security: + oauth2: + client: + registration: + google: + client-id: + client-secret: \ No newline at end of file diff --git a/spring-security-modules/spring-security-oidc/src/main/resources/sessionmanagement-application.yml b/spring-security-modules/spring-security-oidc/src/main/resources/sessionmanagement-application.yml new file mode 100644 index 0000000000..d7dd5e6ec7 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/main/resources/sessionmanagement-application.yml @@ -0,0 +1,16 @@ +spring: + security: + oauth2: + client: + registration: + okta: + client-id: + client-secret: + provider: + okta: + issuer-uri: https://dev-123.okta.com + # Or, optionally: + #authorization-uri https://dev-123-admin.okta.com/oauth2/v1/authorize + #token-uri: https://dev-123-admin.okta.com/oauth2/v1/token + #user-info-uri: https://dev-123-admin.okta.com/oauth2/v1/userinfo + #jwk-set-uri: https://dev-123-admin.okta.com/oauth2/v1/keys \ No newline at end of file diff --git a/spring-security-modules/spring-security-oidc/src/test/java/com/baeldung/openid/oidc/discovery/SpringContextTest.java b/spring-security-modules/spring-security-oidc/src/test/java/com/baeldung/openid/oidc/discovery/SpringContextTest.java new file mode 100644 index 0000000000..25c87cdc6f --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/test/java/com/baeldung/openid/oidc/discovery/SpringContextTest.java @@ -0,0 +1,19 @@ +package com.baeldung.openid.oidc.discovery; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import com.baeldung.openid.oidc.utils.YamlLoaderInitializer; + +//We'll ignore this test, as we don't want to depend on Google's OIDC-configuration endpoint to be available +@Disabled +@SpringBootTest(classes = SpringOidcDiscoveryApplication.class, properties = "custom.configyaml.file=discovery-application.yml") +@ContextConfiguration(initializers = YamlLoaderInitializer.class) +public class SpringContextTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} diff --git a/spring-security-modules/spring-security-oidc/src/test/java/com/baeldung/openid/oidc/login/SpringContextTest.java b/spring-security-modules/spring-security-oidc/src/test/java/com/baeldung/openid/oidc/login/SpringContextTest.java new file mode 100644 index 0000000000..675dcd8727 --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/test/java/com/baeldung/openid/oidc/login/SpringContextTest.java @@ -0,0 +1,16 @@ +package com.baeldung.openid.oidc.login; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import com.baeldung.openid.oidc.utils.YamlLoaderInitializer; + +@SpringBootTest(classes = SpringOidcLoginApplication.class, properties = "custom.configyaml.file=login-application.yml") +@ContextConfiguration(initializers = YamlLoaderInitializer.class) +public class SpringContextTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} diff --git a/spring-security-modules/spring-security-oidc/src/test/java/com/baeldung/openid/oidc/sessionmanagement/SpringContextTest.java b/spring-security-modules/spring-security-oidc/src/test/java/com/baeldung/openid/oidc/sessionmanagement/SpringContextTest.java new file mode 100644 index 0000000000..91ed11fbaf --- /dev/null +++ b/spring-security-modules/spring-security-oidc/src/test/java/com/baeldung/openid/oidc/sessionmanagement/SpringContextTest.java @@ -0,0 +1,19 @@ +package com.baeldung.openid.oidc.sessionmanagement; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import com.baeldung.openid.oidc.utils.YamlLoaderInitializer; + +//We'll ignore this test, as we don't want to depend on the Okta instance OIDC-configuration endpoint to be available +@Disabled +@SpringBootTest(classes = SpringOidcSessionManagementApplication.class, properties = "custom.configyaml.file=sessionmanagement-application.yml") +@ContextConfiguration(initializers = YamlLoaderInitializer.class) +public class SpringContextTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} diff --git a/spring-security-modules/spring-security-openid/README.md b/spring-security-modules/spring-security-openid/README.md deleted file mode 100644 index 1f856fe191..0000000000 --- a/spring-security-modules/spring-security-openid/README.md +++ /dev/null @@ -1,24 +0,0 @@ -## Spring Security OpenID - -This module contains articles about OpenID with Spring Security - -### Relevant articles - -- [Spring Security and OpenID Connect](https://www.baeldung.com/spring-security-openid-connect) - -### OpenID Connect with Spring Security - -### Run the Project - -``` -mvn spring-boot:run -``` - -### Obtain Google App - Client ID, Secret - -- You need to get client id and client secret by creating a new project at [Google Developer Console](https://console.developers.google.com/project/_/apiui/credential?pli=1) -- Make sure to add OAuth2 credentials by selecting Add credentials > OAuth 2.0 client ID -- Make sure you set redirect URI to http://localhost:8081/google-login - -- Once you have your client id and secret, make sure you add them to the `application.properties` of the project - diff --git a/spring-security-modules/spring-security-openid/pom.xml b/spring-security-modules/spring-security-openid/pom.xml deleted file mode 100644 index 970182dc3b..0000000000 --- a/spring-security-modules/spring-security-openid/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - spring-security-openid - spring-security-openid - war - Spring OpenID sample project - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-tomcat - - - - org.springframework.security.oauth - spring-security-oauth2 - ${spring-security-oauth2.version} - - - - org.springframework.security - spring-security-jwt - ${spring-security-jwt.version} - - - - com.auth0 - jwks-rsa - ${jwks-rsa.version} - - - - - 2.2.1.RELEASE - 1.0.9.RELEASE - 0.3.0 - - - diff --git a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/GoogleOpenIdConnectConfig.java b/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/GoogleOpenIdConnectConfig.java deleted file mode 100644 index 8e9c6e974e..0000000000 --- a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/GoogleOpenIdConnectConfig.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.baeldung.config; - -import java.util.Arrays; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.oauth2.client.OAuth2ClientContext; -import org.springframework.security.oauth2.client.OAuth2RestTemplate; -import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; -import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails; -import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client; - -@Configuration -@EnableOAuth2Client -public class GoogleOpenIdConnectConfig { - @Value("${google.clientId}") - private String clientId; - - @Value("${google.clientSecret}") - private String clientSecret; - - @Value("${google.accessTokenUri}") - private String accessTokenUri; - - @Value("${google.userAuthorizationUri}") - private String userAuthorizationUri; - - @Value("${google.redirectUri}") - private String redirectUri; - - @Bean - public OAuth2ProtectedResourceDetails googleOpenId() { - final AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails(); - details.setClientId(clientId); - details.setClientSecret(clientSecret); - details.setAccessTokenUri(accessTokenUri); - details.setUserAuthorizationUri(userAuthorizationUri); - details.setScope(Arrays.asList("openid", "email")); - details.setPreEstablishedRedirectUri(redirectUri); - details.setUseCurrentUri(false); - return details; - } - - @Bean - public OAuth2RestTemplate googleOpenIdTemplate(final OAuth2ClientContext clientContext) { - final OAuth2RestTemplate template = new OAuth2RestTemplate(googleOpenId(), clientContext); - return template; - } - -} diff --git a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/HomeController.java b/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/HomeController.java deleted file mode 100644 index f0a5378019..0000000000 --- a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/HomeController.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.baeldung.config; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class HomeController { - private final Logger logger = LoggerFactory.getLogger(getClass()); - - @RequestMapping("/") - @ResponseBody - public final String home() { - final String username = SecurityContextHolder.getContext().getAuthentication().getName(); - logger.info(username); - return "Welcome, " + username; - } - -} diff --git a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/SecurityConfig.java b/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/SecurityConfig.java deleted file mode 100644 index d929bfd631..0000000000 --- a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/SecurityConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.baeldung.config; - -import org.baeldung.security.OpenIdConnectFilter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.oauth2.client.OAuth2RestTemplate; -import org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter; -import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; -import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter; - -@Configuration -@EnableWebSecurity -public class SecurityConfig extends WebSecurityConfigurerAdapter { - @Autowired - private OAuth2RestTemplate restTemplate; - - @Override - public void configure(WebSecurity web) throws Exception { - web.ignoring().antMatchers("/resources/**"); - } - - @Bean - public OpenIdConnectFilter myFilter() { - final OpenIdConnectFilter filter = new OpenIdConnectFilter("/google-login"); - filter.setRestTemplate(restTemplate); - return filter; - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - // @formatter:off - http - .addFilterAfter(new OAuth2ClientContextFilter(), AbstractPreAuthenticatedProcessingFilter.class) - .addFilterAfter(myFilter(), OAuth2ClientContextFilter.class) - .httpBasic().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/google-login")) - .and() - .authorizeRequests() - // .antMatchers("/","/index*").permitAll() - .anyRequest().authenticated() - ; - - // @formatter:on - } -} \ No newline at end of file diff --git a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/security/OpenIdConnectFilter.java b/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/security/OpenIdConnectFilter.java deleted file mode 100644 index f12169cb27..0000000000 --- a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/security/OpenIdConnectFilter.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.baeldung.security; - -import java.io.IOException; -import java.net.URL; -import java.security.interfaces.RSAPublicKey; -import java.util.Date; -import java.util.Map; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.jwt.Jwt; -import org.springframework.security.jwt.JwtHelper; -import org.springframework.security.jwt.crypto.sign.RsaVerifier; -import org.springframework.security.oauth2.client.OAuth2RestOperations; -import org.springframework.security.oauth2.client.OAuth2RestTemplate; -import org.springframework.security.oauth2.common.OAuth2AccessToken; -import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; -import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; - -import com.auth0.jwk.Jwk; -import com.auth0.jwk.JwkProvider; -import com.auth0.jwk.UrlJwkProvider; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class OpenIdConnectFilter extends AbstractAuthenticationProcessingFilter { - @Value("${google.clientId}") - private String clientId; - - @Value("${google.issuer}") - private String issuer; - - @Value("${google.jwkUrl}") - private String jwkUrl; - - public OAuth2RestOperations restTemplate; - - public OpenIdConnectFilter(String defaultFilterProcessesUrl) { - super(defaultFilterProcessesUrl); - setAuthenticationManager(new NoopAuthenticationManager()); - } - - @Override - public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { - - OAuth2AccessToken accessToken; - try { - accessToken = restTemplate.getAccessToken(); - } catch (final OAuth2Exception e) { - throw new BadCredentialsException("Could not obtain access token", e); - } - try { - final String idToken = accessToken.getAdditionalInformation().get("id_token").toString(); - String kid = JwtHelper.headers(idToken) - .get("kid"); - final Jwt tokenDecoded = JwtHelper.decodeAndVerify(idToken, verifier(kid)); - final Map authInfo = new ObjectMapper().readValue(tokenDecoded.getClaims(), Map.class); - verifyClaims(authInfo); - final OpenIdConnectUserDetails user = new OpenIdConnectUserDetails(authInfo, accessToken); - return new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities()); - } catch (final Exception e) { - throw new BadCredentialsException("Could not obtain user details from token", e); - } - - } - - public void verifyClaims(Map claims) { - int exp = (int) claims.get("exp"); - Date expireDate = new Date(exp * 1000L); - Date now = new Date(); - if (expireDate.before(now) || !claims.get("iss").equals(issuer) || !claims.get("aud").equals(clientId)) { - throw new RuntimeException("Invalid claims"); - } - } - - - private RsaVerifier verifier(String kid) throws Exception { - JwkProvider provider = new UrlJwkProvider(new URL(jwkUrl)); - Jwk jwk = provider.get(kid); - return new RsaVerifier((RSAPublicKey) jwk.getPublicKey()); - } - - public void setRestTemplate(OAuth2RestTemplate restTemplate2) { - restTemplate = restTemplate2; - - } - - private static class NoopAuthenticationManager implements AuthenticationManager { - - @Override - public Authentication authenticate(Authentication authentication) throws AuthenticationException { - throw new UnsupportedOperationException("No authentication should be done with this AuthenticationManager"); - } - - } -} diff --git a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/security/OpenIdConnectUserDetails.java b/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/security/OpenIdConnectUserDetails.java deleted file mode 100644 index f0d91fdc27..0000000000 --- a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/security/OpenIdConnectUserDetails.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.baeldung.security; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.oauth2.common.OAuth2AccessToken; - -public class OpenIdConnectUserDetails implements UserDetails { - - private static final long serialVersionUID = 1L; - - private String userId; - private String username; - private OAuth2AccessToken token; - - public OpenIdConnectUserDetails(Map userInfo, OAuth2AccessToken token) { - this.userId = userInfo.get("sub"); - this.username = userInfo.get("email"); - this.token = token; - } - - @Override - public String getUsername() { - return username; - } - - @Override - public Collection getAuthorities() { - return Arrays.asList(new SimpleGrantedAuthority("ROLE_USER")); - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public OAuth2AccessToken getToken() { - return token; - } - - public void setToken(OAuth2AccessToken token) { - this.token = token; - } - - public void setUsername(String username) { - this.username = username; - } - - @Override - public String getPassword() { - return null; - } - - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - return true; - } - - @Override - public boolean isEnabled() { - return true; - } - -} diff --git a/spring-security-modules/spring-security-openid/src/main/resources/application.properties b/spring-security-modules/spring-security-openid/src/main/resources/application.properties deleted file mode 100644 index 49022bf280..0000000000 --- a/spring-security-modules/spring-security-openid/src/main/resources/application.properties +++ /dev/null @@ -1,8 +0,0 @@ -server.port=8081 -google.clientId=TODO -google.clientSecret=TODO -google.accessTokenUri=https://www.googleapis.com/oauth2/v3/token -google.userAuthorizationUri=https://accounts.google.com/o/oauth2/auth -google.redirectUri=http://localhost:8081/google-login -google.issuer=accounts.google.com -google.jwkUrl=https://www.googleapis.com/oauth2/v2/certs \ No newline at end of file diff --git a/spring-security-modules/spring-security-openid/src/test/java/org/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-openid/src/test/java/org/baeldung/SpringContextTest.java deleted file mode 100644 index fa346b2b31..0000000000 --- a/spring-security-modules/spring-security-openid/src/test/java/org/baeldung/SpringContextTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.baeldung; - -import org.baeldung.config.SpringOpenidApplication; -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 = SpringOpenidApplication.class) -public class SpringContextTest { - - @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { - } -} diff --git a/spring-security-modules/spring-security-react/src/main/webapp/WEB-INF/view/react/package-lock.json b/spring-security-modules/spring-security-react/src/main/webapp/WEB-INF/view/react/package-lock.json index 46f3a86c20..6b183d2e5c 100644 --- a/spring-security-modules/spring-security-react/src/main/webapp/WEB-INF/view/react/package-lock.json +++ b/spring-security-modules/spring-security-react/src/main/webapp/WEB-INF/view/react/package-lock.json @@ -9,6 +9,30 @@ "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", "integrity": "sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4=" }, + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + }, + "dependencies": { + "mime-db": { + "version": "1.43.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" + }, + "mime-types": { + "version": "2.1.26", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", + "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", + "requires": { + "mime-db": "1.43.0" + } + } + } + }, "acorn": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", @@ -123,6 +147,11 @@ "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==" }, + "ansi-html": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/ansi-html/-/ansi-html-0.0.7.tgz", + "integrity": "sha1-gTWEAhliqenm/QOflA0S9WynhZ4=" + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -269,6 +298,11 @@ "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=" }, + "array-flatten": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-2.1.2.tgz", + "integrity": "sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ==" + }, "array-includes": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", @@ -1293,6 +1327,11 @@ "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" }, + "batch": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", + "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=" + }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -1322,6 +1361,56 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + }, + "dependencies": { + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + } + } + }, + "bonjour": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/bonjour/-/bonjour-3.5.0.tgz", + "integrity": "sha1-jokKGD2O6aI5OzhExpGkK897yfU=", + "requires": { + "array-flatten": "^2.1.0", + "deep-equal": "^1.0.1", + "dns-equal": "^1.0.0", + "dns-txt": "^2.0.2", + "multicast-dns": "^6.0.1", + "multicast-dns-service-types": "^1.1.0" + } + }, "boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", @@ -1510,6 +1599,11 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz", "integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==" }, + "buffer-indexof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-indexof/-/buffer-indexof-1.1.1.tgz", + "integrity": "sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g==" + }, "buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", @@ -1525,6 +1619,11 @@ "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=" }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -1936,6 +2035,35 @@ "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" }, + "compressible": { + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", + "integrity": "sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==", + "requires": { + "mime-db": ">= 1.43.0 < 2" + }, + "dependencies": { + "mime-db": { + "version": "1.43.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" + } + } + }, + "compression": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.7.4.tgz", + "integrity": "sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ==", + "requires": { + "accepts": "~1.3.5", + "bytes": "3.0.0", + "compressible": "~2.0.16", + "debug": "2.6.9", + "on-headers": "~1.0.2", + "safe-buffer": "5.1.2", + "vary": "~1.1.2" + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1965,6 +2093,11 @@ "xdg-basedir": "^3.0.0" } }, + "connect-history-api-fallback": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz", + "integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==" + }, "console-browserify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", @@ -1983,6 +2116,19 @@ "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=" }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "requires": { + "safe-buffer": "5.1.2" + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, "content-type-parser": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/content-type-parser/-/content-type-parser-1.0.2.tgz", @@ -1993,6 +2139,16 @@ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=" }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -2377,6 +2533,26 @@ "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" }, + "deep-equal": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz", + "integrity": "sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g==", + "requires": { + "is-arguments": "^1.0.4", + "is-date-object": "^1.0.1", + "is-regex": "^1.0.4", + "object-is": "^1.0.1", + "object-keys": "^1.1.1", + "regexp.prototype.flags": "^1.2.0" + }, + "dependencies": { + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + } + } + }, "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -2472,6 +2648,11 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, "des.js": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", @@ -2481,6 +2662,11 @@ "minimalistic-assert": "^1.0.0" } }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, "detect-indent": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", @@ -2489,6 +2675,11 @@ "repeating": "^2.0.0" } }, + "detect-node": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz", + "integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==" + }, "detect-port-alt": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/detect-port-alt/-/detect-port-alt-1.1.6.tgz", @@ -2513,6 +2704,28 @@ "randombytes": "^2.0.0" } }, + "dns-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", + "integrity": "sha1-s55/HabrCnW6nBcySzR1PEfgZU0=" + }, + "dns-packet": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-1.3.1.tgz", + "integrity": "sha512-0UxfQkMhYAUaZI+xrNZOz/as5KgDU0M/fQ9b6SpkyLbk3GEswDi6PADJVaYJradtRVsRIlF1zLyOodbcTCDzUg==", + "requires": { + "ip": "^1.1.0", + "safe-buffer": "^5.0.1" + } + }, + "dns-txt": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/dns-txt/-/dns-txt-2.0.2.tgz", + "integrity": "sha1-uR2Ab10nGI5Ks+fRB9iBocxGQrY=", + "requires": { + "buffer-indexof": "^1.0.0" + } + }, "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", @@ -2624,6 +2837,11 @@ "jsbn": "~0.1.0" } }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, "electron-to-chromium": { "version": "1.3.50", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.50.tgz", @@ -2653,6 +2871,11 @@ "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=" }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, "encoding": { "version": "0.1.12", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", @@ -2785,6 +3008,11 @@ "es6-symbol": "^3.1.1" } }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -3138,6 +3366,11 @@ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, "event-emitter": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", @@ -3147,11 +3380,24 @@ "es5-ext": "~0.10.14" } }, + "eventemitter3": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.0.tgz", + "integrity": "sha512-qerSRB0p+UDEssxTtm6EDKcE7W4OaoisfIMl4CngyEhjpYglocpNg6UEqCvemdGhosAsg4sO2dXJOdyBifPGCg==" + }, "events": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" }, + "eventsource": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-0.1.6.tgz", + "integrity": "sha1-Cs7ehJ7X3RzMMsgRuxG5RNTykjI=", + "requires": { + "original": ">=0.0.5" + } + }, "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -3269,6 +3515,60 @@ "homedir-polyfill": "^1.0.1" } }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + } + } + }, "extend": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", @@ -3398,6 +3698,14 @@ "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.1.tgz", "integrity": "sha1-0eJkOzipTXWDtHkGDmxK/8lAcfg=" }, + "faye-websocket": { + "version": "0.11.3", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.3.tgz", + "integrity": "sha512-D2y4bovYpzziGgbHYtGCMjlJM36vAl/y+xUyn1C+FVx8szd1E+86KwVw6XvYSzOP8iMpm1X0I4xJD+QtUb36OA==", + "requires": { + "websocket-driver": ">=0.5.1" + } + }, "fb-watchman": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.0.tgz", @@ -3486,6 +3794,20 @@ } } }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + } + }, "find-cache-dir": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-1.0.0.tgz", @@ -3520,6 +3842,29 @@ "resolved": "https://registry.npmjs.org/flatten/-/flatten-1.0.2.tgz", "integrity": "sha1-2uRqnXj74lKSJYzB54CkHZXAN4I=" }, + "follow-redirects": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.9.1.tgz", + "integrity": "sha512-oUNbrdUjHItyCytZQrHxWQ81ebL4xCFLH10sG0poUMgbKWoBnswpICjUBld3PLJ1lF6cCYVUBG7hAdLro0JNvg==", + "requires": { + "debug": "^3.0.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -3553,6 +3898,11 @@ "mime-types": "^2.1.12" } }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -3561,6 +3911,11 @@ "map-cache": "^0.2.2" } }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, "fs-extra": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz", @@ -3593,8 +3948,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -3612,13 +3966,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3631,18 +3983,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -3745,8 +4094,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -3756,7 +4104,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3769,20 +4116,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.2.4", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -3799,7 +4143,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3872,8 +4215,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -3883,7 +4225,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3959,8 +4300,7 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -3990,7 +4330,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4008,7 +4347,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4047,13 +4385,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.2", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -4209,6 +4545,11 @@ "duplexer": "^0.1.1" } }, + "handle-thing": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-1.2.5.tgz", + "integrity": "sha1-/Xqtcmvxpf0W38KbL3pmAdJxOcQ=" + }, "handlebars": { "version": "4.0.11", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", @@ -4301,6 +4642,11 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==" + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -4385,6 +4731,17 @@ "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.1.tgz", "integrity": "sha512-Ba4+0M4YvIDUUsprMjhVTU1yN9F2/LJSAl69ZpzaLT4l4j5mwTS6jqqW9Ojvj6lKz/veqPzpJBqGbXspOb533A==" }, + "hpack.js": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz", + "integrity": "sha1-h3dMCUnlE/QuhFdbPEVoH63ioLI=", + "requires": { + "inherits": "^2.0.1", + "obuf": "^1.0.0", + "readable-stream": "^2.0.1", + "wbuf": "^1.1.0" + } + }, "html-comment-regex": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/html-comment-regex/-/html-comment-regex-1.1.1.tgz", @@ -4398,6 +4755,11 @@ "whatwg-encoding": "^1.0.1" } }, + "html-entities": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", + "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=" + }, "html-minifier": { "version": "3.5.17", "resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.17.tgz", @@ -4487,6 +4849,153 @@ } } }, + "http-deceiver": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", + "integrity": "sha1-+nFolEq5pRnTN8sL7HKE3D5yPYc=" + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "http-parser-js": { + "version": "0.4.10", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.4.10.tgz", + "integrity": "sha1-ksnBN0w1CF912zWexWzCV8u5P6Q=" + }, + "http-proxy": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.0.tgz", + "integrity": "sha512-84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPpQ==", + "requires": { + "eventemitter3": "^4.0.0", + "follow-redirects": "^1.0.0", + "requires-port": "^1.0.0" + } + }, + "http-proxy-middleware": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-0.17.4.tgz", + "integrity": "sha1-ZC6ISIUdZvCdTxJJEoRtuutBuDM=", + "requires": { + "http-proxy": "^1.16.2", + "is-glob": "^3.1.0", + "lodash": "^4.17.2", + "micromatch": "^2.3.11" + }, + "dependencies": { + "arr-diff": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", + "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", + "requires": { + "arr-flatten": "^1.0.1" + } + }, + "array-unique": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", + "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=" + }, + "braces": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", + "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", + "requires": { + "expand-range": "^1.8.1", + "preserve": "^0.2.0", + "repeat-element": "^1.1.2" + } + }, + "expand-brackets": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", + "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", + "requires": { + "is-posix-bracket": "^0.1.0" + } + }, + "extglob": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", + "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", + "requires": { + "is-extglob": "^1.0.0" + }, + "dependencies": { + "is-extglob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=" + } + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "requires": { + "is-extglob": "^2.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "^1.1.5" + } + }, + "micromatch": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", + "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", + "requires": { + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" + }, + "dependencies": { + "is-extglob": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=" + }, + "is-glob": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", + "requires": { + "is-extglob": "^1.0.0" + } + } + } + } + } + }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -4538,6 +5047,15 @@ "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=" }, + "import-local": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-0.1.1.tgz", + "integrity": "sha1-sReVcqrNwRxqkQCftDDbyrX2aKg=", + "requires": { + "pkg-dir": "^2.0.0", + "resolve-cwd": "^2.0.0" + } + }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -4626,6 +5144,14 @@ } } }, + "internal-ip": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-1.2.0.tgz", + "integrity": "sha1-rp+/k7mEh4eF1QqN4bNWlWBYz1w=", + "requires": { + "meow": "^3.3.0" + } + }, "interpret": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", @@ -4644,6 +5170,16 @@ "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + }, + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" + }, "is-absolute-url": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-2.1.0.tgz", @@ -4667,6 +5203,11 @@ } } }, + "is-arguments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", + "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==" + }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -5741,6 +6282,11 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" }, + "json3": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.3.tgz", + "integrity": "sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==" + }, "json5": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", @@ -5775,6 +6321,11 @@ "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz", "integrity": "sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE=" }, + "killable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz", + "integrity": "sha512-LzqtLKlUwirEUyl/nicirVmNiPvYs7l5n8wOPP7fyJVpUPkvCnW/vuiXGpylGUlnPDnB7311rARzAt3Mhswpjg==" + }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", @@ -5962,6 +6513,11 @@ "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=" }, + "loglevel": { + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.6.tgz", + "integrity": "sha512-Sgr5lbboAUBo3eXCSPL4/KoVz3ROKquOjcctxmHIt+vol2DrqTQe3SwkKKuYhEiWB5kYa13YyopJ69deJ1irzQ==" + }, "longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", @@ -6063,6 +6619,11 @@ "inherits": "^2.0.1" } }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, "mem": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", @@ -6109,6 +6670,16 @@ "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.0.tgz", "integrity": "sha1-dTHjnUlJwoGma4xabgJl6LBYlNo=" }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", @@ -6216,6 +6787,20 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "multicast-dns": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-6.2.3.tgz", + "integrity": "sha512-ji6J5enbMyGRHIAkAOu3WdV8nggqviKCEKtXcOqfphZZtQrmHKycfynJ2V7eVPUA4NhJ6V7Wf4TmGbTwKE9B6g==", + "requires": { + "dns-packet": "^1.3.1", + "thunky": "^1.0.2" + } + }, + "multicast-dns-service-types": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz", + "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=" + }, "mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", @@ -6250,6 +6835,11 @@ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, "neo-async": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.5.1.tgz", @@ -6277,6 +6867,11 @@ "is-stream": "^1.0.1" } }, + "node-forge": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.0.tgz", + "integrity": "sha512-7ASaDa3pD+lJ3WvXFsxekJQelBKRpne+GOVbLbtHYdd7pFspyeuJHnWfLplGf3SwKGbfs/aYl5V/JCIaHVUKKQ==" + }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -6439,6 +7034,16 @@ "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-1.3.0.tgz", "integrity": "sha512-05KzQ70lSeGSrZJQXE5wNDiTkBJDlUT/myi6RX9dVIvz7a7Qh4oH93BQdiPMn27nldYvVQCKMUaM83AfizZlsQ==" }, + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==" + }, + "object-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.0.2.tgz", + "integrity": "sha512-Epah+btZd5wrrfjkJZq1AOB9O6OxUQto45hzFd7lXGrpHPGE0W1k+426yrZV+k6NJOzLNNW/nVsmZdIWsAqoOQ==" + }, "object-keys": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", @@ -6452,6 +7057,17 @@ "isobject": "^3.0.0" } }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, "object.omit": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", @@ -6469,6 +7085,24 @@ "isobject": "^3.0.1" } }, + "obuf": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", + "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==" + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -6522,6 +7156,14 @@ "wordwrap": "~1.0.0" } }, + "original": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/original/-/original-1.0.2.tgz", + "integrity": "sha512-hyBVl6iqqUOJ8FqRe+l/gS8H+kKYjrEndd5Pm1MfBtsEKA038HkkdbAl/72EAXGyonD/PFsvmVG+EvcIpliMBg==", + "requires": { + "url-parse": "^1.4.3" + } + }, "os-browserify": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", @@ -6641,6 +7283,11 @@ "resolved": "https://registry.npmjs.org/parse5/-/parse5-1.5.1.tgz", "integrity": "sha1-m387DeMr543CQBsXVzzK8Pb1nZQ=" }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -6754,6 +7401,44 @@ "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" }, + "portfinder": { + "version": "1.0.25", + "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.25.tgz", + "integrity": "sha512-6ElJnHBbxVA1XSLgBp7G1FiCkQdlqGzuF7DswL5tcea+E8UpuvPU7beVAjjRwCioTS9ZluNbu+ZyRvgTsmqEBg==", + "requires": { + "async": "^2.6.2", + "debug": "^3.1.1", + "mkdirp": "^0.5.1" + }, + "dependencies": { + "async": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "requires": { + "lodash": "^4.17.14" + } + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -7978,6 +8663,15 @@ "object-assign": "^4.1.1" } }, + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" + } + }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -8039,6 +8733,11 @@ "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=" }, + "querystringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", + "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==" + }, "raf": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.0.tgz", @@ -8081,6 +8780,37 @@ "safe-buffer": "^5.1.0" } }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "dependencies": { + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + } + } + }, "rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -8130,19 +8860,9 @@ "react-error-overlay": "^4.0.0", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", + "sockjs-client": "1.1.4", "strip-ansi": "3.0.1", "text-table": "0.2.0" - }, - "dependencies": { - "sockjs-client": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.1.5.tgz", - "integrity": "sha1-G7fA9yIsQPQq3xT0RCy9Eml3GoM=", - "requires": { - "debug": "^2.6.6", - "inherits": "^2.0.1" - } - } } }, "react-dom": { @@ -8202,6 +8922,7 @@ "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.6.2", "webpack": "3.8.1", + "webpack-dev-server": "2.9.4", "webpack-manifest-plugin": "1.3.2", "whatwg-fetch": "2.0.3" }, @@ -8233,18 +8954,6 @@ "asap": "~2.0.3" } }, - "webpack-dev-server": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-3.1.5.tgz", - "integrity": "sha512-LVHg+EPwZLHIlfvokSTgtJqO/vI5CQi89fASb5JEDtVMDjY0yuIEqPPdMiKaBJIB/Ab7v/UN/sYZ7WsZvntQKw==", - "requires": { - "array-includes": "^3.0.3", - "chokidar": "^2.0.0", - "opn": "^5.1.0", - "strip-ansi": "^3.0.0", - "supports-color": "^5.1.0" - } - }, "whatwg-fetch": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", @@ -8411,6 +9120,81 @@ "safe-regex": "^1.1.0" } }, + "regexp.prototype.flags": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", + "integrity": "sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==", + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + }, + "dependencies": { + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "requires": { + "object-keys": "^1.0.12" + } + }, + "es-abstract": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" + }, + "dependencies": { + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + } + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "is-callable": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==" + }, + "is-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "requires": { + "has": "^1.0.3" + } + }, + "is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "requires": { + "has-symbols": "^1.0.1" + } + } + } + }, "regexpu-core": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", @@ -8571,6 +9355,11 @@ "resolve-from": "^1.0.0" } }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + }, "resolve": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.6.0.tgz", @@ -8579,6 +9368,21 @@ "path-parse": "^1.0.5" } }, + "resolve-cwd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz", + "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", + "requires": { + "resolve-from": "^3.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=" + } + } + }, "resolve-dir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", @@ -8726,6 +9530,19 @@ "ajv": "^5.0.0" } }, + "select-hose": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", + "integrity": "sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=" + }, + "selfsigned": { + "version": "1.10.7", + "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-1.10.7.tgz", + "integrity": "sha512-8M3wBCzeWIJnQfl43IKwOmC4H/RAp50S8DF60znzjW5GVqTcSe2vWclt7hmYVPkKPlHWOu5EaWOMZ2Y6W8ZXTA==", + "requires": { + "node-forge": "0.9.0" + } + }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", @@ -8739,6 +9556,76 @@ "semver": "^5.0.3" } }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "serve-index": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", + "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", + "requires": { + "accepts": "~1.3.4", + "batch": "0.6.1", + "debug": "2.6.9", + "escape-html": "~1.0.3", + "http-errors": "~1.6.2", + "mime-types": "~2.1.17", + "parseurl": "~1.3.2" + }, + "dependencies": { + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + } + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + } + }, "serviceworker-cache-polyfill": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/serviceworker-cache-polyfill/-/serviceworker-cache-polyfill-4.0.0.tgz", @@ -8780,6 +9667,11 @@ "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, "sha.js": { "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", @@ -8938,6 +9830,43 @@ } } }, + "sockjs": { + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.18.tgz", + "integrity": "sha1-2bKJMWyn33dZXvKZ4HXw+TfrQgc=", + "requires": { + "faye-websocket": "^0.10.0", + "uuid": "^2.0.2" + }, + "dependencies": { + "faye-websocket": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz", + "integrity": "sha1-TkkvjQTftviQA1B/btvy1QHnxvQ=", + "requires": { + "websocket-driver": ">=0.5.1" + } + }, + "uuid": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", + "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=" + } + } + }, + "sockjs-client": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.1.4.tgz", + "integrity": "sha1-W6vjhrd15M8U51IJEUUmVAFsixI=", + "requires": { + "debug": "^2.6.6", + "eventsource": "0.1.6", + "faye-websocket": "~0.11.0", + "inherits": "^2.0.1", + "json3": "^3.3.2", + "url-parse": "^1.1.8" + } + }, "sort-keys": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", @@ -9016,6 +9945,33 @@ "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==" }, + "spdy": { + "version": "3.4.7", + "resolved": "https://registry.npmjs.org/spdy/-/spdy-3.4.7.tgz", + "integrity": "sha1-Qv9B7OXMD5mjpsKKq7c/XDsDrLw=", + "requires": { + "debug": "^2.6.8", + "handle-thing": "^1.2.5", + "http-deceiver": "^1.2.7", + "safe-buffer": "^5.0.1", + "select-hose": "^2.0.0", + "spdy-transport": "^2.0.18" + } + }, + "spdy-transport": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/spdy-transport/-/spdy-transport-2.1.1.tgz", + "integrity": "sha512-q7D8c148escoB3Z7ySCASadkegMmUZW8Wb/Q1u0/XBgDKMO880rLQDj8Twiew/tYi7ghemKUi/whSYOwE17f5Q==", + "requires": { + "debug": "^2.6.8", + "detect-node": "^2.0.3", + "hpack.js": "^2.1.6", + "obuf": "^1.1.1", + "readable-stream": "^2.2.9", + "safe-buffer": "^5.0.1", + "wbuf": "^1.7.2" + } + }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -9064,6 +10020,11 @@ } } }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, "stream-browserify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", @@ -9122,6 +10083,44 @@ } } }, + "string.prototype.trimleft": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", + "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + }, + "dependencies": { + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "requires": { + "object-keys": "^1.0.12" + } + } + } + }, + "string.prototype.trimright": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", + "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + }, + "dependencies": { + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "requires": { + "object-keys": "^1.0.12" + } + } + } + }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -9322,6 +10321,16 @@ "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, + "thunky": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", + "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==" + }, + "time-stamp": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-2.2.0.tgz", + "integrity": "sha512-zxke8goJQpBeEgD82CXABeMh0LSJcj7CXEd0OHOg45HgcofF7pxNwZm9+RknpxpDhwN4gFpySkApKfFYfRQnUA==" + }, "timed-out": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", @@ -9396,6 +10405,11 @@ "repeat-string": "^1.6.1" } }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, "toposort": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/toposort/-/toposort-1.0.7.tgz", @@ -9459,6 +10473,30 @@ "prelude-ls": "~1.1.2" } }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "dependencies": { + "mime-db": { + "version": "1.43.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" + }, + "mime-types": { + "version": "2.1.26", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", + "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", + "requires": { + "mime-db": "1.43.0" + } + } + } + }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -9584,6 +10622,11 @@ "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", @@ -9708,6 +10751,15 @@ "schema-utils": "^0.3.0" } }, + "url-parse": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "url-parse-lax": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", @@ -9742,6 +10794,11 @@ "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", "integrity": "sha1-ihagXURWV6Oupe7MWxKk+lN5dyw=" }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, "uuid": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", @@ -9756,6 +10813,11 @@ "spdx-expression-parse": "^3.0.0" } }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, "vendors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/vendors/-/vendors-1.0.2.tgz", @@ -9802,6 +10864,14 @@ "neo-async": "^2.5.0" } }, + "wbuf": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/wbuf/-/wbuf-1.7.3.tgz", + "integrity": "sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA==", + "requires": { + "minimalistic-assert": "^1.0.0" + } + }, "webidl-conversions": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", @@ -9982,6 +11052,194 @@ } } }, + "webpack-dev-middleware": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-1.12.2.tgz", + "integrity": "sha512-FCrqPy1yy/sN6U/SaEZcHKRXGlqU0DUaEBL45jkUYoB8foVb6wCnbIJ1HKIx+qUFTW+3JpVcCJCxZ8VATL4e+A==", + "requires": { + "memory-fs": "~0.4.1", + "mime": "^1.5.0", + "path-is-absolute": "^1.0.0", + "range-parser": "^1.0.3", + "time-stamp": "^2.0.0" + } + }, + "webpack-dev-server": { + "version": "2.9.4", + "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-2.9.4.tgz", + "integrity": "sha512-thrqC0EQEoSjXeYgP6pUXcUCZ+LNrKsDPn+mItLnn5VyyNZOJKd06hUP5vqkYwL8nWWXsii0loSF9NHNccT6ow==", + "requires": { + "ansi-html": "0.0.7", + "array-includes": "^3.0.3", + "bonjour": "^3.5.0", + "chokidar": "^1.6.0", + "compression": "^1.5.2", + "connect-history-api-fallback": "^1.3.0", + "debug": "^3.1.0", + "del": "^3.0.0", + "express": "^4.13.3", + "html-entities": "^1.2.0", + "http-proxy-middleware": "~0.17.4", + "import-local": "^0.1.1", + "internal-ip": "1.2.0", + "ip": "^1.1.5", + "killable": "^1.0.0", + "loglevel": "^1.4.1", + "opn": "^5.1.0", + "portfinder": "^1.0.9", + "selfsigned": "^1.9.1", + "serve-index": "^1.7.2", + "sockjs": "0.3.18", + "sockjs-client": "1.1.4", + "spdy": "^3.4.1", + "strip-ansi": "^3.0.1", + "supports-color": "^4.2.1", + "webpack-dev-middleware": "^1.11.0", + "yargs": "^6.6.0" + }, + "dependencies": { + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" + }, + "chokidar": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", + "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", + "requires": { + "anymatch": "^1.3.0", + "async-each": "^1.0.0", + "fsevents": "^1.0.0", + "glob-parent": "^2.0.0", + "inherits": "^2.0.1", + "is-binary-path": "^1.0.0", + "is-glob": "^2.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.0.0" + } + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "del": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/del/-/del-3.0.0.tgz", + "integrity": "sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=", + "requires": { + "globby": "^6.1.0", + "is-path-cwd": "^1.0.0", + "is-path-in-cwd": "^1.0.0", + "p-map": "^1.1.1", + "pify": "^3.0.0", + "rimraf": "^2.2.8" + } + }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "requires": { + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + } + } + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "requires": { + "has-flag": "^2.0.0" + } + }, + "yargs": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-6.6.0.tgz", + "integrity": "sha1-eC7CHvQDNF+DCoCMo9UTr1YGUgg=", + "requires": { + "camelcase": "^3.0.0", + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^4.2.0" + } + }, + "yargs-parser": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-4.2.1.tgz", + "integrity": "sha1-KczqwNxPA8bIe0qfIX3RjJ90hxw=", + "requires": { + "camelcase": "^3.0.0" + } + } + } + }, "webpack-manifest-plugin": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/webpack-manifest-plugin/-/webpack-manifest-plugin-1.3.2.tgz", @@ -10022,6 +11280,21 @@ "source-map": "~0.6.1" } }, + "websocket-driver": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.3.tgz", + "integrity": "sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==", + "requires": { + "http-parser-js": ">=0.4.0 <0.4.11", + "safe-buffer": ">=5.1.0", + "websocket-extensions": ">=0.1.1" + } + }, + "websocket-extensions": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz", + "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==" + }, "whatwg-encoding": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.3.tgz", diff --git a/spring-security-modules/spring-security-react/src/test/java/org/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-react/src/test/java/org/baeldung/SpringContextTest.java index 9cc52b4726..cfef3322dc 100644 --- a/spring-security-modules/spring-security-react/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-security-modules/spring-security-react/src/test/java/org/baeldung/SpringContextTest.java @@ -6,8 +6,10 @@ 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) +@WebAppConfiguration @ContextConfiguration(classes = { MvcConfig.class, SecSecurityConfig.class }) public class SpringContextTest { diff --git a/spring-security-modules/spring-security-rest-basic-auth/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java b/spring-security-modules/spring-security-rest-basic-auth/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java index 6e580e7a22..f440bbd10c 100644 --- a/spring-security-modules/spring-security-rest-basic-auth/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java +++ b/spring-security-modules/spring-security-rest-basic-auth/src/main/java/org/baeldung/basic/MyBasicAuthenticationEntryPoint.java @@ -14,7 +14,7 @@ import java.io.PrintWriter; public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { @Override - public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException { + public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException { response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); final PrintWriter writer = response.getWriter(); @@ -22,7 +22,7 @@ public class MyBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoi } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { setRealmName("Baeldung"); super.afterPropertiesSet(); } diff --git a/spring-security-modules/spring-security-rest/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java b/spring-security-modules/spring-security-rest/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java new file mode 100644 index 0000000000..33978962bb --- /dev/null +++ b/spring-security-modules/spring-security-rest/src/main/java/org/baeldung/security/SecurityWebApplicationInitializer.java @@ -0,0 +1,10 @@ +package org.baeldung.security; + +import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; + +public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer { + + public SecurityWebApplicationInitializer() { + super(SecurityJavaConfig.class); + } +} diff --git a/spring-security-sso/spring-security-sso-auth-server/README.md b/spring-security-sso/spring-security-sso-auth-server/README.md deleted file mode 100644 index 845fb50a93..0000000000 --- a/spring-security-sso/spring-security-sso-auth-server/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles - -- [Simple Single Sign-On with Spring Security OAuth2](https://www.baeldung.com/sso-spring-security-oauth2) diff --git a/spring-security-sso/spring-security-sso-ui-2/README.md b/spring-security-sso/spring-security-sso-ui-2/README.md deleted file mode 100644 index aed217bdf0..0000000000 --- a/spring-security-sso/spring-security-sso-ui-2/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Simple Single Sign-On with Spring Security OAuth2](https://www.baeldung.com/sso-spring-security-oauth2) diff --git a/spring-security-sso/spring-security-sso-ui/README.md b/spring-security-sso/spring-security-sso-ui/README.md deleted file mode 100644 index 845fb50a93..0000000000 --- a/spring-security-sso/spring-security-sso-ui/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles - -- [Simple Single Sign-On with Spring Security OAuth2](https://www.baeldung.com/sso-spring-security-oauth2) diff --git a/spring-session/spring-session-mongodb/pom.xml b/spring-session/spring-session-mongodb/pom.xml index 00ffec93c0..10d4eb595e 100644 --- a/spring-session/spring-session-mongodb/pom.xml +++ b/spring-session/spring-session-mongodb/pom.xml @@ -25,13 +25,11 @@ org.springframework.session spring-session-data-mongodb - ${spring-session-data-mongodb.version} org.springframework.boot spring-boot-starter-data-mongodb - ${spring-boot-starter-data-mongodb.version} @@ -56,9 +54,4 @@ - - 2.1.3.RELEASE - 2.1.5.RELEASE - - \ No newline at end of file diff --git a/spring-session/spring-session-mongodb/src/test/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBIntegrationTest.java b/spring-session/spring-session-mongodb/src/test/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBIntegrationTest.java index de41019e49..7233d07536 100644 --- a/spring-session/spring-session-mongodb/src/test/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBIntegrationTest.java +++ b/spring-session/spring-session-mongodb/src/test/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBIntegrationTest.java @@ -10,7 +10,7 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.session.data.mongo.MongoOperationsSessionRepository; +import org.springframework.session.data.mongo.MongoIndexedSessionRepository; import org.springframework.test.context.junit4.SpringRunner; import java.util.Base64; @@ -24,7 +24,7 @@ public class SpringSessionMongoDBIntegrationTest { private int port; @Autowired - private MongoOperationsSessionRepository repository; + private MongoIndexedSessionRepository repository; private TestRestTemplate restTemplate = new TestRestTemplate(); diff --git a/spring-shell/src/main/java/org/baeldung/shell/Main.java b/spring-shell/src/main/java/com/baeldung/shell/Main.java similarity index 87% rename from spring-shell/src/main/java/org/baeldung/shell/Main.java rename to spring-shell/src/main/java/com/baeldung/shell/Main.java index 3d9f7a5860..97871394f7 100644 --- a/spring-shell/src/main/java/org/baeldung/shell/Main.java +++ b/spring-shell/src/main/java/com/baeldung/shell/Main.java @@ -1,4 +1,4 @@ -package org.baeldung.shell; +package com.baeldung.shell; import java.io.IOException; import org.springframework.shell.Bootstrap; diff --git a/spring-shell/src/main/java/org/baeldung/shell/simple/SimpleBannerProvider.java b/spring-shell/src/main/java/com/baeldung/shell/simple/SimpleBannerProvider.java similarity index 96% rename from spring-shell/src/main/java/org/baeldung/shell/simple/SimpleBannerProvider.java rename to spring-shell/src/main/java/com/baeldung/shell/simple/SimpleBannerProvider.java index df7a48cd32..dbfde76f8e 100644 --- a/spring-shell/src/main/java/org/baeldung/shell/simple/SimpleBannerProvider.java +++ b/spring-shell/src/main/java/com/baeldung/shell/simple/SimpleBannerProvider.java @@ -1,4 +1,4 @@ -package org.baeldung.shell.simple; +package com.baeldung.shell.simple; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; diff --git a/spring-shell/src/main/java/org/baeldung/shell/simple/SimpleCLI.java b/spring-shell/src/main/java/com/baeldung/shell/simple/SimpleCLI.java similarity index 98% rename from spring-shell/src/main/java/org/baeldung/shell/simple/SimpleCLI.java rename to spring-shell/src/main/java/com/baeldung/shell/simple/SimpleCLI.java index f73d9bda00..d8a0aef838 100644 --- a/spring-shell/src/main/java/org/baeldung/shell/simple/SimpleCLI.java +++ b/spring-shell/src/main/java/com/baeldung/shell/simple/SimpleCLI.java @@ -1,4 +1,4 @@ -package org.baeldung.shell.simple; +package com.baeldung.shell.simple; import java.io.BufferedReader; import java.io.FileNotFoundException; diff --git a/spring-shell/src/main/java/org/baeldung/shell/simple/SimpleHistoryFileNameProvider.java b/spring-shell/src/main/java/com/baeldung/shell/simple/SimpleHistoryFileNameProvider.java similarity index 93% rename from spring-shell/src/main/java/org/baeldung/shell/simple/SimpleHistoryFileNameProvider.java rename to spring-shell/src/main/java/com/baeldung/shell/simple/SimpleHistoryFileNameProvider.java index cef53adc69..5936006f11 100644 --- a/spring-shell/src/main/java/org/baeldung/shell/simple/SimpleHistoryFileNameProvider.java +++ b/spring-shell/src/main/java/com/baeldung/shell/simple/SimpleHistoryFileNameProvider.java @@ -1,4 +1,4 @@ -package org.baeldung.shell.simple; +package com.baeldung.shell.simple; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; diff --git a/spring-shell/src/main/java/org/baeldung/shell/simple/SimplePromptProvider.java b/spring-shell/src/main/java/com/baeldung/shell/simple/SimplePromptProvider.java similarity index 93% rename from spring-shell/src/main/java/org/baeldung/shell/simple/SimplePromptProvider.java rename to spring-shell/src/main/java/com/baeldung/shell/simple/SimplePromptProvider.java index 9a84954e05..a795d19eed 100644 --- a/spring-shell/src/main/java/org/baeldung/shell/simple/SimplePromptProvider.java +++ b/spring-shell/src/main/java/com/baeldung/shell/simple/SimplePromptProvider.java @@ -1,4 +1,4 @@ -package org.baeldung.shell.simple; +package com.baeldung.shell.simple; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; diff --git a/spring-shell/src/main/java/org/baeldung/shell/simple/SimpleURLConverter.java b/spring-shell/src/main/java/com/baeldung/shell/simple/SimpleURLConverter.java similarity index 96% rename from spring-shell/src/main/java/org/baeldung/shell/simple/SimpleURLConverter.java rename to spring-shell/src/main/java/com/baeldung/shell/simple/SimpleURLConverter.java index 4824cfbf05..7615f31ace 100644 --- a/spring-shell/src/main/java/org/baeldung/shell/simple/SimpleURLConverter.java +++ b/spring-shell/src/main/java/com/baeldung/shell/simple/SimpleURLConverter.java @@ -1,4 +1,4 @@ -package org.baeldung.shell.simple; +package com.baeldung.shell.simple; import java.net.MalformedURLException; import java.net.URL; diff --git a/spring-shell/src/main/resources/META-INF/spring/spring-shell-plugin.xml b/spring-shell/src/main/resources/META-INF/spring/spring-shell-plugin.xml index 1b97ab3b59..3ff60f3c08 100644 --- a/spring-shell/src/main/resources/META-INF/spring/spring-shell-plugin.xml +++ b/spring-shell/src/main/resources/META-INF/spring/spring-shell-plugin.xml @@ -8,6 +8,6 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"> - + \ No newline at end of file diff --git a/spring-shell/src/test/java/org/baeldung/shell/simple/SimpleCLIIntegrationTest.java b/spring-shell/src/test/java/com/baeldung/shell/simple/SimpleCLIIntegrationTest.java similarity index 98% rename from spring-shell/src/test/java/org/baeldung/shell/simple/SimpleCLIIntegrationTest.java rename to spring-shell/src/test/java/com/baeldung/shell/simple/SimpleCLIIntegrationTest.java index 3ec756e238..53627700c5 100644 --- a/spring-shell/src/test/java/org/baeldung/shell/simple/SimpleCLIIntegrationTest.java +++ b/spring-shell/src/test/java/com/baeldung/shell/simple/SimpleCLIIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.shell.simple; +package com.baeldung.shell.simple; import org.junit.AfterClass; import org.junit.Assert; diff --git a/spring-vault/src/main/java/org/baeldung/springvault/Credentials.java b/spring-vault/src/main/java/com/baeldung/springvault/Credentials.java similarity index 93% rename from spring-vault/src/main/java/org/baeldung/springvault/Credentials.java rename to spring-vault/src/main/java/com/baeldung/springvault/Credentials.java index f90ab66a4e..548ebd4ff6 100644 --- a/spring-vault/src/main/java/org/baeldung/springvault/Credentials.java +++ b/spring-vault/src/main/java/com/baeldung/springvault/Credentials.java @@ -1,4 +1,4 @@ -package org.baeldung.springvault; +package com.baeldung.springvault; public class Credentials { diff --git a/spring-vault/src/main/java/org/baeldung/springvault/CredentialsService.java b/spring-vault/src/main/java/com/baeldung/springvault/CredentialsService.java similarity index 76% rename from spring-vault/src/main/java/org/baeldung/springvault/CredentialsService.java rename to spring-vault/src/main/java/com/baeldung/springvault/CredentialsService.java index 87c24bd947..6a4b7cb784 100644 --- a/spring-vault/src/main/java/org/baeldung/springvault/CredentialsService.java +++ b/spring-vault/src/main/java/com/baeldung/springvault/CredentialsService.java @@ -1,16 +1,10 @@ -package org.baeldung.springvault; +package com.baeldung.springvault; -import java.net.URI; import java.net.URISyntaxException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import org.springframework.vault.authentication.TokenAuthentication; -import org.springframework.vault.client.VaultEndpoint; import org.springframework.vault.core.VaultTemplate; -import org.springframework.vault.core.env.VaultPropertySource; -import org.springframework.vault.support.VaultResponse; import org.springframework.vault.support.VaultResponseSupport; /** diff --git a/spring-vault/src/main/java/org/baeldung/springvault/SpringVaultApplication.java b/spring-vault/src/main/java/com/baeldung/springvault/SpringVaultApplication.java similarity index 91% rename from spring-vault/src/main/java/org/baeldung/springvault/SpringVaultApplication.java rename to spring-vault/src/main/java/com/baeldung/springvault/SpringVaultApplication.java index 916a809be5..979b2fb42e 100644 --- a/spring-vault/src/main/java/org/baeldung/springvault/SpringVaultApplication.java +++ b/spring-vault/src/main/java/com/baeldung/springvault/SpringVaultApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.springvault; +package com.baeldung.springvault; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-vault/src/main/java/org/baeldung/springvault/VaultConfig.java b/spring-vault/src/main/java/com/baeldung/springvault/VaultConfig.java similarity index 95% rename from spring-vault/src/main/java/org/baeldung/springvault/VaultConfig.java rename to spring-vault/src/main/java/com/baeldung/springvault/VaultConfig.java index 106a1a3d42..f13c605bd8 100644 --- a/spring-vault/src/main/java/org/baeldung/springvault/VaultConfig.java +++ b/spring-vault/src/main/java/com/baeldung/springvault/VaultConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.springvault; +package com.baeldung.springvault; import org.springframework.context.annotation.Configuration; import org.springframework.vault.authentication.ClientAuthentication; diff --git a/spring-vault/src/main/java/org/baeldung/springvault/VaultEnvironmentConfig.java b/spring-vault/src/main/java/com/baeldung/springvault/VaultEnvironmentConfig.java similarity index 95% rename from spring-vault/src/main/java/org/baeldung/springvault/VaultEnvironmentConfig.java rename to spring-vault/src/main/java/com/baeldung/springvault/VaultEnvironmentConfig.java index 6c796bc718..4f5777e94c 100644 --- a/spring-vault/src/main/java/org/baeldung/springvault/VaultEnvironmentConfig.java +++ b/spring-vault/src/main/java/com/baeldung/springvault/VaultEnvironmentConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.springvault; +package com.baeldung.springvault; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; diff --git a/spring-vault/src/test/java/org/baeldung/SpringContextLiveTest.java b/spring-vault/src/test/java/com/baeldung/springvault/SpringContextLiveTest.java similarity index 86% rename from spring-vault/src/test/java/org/baeldung/SpringContextLiveTest.java rename to spring-vault/src/test/java/com/baeldung/springvault/SpringContextLiveTest.java index 60dc119f13..8139522745 100644 --- a/spring-vault/src/test/java/org/baeldung/SpringContextLiveTest.java +++ b/spring-vault/src/test/java/com/baeldung/springvault/SpringContextLiveTest.java @@ -1,6 +1,6 @@ -package org.baeldung; +package com.baeldung.springvault; -import org.baeldung.springvault.SpringVaultApplication; +import com.baeldung.springvault.SpringVaultApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-vault/src/test/java/org/baeldung/springvault/VaultInitializer.java b/spring-vault/src/test/java/com/baeldung/springvault/VaultInitializer.java similarity index 99% rename from spring-vault/src/test/java/org/baeldung/springvault/VaultInitializer.java rename to spring-vault/src/test/java/com/baeldung/springvault/VaultInitializer.java index c7db5eb199..a823a4cd27 100644 --- a/spring-vault/src/test/java/org/baeldung/springvault/VaultInitializer.java +++ b/spring-vault/src/test/java/com/baeldung/springvault/VaultInitializer.java @@ -1,4 +1,4 @@ -package org.baeldung.springvault; +package com.baeldung.springvault; import java.io.BufferedReader; import java.io.Closeable; diff --git a/spring-vault/src/test/java/org/baeldung/springvault/VaultIntegrationTest.java b/spring-vault/src/test/java/com/baeldung/springvault/VaultIntegrationTest.java similarity index 98% rename from spring-vault/src/test/java/org/baeldung/springvault/VaultIntegrationTest.java rename to spring-vault/src/test/java/com/baeldung/springvault/VaultIntegrationTest.java index 9f4b5d82a4..dd8797aacc 100644 --- a/spring-vault/src/test/java/org/baeldung/springvault/VaultIntegrationTest.java +++ b/spring-vault/src/test/java/com/baeldung/springvault/VaultIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.springvault; +package com.baeldung.springvault; import org.junit.FixMethodOrder; import org.junit.Ignore; diff --git a/spring-vault/src/test/java/org/baeldung/springvault/VaultTestConfiguration.java b/spring-vault/src/test/java/com/baeldung/springvault/VaultTestConfiguration.java similarity index 96% rename from spring-vault/src/test/java/org/baeldung/springvault/VaultTestConfiguration.java rename to spring-vault/src/test/java/com/baeldung/springvault/VaultTestConfiguration.java index 09a1445788..42f0bfbce9 100644 --- a/spring-vault/src/test/java/org/baeldung/springvault/VaultTestConfiguration.java +++ b/spring-vault/src/test/java/com/baeldung/springvault/VaultTestConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.springvault; +package com.baeldung.springvault; import java.net.URI; import java.net.URISyntaxException; diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java b/spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java new file mode 100644 index 0000000000..23ca74ae80 --- /dev/null +++ b/spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java @@ -0,0 +1,31 @@ +package com.baeldung.vertxspring.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +import java.io.IOException; +import java.net.ServerSocket; + +@Configuration +public class PortConfiguration { + + private static final int DEFAULT_PORT = 8069; + + @Profile("default") + @Bean + public Integer defaultPort() { + return DEFAULT_PORT; + } + + @Profile("test") + @Bean + public Integer randomPort() { + try (ServerSocket socket = new ServerSocket(0)) { + return socket.getLocalPort(); + + } catch (IOException e) { + return DEFAULT_PORT; + } + } +} diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java b/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java index 3c23cb15bc..a84845f030 100644 --- a/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java +++ b/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java @@ -1,5 +1,6 @@ package com.baeldung.vertxspring.verticles; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import io.vertx.core.AbstractVerticle; @@ -9,6 +10,9 @@ import io.vertx.ext.web.RoutingContext; @Component public class ServerVerticle extends AbstractVerticle { + @Autowired + private Integer defaultPort; + private void getAllArticlesHandler(RoutingContext routingContext) { vertx.eventBus() .send(ArticleRecipientVerticle.GET_ALL_ARTICLES, "", result -> { @@ -36,7 +40,7 @@ public class ServerVerticle extends AbstractVerticle { vertx.createHttpServer() .requestHandler(router::accept) - .listen(config().getInteger("http.port", 8080)); + .listen(config().getInteger("http.port", defaultPort)); } } diff --git a/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java b/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java index bfb902e5d4..1eda45eb3b 100644 --- a/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java +++ b/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java @@ -1,27 +1,33 @@ package com.baeldung.vertxspring; -import static org.junit.Assert.assertEquals; - import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.junit.Assert.assertEquals; + @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest +@ActiveProfiles("test") public class VertxSpringApplicationIntegrationTest { + @Autowired + private Integer port; + private TestRestTemplate restTemplate = new TestRestTemplate(); @Test public void givenUrl_whenReceivedArticles_thenSuccess() throws InterruptedException { - ResponseEntity responseEntity = restTemplate.getForEntity("http://localhost:8080/api/baeldung/articles", String.class); + ResponseEntity responseEntity = restTemplate + .getForEntity("http://localhost:" + port + "/api/baeldung/articles", String.class); assertEquals(200, responseEntity.getStatusCodeValue()); } - } diff --git a/spring-webflux-amqp/pom.xml b/spring-webflux-amqp/pom.xml index f9b14eea06..7a7f6ef600 100755 --- a/spring-webflux-amqp/pom.xml +++ b/spring-webflux-amqp/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - org.baeldung.spring + com.baeldung.spring spring-webflux-amqp 1.0.0-SNAPSHOT spring-webflux-amqp diff --git a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/AmqpReactiveController.java b/spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/AmqpReactiveController.java similarity index 94% rename from spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/AmqpReactiveController.java rename to spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/AmqpReactiveController.java index 52f6d924fa..b71c32bd05 100644 --- a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/AmqpReactiveController.java +++ b/spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/AmqpReactiveController.java @@ -1,11 +1,9 @@ -package org.baeldung.spring.amqp; +package com.baeldung.spring.amqp; import java.time.Duration; -import java.util.Date; import javax.annotation.PostConstruct; -import org.baeldung.spring.amqp.DestinationsConfig.DestinationInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.amqp.core.AmqpAdmin; @@ -29,7 +27,6 @@ import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; @RestController public class AmqpReactiveController { @@ -105,7 +102,7 @@ public class AmqpReactiveController { public Mono> sendMessageToQueue(@PathVariable String name, @RequestBody String payload) { // Lookup exchange details - final DestinationInfo d = destinationsConfig.getQueues() + final DestinationsConfig.DestinationInfo d = destinationsConfig.getQueues() .get(name); if (d == null) { @@ -135,7 +132,7 @@ public class AmqpReactiveController { @GetMapping(value = "/queue/{name}", produces = MediaType.TEXT_EVENT_STREAM_VALUE) public Flux receiveMessagesFromQueue(@PathVariable String name) { - DestinationInfo d = destinationsConfig.getQueues() + DestinationsConfig.DestinationInfo d = destinationsConfig.getQueues() .get(name); if (d == null) { @@ -201,7 +198,7 @@ public class AmqpReactiveController { public Mono> sendMessageToTopic(@PathVariable String name, @RequestBody String payload) { // Lookup exchange details - final DestinationInfo d = destinationsConfig.getTopics() + final DestinationsConfig.DestinationInfo d = destinationsConfig.getTopics() .get(name); if (d == null) { // Destination not found. @@ -223,7 +220,7 @@ public class AmqpReactiveController { @GetMapping(value = "/topic/{name}", produces = MediaType.TEXT_EVENT_STREAM_VALUE) public Flux receiveMessagesFromTopic(@PathVariable String name) { - DestinationInfo d = destinationsConfig.getTopics() + DestinationsConfig.DestinationInfo d = destinationsConfig.getTopics() .get(name); if (d == null) { @@ -281,7 +278,7 @@ public class AmqpReactiveController { } - private Queue createTopicQueue(DestinationInfo destination) { + private Queue createTopicQueue(DestinationsConfig.DestinationInfo destination) { Exchange ex = ExchangeBuilder.topicExchange(destination.getExchange()) .durable(true) diff --git a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/DestinationsConfig.java b/spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/DestinationsConfig.java old mode 100755 new mode 100644 similarity index 93% rename from spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/DestinationsConfig.java rename to spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/DestinationsConfig.java index 410b87c764..0f9a0d890f --- a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/DestinationsConfig.java +++ b/spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/DestinationsConfig.java @@ -1,59 +1,59 @@ -package org.baeldung.spring.amqp; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -@ConfigurationProperties("destinations") -public class DestinationsConfig { - - - private Map queues = new HashMap<>(); - - private Map topics = new HashMap<>(); - - - - public Map getQueues() { - return queues; - } - - public void setQueues(Map queues) { - this.queues = queues; - } - - public Map getTopics() { - return topics; - } - - public void setTopics(Map topics) { - this.topics = topics; - } - - // DestinationInfo stores the Exchange name and routing key used - // by our producers when posting messages - static class DestinationInfo { - - private String exchange; - private String routingKey; - - - public String getExchange() { - return exchange; - } - public void setExchange(String exchange) { - this.exchange = exchange; - } - public String getRoutingKey() { - return routingKey; - } - public void setRoutingKey(String routingKey) { - this.routingKey = routingKey; - } - - - - } - -} +package com.baeldung.spring.amqp; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("destinations") +public class DestinationsConfig { + + + private Map queues = new HashMap<>(); + + private Map topics = new HashMap<>(); + + + + public Map getQueues() { + return queues; + } + + public void setQueues(Map queues) { + this.queues = queues; + } + + public Map getTopics() { + return topics; + } + + public void setTopics(Map topics) { + this.topics = topics; + } + + // DestinationInfo stores the Exchange name and routing key used + // by our producers when posting messages + static class DestinationInfo { + + private String exchange; + private String routingKey; + + + public String getExchange() { + return exchange; + } + public void setExchange(String exchange) { + this.exchange = exchange; + } + public String getRoutingKey() { + return routingKey; + } + public void setRoutingKey(String routingKey) { + this.routingKey = routingKey; + } + + + + } + +} diff --git a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/MessageListenerContainerFactory.java b/spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/MessageListenerContainerFactory.java similarity index 96% rename from spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/MessageListenerContainerFactory.java rename to spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/MessageListenerContainerFactory.java index 29b8d28a80..d868e6afa8 100644 --- a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/MessageListenerContainerFactory.java +++ b/spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/MessageListenerContainerFactory.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.amqp; +package com.baeldung.spring.amqp; import org.springframework.amqp.core.AcknowledgeMode; import org.springframework.amqp.rabbit.connection.ConnectionFactory; diff --git a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java b/spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java old mode 100755 new mode 100644 similarity index 97% rename from spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java rename to spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java index 8a31299333..d6a7a84d30 --- a/spring-webflux-amqp/src/main/java/org/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java +++ b/spring-webflux-amqp/src/main/java/com/baeldung/spring/amqp/SpringWebfluxAmqpApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.amqp; +package com.baeldung.spring.amqp; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-webflux-amqp/src/test/java/org/baeldung/SpringContextLiveTest.java b/spring-webflux-amqp/src/test/java/com/baeldung/SpringContextLiveTest.java similarity index 87% rename from spring-webflux-amqp/src/test/java/org/baeldung/SpringContextLiveTest.java rename to spring-webflux-amqp/src/test/java/com/baeldung/SpringContextLiveTest.java index 4d9f658cdc..c443042d3d 100644 --- a/spring-webflux-amqp/src/test/java/org/baeldung/SpringContextLiveTest.java +++ b/spring-webflux-amqp/src/test/java/com/baeldung/SpringContextLiveTest.java @@ -1,6 +1,6 @@ -package org.baeldung; +package com.baeldung; -import org.baeldung.spring.amqp.SpringWebfluxAmqpApplication; +import com.baeldung.spring.amqp.SpringWebfluxAmqpApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-webflux-amqp/src/test/java/org/baeldung/spring/amqp/SpringWebfluxAmqpLiveTest.java b/spring-webflux-amqp/src/test/java/com/baeldung/spring/amqp/SpringWebfluxAmqpLiveTest.java old mode 100755 new mode 100644 similarity index 93% rename from spring-webflux-amqp/src/test/java/org/baeldung/spring/amqp/SpringWebfluxAmqpLiveTest.java rename to spring-webflux-amqp/src/test/java/com/baeldung/spring/amqp/SpringWebfluxAmqpLiveTest.java index bda490c189..81782ce575 --- a/spring-webflux-amqp/src/test/java/org/baeldung/spring/amqp/SpringWebfluxAmqpLiveTest.java +++ b/spring-webflux-amqp/src/test/java/com/baeldung/spring/amqp/SpringWebfluxAmqpLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.spring.amqp; +package com.baeldung.spring.amqp; import org.junit.Test; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/spring-websockets/README.md b/spring-websockets/README.md new file mode 100644 index 0000000000..26e1c6db7c --- /dev/null +++ b/spring-websockets/README.md @@ -0,0 +1,7 @@ +## Spring WebSockets + +This module contains articles about Spring WebSockets. + +### Relevant articles +- [Intro to WebSockets with Spring](https://www.baeldung.com/websockets-spring) +- [A Quick Example of Spring Websockets’ @SendToUser Annotation](https://www.baeldung.com/spring-websockets-sendtouser) diff --git a/spring-websockets/pom.xml b/spring-websockets/pom.xml new file mode 100644 index 0000000000..ddfd512476 --- /dev/null +++ b/spring-websockets/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + spring-websockets + spring-websockets + war + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-websocket + + + com.google.code.gson + gson + + + + + spring-websockets + + + src/main/resources + true + + + + + diff --git a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/SpringOpenidApplication.java b/spring-websockets/src/main/java/com/baeldung/SpringBootApp.java similarity index 61% rename from spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/SpringOpenidApplication.java rename to spring-websockets/src/main/java/com/baeldung/SpringBootApp.java index 1acdba0623..ea2a461dfc 100644 --- a/spring-security-modules/spring-security-openid/src/main/java/org/baeldung/config/SpringOpenidApplication.java +++ b/spring-websockets/src/main/java/com/baeldung/SpringBootApp.java @@ -1,14 +1,12 @@ -package org.baeldung.config; +package com.baeldung; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication -public class SpringOpenidApplication extends SpringBootServletInitializer { - +public class SpringBootApp extends SpringBootServletInitializer { public static void main(String[] args) { - SpringApplication.run(SpringOpenidApplication.class, args); + SpringApplication.run(SpringBootApp.class, args); } - -} +} \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketSendToUserConfig.java b/spring-websockets/src/main/java/com/baeldung/sendtouser/WebSocketSendToUserConfig.java similarity index 98% rename from spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketSendToUserConfig.java rename to spring-websockets/src/main/java/com/baeldung/sendtouser/WebSocketSendToUserConfig.java index dbd52e20ba..76837d27f5 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketSendToUserConfig.java +++ b/spring-websockets/src/main/java/com/baeldung/sendtouser/WebSocketSendToUserConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.web.config; +package com.baeldung.sendtouser; import org.springframework.context.annotation.Configuration; import org.springframework.http.server.ServerHttpRequest; diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/WebsocketSendToUserController.java b/spring-websockets/src/main/java/com/baeldung/sendtouser/WebsocketSendToUserController.java similarity index 96% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/WebsocketSendToUserController.java rename to spring-websockets/src/main/java/com/baeldung/sendtouser/WebsocketSendToUserController.java index 4b55bcc00f..12475ad055 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/WebsocketSendToUserController.java +++ b/spring-websockets/src/main/java/com/baeldung/sendtouser/WebsocketSendToUserController.java @@ -1,15 +1,14 @@ -package com.baeldung.web.controller; - -import java.security.Principal; -import java.util.Map; +package com.baeldung.sendtouser; +import com.google.gson.Gson; import org.springframework.messaging.handler.annotation.MessageExceptionHandler; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.handler.annotation.Payload; import org.springframework.messaging.simp.annotation.SendToUser; import org.springframework.stereotype.Controller; -import com.google.gson.Gson; +import java.security.Principal; +import java.util.Map; @Controller public class WebsocketSendToUserController { diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/ChatController.java b/spring-websockets/src/main/java/com/baeldung/websockets/ChatController.java similarity index 83% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/ChatController.java rename to spring-websockets/src/main/java/com/baeldung/websockets/ChatController.java index f4bed1950b..4ac78c2730 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/ChatController.java +++ b/spring-websockets/src/main/java/com/baeldung/websockets/ChatController.java @@ -1,7 +1,5 @@ -package com.baeldung.web.controller; +package com.baeldung.websockets; -import com.baeldung.model.Message; -import com.baeldung.model.OutputMessage; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.handler.annotation.SendTo; import org.springframework.stereotype.Controller; diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/Message.java b/spring-websockets/src/main/java/com/baeldung/websockets/Message.java similarity index 85% rename from spring-mvc-java/src/main/java/com/baeldung/model/Message.java rename to spring-websockets/src/main/java/com/baeldung/websockets/Message.java index 76d53e132a..dd147a7bf5 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/model/Message.java +++ b/spring-websockets/src/main/java/com/baeldung/websockets/Message.java @@ -1,4 +1,4 @@ -package com.baeldung.model; +package com.baeldung.websockets; public class Message { diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/OutputMessage.java b/spring-websockets/src/main/java/com/baeldung/websockets/OutputMessage.java similarity index 93% rename from spring-mvc-java/src/main/java/com/baeldung/model/OutputMessage.java rename to spring-websockets/src/main/java/com/baeldung/websockets/OutputMessage.java index 9aad564b1e..33d1f42743 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/model/OutputMessage.java +++ b/spring-websockets/src/main/java/com/baeldung/websockets/OutputMessage.java @@ -1,4 +1,4 @@ -package com.baeldung.model; +package com.baeldung.websockets; public class OutputMessage { diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketConfig.java b/spring-websockets/src/main/java/com/baeldung/websockets/WebSocketConfig.java similarity index 95% rename from spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketConfig.java rename to spring-websockets/src/main/java/com/baeldung/websockets/WebSocketConfig.java index 0793658e90..7b53dbc3f3 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketConfig.java +++ b/spring-websockets/src/main/java/com/baeldung/websockets/WebSocketConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.web.config; +package com.baeldung.websockets; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; diff --git a/spring-mvc-java/src/main/webapp/resources/chat.html b/spring-websockets/src/main/webapp/resources/chat.html similarity index 96% rename from spring-mvc-java/src/main/webapp/resources/chat.html rename to spring-websockets/src/main/webapp/resources/chat.html index 92a54534fd..17c8494dd8 100644 --- a/spring-mvc-java/src/main/webapp/resources/chat.html +++ b/spring-websockets/src/main/webapp/resources/chat.html @@ -1,88 +1,88 @@ - - - Chat WebSocket - - - - - - - - - - -
- - -
- -
-
-
- - -
-
-
- - -

-
-
- - + + + Chat WebSocket + + + + + + + + + + +
+ + +
+ +
+
+
+ + +
+
+
+ + +

+
+
+ + \ No newline at end of file diff --git a/spring-mvc-java/src/main/webapp/resources/js/sockjs-0.3.4.js b/spring-websockets/src/main/webapp/resources/js/sockjs-0.3.4.js similarity index 100% rename from spring-mvc-java/src/main/webapp/resources/js/sockjs-0.3.4.js rename to spring-websockets/src/main/webapp/resources/js/sockjs-0.3.4.js diff --git a/spring-mvc-java/src/main/webapp/resources/js/stomp.js b/spring-websockets/src/main/webapp/resources/js/stomp.js similarity index 100% rename from spring-mvc-java/src/main/webapp/resources/js/stomp.js rename to spring-websockets/src/main/webapp/resources/js/stomp.js diff --git a/spring-mvc-java/src/main/webapp/resources/js/webSocketSendToUserApp.js b/spring-websockets/src/main/webapp/resources/js/webSocketSendToUserApp.js similarity index 100% rename from spring-mvc-java/src/main/webapp/resources/js/webSocketSendToUserApp.js rename to spring-websockets/src/main/webapp/resources/js/webSocketSendToUserApp.js diff --git a/tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowGraph.java b/tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowGraph.java similarity index 98% rename from tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowGraph.java rename to tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowGraph.java index a44ef4c4ee..5d9a85a491 100644 --- a/tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowGraph.java +++ b/tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowGraph.java @@ -1,4 +1,4 @@ -package org.baeldung.tensorflow; +package com.baeldung.tensorflow; import org.tensorflow.DataType; import org.tensorflow.Graph; diff --git a/tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowSavedModel.java b/tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowSavedModel.java similarity index 93% rename from tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowSavedModel.java rename to tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowSavedModel.java index 4259a787e8..96a063dff2 100644 --- a/tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowSavedModel.java +++ b/tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowSavedModel.java @@ -1,4 +1,4 @@ -package org.baeldung.tensorflow; +package com.baeldung.tensorflow; import org.tensorflow.SavedModelBundle; import org.tensorflow.Tensor; diff --git a/tensorflow-java/src/test/java/org/baeldung/tensorflow/TensorflowGraphUnitTest.java b/tensorflow-java/src/test/java/com/baeldung/tensorflow/TensorflowGraphUnitTest.java similarity index 92% rename from tensorflow-java/src/test/java/org/baeldung/tensorflow/TensorflowGraphUnitTest.java rename to tensorflow-java/src/test/java/com/baeldung/tensorflow/TensorflowGraphUnitTest.java index 51df6a4322..c2799a4bb1 100644 --- a/tensorflow-java/src/test/java/org/baeldung/tensorflow/TensorflowGraphUnitTest.java +++ b/tensorflow-java/src/test/java/com/baeldung/tensorflow/TensorflowGraphUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.tensorflow; +package com.baeldung.tensorflow; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Department.java b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Department.java similarity index 90% rename from testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Department.java rename to testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Department.java index ee4dc82771..87bff514a0 100644 --- a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Department.java +++ b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Department.java @@ -1,4 +1,4 @@ -package org.baeldung.easy.random.model; +package com.baeldung.easy.random.model; import java.util.StringJoiner; diff --git a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Employee.java b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Employee.java similarity index 97% rename from testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Employee.java rename to testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Employee.java index ef63642ca2..af44822215 100644 --- a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Employee.java +++ b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Employee.java @@ -1,4 +1,4 @@ -package org.baeldung.easy.random.model; +package com.baeldung.easy.random.model; import java.util.*; diff --git a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Grade.java b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Grade.java similarity index 90% rename from testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Grade.java rename to testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Grade.java index cb979be3b8..1d18a3f183 100644 --- a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Grade.java +++ b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Grade.java @@ -1,4 +1,4 @@ -package org.baeldung.easy.random.model; +package com.baeldung.easy.random.model; import java.util.StringJoiner; diff --git a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Person.java b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Person.java similarity index 93% rename from testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Person.java rename to testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Person.java index c941499993..3269af7b0f 100644 --- a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/Person.java +++ b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/Person.java @@ -1,4 +1,4 @@ -package org.baeldung.easy.random.model; +package com.baeldung.easy.random.model; import java.util.StringJoiner; diff --git a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/YearQuarter.java b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/YearQuarter.java similarity index 96% rename from testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/YearQuarter.java rename to testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/YearQuarter.java index c2868f09b8..576fe67dd0 100644 --- a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/model/YearQuarter.java +++ b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/model/YearQuarter.java @@ -1,4 +1,4 @@ -package org.baeldung.easy.random.model; +package com.baeldung.easy.random.model; import java.time.LocalDate; import java.util.Objects; diff --git a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/randomizer/YearQuarterRandomizer.java b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/randomizer/YearQuarterRandomizer.java similarity index 79% rename from testing-modules/easy-random/src/main/java/org/baeldung/easy/random/randomizer/YearQuarterRandomizer.java rename to testing-modules/easy-random/src/main/java/com/baeldung/easy/random/randomizer/YearQuarterRandomizer.java index 05232ffcbc..28db724684 100644 --- a/testing-modules/easy-random/src/main/java/org/baeldung/easy/random/randomizer/YearQuarterRandomizer.java +++ b/testing-modules/easy-random/src/main/java/com/baeldung/easy/random/randomizer/YearQuarterRandomizer.java @@ -1,6 +1,6 @@ -package org.baeldung.easy.random.randomizer; +package com.baeldung.easy.random.randomizer; -import org.baeldung.easy.random.model.YearQuarter; +import com.baeldung.easy.random.model.YearQuarter; import org.jeasy.random.api.Randomizer; import java.time.LocalDate; diff --git a/testing-modules/easy-random/src/test/java/org/baeldung/easy/random/EasyRandomUnitTest.java b/testing-modules/easy-random/src/test/java/com/baeldung/easy/random/EasyRandomUnitTest.java similarity index 89% rename from testing-modules/easy-random/src/test/java/org/baeldung/easy/random/EasyRandomUnitTest.java rename to testing-modules/easy-random/src/test/java/com/baeldung/easy/random/EasyRandomUnitTest.java index 9f7a23db66..4e0df74923 100644 --- a/testing-modules/easy-random/src/test/java/org/baeldung/easy/random/EasyRandomUnitTest.java +++ b/testing-modules/easy-random/src/test/java/com/baeldung/easy/random/EasyRandomUnitTest.java @@ -1,9 +1,9 @@ -package org.baeldung.easy.random; +package com.baeldung.easy.random; -import org.baeldung.easy.random.model.Employee; -import org.baeldung.easy.random.model.Person; -import org.baeldung.easy.random.model.YearQuarter; -import org.baeldung.easy.random.randomizer.YearQuarterRandomizer; +import com.baeldung.easy.random.model.Employee; +import com.baeldung.easy.random.model.Person; +import com.baeldung.easy.random.model.YearQuarter; +import com.baeldung.easy.random.randomizer.YearQuarterRandomizer; import org.jeasy.random.EasyRandom; import org.jeasy.random.EasyRandomParameters; import org.jeasy.random.FieldPredicates; diff --git a/testing-modules/gatling/README.md b/testing-modules/gatling/README.md index 941ab75f06..7352479d1b 100644 --- a/testing-modules/gatling/README.md +++ b/testing-modules/gatling/README.md @@ -1,5 +1,6 @@ ### Relevant Articles: - [Intro to Gatling](http://www.baeldung.com/introduction-to-gatling) +- [Run Gatling Tests From Jenkins](https://www.baeldung.com/jenkins-run-gatling-tests) ### Running a simualtion - To run a simulation use "simulation" profile, command - `mvn install -Psimulation -Dgib.enabled=false` diff --git a/testing-modules/junit-4/README.md b/testing-modules/junit-4/README.md index d19a0a1e47..6cc3981ed4 100644 --- a/testing-modules/junit-4/README.md +++ b/testing-modules/junit-4/README.md @@ -4,3 +4,4 @@ - [Custom JUnit 4 Test Runners](http://www.baeldung.com/junit-4-custom-runners) - [Introduction to JUnitParams](http://www.baeldung.com/junit-params) - [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java) +- [Introduction to Lambda Behave](https://www.baeldung.com/lambda-behave) diff --git a/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java index 8f2eb2b5c5..7378eafaa7 100644 --- a/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java +++ b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java @@ -5,7 +5,7 @@ import org.junit.platform.suite.api.SelectPackages; import org.junit.runner.RunWith; @RunWith(JUnitPlatform.class) -@SelectPackages({ "org.baeldung.java.suite.childpackage1", "org.baeldung.java.suite.childpackage2" }) +@SelectPackages({ "com.baeldung.java.suite.childpackage1", "com.baeldung.java.suite.childpackage2" }) public class SelectPackagesSuiteUnitTest { } diff --git a/testing-modules/mockito-2/README.md b/testing-modules/mockito-2/README.md index 1d1bd6af7c..d7069949e4 100644 --- a/testing-modules/mockito-2/README.md +++ b/testing-modules/mockito-2/README.md @@ -5,3 +5,4 @@ - [Mockito Strict Stubbing and The UnnecessaryStubbingException](https://www.baeldung.com/mockito-unnecessary-stubbing-exception) - [Quick Guide to BDDMockito](https://www.baeldung.com/bdd-mockito) - [Mockito – Using Spies](https://www.baeldung.com/mockito-spy) +- [Mockito and Fluent APIs](https://www.baeldung.com/mockito-fluent-apis) diff --git a/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationsUninitializedUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationsUninitializedUnitTest.java new file mode 100644 index 0000000000..ed50732183 --- /dev/null +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationsUninitializedUnitTest.java @@ -0,0 +1,18 @@ +package com.baeldung.mockito; + +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; + +import java.util.List; + +public class MockitoAnnotationsUninitializedUnitTest { + + @Mock + List mockedList; + + @Test(expected = NullPointerException.class) + public void whenMockitoAnnotationsUninitialized_thenNPEThrown() { + Mockito.when(mockedList.size()).thenReturn(1); + } +} diff --git a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/AdvancedCollaborator.java b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/AdvancedCollaborator.java similarity index 93% rename from testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/AdvancedCollaborator.java rename to testing-modules/mocks/src/main/java/com/baeldung/jmockit/AdvancedCollaborator.java index 4d25f466a6..ef7484cfdd 100644 --- a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/AdvancedCollaborator.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/AdvancedCollaborator.java @@ -1,4 +1,4 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; public class AdvancedCollaborator { int i; diff --git a/testing-modules/mocks/src/main/java/com/baeldung/mocks/jmockit/AppManager.java b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/AppManager.java similarity index 94% rename from testing-modules/mocks/src/main/java/com/baeldung/mocks/jmockit/AppManager.java rename to testing-modules/mocks/src/main/java/com/baeldung/jmockit/AppManager.java index 615650ea6d..6306a94d29 100644 --- a/testing-modules/mocks/src/main/java/com/baeldung/mocks/jmockit/AppManager.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/AppManager.java @@ -1,4 +1,4 @@ -package com.baeldung.mocks.jmockit; +package com.baeldung.jmockit; import java.util.Random; diff --git a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/Collaborator.java b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/Collaborator.java similarity index 80% rename from testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/Collaborator.java rename to testing-modules/mocks/src/main/java/com/baeldung/jmockit/Collaborator.java index 60da12fa7c..8c4f6b15b6 100644 --- a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/Collaborator.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/Collaborator.java @@ -1,4 +1,4 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; public class Collaborator { diff --git a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/ExpectationsCollaborator.java b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java similarity index 94% rename from testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/ExpectationsCollaborator.java rename to testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java index 8209464936..799e7721e0 100644 --- a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/ExpectationsCollaborator.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java @@ -1,4 +1,4 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; import java.util.List; diff --git a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/Model.java b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/Model.java similarity index 69% rename from testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/Model.java rename to testing-modules/mocks/src/main/java/com/baeldung/jmockit/Model.java index 79ae24c2f5..ac81e5059a 100644 --- a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/Model.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/Model.java @@ -1,4 +1,4 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; public class Model { public String getInfo() { diff --git a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/Performer.java b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/Performer.java similarity index 84% rename from testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/Performer.java rename to testing-modules/mocks/src/main/java/com/baeldung/jmockit/Performer.java index 4f8e8adb24..82fd03fef1 100644 --- a/testing-modules/mocks/src/main/java/org/baeldung/mocks/jmockit/Performer.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/Performer.java @@ -1,4 +1,4 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; public class Performer { private Collaborator collaborator; diff --git a/testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/LoginController.java b/testing-modules/mocks/src/main/java/com/baeldung/testCase/LoginController.java similarity index 94% rename from testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/LoginController.java rename to testing-modules/mocks/src/main/java/com/baeldung/testCase/LoginController.java index 914b0034d2..e7e972a3ce 100644 --- a/testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/LoginController.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/testCase/LoginController.java @@ -1,4 +1,4 @@ -package org.baeldung.mocks.testCase; +package com.baeldung.testCase; public class LoginController { diff --git a/testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/LoginDao.java b/testing-modules/mocks/src/main/java/com/baeldung/testCase/LoginDao.java similarity index 79% rename from testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/LoginDao.java rename to testing-modules/mocks/src/main/java/com/baeldung/testCase/LoginDao.java index 2cbff6c9d4..f2efe38019 100644 --- a/testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/LoginDao.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/testCase/LoginDao.java @@ -1,4 +1,4 @@ -package org.baeldung.mocks.testCase; +package com.baeldung.testCase; public class LoginDao { diff --git a/testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/LoginService.java b/testing-modules/mocks/src/main/java/com/baeldung/testCase/LoginService.java similarity index 94% rename from testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/LoginService.java rename to testing-modules/mocks/src/main/java/com/baeldung/testCase/LoginService.java index d6a31a8047..3e34024971 100644 --- a/testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/LoginService.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/testCase/LoginService.java @@ -1,4 +1,4 @@ -package org.baeldung.mocks.testCase; +package com.baeldung.testCase; public class LoginService { diff --git a/testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/UserForm.java b/testing-modules/mocks/src/main/java/com/baeldung/testCase/UserForm.java similarity index 84% rename from testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/UserForm.java rename to testing-modules/mocks/src/main/java/com/baeldung/testCase/UserForm.java index 14136d0f31..bfb1411ce5 100644 --- a/testing-modules/mocks/src/main/java/org/baeldung/mocks/testCase/UserForm.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/testCase/UserForm.java @@ -1,4 +1,4 @@ -package org.baeldung.mocks.testCase; +package com.baeldung.testCase; public class UserForm { diff --git a/testing-modules/mocks/src/test/java/org/baeldung/mocks/easymock/LoginControllerIntegrationTest.java b/testing-modules/mocks/src/test/java/com/baeldung/easymock/LoginControllerIntegrationTest.java similarity index 94% rename from testing-modules/mocks/src/test/java/org/baeldung/mocks/easymock/LoginControllerIntegrationTest.java rename to testing-modules/mocks/src/test/java/com/baeldung/easymock/LoginControllerIntegrationTest.java index 4cf2a23ee8..5636382efd 100644 --- a/testing-modules/mocks/src/test/java/org/baeldung/mocks/easymock/LoginControllerIntegrationTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/easymock/LoginControllerIntegrationTest.java @@ -1,9 +1,9 @@ -package org.baeldung.mocks.easymock; +package com.baeldung.easymock; -import org.baeldung.mocks.testCase.LoginController; -import org.baeldung.mocks.testCase.LoginDao; -import org.baeldung.mocks.testCase.LoginService; -import org.baeldung.mocks.testCase.UserForm; +import com.baeldung.testCase.LoginController; +import com.baeldung.testCase.LoginDao; +import com.baeldung.testCase.LoginService; +import com.baeldung.testCase.UserForm; import org.easymock.*; import org.junit.Assert; import org.junit.Test; diff --git a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/AdvancedCollaboratorIntegrationTest.java b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/AdvancedCollaboratorIntegrationTest.java similarity index 96% rename from testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/AdvancedCollaboratorIntegrationTest.java rename to testing-modules/mocks/src/test/java/com/baeldung/jmockit/AdvancedCollaboratorIntegrationTest.java index 3a30342eb9..e55a69895f 100644 --- a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/AdvancedCollaboratorIntegrationTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/AdvancedCollaboratorIntegrationTest.java @@ -1,10 +1,11 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.List; +import com.baeldung.jmockit.AdvancedCollaborator; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/testing-modules/mocks/src/test/java/com/baeldung/mocks/jmockit/AppManagerUnitTest.java b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/AppManagerUnitTest.java similarity index 91% rename from testing-modules/mocks/src/test/java/com/baeldung/mocks/jmockit/AppManagerUnitTest.java rename to testing-modules/mocks/src/test/java/com/baeldung/jmockit/AppManagerUnitTest.java index ecdc6e441e..bc88f62024 100644 --- a/testing-modules/mocks/src/test/java/com/baeldung/mocks/jmockit/AppManagerUnitTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/AppManagerUnitTest.java @@ -1,10 +1,9 @@ -package com.baeldung.mocks.jmockit; +package com.baeldung.jmockit; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import mockit.Deencapsulation; import mockit.Mock; import mockit.MockUp; diff --git a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/ExpectationsIntegrationTest.java b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java similarity index 97% rename from testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/ExpectationsIntegrationTest.java rename to testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java index 8b85af6243..8b0c3ab4ec 100644 --- a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/ExpectationsIntegrationTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java @@ -1,5 +1,7 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; +import com.baeldung.jmockit.ExpectationsCollaborator; +import com.baeldung.jmockit.Model; import mockit.Delegate; import mockit.Expectations; import mockit.Mocked; diff --git a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/LoginControllerIntegrationTest.java b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/LoginControllerIntegrationTest.java similarity index 83% rename from testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/LoginControllerIntegrationTest.java rename to testing-modules/mocks/src/test/java/com/baeldung/jmockit/LoginControllerIntegrationTest.java index ecad7df5b5..df3eeccca2 100644 --- a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/LoginControllerIntegrationTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/LoginControllerIntegrationTest.java @@ -1,11 +1,11 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; import mockit.*; import mockit.integration.junit4.JMockit; -import org.baeldung.mocks.testCase.LoginController; -import org.baeldung.mocks.testCase.LoginDao; -import org.baeldung.mocks.testCase.LoginService; -import org.baeldung.mocks.testCase.UserForm; +import com.baeldung.testCase.LoginController; +import com.baeldung.testCase.LoginDao; +import com.baeldung.testCase.LoginService; +import com.baeldung.testCase.UserForm; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Assert; @@ -130,30 +130,33 @@ public class LoginControllerIntegrationTest { }; } + @Test public void partialMocking() { - // use partial mock - final LoginService partialLoginService = new LoginService(); + LoginService partialLoginService = new LoginService(); partialLoginService.setLoginDao(loginDao); loginController.loginService = partialLoginService; - final UserForm userForm = new UserForm(); + UserForm userForm = new UserForm(); userForm.username = "foo"; - // let service's login use implementation so let's mock DAO call - new Expectations() {{ - loginDao.login(userForm); - result = 1; - // no expectation for loginService.login + + new Expectations(partialLoginService) {{ + // let's mock DAO call + loginDao.login(userForm); result = 1; + + // no expectation for login method so that real implementation is used + + // mock setCurrentUser call partialLoginService.setCurrentUser("foo"); }}; String login = loginController.login(userForm); Assert.assertEquals("OK", login); - // verify mocked call - new FullVerifications(partialLoginService) { - }; - new FullVerifications(loginDao) { - }; + // verify mocked call + new Verifications() {{ + partialLoginService.setCurrentUser("foo"); + }}; + } } diff --git a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/PerformerIntegrationTest.java b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/PerformerIntegrationTest.java similarity index 80% rename from testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/PerformerIntegrationTest.java rename to testing-modules/mocks/src/test/java/com/baeldung/jmockit/PerformerIntegrationTest.java index 7c79a5979e..fb94ae908b 100644 --- a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/PerformerIntegrationTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/PerformerIntegrationTest.java @@ -1,5 +1,8 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; +import com.baeldung.jmockit.Collaborator; +import com.baeldung.jmockit.Model; +import com.baeldung.jmockit.Performer; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/ReusingIntegrationTest.java b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ReusingIntegrationTest.java similarity index 89% rename from testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/ReusingIntegrationTest.java rename to testing-modules/mocks/src/test/java/com/baeldung/jmockit/ReusingIntegrationTest.java index 73bc712143..30b17ee2e4 100644 --- a/testing-modules/mocks/src/test/java/org/baeldung/mocks/jmockit/ReusingIntegrationTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ReusingIntegrationTest.java @@ -1,5 +1,8 @@ -package org.baeldung.mocks.jmockit; +package com.baeldung.jmockit; +import com.baeldung.jmockit.Collaborator; +import com.baeldung.jmockit.Model; +import com.baeldung.jmockit.Performer; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/testing-modules/mocks/src/test/java/org/baeldung/mocks/mockito/LoginControllerIntegrationTest.java b/testing-modules/mocks/src/test/java/com/baeldung/mockito/LoginControllerIntegrationTest.java similarity index 94% rename from testing-modules/mocks/src/test/java/org/baeldung/mocks/mockito/LoginControllerIntegrationTest.java rename to testing-modules/mocks/src/test/java/com/baeldung/mockito/LoginControllerIntegrationTest.java index 9d47b2f5d4..98df2cf850 100644 --- a/testing-modules/mocks/src/test/java/org/baeldung/mocks/mockito/LoginControllerIntegrationTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/mockito/LoginControllerIntegrationTest.java @@ -1,9 +1,9 @@ -package org.baeldung.mocks.mockito; +package com.baeldung.mockito; -import org.baeldung.mocks.testCase.LoginController; -import org.baeldung.mocks.testCase.LoginDao; -import org.baeldung.mocks.testCase.LoginService; -import org.baeldung.mocks.testCase.UserForm; +import com.baeldung.testCase.LoginController; +import com.baeldung.testCase.LoginDao; +import com.baeldung.testCase.LoginService; +import com.baeldung.testCase.UserForm; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/testing-modules/rest-assured/pom.xml b/testing-modules/rest-assured/pom.xml index 74935bcf6f..0b027312d6 100644 --- a/testing-modules/rest-assured/pom.xml +++ b/testing-modules/rest-assured/pom.xml @@ -147,16 +147,6 @@ wiremock ${wiremock.version}
- - com.github.fge - json-schema-validator - ${github-json-schema-validator.version} - - - com.github.fge - json-schema-core - ${json-schema-core.version} - commons-collections commons-collections @@ -208,12 +198,6 @@ 2.4.7 2.4.1 - 2.2.6 - 1.2.5 - - 3.0.1 - 3.0.1 - 2.5.3 diff --git a/testing-modules/rest-testing/src/test/java/org/baeldung/rest/GitHubUser.java b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/GitHubUser.java similarity index 88% rename from testing-modules/rest-testing/src/test/java/org/baeldung/rest/GitHubUser.java rename to testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/GitHubUser.java index 73c9677377..6992789f0e 100644 --- a/testing-modules/rest-testing/src/test/java/org/baeldung/rest/GitHubUser.java +++ b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/GitHubUser.java @@ -1,4 +1,4 @@ -package org.baeldung.rest; +package com.baeldung.rest.jbehave; public class GitHubUser { diff --git a/testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/GithubUserResponsePayloadSteps.java b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/GithubUserResponsePayloadSteps.java index d9401a5d00..51beb609c2 100644 --- a/testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/GithubUserResponsePayloadSteps.java +++ b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/GithubUserResponsePayloadSteps.java @@ -1,11 +1,6 @@ package com.baeldung.rest.jbehave; import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.impl.client.HttpClientBuilder; -import org.baeldung.rest.GitHubUser; -import org.baeldung.rest.RetrieveUtil; import org.hamcrest.Matchers; import org.jbehave.core.annotations.Given; import org.jbehave.core.annotations.Then; diff --git a/testing-modules/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/RetrieveUtil.java similarity index 95% rename from testing-modules/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java rename to testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/RetrieveUtil.java index 75ec3c842c..03f96bed73 100644 --- a/testing-modules/rest-testing/src/test/java/org/baeldung/rest/RetrieveUtil.java +++ b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/jbehave/RetrieveUtil.java @@ -1,4 +1,4 @@ -package org.baeldung.rest; +package com.baeldung.rest.jbehave; import java.io.IOException; diff --git a/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/SeleniumCookiesJUnitLiveTest.java b/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/SeleniumCookiesJUnitLiveTest.java new file mode 100644 index 0000000000..0cbbf52454 --- /dev/null +++ b/testing-modules/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/SeleniumCookiesJUnitLiveTest.java @@ -0,0 +1,110 @@ +package test.java.com.baeldung.selenium.junit; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.Capabilities; +import org.openqa.selenium.Cookie; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.remote.DesiredCapabilities; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; + +public class SeleniumCookiesJUnitLiveTest { + + private WebDriver driver; + private String navUrl; + + @Before + public void setUp() { + Capabilities capabilities = DesiredCapabilities.firefox(); + driver = new FirefoxDriver(capabilities); + navUrl = "https://baeldung.com"; + driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); + System.setProperty("webdriver.gecko.driver", "geckodriver.exe"); + } + + @After + public void teardown() { + driver.quit(); + } + + @Test + public void whenNavigate_thenCookiesExist() { + driver.navigate().to(navUrl); + Set cookies = driver.manage().getCookies(); + + assertThat(cookies, is(not(empty()))); + } + + @Test + public void whenNavigate_thenLpCookieExists() { + driver.navigate().to(navUrl); + Cookie lpCookie = driver.manage().getCookieNamed("lp_120073"); + + assertThat(lpCookie, is(not(nullValue()))); + } + + @Test + public void whenNavigate_thenLpCookieIsHasCorrectValue() { + driver.navigate().to(navUrl); + Cookie lpCookie = driver.manage().getCookieNamed("lp_120073"); + + assertThat(lpCookie.getValue(), containsString("www.baeldung.com")); + } + + @Test + public void whenNavigate_thenLpCookieHasCorrectProps() { + driver.navigate().to(navUrl); + Cookie lpCookie = driver.manage().getCookieNamed("lp_120073"); + + assertThat(lpCookie.getDomain(), equalTo(".baeldung.com")); + assertThat(lpCookie.getPath(), equalTo("/")); + assertThat(lpCookie.getExpiry(), is(not(nullValue()))); + assertThat(lpCookie.isSecure(), equalTo(false)); + assertThat(lpCookie.isHttpOnly(), equalTo(false)); + } + + @Test + public void whenAddingCookie_thenItIsPresent() { + driver.navigate().to(navUrl); + Cookie cookie = new Cookie("foo", "bar"); + driver.manage().addCookie(cookie); + Cookie driverCookie = driver.manage().getCookieNamed("foo"); + + assertThat(driverCookie.getValue(), equalTo("bar")); + } + + @Test + public void whenDeletingCookie_thenItIsAbsent() { + driver.navigate().to(navUrl); + Cookie lpCookie = driver.manage().getCookieNamed("lp_120073"); + + assertThat(lpCookie, is(not(nullValue()))); + + driver.manage().deleteCookie(lpCookie); + Cookie deletedCookie = driver.manage().getCookieNamed("lp_120073"); + + assertThat(deletedCookie, is(nullValue())); + } + + @Test + public void whenOverridingCookie_thenItIsUpdated() { + driver.navigate().to(navUrl); + Cookie lpCookie = driver.manage().getCookieNamed("lp_120073"); + driver.manage().deleteCookie(lpCookie); + + Cookie newLpCookie = new Cookie("lp_120073", "foo"); + driver.manage().addCookie(newLpCookie); + + Cookie overriddenCookie = driver.manage().getCookieNamed("lp_120073"); + + assertThat(overriddenCookie.getValue(), equalTo("foo")); + } + +} diff --git a/testing-modules/spring-testing/pom.xml b/testing-modules/spring-testing/pom.xml index 22f5f68240..38e7a0dd46 100644 --- a/testing-modules/spring-testing/pom.xml +++ b/testing-modules/spring-testing/pom.xml @@ -3,7 +3,7 @@ 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"> 4.0.0 - org.baeldung + com.baeldung spring-testing 0.1-SNAPSHOT spring-testing diff --git a/testing-modules/spring-testing/src/main/java/org/baeldung/mockito/repository/User.java b/testing-modules/spring-testing/src/main/java/com/baeldung/mockito/repository/User.java similarity index 95% rename from testing-modules/spring-testing/src/main/java/org/baeldung/mockito/repository/User.java rename to testing-modules/spring-testing/src/main/java/com/baeldung/mockito/repository/User.java index 28cd4f9fb0..1854a085ac 100644 --- a/testing-modules/spring-testing/src/main/java/org/baeldung/mockito/repository/User.java +++ b/testing-modules/spring-testing/src/main/java/com/baeldung/mockito/repository/User.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito.repository; +package com.baeldung.mockito.repository; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/testing-modules/spring-testing/src/main/java/org/baeldung/mockito/repository/UserRepository.java b/testing-modules/spring-testing/src/main/java/com/baeldung/mockito/repository/UserRepository.java similarity index 84% rename from testing-modules/spring-testing/src/main/java/org/baeldung/mockito/repository/UserRepository.java rename to testing-modules/spring-testing/src/main/java/com/baeldung/mockito/repository/UserRepository.java index 3f1952a5e7..fd5bd55c84 100644 --- a/testing-modules/spring-testing/src/main/java/org/baeldung/mockito/repository/UserRepository.java +++ b/testing-modules/spring-testing/src/main/java/com/baeldung/mockito/repository/UserRepository.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito.repository; +package com.baeldung.mockito.repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/testing-modules/spring-testing/src/main/java/org/baeldung/reflectiontestutils/repository/Employee.java b/testing-modules/spring-testing/src/main/java/com/baeldung/reflectiontestutils/repository/Employee.java similarity index 87% rename from testing-modules/spring-testing/src/main/java/org/baeldung/reflectiontestutils/repository/Employee.java rename to testing-modules/spring-testing/src/main/java/com/baeldung/reflectiontestutils/repository/Employee.java index 8d4eeb57c4..d542f9c234 100644 --- a/testing-modules/spring-testing/src/main/java/org/baeldung/reflectiontestutils/repository/Employee.java +++ b/testing-modules/spring-testing/src/main/java/com/baeldung/reflectiontestutils/repository/Employee.java @@ -1,4 +1,4 @@ -package org.baeldung.reflectiontestutils.repository; +package com.baeldung.reflectiontestutils.repository; public class Employee { private Integer id; diff --git a/testing-modules/spring-testing/src/main/java/org/baeldung/reflectiontestutils/repository/EmployeeService.java b/testing-modules/spring-testing/src/main/java/com/baeldung/reflectiontestutils/repository/EmployeeService.java similarity index 87% rename from testing-modules/spring-testing/src/main/java/org/baeldung/reflectiontestutils/repository/EmployeeService.java rename to testing-modules/spring-testing/src/main/java/com/baeldung/reflectiontestutils/repository/EmployeeService.java index d28745e2ab..9feae7ae30 100644 --- a/testing-modules/spring-testing/src/main/java/org/baeldung/reflectiontestutils/repository/EmployeeService.java +++ b/testing-modules/spring-testing/src/main/java/com/baeldung/reflectiontestutils/repository/EmployeeService.java @@ -1,4 +1,4 @@ -package org.baeldung.reflectiontestutils.repository; +package com.baeldung.reflectiontestutils.repository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/testing-modules/spring-testing/src/main/java/org/baeldung/reflectiontestutils/repository/HRService.java b/testing-modules/spring-testing/src/main/java/com/baeldung/reflectiontestutils/repository/HRService.java similarity index 77% rename from testing-modules/spring-testing/src/main/java/org/baeldung/reflectiontestutils/repository/HRService.java rename to testing-modules/spring-testing/src/main/java/com/baeldung/reflectiontestutils/repository/HRService.java index 13a5973ee8..bb2c34d82f 100644 --- a/testing-modules/spring-testing/src/main/java/org/baeldung/reflectiontestutils/repository/HRService.java +++ b/testing-modules/spring-testing/src/main/java/com/baeldung/reflectiontestutils/repository/HRService.java @@ -1,4 +1,4 @@ -package org.baeldung.reflectiontestutils.repository; +package com.baeldung.reflectiontestutils.repository; import org.springframework.stereotype.Component; diff --git a/testing-modules/spring-testing/src/test/java/org/baeldung/mockito/MockAnnotationUnitTest.java b/testing-modules/spring-testing/src/test/java/com/baeldung/mockito/MockAnnotationUnitTest.java similarity index 92% rename from testing-modules/spring-testing/src/test/java/org/baeldung/mockito/MockAnnotationUnitTest.java rename to testing-modules/spring-testing/src/test/java/com/baeldung/mockito/MockAnnotationUnitTest.java index 1fa7f241e7..424a622b65 100644 --- a/testing-modules/spring-testing/src/test/java/org/baeldung/mockito/MockAnnotationUnitTest.java +++ b/testing-modules/spring-testing/src/test/java/com/baeldung/mockito/MockAnnotationUnitTest.java @@ -1,6 +1,6 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; -import org.baeldung.mockito.repository.UserRepository; +import com.baeldung.mockito.repository.UserRepository; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/testing-modules/spring-testing/src/test/java/org/baeldung/mockito/MockBeanAnnotationIntegrationTest.java b/testing-modules/spring-testing/src/test/java/com/baeldung/mockito/MockBeanAnnotationIntegrationTest.java similarity index 91% rename from testing-modules/spring-testing/src/test/java/org/baeldung/mockito/MockBeanAnnotationIntegrationTest.java rename to testing-modules/spring-testing/src/test/java/com/baeldung/mockito/MockBeanAnnotationIntegrationTest.java index 3a7e58fb48..b7617ef652 100644 --- a/testing-modules/spring-testing/src/test/java/org/baeldung/mockito/MockBeanAnnotationIntegrationTest.java +++ b/testing-modules/spring-testing/src/test/java/com/baeldung/mockito/MockBeanAnnotationIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; -import org.baeldung.mockito.repository.UserRepository; +import com.baeldung.mockito.repository.UserRepository; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/testing-modules/spring-testing/src/test/java/org/baeldung/reflectiontestutils/ReflectionTestUtilsUnitTest.java b/testing-modules/spring-testing/src/test/java/com/baeldung/reflectiontestutils/ReflectionTestUtilsUnitTest.java similarity index 87% rename from testing-modules/spring-testing/src/test/java/org/baeldung/reflectiontestutils/ReflectionTestUtilsUnitTest.java rename to testing-modules/spring-testing/src/test/java/com/baeldung/reflectiontestutils/ReflectionTestUtilsUnitTest.java index 36e5428b58..33d4db22f3 100644 --- a/testing-modules/spring-testing/src/test/java/org/baeldung/reflectiontestutils/ReflectionTestUtilsUnitTest.java +++ b/testing-modules/spring-testing/src/test/java/com/baeldung/reflectiontestutils/ReflectionTestUtilsUnitTest.java @@ -1,11 +1,11 @@ -package org.baeldung.reflectiontestutils; +package com.baeldung.reflectiontestutils; import static org.junit.Assert.*; import static org.mockito.Mockito.mock; -import org.baeldung.reflectiontestutils.repository.Employee; -import org.baeldung.reflectiontestutils.repository.EmployeeService; -import org.baeldung.reflectiontestutils.repository.HRService; +import com.baeldung.reflectiontestutils.repository.EmployeeService; +import com.baeldung.reflectiontestutils.repository.HRService; +import com.baeldung.reflectiontestutils.repository.Employee; import org.junit.Test; import org.springframework.test.util.ReflectionTestUtils; diff --git a/testing-modules/testing-libraries/README.md b/testing-modules/testing-libraries/README.md index d76b7b1308..e5145d6af8 100644 --- a/testing-modules/testing-libraries/README.md +++ b/testing-modules/testing-libraries/README.md @@ -8,5 +8,5 @@ - [Introduction to Lambda Behave](http://www.baeldung.com/lambda-behave) - [Introduction to CheckStyle](https://www.baeldung.com/checkstyle-java) - [Introduction to FindBugs](https://www.baeldung.com/intro-to-findbugs) - +- [Cucumber Data Tables](https://www.baeldung.com/cucumber-data-tables) diff --git a/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumberhooks/books/Book.java b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumberhooks/books/Book.java new file mode 100644 index 0000000000..dc8f1dcf64 --- /dev/null +++ b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumberhooks/books/Book.java @@ -0,0 +1,35 @@ +package com.baeldung.cucumberhooks.books; + +public class Book { + + private String title; + private String author; + + public Book(String title, String author) { + this.title = title; + this.author = author; + } + + public Book() {} + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + @Override + public String toString() { + return "Book [title=" + title + ", author=" + author + "]"; + } +} diff --git a/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumberhooks/books/BookStore.java b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumberhooks/books/BookStore.java new file mode 100644 index 0000000000..cc4e42d28f --- /dev/null +++ b/testing-modules/testing-libraries/src/main/java/com/baeldung/cucumberhooks/books/BookStore.java @@ -0,0 +1,28 @@ +package com.baeldung.cucumberhooks.books; + +import java.util.*; +import java.util.stream.Collectors; + +public class BookStore { + private List books = new ArrayList<>(); + + public void addBook(Book book) { + books.add(book); + } + + public void addAllBooks(Collection books) { + this.books.addAll(books); + } + + public List booksByAuthor(String author) { + return books.stream() + .filter(book -> Objects.equals(author, book.getAuthor())) + .collect(Collectors.toList()); + } + + public Optional bookByTitle(String title) { + return books.stream() + .filter(book -> book.getTitle().equals(title)) + .findFirst(); + } +} diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumberhooks/books/BookStoreWithHooksIntegrationHooks.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumberhooks/books/BookStoreWithHooksIntegrationHooks.java new file mode 100644 index 0000000000..8de55e4611 --- /dev/null +++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumberhooks/books/BookStoreWithHooksIntegrationHooks.java @@ -0,0 +1,48 @@ +package com.baeldung.cucumberhooks.books; + +import io.cucumber.core.api.Scenario; +import io.cucumber.java.After; +import io.cucumber.java.AfterStep; +import io.cucumber.java.Before; +import io.cucumber.java.BeforeStep; +import io.cucumber.java8.En; + +public class BookStoreWithHooksIntegrationHooks implements En { + + public BookStoreWithHooksIntegrationHooks() { + Before(1, () -> startBrowser()); + } + + @Before(order=2, value="@Screenshots") + public void beforeScenario(Scenario scenario) { + takeScreenshot(); + } + + @After + public void afterScenario(Scenario scenario) { + takeScreenshot(); + } + + @BeforeStep + public void beforeStep(Scenario scenario) { + takeScreenshot(); + } + + @AfterStep + public void afterStep(Scenario scenario) { + takeScreenshot(); + closeBrowser(); + } + + public void takeScreenshot() { + //code to take and save screenshot + } + + public void startBrowser() { + //code to open browser + } + + public void closeBrowser() { + //code to close browser + } +} diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumberhooks/books/BookStoreWithHooksIntegrationTest.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumberhooks/books/BookStoreWithHooksIntegrationTest.java new file mode 100644 index 0000000000..79e43bad27 --- /dev/null +++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumberhooks/books/BookStoreWithHooksIntegrationTest.java @@ -0,0 +1,13 @@ +package com.baeldung.cucumberhooks.books; + +import io.cucumber.junit.Cucumber; +import io.cucumber.junit.CucumberOptions; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions(features = "classpath:features/book-store-with-hooks.feature", + glue = "com.baeldung.cucumberhooks.books" +) +public class BookStoreWithHooksIntegrationTest { + +} diff --git a/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumberhooks/books/BookStoreWithHooksRunSteps.java b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumberhooks/books/BookStoreWithHooksRunSteps.java new file mode 100644 index 0000000000..8ebda5ffa4 --- /dev/null +++ b/testing-modules/testing-libraries/src/test/java/com/baeldung/cucumberhooks/books/BookStoreWithHooksRunSteps.java @@ -0,0 +1,44 @@ +package com.baeldung.cucumberhooks.books; + +import io.cucumber.datatable.DataTable; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import io.cucumber.java8.En; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +public class BookStoreWithHooksRunSteps implements En { + + private BookStore store; + private List foundBooks; + private Book foundBook; + + public BookStoreWithHooksRunSteps() { + store = new BookStore(); + foundBooks = new ArrayList<>(); + } + + @Given("^The following books are available in the store$") + public void haveBooksInTheStore(DataTable table) { + List> rows = table.asLists(String.class); + + for (List columns: rows) { + store.addBook(new Book(columns.get(0), columns.get(1))); + } + } + + @When("^I ask for a book by the author (.+)$") + public void searchForBooksByAuthor(String author) { + foundBooks = store.booksByAuthor(author); + } + + @Then("^The salesperson says that there are (\\d+) books$") + public void findBooks(int count) { + assertEquals(count, foundBooks.size()); + } + +} diff --git a/testing-modules/testing-libraries/src/test/resources/features/book-store-with-hooks.feature b/testing-modules/testing-libraries/src/test/resources/features/book-store-with-hooks.feature new file mode 100644 index 0000000000..78e136d68d --- /dev/null +++ b/testing-modules/testing-libraries/src/test/resources/features/book-store-with-hooks.feature @@ -0,0 +1,17 @@ +Feature: Book Store With Hooks + Background: The Book Store + Given The following books are available in the store + | The Devil in the White City | Erik Larson | + | The Lion, the Witch and the Wardrobe | C.S. Lewis | + | In the Garden of Beasts | Erik Larson | + + @Screenshots + Scenario: 1 - Find books by author + When I ask for a book by the author Erik Larson + Then The salesperson says that there are 2 books + + Scenario: 2 - Find books by author, but isn't there + When I ask for a book by the author Marcel Proust + Then The salesperson says that there are 0 books + + diff --git a/webrtc/README.md b/webrtc/README.md new file mode 100644 index 0000000000..42c06341b4 --- /dev/null +++ b/webrtc/README.md @@ -0,0 +1,8 @@ +## WebRTC + +This module contains articles about WebRTC + +### Relevant Articles: + +- [Guide to WebRTC](https://www.baeldung.com/webrtc) + diff --git a/webrtc/pom.xml b/webrtc/pom.xml new file mode 100644 index 0000000000..2a3b48b2ed --- /dev/null +++ b/webrtc/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + webrtc + 0.0.1 + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-websocket + + + + + 1.8 + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/webrtc/src/main/java/com/baeldung/webrtc/SocketHandler.java b/webrtc/src/main/java/com/baeldung/webrtc/SocketHandler.java new file mode 100644 index 0000000000..bffd57f6cf --- /dev/null +++ b/webrtc/src/main/java/com/baeldung/webrtc/SocketHandler.java @@ -0,0 +1,31 @@ +package com.baeldung.webrtc; + +import org.springframework.stereotype.Component; +import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketSession; +import org.springframework.web.socket.handler.TextWebSocketHandler; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +@Component +public class SocketHandler extends TextWebSocketHandler { + + List sessions = new CopyOnWriteArrayList<>(); + + @Override + public void handleTextMessage(WebSocketSession session, TextMessage message) throws InterruptedException, IOException { + + for (WebSocketSession webSocketSession : sessions) { + if (webSocketSession.isOpen() && !session.getId().equals(webSocketSession.getId())) { + webSocketSession.sendMessage(message); + } + } + } + + @Override + public void afterConnectionEstablished(WebSocketSession session) throws Exception { + sessions.add(session); + } +} \ No newline at end of file diff --git a/webrtc/src/main/java/com/baeldung/webrtc/WebRTCDemoApplication.java b/webrtc/src/main/java/com/baeldung/webrtc/WebRTCDemoApplication.java new file mode 100644 index 0000000000..f54946547d --- /dev/null +++ b/webrtc/src/main/java/com/baeldung/webrtc/WebRTCDemoApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.webrtc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class WebRTCDemoApplication { + + public static void main(String[] args) { + SpringApplication.run(WebRTCDemoApplication.class, args); + } +} diff --git a/webrtc/src/main/java/com/baeldung/webrtc/WebSocketConfiguration.java b/webrtc/src/main/java/com/baeldung/webrtc/WebSocketConfiguration.java new file mode 100644 index 0000000000..9deb395dad --- /dev/null +++ b/webrtc/src/main/java/com/baeldung/webrtc/WebSocketConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.webrtc; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.config.annotation.WebSocketConfigurer; +import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; + +@Configuration +@EnableWebSocket +public class WebSocketConfiguration implements WebSocketConfigurer { + + @Override + public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { + registry.addHandler(new SocketHandler(), "/socket") + .setAllowedOrigins("*"); + } +} diff --git a/webrtc/src/main/resources/application.properties b/webrtc/src/main/resources/application.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/webrtc/src/main/resources/static/client.js b/webrtc/src/main/resources/static/client.js new file mode 100644 index 0000000000..059dc84bcb --- /dev/null +++ b/webrtc/src/main/resources/static/client.js @@ -0,0 +1,116 @@ +//connecting to our signaling server +var conn = new WebSocket('ws://localhost:8080/socket'); + +conn.onopen = function() { + console.log("Connected to the signaling server"); + initialize(); +}; + +conn.onmessage = function(msg) { + console.log("Got message", msg.data); + var content = JSON.parse(msg.data); + var data = content.data; + switch (content.event) { + // when somebody wants to call us + case "offer": + handleOffer(data); + break; + case "answer": + handleAnswer(data); + break; + // when a remote peer sends an ice candidate to us + case "candidate": + handleCandidate(data); + break; + default: + break; + } +}; + +function send(message) { + conn.send(JSON.stringify(message)); +} + +var peerConnection; +var dataChannel; +var input = document.getElementById("messageInput"); + +function initialize() { + var configuration = null; + + peerConnection = new RTCPeerConnection(configuration, { + optional : [ { + RtpDataChannels : true + } ] + }); + + // Setup ice handling + peerConnection.onicecandidate = function(event) { + if (event.candidate) { + send({ + event : "candidate", + data : event.candidate + }); + } + }; + + // creating data channel + dataChannel = peerConnection.createDataChannel("dataChannel", { + reliable : true + }); + + dataChannel.onerror = function(error) { + console.log("Error occured on datachannel:", error); + }; + + // when we receive a message from the other peer, printing it on the console + dataChannel.onmessage = function(event) { + console.log("message:", event.data); + }; + + dataChannel.onclose = function() { + console.log("data channel is closed"); + }; +} + +function createOffer() { + peerConnection.createOffer(function(offer) { + send({ + event : "offer", + data : offer + }); + peerConnection.setLocalDescription(offer); + }, function(error) { + alert("Error creating an offer"); + }); +} + +function handleOffer(offer) { + peerConnection.setRemoteDescription(new RTCSessionDescription(offer)); + + // create and send an answer to an offer + peerConnection.createAnswer(function(answer) { + peerConnection.setLocalDescription(answer); + send({ + event : "answer", + data : answer + }); + }, function(error) { + alert("Error creating an answer"); + }); + +}; + +function handleCandidate(candidate) { + peerConnection.addIceCandidate(new RTCIceCandidate(candidate)); +}; + +function handleAnswer(answer) { + peerConnection.setRemoteDescription(new RTCSessionDescription(answer)); + console.log("connection established successfully!!"); +}; + +function sendMessage() { + dataChannel.send(input.value); + input.value = ""; +} diff --git a/webrtc/src/main/resources/static/index.html b/webrtc/src/main/resources/static/index.html new file mode 100644 index 0000000000..39a86ec61e --- /dev/null +++ b/webrtc/src/main/resources/static/index.html @@ -0,0 +1,67 @@ + + + +WebRTC demo + + + + + + + + + + +
+

A Demo for messaging in WebRTC

+ +

+ Run two instances of this webpage along with the server to test this + application.
Create an offer, and then send the message.
Check + the browser console to see the output. +

+ + + + + + + + +
+ + + + + diff --git a/wildfly/pom.xml b/wildfly/pom.xml index e81b609206..cdffe8b996 100644 --- a/wildfly/pom.xml +++ b/wildfly/pom.xml @@ -9,9 +9,10 @@ war - org.springframework.boot - spring-boot-starter-parent - 2.1.6.RELEASE + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2