diff --git a/akka-streams/README.md b/akka-streams/README.md index 7f2751422b..5f71991def 100644 --- a/akka-streams/README.md +++ b/akka-streams/README.md @@ -1,3 +1,3 @@ ### Relevant articles -- [Guide to Akka Streams](http://www.baeldung.com/akka-streams) +- [Guide to Akka Streams](https://www.baeldung.com/akka-streams) diff --git a/algorithms-genetic/README.md b/algorithms-genetic/README.md index 39f8d59eee..124e9c09e5 100644 --- a/algorithms-genetic/README.md +++ b/algorithms-genetic/README.md @@ -1,6 +1,6 @@ ## Relevant articles: -- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics) -- [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization) +- [Introduction to Jenetics Library](https://www.baeldung.com/jenetics) +- [Ant Colony Optimization](https://www.baeldung.com/java-ant-colony-optimization) - [Design a Genetic Algorithm in Java](https://www.baeldung.com/java-genetic-algorithm) - [The Traveling Salesman Problem in Java](https://www.baeldung.com/java-simulated-annealing-for-traveling-salesman) diff --git a/algorithms-miscellaneous-2/README.md b/algorithms-miscellaneous-2/README.md index 745b106963..76727a1d4f 100644 --- a/algorithms-miscellaneous-2/README.md +++ b/algorithms-miscellaneous-2/README.md @@ -1,10 +1,10 @@ ## Relevant articles: -- [Dijkstra Algorithm in Java](https://www.baeldung.com/java-dijkstra) +- [Dijkstra Shortest Path Algorithm in Java](https://www.baeldung.com/java-dijkstra) - [Introduction to Cobertura](https://www.baeldung.com/cobertura) - [Test a Linked List for Cyclicity](https://www.baeldung.com/java-linked-list-cyclicity) - [Introduction to JGraphT](https://www.baeldung.com/jgrapht) - [A Maze Solver in Java](https://www.baeldung.com/java-solve-maze) - [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) \ No newline at end of file +- [A Collaborative Filtering Recommendation System in Java](https://www.baeldung.com/java-collaborative-filtering-recommendations) diff --git a/algorithms-miscellaneous-3/README.md b/algorithms-miscellaneous-3/README.md index 843407f047..d2d73ec8a1 100644 --- a/algorithms-miscellaneous-3/README.md +++ b/algorithms-miscellaneous-3/README.md @@ -2,10 +2,10 @@ - [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique) - [Implementing Simple State Machines with Java Enums](https://www.baeldung.com/java-enum-simple-state-machine) -- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic) -- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity) +- [Converting Between Roman and Arabic Numerals in Java](https://www.baeldung.com/java-convert-roman-arabic) +- [Practical Java Examples of the Big O Notation](https://www.baeldung.com/java-algorithm-complexity) - [Checking If a List Is Sorted in Java](https://www.baeldung.com/java-check-if-list-sorted) - [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle) - [A Guide to the Folding Technique in Java](https://www.baeldung.com/folding-hashing-technique) - [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) \ No newline at end of file +- [Efficient Word Frequency Calculator in Java](https://www.baeldung.com/java-word-frequency) diff --git a/algorithms-sorting/README.md b/algorithms-sorting/README.md index 968d51aecf..903865046a 100644 --- a/algorithms-sorting/README.md +++ b/algorithms-sorting/README.md @@ -1,9 +1,10 @@ ## Relevant articles: -- [Bubble Sort in Java](http://www.baeldung.com/java-bubble-sort) +- [Bubble Sort in Java](https://www.baeldung.com/java-bubble-sort) - [Merge Sort in Java](https://www.baeldung.com/java-merge-sort) - [Quicksort Algorithm Implementation in Java](https://www.baeldung.com/java-quicksort) - [Insertion Sort in Java](https://www.baeldung.com/java-insertion-sort) - [Heap Sort in Java](https://www.baeldung.com/java-heap-sort) - [Shell Sort in Java](https://www.baeldung.com/java-shell-sort) - [Counting Sort in Java](https://www.baeldung.com/java-counting-sort) +- [Sorting Strings by Contained Numbers in Java](https://www.baeldung.com/java-sort-strings-contained-numbers) diff --git a/animal-sniffer-mvn-plugin/README.md b/animal-sniffer-mvn-plugin/README.md index 4c7c381da4..e292fe29ca 100644 --- a/animal-sniffer-mvn-plugin/README.md +++ b/animal-sniffer-mvn-plugin/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -[Introduction to Animal Sniffer Maven Plugin](http://www.baeldung.com/maven-animal-sniffer) +[Introduction to Animal Sniffer Maven Plugin](https://www.baeldung.com/maven-animal-sniffer) diff --git a/annotations/readme.md b/annotations/readme.md index 2b052803e6..dc40a7e116 100644 --- a/annotations/readme.md +++ b/annotations/readme.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Java Annotation Processing and Creating a Builder](http://www.baeldung.com/java-annotation-processing-builder) +- [Java Annotation Processing and Creating a Builder](https://www.baeldung.com/java-annotation-processing-builder) diff --git a/antlr/README.md b/antlr/README.md index 419d9ddfbb..b6dac4aa4b 100644 --- a/antlr/README.md +++ b/antlr/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Java with ANTLR](http://www.baeldung.com/java-antlr) +- [Java with ANTLR](https://www.baeldung.com/java-antlr) diff --git a/apache-avro/README.md b/apache-avro/README.md index 32d84ecc76..45ae6e2b9b 100644 --- a/apache-avro/README.md +++ b/apache-avro/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Guide to Apache Avro](http://www.baeldung.com/java-apache-avro) +- [Guide to Apache Avro](https://www.baeldung.com/java-apache-avro) diff --git a/apache-bval/README.md b/apache-bval/README.md index 80ea149993..a9b3979828 100644 --- a/apache-bval/README.md +++ b/apache-bval/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Intro to Apache BVal](http://www.baeldung.com/apache-bval) +- [Intro to Apache BVal](https://www.baeldung.com/apache-bval) diff --git a/apache-curator/README.md b/apache-curator/README.md index 9bda573292..30336d7cdc 100644 --- a/apache-curator/README.md +++ b/apache-curator/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Introduction to Apache Curator](http://www.baeldung.com/apache-curator) +- [Introduction to Apache Curator](https://www.baeldung.com/apache-curator) diff --git a/apache-cxf/README.md b/apache-cxf/README.md index d03999dce3..87413df8c9 100644 --- a/apache-cxf/README.md +++ b/apache-cxf/README.md @@ -1,6 +1,6 @@ ## Relevant Articles: -- [Introduction to Apache CXF Aegis Data Binding](http://www.baeldung.com/aegis-data-binding-in-apache-cxf) -- [Apache CXF Support for RESTful Web Services](http://www.baeldung.com/apache-cxf-rest-api) -- [A Guide to Apache CXF with Spring](http://www.baeldung.com/apache-cxf-with-spring) -- [Introduction to Apache CXF](http://www.baeldung.com/introduction-to-apache-cxf) +- [Introduction to Apache CXF Aegis Data Binding](https://www.baeldung.com/aegis-data-binding-in-apache-cxf) +- [Apache CXF Support for RESTful Web Services](https://www.baeldung.com/apache-cxf-rest-api) +- [A Guide to Apache CXF with Spring](https://www.baeldung.com/apache-cxf-with-spring) +- [Introduction to Apache CXF](https://www.baeldung.com/introduction-to-apache-cxf) - [Server-Sent Events (SSE) In JAX-RS](https://www.baeldung.com/java-ee-jax-rs-sse) diff --git a/apache-meecrowave/README.md b/apache-meecrowave/README.md index 42b93a383e..0dea60816b 100644 --- a/apache-meecrowave/README.md +++ b/apache-meecrowave/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: ================================ -- [Building a Microservice with Apache Meecrowave](http://www.baeldung.com/apache-meecrowave) +- [Building a Microservice with Apache Meecrowave](https://www.baeldung.com/apache-meecrowave) diff --git a/apache-olingo/README.md b/apache-olingo/README.md index bfbdc97700..22fa6b3b51 100644 --- a/apache-olingo/README.md +++ b/apache-olingo/README.md @@ -1,3 +1,4 @@ ## Relevant articles: - [OData Protocol Guide](https://www.baeldung.com/odata) +- [Intro to OData with Olingo](https://www.baeldung.com/olingo) diff --git a/apache-opennlp/README.md b/apache-opennlp/README.md index 2e9fa0e384..006ca588f2 100644 --- a/apache-opennlp/README.md +++ b/apache-opennlp/README.md @@ -1,3 +1,3 @@ ### Relevant Articles -- [Intro to Apache OpenNLP](http://www.baeldung.com/apache-open-nlp) +- [Intro to Apache OpenNLP](https://www.baeldung.com/apache-open-nlp) diff --git a/apache-poi/README.md b/apache-poi/README.md index 862981991d..8ffd8ef517 100644 --- a/apache-poi/README.md +++ b/apache-poi/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: -- [Microsoft Word Processing in Java with Apache POI](http://www.baeldung.com/java-microsoft-word-with-apache-poi) -- [Working with Microsoft Excel in Java](http://www.baeldung.com/java-microsoft-excel) -- [Creating a MS PowerPoint Presentation in Java](http://www.baeldung.com/apache-poi-slideshow) +- [Microsoft Word Processing in Java with Apache POI](https://www.baeldung.com/java-microsoft-word-with-apache-poi) +- [Working with Microsoft Excel in Java](https://www.baeldung.com/java-microsoft-excel) +- [Creating a MS PowerPoint Presentation in Java](https://www.baeldung.com/apache-poi-slideshow) diff --git a/apache-shiro/README.md b/apache-shiro/README.md index bc3480b266..85f2a99a59 100644 --- a/apache-shiro/README.md +++ b/apache-shiro/README.md @@ -1,2 +1,2 @@ ### Relevant articles -- [Introduction to Apache Shiro](http://www.baeldung.com/apache-shiro) +- [Introduction to Apache Shiro](https://www.baeldung.com/apache-shiro) diff --git a/apache-solrj/README.md b/apache-solrj/README.md index 7a32becb64..55f35b90a7 100644 --- a/apache-solrj/README.md +++ b/apache-solrj/README.md @@ -1,4 +1,4 @@ ## Apache Solrj Tutorials Project ### Relevant Articles -- [Guide to Solr in Java with Apache Solrj](http://www.baeldung.com/apache-solrj) +- [Guide to Solr in Java with Apache Solrj](https://www.baeldung.com/apache-solrj) diff --git a/apache-spark/README.md b/apache-spark/README.md index a4dce212b4..a867fd57ff 100644 --- a/apache-spark/README.md +++ b/apache-spark/README.md @@ -1,4 +1,4 @@ ### Relevant articles -- [Introduction to Apache Spark](http://www.baeldung.com/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) diff --git a/apache-thrift/README.md b/apache-thrift/README.md index d8b9195dcc..b90192f342 100644 --- a/apache-thrift/README.md +++ b/apache-thrift/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [Working with Apache Thrift](http://www.baeldung.com/apache-thrift) +- [Working with Apache Thrift](https://www.baeldung.com/apache-thrift) diff --git a/apache-tika/README.md b/apache-tika/README.md index b92a7bebf1..6f5fd054ca 100644 --- a/apache-tika/README.md +++ b/apache-tika/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [Content Analysis with Apache Tika](http://www.baeldung.com/apache-tika) +- [Content Analysis with Apache Tika](https://www.baeldung.com/apache-tika) diff --git a/apache-velocity/README.md b/apache-velocity/README.md index 53c67f847e..0d659a0381 100644 --- a/apache-velocity/README.md +++ b/apache-velocity/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [Introduction to Apache Velocity](http://www.baeldung.com/apache-velocity) +- [Introduction to Apache Velocity](https://www.baeldung.com/apache-velocity) diff --git a/apache-zookeeper/README.md b/apache-zookeeper/README.md index 6bddcfd5a8..d3ef944b0e 100644 --- a/apache-zookeeper/README.md +++ b/apache-zookeeper/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [Getting Started with Java and Zookeeper](http://www.baeldung.com/java-zookeeper) +- [Getting Started with Java and Zookeeper](https://www.baeldung.com/java-zookeeper) diff --git a/asciidoctor/README.md b/asciidoctor/README.md index 2124907e87..e8bf55792b 100644 --- a/asciidoctor/README.md +++ b/asciidoctor/README.md @@ -1,4 +1,4 @@ ### Relevant articles -- [Generating a Book with Asciidoctor](http://www.baeldung.com/asciidoctor-book) -- [Introduction to Asciidoctor in Java](http://www.baeldung.com/asciidoctor) +- [Generating a Book with Asciidoctor](https://www.baeldung.com/asciidoctor-book) +- [Introduction to Asciidoctor in Java](https://www.baeldung.com/asciidoctor) diff --git a/asm/README.md b/asm/README.md index 50d9c34324..d12ee1ce13 100644 --- a/asm/README.md +++ b/asm/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [A Guide to Java Bytecode Manipulation with ASM](http://www.baeldung.com/java-asm) +- [A Guide to Java Bytecode Manipulation with ASM](https://www.baeldung.com/java-asm) diff --git a/atomix/README.md b/atomix/README.md index fb22eec8dc..c544458974 100644 --- a/atomix/README.md +++ b/atomix/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [Introduction to Atomix](http://www.baeldung.com/atomix) +- [Introduction to Atomix](https://www.baeldung.com/atomix) diff --git a/autovalue/README.md b/autovalue/README.md index f33ff6899f..7defca1161 100644 --- a/autovalue/README.md +++ b/autovalue/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: -- [Introduction to AutoValue](http://www.baeldung.com/introduction-to-autovalue) -- [Introduction to AutoFactory](http://www.baeldung.com/autofactory) +- [Introduction to AutoValue](https://www.baeldung.com/introduction-to-autovalue) +- [Introduction to AutoFactory](https://www.baeldung.com/autofactory) - [Google AutoService](https://www.baeldung.com/google-autoservice) diff --git a/aws-lambda/README.md b/aws-lambda/README.md index 921b699bdd..a8f9f3e98a 100644 --- a/aws-lambda/README.md +++ b/aws-lambda/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Using AWS Lambda with API Gateway](http://www.baeldung.com/aws-lambda-api-gateway) -- [Introduction to AWS Serverless Application Model](http://www.baeldung.com/aws-serverless) +- [Using AWS Lambda with API Gateway](https://www.baeldung.com/aws-lambda-api-gateway) +- [Introduction to AWS Serverless Application Model](https://www.baeldung.com/aws-serverless) diff --git a/aws/README.md b/aws/README.md index d14ea8a75e..b97db02723 100644 --- a/aws/README.md +++ b/aws/README.md @@ -1,11 +1,11 @@ ### Relevant articles -- [AWS Lambda Using DynamoDB With Java](http://www.baeldung.com/aws-lambda-dynamodb-java) -- [AWS S3 with Java](http://www.baeldung.com/aws-s3-java) -- [AWS Lambda With Java](http://www.baeldung.com/java-aws-lambda) -- [Managing EC2 Instances in Java](http://www.baeldung.com/ec2-java) -- [Multipart Uploads in Amazon S3 with Java](http://www.baeldung.com/aws-s3-multipart-upload) -- [Integration Testing with a Local DynamoDB Instance](http://www.baeldung.com/dynamodb-local-integration-tests) -- [Using the JetS3t Java Client With Amazon S3](http://www.baeldung.com/jets3t-amazon-s3) -- [Managing Amazon SQS Queues in Java](http://www.baeldung.com/aws-queues-java) +- [AWS Lambda Using DynamoDB With Java](https://www.baeldung.com/aws-lambda-dynamodb-java) +- [AWS S3 with Java](https://www.baeldung.com/aws-s3-java) +- [AWS Lambda With Java](https://www.baeldung.com/java-aws-lambda) +- [Managing EC2 Instances in Java](https://www.baeldung.com/ec2-java) +- [Multipart Uploads in Amazon S3 with Java](https://www.baeldung.com/aws-s3-multipart-upload) +- [Integration Testing with a Local DynamoDB Instance](https://www.baeldung.com/dynamodb-local-integration-tests) +- [Using the JetS3t Java Client With Amazon S3](https://www.baeldung.com/jets3t-amazon-s3) +- [Managing Amazon SQS Queues in Java](https://www.baeldung.com/aws-queues-java) - [Guide to AWS Aurora RDS with Java](https://www.baeldung.com/aws-aurora-rds-java) diff --git a/axon/README.md b/axon/README.md index f1ae5d00d8..8938be7ec2 100644 --- a/axon/README.md +++ b/axon/README.md @@ -1,3 +1,3 @@ ### Relevant articles -- [A Guide to the Axon Framework](http://www.baeldung.com/axon-cqrs-event-sourcing) +- [A Guide to the Axon Framework](https://www.baeldung.com/axon-cqrs-event-sourcing) diff --git a/azure/README.md b/azure/README.md index ae8c443660..3c70622b85 100644 --- a/azure/README.md +++ b/azure/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: -- [Deploy a Spring Boot App to Azure](http://www.baeldung.com/spring-boot-azure) +- [Deploy a Spring Boot App to Azure](https://www.baeldung.com/spring-boot-azure) diff --git a/blade/README.md b/blade/README.md index 1f2a00ed3f..202494330f 100644 --- a/blade/README.md +++ b/blade/README.md @@ -1,5 +1,5 @@ ### Relevant Articles: -- [Blade – A Complete Guidebook](http://www.baeldung.com/blade) +- [Blade – A Complete Guidebook](https://www.baeldung.com/blade) Run Integration Tests with `mvn integration-test` diff --git a/bootique/README.md b/bootique/README.md index 2ef898fcf7..beb61c2a78 100644 --- a/bootique/README.md +++ b/bootique/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Introduction to Bootique](http://www.baeldung.com/bootique) +- [Introduction to Bootique](https://www.baeldung.com/bootique) diff --git a/cdi/README.md b/cdi/README.md index bfb635be9e..69ce285d7b 100644 --- a/cdi/README.md +++ b/cdi/README.md @@ -1,5 +1,5 @@ ### Relevant Articles: -- [CDI Interceptor vs Spring AspectJ](http://www.baeldung.com/cdi-interceptor-vs-spring-aspectj) -- [An Introduction to CDI (Contexts and Dependency Injection) in Java](http://www.baeldung.com/java-ee-cdi) +- [CDI Interceptor vs Spring AspectJ](https://www.baeldung.com/cdi-interceptor-vs-spring-aspectj) +- [An Introduction to CDI (Contexts and Dependency Injection) in Java](https://www.baeldung.com/java-ee-cdi) - [Introduction to the Event Notification Model in CDI 2.0](https://www.baeldung.com/cdi-event-notification) diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java b/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java index 4896408502..dc0bdeb951 100644 --- a/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java +++ b/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java @@ -1,15 +1,16 @@ -package com.baeldung.cdi.cdi2observers.application; - -import com.baeldung.cdi.cdi2observers.events.ExampleEvent; -import javax.enterprise.inject.se.SeContainer; -import javax.enterprise.inject.se.SeContainerInitializer; - -public class BootstrappingApplication { - - public static void main(String... args) { - SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance(); - try (SeContainer container = containerInitializer.initialize()) { - container.getBeanManager().fireEvent(new ExampleEvent("Welcome to Baeldung!")); - } - } -} +package com.baeldung.cdi2observers.application; + +import com.baeldung.cdi2observers.events.ExampleEvent; + +import javax.enterprise.inject.se.SeContainer; +import javax.enterprise.inject.se.SeContainerInitializer; + +public class BootstrappingApplication { + + public static void main(String... args) { + SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance(); + try (SeContainer container = containerInitializer.initialize()) { + container.getBeanManager().fireEvent(new ExampleEvent("Welcome to Baeldung!")); + } + } +} diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java index a2329d2ef1..9adfad4d39 100644 --- a/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java +++ b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java @@ -1,14 +1,14 @@ -package com.baeldung.cdi.cdi2observers.events; - -public class ExampleEvent { - - private final String eventMessage; - - public ExampleEvent(String eventMessage) { - this.eventMessage = eventMessage; - } - - public String getEventMessage() { - return eventMessage; - } -} +package com.baeldung.cdi2observers.events; + +public class ExampleEvent { + + private final String eventMessage; + + public ExampleEvent(String eventMessage) { + this.eventMessage = eventMessage; + } + + public String getEventMessage() { + return eventMessage; + } +} diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java index f37030778a..5a0aa0b5e3 100644 --- a/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java +++ b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java @@ -1,14 +1,14 @@ -package com.baeldung.cdi.cdi2observers.events; - -import javax.enterprise.event.Event; -import javax.inject.Inject; - -public class ExampleEventSource { - - @Inject - Event exampleEvent; - - public void fireEvent() { - exampleEvent.fireAsync(new ExampleEvent("Welcome to Baeldung!")); - } -} +package com.baeldung.cdi2observers.events; + +import javax.enterprise.event.Event; +import javax.inject.Inject; + +public class ExampleEventSource { + + @Inject + Event exampleEvent; + + public void fireEvent() { + exampleEvent.fireAsync(new ExampleEvent("Welcome to Baeldung!")); + } +} diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java b/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java index 34520c2b3d..3af48af13f 100644 --- a/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java +++ b/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java @@ -1,12 +1,13 @@ -package com.baeldung.cdi.cdi2observers.observers; - -import com.baeldung.cdi.cdi2observers.events.ExampleEvent; -import javax.annotation.Priority; -import javax.enterprise.event.Observes; - -public class AnotherExampleEventObserver { - - public String onEvent(@Observes @Priority(2) ExampleEvent event) { - return event.getEventMessage(); - } -} +package com.baeldung.cdi2observers.observers; + +import com.baeldung.cdi2observers.events.ExampleEvent; + +import javax.annotation.Priority; +import javax.enterprise.event.Observes; + +public class AnotherExampleEventObserver { + + public String onEvent(@Observes @Priority(2) ExampleEvent event) { + return event.getEventMessage(); + } +} diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java b/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java index b3522b2ad0..33fdc43bbb 100644 --- a/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java +++ b/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java @@ -1,13 +1,13 @@ -package com.baeldung.cdi.cdi2observers.observers; - -import com.baeldung.cdi.cdi2observers.events.ExampleEvent; -import com.baeldung.cdi.cdi2observers.services.TextService; -import javax.annotation.Priority; -import javax.enterprise.event.Observes; - -public class ExampleEventObserver { - - public String onEvent(@Observes @Priority(1) ExampleEvent event, TextService textService) { - return textService.parseText(event.getEventMessage()); - } -} +package com.baeldung.cdi2observers.observers; + +import com.baeldung.cdi2observers.events.ExampleEvent; +import com.baeldung.cdi2observers.services.TextService; +import javax.annotation.Priority; +import javax.enterprise.event.Observes; + +public class ExampleEventObserver { + + public String onEvent(@Observes @Priority(1) ExampleEvent event, TextService textService) { + return textService.parseText(event.getEventMessage()); + } +} diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java b/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java index 47788a0657..eabe031223 100644 --- a/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java +++ b/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java @@ -1,8 +1,8 @@ -package com.baeldung.cdi.cdi2observers.services; - -public class TextService { - - public String parseText(String text) { - return text.toUpperCase(); - } -} +package com.baeldung.cdi2observers.services; + +public class TextService { + + public String parseText(String text) { + return text.toUpperCase(); + } +} diff --git a/cdi/src/main/resources/META-INF/beans.xml b/cdi/src/main/resources/META-INF/beans.xml index d41b35e7d9..144e9e567f 100644 --- a/cdi/src/main/resources/META-INF/beans.xml +++ b/cdi/src/main/resources/META-INF/beans.xml @@ -1,7 +1,8 @@ - + + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" + bean-discovery-mode="all"> com.baeldung.interceptor.AuditedInterceptor diff --git a/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java b/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java index deecf13f9a..1b976144aa 100644 --- a/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java +++ b/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java @@ -1,14 +1,15 @@ -package com.baeldung.cdi.cdi2observers.tests; - -import com.baeldung.cdi.cdi2observers.services.TextService; -import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; - -public class TextServiceUnitTest { - - @Test - public void givenTextServiceInstance_whenCalledparseText_thenCorrect() { - TextService textService = new TextService(); - assertThat(textService.parseText("Baeldung")).isEqualTo("BAELDUNG"); - } -} +package com.baeldung.test.cdi2observers.tests; + +import com.baeldung.cdi2observers.services.TextService; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TextServiceUnitTest { + + @Test + public void givenTextServiceInstance_whenCalledparseText_thenCorrect() { + TextService textService = new TextService(); + assertThat(textService.parseText("Baeldung")).isEqualTo("BAELDUNG"); + } +} diff --git a/cdi/src/test/java/com/baeldung/test/dependencyinjection/TimeLoggerFactoryUnitTest.java b/cdi/src/test/java/com/baeldung/test/dependencyinjection/TimeLoggerFactoryUnitTest.java index caf2ed32b5..b22f189373 100644 --- a/cdi/src/test/java/com/baeldung/test/dependencyinjection/TimeLoggerFactoryUnitTest.java +++ b/cdi/src/test/java/com/baeldung/test/dependencyinjection/TimeLoggerFactoryUnitTest.java @@ -6,7 +6,6 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; public class TimeLoggerFactoryUnitTest { - @Test public void givenTimeLoggerFactory_whenCalledgetTimeLogger_thenOneAssertion() { TimeLoggerFactory timeLoggerFactory = new TimeLoggerFactory(); diff --git a/checker-plugin/README.md b/checker-plugin/README.md index f4534b09e8..5c73b86f91 100644 --- a/checker-plugin/README.md +++ b/checker-plugin/README.md @@ -1,3 +1,3 @@ ### Relevant articles -- [The Checker Framework – Pluggable Type Systems for Java](http://www.baeldung.com/checker-framework) +- [The Checker Framework – Pluggable Type Systems for Java](https://www.baeldung.com/checker-framework) diff --git a/core-groovy-2/README.md b/core-groovy-2/README.md index 1211dae76d..1dbfbd07a5 100644 --- a/core-groovy-2/README.md +++ b/core-groovy-2/README.md @@ -2,10 +2,10 @@ ## Relevant articles: -- [String Matching in Groovy](http://www.baeldung.com/) - [Template Engines in Groovy](https://www.baeldung.com/groovy-template-engines) - [Groovy def Keyword](https://www.baeldung.com/groovy-def-keyword) - [Pattern Matching in Strings in Groovy](https://www.baeldung.com/groovy-pattern-matching) - [Working with XML in Groovy](https://www.baeldung.com/groovy-xml) - [Integrating Groovy into Java Applications](https://www.baeldung.com/groovy-java-applications) - [Concatenate Strings with Groovy](https://www.baeldung.com/groovy-concatenate-strings) +- [Metaprogramming in Groovy](https://www.baeldung.com/groovy-metaprogramming) diff --git a/core-groovy/README.md b/core-groovy/README.md index 321c37be8d..2e62884b1f 100644 --- a/core-groovy/README.md +++ b/core-groovy/README.md @@ -2,8 +2,8 @@ ## Relevant articles: -- [JDBC with Groovy](http://www.baeldung.com/jdbc-groovy) -- [Working with JSON in Groovy](http://www.baeldung.com/groovy-json) +- [JDBC with Groovy](https://www.baeldung.com/jdbc-groovy) +- [Working with JSON in Groovy](https://www.baeldung.com/groovy-json) - [Reading a File in Groovy](https://www.baeldung.com/groovy-file-read) - [Types of Strings in Groovy](https://www.baeldung.com/groovy-strings) - [A Quick Guide to Iterating a Map in Groovy](https://www.baeldung.com/groovy-map-iterating) @@ -12,4 +12,4 @@ - [Finding Elements in Collections in Groovy](https://www.baeldung.com/groovy-collections-find-elements) - [Lists in Groovy](https://www.baeldung.com/groovy-lists) - [Converting a String to a Date in Groovy](https://www.baeldung.com/groovy-string-to-date) -- [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io) \ No newline at end of file +- [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io) diff --git a/core-java-modules/core-java-8-2/README.md b/core-java-modules/core-java-8-2/README.md index d11510b2aa..4952cf4eb7 100644 --- a/core-java-modules/core-java-8-2/README.md +++ b/core-java-modules/core-java-8-2/README.md @@ -5,6 +5,6 @@ ### Relevant Articles: - [Anonymous Classes in Java](http://www.baeldung.com/) - [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution) -- [Run JAR Application With Command Line Arguments](https://www.baeldung.com/java-run-jar-with-arguments) +- [Run a Java Application from the Command Line](https://www.baeldung.com/java-run-jar-with-arguments) - [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit) - [Guide to Java BiFunction Interface](https://www.baeldung.com/java-bifunction-interface) diff --git a/core-java-modules/core-java-arrays-2/README.MD b/core-java-modules/core-java-arrays-2/README.MD index 280fb33dc3..952770a2da 100644 --- a/core-java-modules/core-java-arrays-2/README.MD +++ b/core-java-modules/core-java-arrays-2/README.MD @@ -7,3 +7,4 @@ - [Array Operations in Java](https://www.baeldung.com/java-common-array-operations) - [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection) - [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element) +- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element) diff --git a/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java b/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/removefirst/RemoveFirstElementUnitTest.java similarity index 97% rename from core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java rename to core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/removefirst/RemoveFirstElementUnitTest.java index f2b1bd9d88..83a97973f3 100644 --- a/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/list/removefirst/RemoveFirstElementUnitTest.java +++ b/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/removefirst/RemoveFirstElementUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.list.removefirst; +package com.baeldung.array.removefirst; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; diff --git a/core-java-modules/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md index 088e927910..36d2d4c4ad 100644 --- a/core-java-modules/core-java-arrays/README.md +++ b/core-java-modules/core-java-arrays/README.md @@ -10,6 +10,7 @@ - [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays) - [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average) - [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide) -- [How to Invert an Array in Java](https://www.baeldung.com/java-invert-array) +- [Read and Write User Input in Java](https://www.baeldung.com/java-console-input-output) +- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array) - [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays) - [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array) diff --git a/core-java-modules/core-java-collections-2/README.md b/core-java-modules/core-java-collections-2/README.md new file mode 100644 index 0000000000..13ca191edb --- /dev/null +++ b/core-java-modules/core-java-collections-2/README.md @@ -0,0 +1,15 @@ +========= + +## Core Java Collections Cookbooks and Examples + +### Relevant Articles: +- [Removing Elements from Java Collections](https://www.baeldung.com/java-collection-remove-elements) +- [How to Filter a Collection in Java](https://www.baeldung.com/java-collection-filtering) +- [Join and Split Arrays and Collections in Java](https://www.baeldung.com/java-join-and-split) +- [Java – Combine Multiple Collections](https://www.baeldung.com/java-combine-multiple-collections) +- [Combining Different Types of Collections in Java](https://www.baeldung.com/java-combine-collections) +- [Shuffling Collections In Java](https://www.baeldung.com/java-shuffle-collection) +- [Sorting in Java](https://www.baeldung.com/java-sorting) +- [Getting the Size of an Iterable in Java](https://www.baeldung.com/java-iterable-size) +- [Java Null-Safe Streams from Collections](https://www.baeldung.com/java-null-safe-streams-from-collections) + diff --git a/core-java-modules/core-java-collections-2/pom.xml b/core-java-modules/core-java-collections-2/pom.xml new file mode 100644 index 0000000000..0ac53ec180 --- /dev/null +++ b/core-java-modules/core-java-collections-2/pom.xml @@ -0,0 +1,58 @@ + + 4.0.0 + core-java-collections-2 + 0.0.1-SNAPSHOT + core-java-collections-2 + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.eclipse.collections + eclipse-collections + ${eclipse.collections.version} + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + org.apache.commons + commons-exec + ${commons-exec.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + + + 7.1.0 + 4.1 + 3.11.1 + 1.2.0 + 1.3 + + diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningArrays.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningArrays.java similarity index 95% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningArrays.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningArrays.java index 2ad48033c0..5f63123f6a 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningArrays.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningArrays.java @@ -1,4 +1,4 @@ -package com.baeldung.combiningcollections; +package com.baeldung.collections.combiningcollections; import java.util.Arrays; import java.util.stream.Stream; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningLists.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningLists.java similarity index 96% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningLists.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningLists.java index 3fdf672758..a45e9cdfe8 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningLists.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningLists.java @@ -1,4 +1,4 @@ -package com.baeldung.combiningcollections; +package com.baeldung.collections.combiningcollections; import java.util.ArrayList; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningMaps.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningMaps.java similarity index 96% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningMaps.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningMaps.java index d8bbd01ed3..d4d21d0dad 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningMaps.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningMaps.java @@ -1,4 +1,4 @@ -package com.baeldung.combiningcollections; +package com.baeldung.collections.combiningcollections; import java.util.Collection; import java.util.HashMap; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningSets.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningSets.java similarity index 96% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningSets.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningSets.java index 5f531c1d43..27a5681eee 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/combiningcollections/CombiningSets.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/combiningcollections/CombiningSets.java @@ -1,4 +1,4 @@ -package com.baeldung.combiningcollections; +package com.baeldung.collections.combiningcollections; import java.util.Collection; import java.util.HashSet; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/CollectionUtilsCollectionFilter.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/CollectionUtilsCollectionFilter.java similarity index 91% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/CollectionUtilsCollectionFilter.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/CollectionUtilsCollectionFilter.java index 58f9f6af54..de5158e147 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/CollectionUtilsCollectionFilter.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/CollectionUtilsCollectionFilter.java @@ -1,4 +1,4 @@ -package com.baeldung.java.filtering; +package com.baeldung.collections.filtering; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/EclipseCollectionsCollectionFilter.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/EclipseCollectionsCollectionFilter.java similarity index 96% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/EclipseCollectionsCollectionFilter.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/EclipseCollectionsCollectionFilter.java index 981d6ca241..a7b78b1f9b 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/EclipseCollectionsCollectionFilter.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/EclipseCollectionsCollectionFilter.java @@ -1,4 +1,4 @@ -package com.baeldung.java.filtering; +package com.baeldung.collections.filtering; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/GuavaCollectionFilter.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/GuavaCollectionFilter.java similarity index 91% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/GuavaCollectionFilter.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/GuavaCollectionFilter.java index 88338fd6d4..0a2a782c33 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/GuavaCollectionFilter.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/GuavaCollectionFilter.java @@ -1,4 +1,4 @@ -package com.baeldung.java.filtering; +package com.baeldung.collections.filtering; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/StreamsCollectionFilter.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/StreamsCollectionFilter.java similarity index 95% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/StreamsCollectionFilter.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/StreamsCollectionFilter.java index f074f74199..a9fb8481e5 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/filtering/StreamsCollectionFilter.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/filtering/StreamsCollectionFilter.java @@ -1,4 +1,4 @@ -package com.baeldung.java.filtering; +package com.baeldung.collections.filtering; import java.util.Collection; import java.util.function.Predicate; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/iterable/IterableSize.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/iterablesize/IterableSize.java similarity index 97% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/java/iterable/IterableSize.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/iterablesize/IterableSize.java index 03864f16f2..b96e2bb571 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/iterable/IterableSize.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/iterablesize/IterableSize.java @@ -1,4 +1,4 @@ -package com.baeldung.java.iterable; +package com.baeldung.collections.iterablesize; import java.util.Collection; import java.util.stream.StreamSupport; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java similarity index 92% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java index 2405c26aac..ce5cbb39d6 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNull.java @@ -1,4 +1,4 @@ -package com.baeldung.nullsafecollectionstreams; +package com.baeldung.collections.nullsafecollectionstreams; import java.util.Collection; import java.util.stream.Stream; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java similarity index 92% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java index da767d4563..68d51c2d87 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainer.java @@ -1,4 +1,4 @@ -package com.baeldung.nullsafecollectionstreams; +package com.baeldung.collections.nullsafecollectionstreams; import java.util.Collection; import java.util.Optional; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java similarity index 91% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java index 0c10f1cebc..6c606ebedd 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheck.java @@ -1,4 +1,4 @@ -package com.baeldung.nullsafecollectionstreams; +package com.baeldung.collections.nullsafecollectionstreams; import java.util.Collection; import java.util.stream.Stream; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/CollectionRemoveIf.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/CollectionRemoveIf.java similarity index 91% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/CollectionRemoveIf.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/CollectionRemoveIf.java index 2f5e91596f..4089382376 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/CollectionRemoveIf.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/CollectionRemoveIf.java @@ -1,4 +1,4 @@ -package com.baeldung.removal; +package com.baeldung.collections.removal; import java.util.ArrayList; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/Iterators.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/Iterators.java similarity index 93% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/Iterators.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/Iterators.java index 86b91b3fdc..d551b04eae 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/Iterators.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/Iterators.java @@ -1,4 +1,4 @@ -package com.baeldung.removal; +package com.baeldung.collections.removal; import java.util.ArrayList; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamFilterAndCollector.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/StreamFilterAndCollector.java similarity index 93% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamFilterAndCollector.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/StreamFilterAndCollector.java index bf6db68bae..e0dc75f428 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamFilterAndCollector.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/StreamFilterAndCollector.java @@ -1,4 +1,4 @@ -package com.baeldung.removal; +package com.baeldung.collections.removal; import java.util.ArrayList; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamPartitioningBy.java b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/StreamPartitioningBy.java similarity index 95% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamPartitioningBy.java rename to core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/StreamPartitioningBy.java index c77e996616..c01c334f01 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/removal/StreamPartitioningBy.java +++ b/core-java-modules/core-java-collections-2/src/main/java/com/baeldung/collections/removal/StreamPartitioningBy.java @@ -1,4 +1,4 @@ -package com.baeldung.removal; +package com.baeldung.collections.removal; import java.util.ArrayList; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningArraysUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningArraysUnitTest.java similarity index 96% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningArraysUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningArraysUnitTest.java index 3b80d773ad..312f5582ba 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningArraysUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningArraysUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.combiningcollections; +package com.baeldung.collections.combiningcollections; import static org.junit.Assert.*; import org.junit.Test; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningListsUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningListsUnitTest.java similarity index 96% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningListsUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningListsUnitTest.java index c5851d7daf..5443e56e5f 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningListsUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningListsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.combiningcollections; +package com.baeldung.collections.combiningcollections; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningMapsUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningMapsUnitTest.java similarity index 96% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningMapsUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningMapsUnitTest.java index 3fa9cc7dc4..644f178f80 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningMapsUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningMapsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.combiningcollections; +package com.baeldung.collections.combiningcollections; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningSetsUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningSetsUnitTest.java similarity index 96% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningSetsUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningSetsUnitTest.java index 330827bdc2..c9976eb6de 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/combiningcollections/CombiningSetsUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/combiningcollections/CombiningSetsUnitTest.java @@ -1,5 +1,5 @@ -package com.baeldung.combiningcollections; +package com.baeldung.collections.combiningcollections; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/filtering/CollectionFiltersUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/filtering/CollectionFiltersUnitTest.java similarity index 98% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/java/filtering/CollectionFiltersUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/filtering/CollectionFiltersUnitTest.java index b30805d471..db387818b8 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/filtering/CollectionFiltersUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/filtering/CollectionFiltersUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.java.filtering; +package com.baeldung.collections.filtering; import static org.assertj.core.api.Assertions.assertThat; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/iterable/IterableSizeUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/iterablesize/IterableSizeUnitTest.java similarity index 96% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/java/iterable/IterableSizeUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/iterablesize/IterableSizeUnitTest.java index 4bc413dee0..35702a74b3 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/iterable/IterableSizeUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/iterablesize/IterableSizeUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.java.iterable; +package com.baeldung.collections.iterablesize; import static org.junit.Assert.assertEquals; diff --git a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsJoinAndSplitJUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/joinsplit/CollectionsJoinAndSplitJUnitTest.java similarity index 97% rename from core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsJoinAndSplitJUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/joinsplit/CollectionsJoinAndSplitJUnitTest.java index c288cf499d..1904fd1587 100644 --- a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsJoinAndSplitJUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/joinsplit/CollectionsJoinAndSplitJUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.collections; +package com.baeldung.collections.joinsplit; import java.util.ArrayList; import java.util.Collections; diff --git a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/JoinSplitCollectionsUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/joinsplit/JoinSplitCollectionsUnitTest.java similarity index 99% rename from core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/JoinSplitCollectionsUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/joinsplit/JoinSplitCollectionsUnitTest.java index c594529f41..1fbe210ad4 100644 --- a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/JoinSplitCollectionsUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/joinsplit/JoinSplitCollectionsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.collections; +package com.baeldung.collections.joinsplit; import org.junit.Test; diff --git a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsConcatenateUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/multiplecollections/CombineMultipleCollectionsUnitTest.java similarity index 98% rename from core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsConcatenateUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/multiplecollections/CombineMultipleCollectionsUnitTest.java index d43075c925..ebef8d6875 100644 --- a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsConcatenateUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/multiplecollections/CombineMultipleCollectionsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.collections; +package com.baeldung.collections.multiplecollections; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -14,7 +14,7 @@ import java.util.stream.Stream; import static java.util.Arrays.asList; -public class CollectionsConcatenateUnitTest { +public class CombineMultipleCollectionsUnitTest { @Test public void givenUsingJava8_whenConcatenatingUsingConcat_thenCorrect() { diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java similarity index 95% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java index 875045946d..42cda7926c 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingCommonsEmptyIfNullUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.nullsafecollectionstreams; +package com.baeldung.collections.nullsafecollectionstreams; import java.util.Arrays; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java similarity index 95% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java index 402f1a6a19..666d5e7d04 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.nullsafecollectionstreams; +package com.baeldung.collections.nullsafecollectionstreams; import java.util.Arrays; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java similarity index 95% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java index bb6152371d..2e8eeb35ad 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/nullsafecollectionstreams/NullSafeCollectionStreamsUsingNullDereferenceCheckUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.nullsafecollectionstreams; +package com.baeldung.collections.nullsafecollectionstreams; import java.util.Arrays; import java.util.Collection; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/removal/RemovalUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/removal/RemovalUnitTest.java similarity index 98% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/removal/RemovalUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/removal/RemovalUnitTest.java index 1b379f32de..998dbe6cca 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/removal/RemovalUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/removal/RemovalUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.removal; +package com.baeldung.collections.removal; import org.junit.Before; import org.junit.Test; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/shufflingcollections/ShufflingCollectionsUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/shufflingcollections/ShufflingCollectionsUnitTest.java similarity index 97% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/shufflingcollections/ShufflingCollectionsUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/shufflingcollections/ShufflingCollectionsUnitTest.java index d013907c9a..041e67ba7f 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/shufflingcollections/ShufflingCollectionsUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/shufflingcollections/ShufflingCollectionsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.shufflingcollections; +package com.baeldung.collections.shufflingcollections; import org.junit.Test; diff --git a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/Employee.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/sorting/Employee.java similarity index 96% rename from core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/Employee.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/sorting/Employee.java index 99af49c8d3..e838dbea18 100644 --- a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/Employee.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/sorting/Employee.java @@ -1,4 +1,4 @@ -package org.baeldung.java.sorting; +package com.baeldung.collections.sorting; public class Employee implements Comparable { diff --git a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/JavaSortingUnitTest.java b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/sorting/JavaSortingUnitTest.java similarity index 99% rename from core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/JavaSortingUnitTest.java rename to core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/sorting/JavaSortingUnitTest.java index ca9c9b4b5d..2505adcea7 100644 --- a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/sorting/JavaSortingUnitTest.java +++ b/core-java-modules/core-java-collections-2/src/test/java/com/baeldung/collections/sorting/JavaSortingUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.sorting; +package com.baeldung.collections.sorting; import com.google.common.primitives.Ints; import org.apache.commons.lang3.ArrayUtils; diff --git a/core-java-modules/core-java-collections-3/README.md b/core-java-modules/core-java-collections-3/README.md new file mode 100644 index 0000000000..9218384640 --- /dev/null +++ b/core-java-modules/core-java-collections-3/README.md @@ -0,0 +1,11 @@ +========= + +## Core Java Collections Cookbooks and Examples + +### Relevant Articles: +- [Time Comparison of Arrays.sort(Object[]) and Arrays.sort(int[])](https://www.baeldung.com/arrays-sortobject-vs-sortint) +- [Java ArrayList vs Vector](https://www.baeldung.com/java-arraylist-vs-vector) +- [Differences Between HashMap and Hashtable](https://www.baeldung.com/hashmap-hashtable-differences) +- [Differences Between Collection.clear() and Collection.removeAll()](https://www.baeldung.com/java-collection-clear-vs-removeall) +- [Performance of contains() in a HashSet vs ArrayList](https://www.baeldung.com/java-hashset-arraylist-contains-performance) +- [Fail-Safe Iterator vs Fail-Fast Iterator](https://www.baeldung.com/java-fail-safe-vs-fail-fast-iterator) diff --git a/core-java-modules/core-java-collections-3/pom.xml b/core-java-modules/core-java-collections-3/pom.xml new file mode 100644 index 0000000000..84c7865e68 --- /dev/null +++ b/core-java-modules/core-java-collections-3/pom.xml @@ -0,0 +1,34 @@ + + 4.0.0 + core-java-collections-3 + 0.1.0-SNAPSHOT + core-java-collections-3 + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.openjdk.jmh + jmh-core + ${openjdk.jmh.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + 1.19 + 3.11.1 + + diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/arraylistvsvector/ArrayListBenchmark.java similarity index 98% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java rename to core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/arraylistvsvector/ArrayListBenchmark.java index 331ae8d908..7fcadf019c 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/arraylistvsvector/ArrayListBenchmark.java @@ -1,4 +1,4 @@ -package com.baeldung.performance; +package com.baeldung.collections.arraylistvsvector; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/arraylistvsvector/Employee.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/arraylistvsvector/Employee.java new file mode 100644 index 0000000000..02f25a7558 --- /dev/null +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/arraylistvsvector/Employee.java @@ -0,0 +1,55 @@ +package com.baeldung.collections.arraylistvsvector; + +public class Employee { + + private Long id; + private String name; + + public Employee(Long id, String name) { + this.name = name; + this.id = id; + } + + 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; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Employee employee = (Employee) o; + + if (!id.equals(employee.id)) return false; + return name.equals(employee.name); + + } + + @Override + public int hashCode() { + int result = id.hashCode(); + result = 31 * result + name.hashCode(); + return result; + } + + @Override + public String toString() { + return "Employee{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/arraylistvsvector/VectorExample.java similarity index 92% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java rename to core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/arraylistvsvector/VectorExample.java index 7debc07911..e82e47cdbb 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/arraylistvsvector/VectorExample.java @@ -1,4 +1,4 @@ -package com.baeldung.java.list; +package com.baeldung.collections.arraylistvsvector; import java.util.Enumeration; import java.util.Iterator; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/CollectionsBenchmark.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/containsperformance/CollectionsBenchmark.java similarity index 96% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/CollectionsBenchmark.java rename to core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/containsperformance/CollectionsBenchmark.java index 921e1608ea..76edd10e92 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/CollectionsBenchmark.java +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/containsperformance/CollectionsBenchmark.java @@ -1,4 +1,4 @@ -package com.baeldung.performance; +package com.baeldung.collections.containsperformance; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; diff --git a/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/containsperformance/Employee.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/containsperformance/Employee.java new file mode 100644 index 0000000000..6c60f8772c --- /dev/null +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/containsperformance/Employee.java @@ -0,0 +1,55 @@ +package com.baeldung.collections.containsperformance; + +public class Employee { + + private Long id; + private String name; + + public Employee(Long id, String name) { + this.name = name; + this.id = id; + } + + 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; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Employee employee = (Employee) o; + + if (!id.equals(employee.id)) return false; + return name.equals(employee.name); + + } + + @Override + public int hashCode() { + int result = id.hashCode(); + result = 31 * result + name.hashCode(); + return result; + } + + @Override + public String toString() { + return "Employee{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/iterators/Iterators.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/iterators/Iterators.java similarity index 97% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/iterators/Iterators.java rename to core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/iterators/Iterators.java index 5e7cfdb54f..23e6bbda77 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/iterators/Iterators.java +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/iterators/Iterators.java @@ -1,4 +1,4 @@ -package com.baeldung.iterators; +package com.baeldung.collections.iterators; import java.util.ArrayList; import java.util.Iterator; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArraySortBenchmark.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/sortingcomparison/ArraySortBenchmark.java similarity index 97% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArraySortBenchmark.java rename to core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/sortingcomparison/ArraySortBenchmark.java index b93f8e9cc2..1cd56aa29d 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/performance/ArraySortBenchmark.java +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/sortingcomparison/ArraySortBenchmark.java @@ -1,4 +1,4 @@ -package com.baeldung.performance; +package com.baeldung.collections.sortingcomparison; import java.util.Arrays; import java.util.concurrent.TimeUnit; diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/sort/CollectionsSortCompare.java b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/sortingcomparison/CollectionsSortCompare.java similarity index 94% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/java/sort/CollectionsSortCompare.java rename to core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/sortingcomparison/CollectionsSortCompare.java index 1eff522877..abe7a12a00 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/java/sort/CollectionsSortCompare.java +++ b/core-java-modules/core-java-collections-3/src/main/java/com/baeldung/collections/sortingcomparison/CollectionsSortCompare.java @@ -1,4 +1,4 @@ -package com.baeldung.java.sort; +package com.baeldung.collections.sortingcomparison; import java.util.ArrayList; import java.util.Arrays; diff --git a/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/clearvsremoveall/ClearVsRemoveAllUnitTest.java similarity index 95% rename from core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java rename to core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/clearvsremoveall/ClearVsRemoveAllUnitTest.java index 8b0a7ef0db..9cd9c6aa50 100644 --- a/core-java-modules/core-java-collections-list/src/test/java/com/baeldung/collection/ClearVsRemoveAllUnitTest.java +++ b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/clearvsremoveall/ClearVsRemoveAllUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.collection; +package com.baeldung.collections.clearvsremoveall; import org.junit.jupiter.api.Test; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java similarity index 98% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java rename to core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java index 5218332d60..b00a7fd953 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java +++ b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/hashmapvshashtable/HashmapVsHashtableDifferenceUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.hashmapvshashtable; +package com.baeldung.collections.hashmapvshashtable; import static org.junit.Assert.assertEquals; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/iterators/IteratorsUnitTest.java b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/iterators/IteratorsUnitTest.java similarity index 77% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/iterators/IteratorsUnitTest.java rename to core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/iterators/IteratorsUnitTest.java index 36e1f4a83c..95cf590857 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/iterators/IteratorsUnitTest.java +++ b/core-java-modules/core-java-collections-3/src/test/java/com/baeldung/collections/iterators/IteratorsUnitTest.java @@ -1,8 +1,8 @@ -package com.baeldung.iterators; +package com.baeldung.collections.iterators; -import static com.baeldung.iterators.Iterators.failFast1; -import static com.baeldung.iterators.Iterators.failFast2; -import static com.baeldung.iterators.Iterators.failSafe1; +import static com.baeldung.collections.iterators.Iterators.failFast1; +import static com.baeldung.collections.iterators.Iterators.failFast2; +import static com.baeldung.collections.iterators.Iterators.failSafe1; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; diff --git a/core-java-modules/core-java-collections-list/README.md b/core-java-modules/core-java-collections-list/README.md index e83fcce5ff..367f62780d 100644 --- a/core-java-modules/core-java-collections-list/README.md +++ b/core-java-modules/core-java-collections-list/README.md @@ -11,4 +11,4 @@ - [Remove the First Element from a List](http://www.baeldung.com/java-remove-first-element-from-list) - [How to Find an Element in a List with Java](http://www.baeldung.com/find-list-element-java) - [Finding Max/Min of a List or Collection](http://www.baeldung.com/java-collection-min-max) -- [Remove All Occurrences of a Specific Value from a List](https://www.baeldung.com/java-remove-value-from-list) \ No newline at end of file +- [Remove All Occurrences of a Specific Value from a List](https://www.baeldung.com/java-remove-value-from-list) diff --git a/core-java-modules/core-java-collections/README.md b/core-java-modules/core-java-collections/README.md index b34293769d..7be7d02b3f 100644 --- a/core-java-modules/core-java-collections/README.md +++ b/core-java-modules/core-java-collections/README.md @@ -3,29 +3,13 @@ ## Core Java Collections Cookbooks and Examples ### Relevant Articles: -- [Java – Combine Multiple Collections](http://www.baeldung.com/java-combine-multiple-collections) -- [Collect a Java Stream to an Immutable Collection](http://www.baeldung.com/java-stream-immutable-collection) -- [Introduction to the Java ArrayDeque](http://www.baeldung.com/java-array-deque) -- [Getting the Size of an Iterable in Java](http://www.baeldung.com/java-iterable-size) -- [How to Filter a Collection in Java](http://www.baeldung.com/java-collection-filtering) -- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element) -- [Fail-Safe Iterator vs Fail-Fast Iterator](http://www.baeldung.com/java-fail-safe-vs-fail-fast-iterator) -- [Shuffling Collections In Java](http://www.baeldung.com/java-shuffle-collection) -- [An Introduction to Java.util.Hashtable Class](http://www.baeldung.com/java-hash-table) -- [Java Null-Safe Streams from Collections](https://www.baeldung.com/java-null-safe-streams-from-collections) +- [Collect a Java Stream to an Immutable Collection](https://www.baeldung.com/java-stream-immutable-collection) +- [Introduction to the Java ArrayDeque](https://www.baeldung.com/java-array-deque) +- [An Introduction to Java.util.Hashtable Class](https://www.baeldung.com/java-hash-table) - [Thread Safe LIFO Data Structure Implementations](https://www.baeldung.com/java-lifo-thread-safe) -- [Differences Between Collection.clear() and Collection.removeAll()](https://www.baeldung.com/java-collection-clear-vs-removeall) -- [Performance of contains() in a HashSet vs ArrayList](https://www.baeldung.com/java-hashset-arraylist-contains-performance) - [Time Complexity of Java Collections](https://www.baeldung.com/java-collections-complexity) -- [Operating on and Removing an Item from Stream](https://www.baeldung.com/java-use-remove-item-stream) -- [An Introduction to Synchronized Java Collections](https://www.baeldung.com/java-synchronized-collections) -- [Removing Elements from Java Collections](https://www.baeldung.com/java-collection-remove-elements) -- [Combining Different Types of Collections in Java](https://www.baeldung.com/java-combine-collections) -- [Sorting in Java](http://www.baeldung.com/java-sorting) -- [Join and Split Arrays and Collections in Java](http://www.baeldung.com/java-join-and-split) - [A Guide to EnumMap](https://www.baeldung.com/java-enum-map) -- [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator) -- [Differences Between HashMap and Hashtable](https://www.baeldung.com/hashmap-hashtable-differences) -- [Java ArrayList vs Vector](https://www.baeldung.com/java-arraylist-vs-vector) +- [A Guide to Iterator in Java](https://www.baeldung.com/java-iterator) - [Defining a Char Stack in Java](https://www.baeldung.com/java-char-stack) -- [Time Comparison of Arrays.sort(Object[]) and Arrays.sort(int[])](https://www.baeldung.com/arrays-sortobject-vs-sortint) +- [Guide to the Java Queue Interface](https://www.baeldung.com/java-queue) +- [An Introduction to Synchronized Java Collections](https://www.baeldung.com/java-synchronized-collections) diff --git a/core-java-modules/core-java-collections/pom.xml b/core-java-modules/core-java-collections/pom.xml index e5b89c3d16..7fd702845b 100644 --- a/core-java-modules/core-java-collections/pom.xml +++ b/core-java-modules/core-java-collections/pom.xml @@ -14,33 +14,12 @@ - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.eclipse.collections - eclipse-collections - ${eclipse.collections.version} - org.assertj assertj-core ${assertj.version} test - - org.junit.platform - junit-platform-runner - ${junit.platform.version} - test - org.openjdk.jmh jmh-core @@ -51,11 +30,6 @@ jmh-generator-annprocess ${openjdk.jmh.version} - - org.apache.commons - commons-exec - ${commons-exec.version} - org.projectlombok lombok @@ -66,13 +40,6 @@ 1.19 - 1.2.0 - 3.8.1 - 4.1 - 4.01 - 1.7.0 3.11.1 - 7.1.0 - 1.3 diff --git a/core-java-modules/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java b/core-java-modules/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/Application.java similarity index 90% rename from core-java-modules/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java rename to core-java-modules/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/Application.java index 093308a34a..f974a24839 100644 --- a/core-java-modules/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java +++ b/core-java-modules/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/Application.java @@ -1,4 +1,4 @@ -package com.baeldung.synchronizedcollections.application; +package com.baeldung.synchronizedcollections; import java.util.Arrays; import java.util.Collections; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/collections/ConcurrentModificationExceptionUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/collections/ConcurrentModificationExceptionUnitTest.java deleted file mode 100644 index d0d8c3923c..0000000000 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/java/collections/ConcurrentModificationExceptionUnitTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.baeldung.java.collections; - -import org.junit.Test; - -import java.util.*; -import java.util.concurrent.CopyOnWriteArrayList; - -import static java.util.Arrays.asList; -import static org.junit.Assert.assertEquals; - -public class ConcurrentModificationExceptionUnitTest { - - @Test - public void changingContentWithSetDoesNotThrowConcurrentModificationException() throws Exception { - ArrayList array = new ArrayList<>(asList(0, "one", 2, "three")); - - for (Object item : array) { - array.set(3, 3); - } - } - - @Test - public void removingElementUsingIteratorAPI() throws Exception { - List originalList = new ArrayList<>(asList("zero", "one", "two", "three")); - - Iterator iterator = originalList.iterator(); - - while (iterator.hasNext()) { - String next = iterator.next(); - if (Objects.equals(next, "one")) iterator.remove(); - } - - assertEquals(originalList, asList("zero", "two", "three")); - } - - @Test - public void modifyingContentAndIteratingUsingListIteratorAPI() throws Exception { - List originalList = new ArrayList<>(asList("zero", "one", "two", "three")); - - ListIterator iterator = originalList.listIterator(); - - while (iterator.hasNext()) { - String next = iterator.next(); - if (Objects.equals(next, "one")) { - iterator.set("another"); - } - - if (Objects.equals(next, "two")) { - iterator.remove(); - } - - if (Objects.equals(next, "three")) { - iterator.add("four"); - } - } - - assertEquals(originalList, asList("zero", "another", "three", "four")); - } - - @Test - public void removingElementUsingCopyAndListAPI() throws Exception { - List originalList = new ArrayList<>(asList("zero", "one", "two", "three")); - - List listCopy = new ArrayList<>(originalList); - - for (String next : listCopy) { - if (Objects.equals(next, "one")) originalList.remove(originalList.indexOf(next) - 1); - } - - assertEquals(originalList, asList("one", "two", "three")); - } - - @Test - public void copyOnWriteList() throws Exception { - List originalList = new CopyOnWriteArrayList<>(asList("zero", "one", "two", "three")); - - for (String next : originalList) { - if (Objects.equals(next, "one")) originalList.remove(originalList.indexOf(next) - 1); - } - - assertEquals(originalList, asList("one", "two", "three")); - } -} diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedCollectionUnitTest.java similarity index 94% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedCollectionUnitTest.java index fd84503226..29b1ab9e70 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedCollectionUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.synchronizedcollections.test; +package com.baeldung.synchronizedcollections; import java.util.ArrayList; import java.util.Arrays; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedListUnitTest.java similarity index 97% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedListUnitTest.java index 72354622ae..0e3c9cd217 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedListUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.synchronizedcollections.test; +package com.baeldung.synchronizedcollections; import java.util.ArrayList; import java.util.Arrays; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedMapUnitTest.java similarity index 94% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedMapUnitTest.java index 842e253e9e..9a4d80b403 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedMapUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.synchronizedcollections.test; +package com.baeldung.synchronizedcollections; import java.util.Collections; import java.util.HashMap; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedSetUnitTest.java similarity index 93% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedSetUnitTest.java index f88f58a55b..88fd343f56 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedSetUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.synchronizedcollections.test; +package com.baeldung.synchronizedcollections; import java.util.Arrays; import java.util.Collections; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedSortedMapUnitTest.java similarity index 94% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedSortedMapUnitTest.java index 23933b2b4b..7cbfa9bfa9 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedSortedMapUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.synchronizedcollections.test; +package com.baeldung.synchronizedcollections; import java.util.Collections; import java.util.Map; diff --git a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedSortedSetUnitTest.java similarity index 94% rename from core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java rename to core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedSortedSetUnitTest.java index 3ce1e6ed26..98820665c1 100644 --- a/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java +++ b/core-java-modules/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/SynchronizedSortedSetUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.synchronizedcollections.test; +package com.baeldung.synchronizedcollections; import java.util.Arrays; import java.util.Collections; diff --git a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/README.md b/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/README.md deleted file mode 100644 index 317d81fae7..0000000000 --- a/core-java-modules/core-java-collections/src/test/java/org/baeldung/java/collections/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: -- [Join and Split Arrays and Collections in Java](http://www.baeldung.com/java-join-and-split) -- [Introduction to Java Servlets](http://www.baeldung.com/intro-to-servlets) diff --git a/core-java-modules/core-java-exceptions/README.md b/core-java-modules/core-java-exceptions/README.md index 78599c6b7b..0120b970c3 100644 --- a/core-java-modules/core-java-exceptions/README.md +++ b/core-java-modules/core-java-exceptions/README.md @@ -1,8 +1,13 @@ -## Relevant Articles: +## Core Java Exceptions -- [Will an Error Be Caught by Catch Block in Java?](https://www.baeldung.com/java-error-catch) -- [Java Global Exception Handler](http://www.baeldung.com/java-global-exception-handler) -- [Common Java Exceptions](http://www.baeldung.com/java-common-exceptions) -- [Throw Exception in Optional in Java 8](https://www.baeldung.com/java-optional-throw-exception) -- [How to Find an Exception’s Root Cause in Java](https://www.baeldung.com/java-exception-root-cause) -- [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources) +This module contains articles about core java exceptions + +### Relevant articles: +- [Chained Exceptions in Java](https://www.baeldung.com/java-chained-exceptions) +- [ClassNotFoundException vs NoClassDefFoundError](https://www.baeldung.com/java-classnotfoundexception-and-noclassdeffounderror) +- [Create a Custom Exception in Java](https://www.baeldung.com/java-new-custom-exception) +- [Exception Handling in Java](https://www.baeldung.com/java-exceptions) +- [Differences Between Final, Finally and Finalize in Java](https://www.baeldung.com/java-final-finally-finalize) +- [Difference Between Throw and Throws in Java](https://www.baeldung.com/java-throw-throws) +- [“Sneaky Throws” in Java](https://www.baeldung.com/java-sneaky-throws) +- [The StackOverflowError in Java](https://www.baeldung.com/java-stack-overflow-error) diff --git a/core-java-modules/core-java-exceptions/pom.xml b/core-java-modules/core-java-exceptions/pom.xml index 43c4e31033..da5ec76622 100644 --- a/core-java-modules/core-java-exceptions/pom.xml +++ b/core-java-modules/core-java-exceptions/pom.xml @@ -1,55 +1,46 @@ + - 4.0.0 - com.baeldung.exception.numberformat - core-java-exceptions - 0.0.1-SNAPSHOT - core-java-exceptions + 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"> + com.baeldung.exceptions + 4.0.0 + core-java-exceptions + 0.1.0-SNAPSHOT + core-java-exceptions + jar - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + - - - junit - junit - ${junit.version} - test - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.openjdk.jmh - jmh-core - ${jmh-core.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh-generator-annprocess.version} - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - + + + javax.mail + mail + ${javax.mail.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + - - 3.9 - 1.19 - 3.10.0 - 1.19 - + + 1.5.0-b01 + + 3.10.0 + - + \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/Arithmetic.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/Arithmetic.java deleted file mode 100644 index 138916ec60..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/Arithmetic.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Arithmetic { - - private static Logger LOGGER = LoggerFactory.getLogger(Arithmetic.class); - - public static void main(String[] args) { - - try { - int result = 30 / 0; // Trying to divide by zero - } catch (ArithmeticException e) { - LOGGER.error("ArithmeticException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java deleted file mode 100644 index 93b53f284c..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ArrayIndexOutOfBounds.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ArrayIndexOutOfBounds { - - private static Logger LOGGER = LoggerFactory.getLogger(ArrayIndexOutOfBounds.class); - - public static void main(String[] args) { - - int[] nums = new int[] { 1, 2, 3 }; - - try { - int numFromNegativeIndex = nums[-1]; // Trying to access at negative index - int numFromGreaterIndex = nums[4]; // Trying to access at greater index - int numFromLengthIndex = nums[3]; // Trying to access at index equal to size of the array - } catch (ArrayIndexOutOfBoundsException e) { - LOGGER.error("ArrayIndexOutOfBoundsException caught"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/CheckedUncheckedExceptions.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/CheckedUncheckedExceptions.java deleted file mode 100644 index 780189b654..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/CheckedUncheckedExceptions.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.exceptions; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -public class CheckedUncheckedExceptions { - public static void checkedExceptionWithThrows() throws FileNotFoundException { - File file = new File("not_existing_file.txt"); - FileInputStream stream = new FileInputStream(file); - } - - public static void checkedExceptionWithTryCatch() { - File file = new File("not_existing_file.txt"); - try { - FileInputStream stream = new FileInputStream(file); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - - public static int divideByZero() { - int numerator = 1; - int denominator = 0; - return numerator / denominator; - } - - public static void checkFile(String fileName) throws IncorrectFileNameException { - if (fileName == null || fileName.isEmpty()) { - throw new NullOrEmptyException("The filename is null."); - } - if (!isCorrectFileName(fileName)) { - throw new IncorrectFileNameException("Incorrect filename : " + fileName); - } - } - - private static boolean isCorrectFileName(String fileName) { - if (fileName.equals("wrongFileName.txt")) - return false; - else - return true; - } -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ClassCast.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ClassCast.java deleted file mode 100644 index 183f8f54a3..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ClassCast.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -class Animal { - -} - -class Dog extends Animal { - -} - -class Lion extends Animal { - -} - -public class ClassCast { - - private static Logger LOGGER = LoggerFactory.getLogger(ClassCast.class); - - public static void main(String[] args) { - - try { - Animal animalOne = new Dog(); // At runtime the instance is dog - Dog bruno = (Dog) animalOne; // Downcasting - - Animal animalTwo = new Lion(); // At runtime the instance is animal - Dog tommy = (Dog) animalTwo; // Downcasting - } catch (ClassCastException e) { - LOGGER.error("ClassCastException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/FileNotFound.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/FileNotFound.java deleted file mode 100644 index bb9e0bf4ac..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/FileNotFound.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.exceptions; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FileNotFound { - - private static Logger LOGGER = LoggerFactory.getLogger(FileNotFound.class); - - public static void main(String[] args) { - - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(new File("/invalid/file/location"))); - } catch (FileNotFoundException e) { - LOGGER.error("FileNotFoundException caught!"); - } - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java deleted file mode 100644 index ab46c83da4..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/GlobalExceptionHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GlobalExceptionHandler { - - public static void main(String[] args) { - - Handler globalExceptionHandler = new Handler(); - Thread.setDefaultUncaughtExceptionHandler(globalExceptionHandler); - new GlobalExceptionHandler().performArithmeticOperation(10, 0); - } - - public int performArithmeticOperation(int num1, int num2) { - return num1/num2; - } - -} - -class Handler implements Thread.UncaughtExceptionHandler { - - private static Logger LOGGER = LoggerFactory.getLogger(Handler.class); - - public void uncaughtException(Thread t, Throwable e) { - LOGGER.info("Unhandled exception caught!"); - } -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalArgument.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalArgument.java deleted file mode 100644 index 801536cb2d..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalArgument.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class IllegalArgument { - - private static Logger LOGGER = LoggerFactory.getLogger(IllegalArgument.class); - - public static void main(String[] args) { - try { - Thread.sleep(-1000); - } catch (InterruptedException e) { - LOGGER.error("IllegalArgumentException caught!"); - } - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalState.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalState.java deleted file mode 100644 index e8ddcea3c2..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IllegalState.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.exceptions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class IllegalState { - - private static Logger LOGGER = LoggerFactory.getLogger(IllegalState.class); - - public static void main(String[] args) { - - List intList = new ArrayList<>(); - - for (int i = 0; i < 10; i++) { - intList.add(i); - } - - Iterator intListIterator = intList.iterator(); // Initialized with index at -1 - - try { - intListIterator.remove(); // IllegalStateException - } catch (IllegalStateException e) { - LOGGER.error("IllegalStateException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IncorrectFileNameException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IncorrectFileNameException.java deleted file mode 100644 index 9877fe25ca..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/IncorrectFileNameException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.exceptions; - -public class IncorrectFileNameException extends Exception { - private static final long serialVersionUID = 1L; - - public IncorrectFileNameException(String errorMessage) { - super(errorMessage); - } - - public IncorrectFileNameException(String errorMessage, Throwable thr) { - super(errorMessage, thr); - } -} \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java deleted file mode 100644 index 319fd33591..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/InterruptedExceptionExample.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -class ChildThread extends Thread { - - private static Logger LOGGER = LoggerFactory.getLogger(ChildThread.class); - - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - LOGGER.error("InterruptedException caught!"); - } - } - -} - -public class InterruptedExceptionExample { - - public static void main(String[] args) throws InterruptedException { - ChildThread childThread = new ChildThread(); - childThread.start(); - childThread.interrupt(); - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/MalformedURL.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/MalformedURL.java deleted file mode 100644 index 57fcddf76b..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/MalformedURL.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.exceptions; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MalformedURL { - - private static Logger LOGGER = LoggerFactory.getLogger(MalformedURL.class); - - public static void main(String[] args) { - - URL baeldungURL = null; - - try { - baeldungURL = new URL("malformedurl"); - } catch (MalformedURLException e) { - LOGGER.error("MalformedURLException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullOrEmptyException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullOrEmptyException.java deleted file mode 100644 index d4ee9c0d6f..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullOrEmptyException.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.exceptions; - -public class NullOrEmptyException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public NullOrEmptyException(String errorMessage) { - super(errorMessage); - } - - public NullOrEmptyException(String errorMessage, Throwable thr) { - super(errorMessage, thr); - } -} \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullPointer.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullPointer.java deleted file mode 100644 index 2402a786a9..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NullPointer.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NullPointer { - - private static Logger LOGGER = LoggerFactory.getLogger(NullPointer.class); - - public static void main(String[] args) { - - Person personObj = null; - - try { - String name = personObj.personName; // Accessing the field of a null object - personObj.personName = "Jon Doe"; // Modifying the field of a null object - } catch (NullPointerException e) { - LOGGER.error("NullPointerException caught!"); - } - - } -} - -class Person { - - public String personName; - - public String getPersonName() { - return personName; - } - - public void setPersonName(String personName) { - this.personName = personName; - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NumberFormat.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NumberFormat.java deleted file mode 100644 index 7050e70aee..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/NumberFormat.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NumberFormat { - - private static Logger LOGGER = LoggerFactory.getLogger(NumberFormat.class); - - public static void main(String[] args) { - - String str1 = "100ABCD"; - - try { - int x = Integer.parseInt(str1); // Converting string with inappropriate format - int y = Integer.valueOf(str1); - } catch (NumberFormatException e) { - LOGGER.error("NumberFormatException caught!"); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java deleted file mode 100644 index f7fb4c91e4..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/ParseExceptionExample.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.exceptions; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ParseExceptionExample { - - private static Logger LOGGER = LoggerFactory.getLogger(ParseExceptionExample.class); - - public static void main(String[] args) { - - DateFormat format = new SimpleDateFormat("MM, dd, yyyy"); - - try { - format.parse("01, , 2010"); - } catch (ParseException e) { - LOGGER.error("ParseException caught!"); - } - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/RootCauseFinder.java deleted file mode 100644 index cf449110e6..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/RootCauseFinder.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.baeldung.exceptions; - -import java.time.LocalDate; -import java.time.Period; -import java.time.format.DateTimeParseException; -import java.util.Objects; - -/** - * Utility class to find root cause exceptions. - */ -public class RootCauseFinder { - - private RootCauseFinder() { - } - - public static Throwable findCauseUsingPlainJava(Throwable throwable) { - Objects.requireNonNull(throwable); - Throwable rootCause = throwable; - while (rootCause.getCause() != null && rootCause.getCause() != rootCause) { - rootCause = rootCause.getCause(); - } - return rootCause; - } - - /** - * Calculates the age of a person from a given date. - */ - static class AgeCalculator { - - private AgeCalculator() { - } - - public static int calculateAge(String birthDate) { - if (birthDate == null || birthDate.isEmpty()) { - throw new IllegalArgumentException(); - } - - try { - return Period - .between(parseDate(birthDate), LocalDate.now()) - .getYears(); - } catch (DateParseException ex) { - throw new CalculationException(ex); - } - } - - private static LocalDate parseDate(String birthDateAsString) { - - LocalDate birthDate; - try { - birthDate = LocalDate.parse(birthDateAsString); - } catch (DateTimeParseException ex) { - throw new InvalidFormatException(birthDateAsString, ex); - } - - if (birthDate.isAfter(LocalDate.now())) { - throw new DateOutOfRangeException(birthDateAsString); - } - - return birthDate; - } - - } - - static class CalculationException extends RuntimeException { - - CalculationException(DateParseException ex) { - super(ex); - } - } - - static class DateParseException extends RuntimeException { - - DateParseException(String input) { - super(input); - } - - DateParseException(String input, Throwable thr) { - super(input, thr); - } - } - - static class InvalidFormatException extends DateParseException { - - InvalidFormatException(String input, Throwable thr) { - super("Invalid date format: " + input, thr); - } - } - - static class DateOutOfRangeException extends DateParseException { - - DateOutOfRangeException(String date) { - super("Date out of range: " + date); - } - - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StackTraceToString.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StackTraceToString.java deleted file mode 100644 index c6bf915996..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StackTraceToString.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.exceptions; - -import org.apache.commons.lang3.exception.ExceptionUtils; - -import java.io.PrintWriter; -import java.io.StringWriter; - -public class StackTraceToString { - - public static void main(String[] args) { - // Convert a StackTrace to String using core java - try { - throw new NullPointerException(); - } catch (Exception e) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - - System.out.println(sw.toString()); - } - - // Convert a StackTrace to String using Apache Commons - try { - throw new IndexOutOfBoundsException(); - } catch (Exception e) { - System.out.println(ExceptionUtils.getStackTrace(e)); - } - } - -} diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java deleted file mode 100644 index bc297be498..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/StringIndexOutOfBounds.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.exceptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class StringIndexOutOfBounds { - - private static Logger LOGGER = LoggerFactory.getLogger(StringIndexOutOfBounds.class); - - public static void main(String[] args) { - - String str = "Hello World"; - - try { - char charAtNegativeIndex = str.charAt(-1); // Trying to access at negative index - char charAtLengthIndex = str.charAt(11); // Trying to access at index equal to size of the string - } catch (StringIndexOutOfBoundsException e) { - LOGGER.error("StringIndexOutOfBoundsException caught"); - } - - } - -} diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithChain.java similarity index 73% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithChain.java index 3d66c2b535..a2eae50108 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithChain.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithChain.java @@ -1,9 +1,9 @@ -package com.baeldung.chainedexception; +package com.baeldung.exceptions.chainedexception; -import com.baeldung.chainedexception.exceptions.GirlFriendOfManagerUpsetException; -import com.baeldung.chainedexception.exceptions.ManagerUpsetException; -import com.baeldung.chainedexception.exceptions.NoLeaveGrantedException; -import com.baeldung.chainedexception.exceptions.TeamLeadUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.GirlFriendOfManagerUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.ManagerUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.NoLeaveGrantedException; +import com.baeldung.exceptions.chainedexception.exceptions.TeamLeadUpsetException; public class LogWithChain { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithoutChain.java similarity index 75% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithoutChain.java index 7556e30663..8c37db0307 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/LogWithoutChain.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/LogWithoutChain.java @@ -1,9 +1,9 @@ -package com.baeldung.chainedexception; +package com.baeldung.exceptions.chainedexception; -import com.baeldung.chainedexception.exceptions.GirlFriendOfManagerUpsetException; -import com.baeldung.chainedexception.exceptions.ManagerUpsetException; -import com.baeldung.chainedexception.exceptions.NoLeaveGrantedException; -import com.baeldung.chainedexception.exceptions.TeamLeadUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.GirlFriendOfManagerUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.ManagerUpsetException; +import com.baeldung.exceptions.chainedexception.exceptions.NoLeaveGrantedException; +import com.baeldung.exceptions.chainedexception.exceptions.TeamLeadUpsetException; public class LogWithoutChain { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java similarity index 82% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java index e20c58ea5b..91537b58d4 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/GirlFriendOfManagerUpsetException.java @@ -1,4 +1,4 @@ -package com.baeldung.chainedexception.exceptions; +package com.baeldung.exceptions.chainedexception.exceptions; public class GirlFriendOfManagerUpsetException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/ManagerUpsetException.java similarity index 80% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/ManagerUpsetException.java index e95a3921a4..351521a522 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/ManagerUpsetException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/ManagerUpsetException.java @@ -1,4 +1,4 @@ -package com.baeldung.chainedexception.exceptions; +package com.baeldung.exceptions.chainedexception.exceptions; public class ManagerUpsetException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/NoLeaveGrantedException.java similarity index 80% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/NoLeaveGrantedException.java index b9521858b3..dd84baae74 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/NoLeaveGrantedException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/NoLeaveGrantedException.java @@ -1,4 +1,4 @@ -package com.baeldung.chainedexception.exceptions; +package com.baeldung.exceptions.chainedexception.exceptions; public class NoLeaveGrantedException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/TeamLeadUpsetException.java similarity index 80% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/TeamLeadUpsetException.java index f874620f00..4ea8c3db7a 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/chainedexception/exceptions/TeamLeadUpsetException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/chainedexception/exceptions/TeamLeadUpsetException.java @@ -1,4 +1,4 @@ -package com.baeldung.chainedexception.exceptions; +package com.baeldung.exceptions.chainedexception.exceptions; public class TeamLeadUpsetException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/FileManager.java similarity index 96% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/FileManager.java index b6f4d960aa..adc1b1613c 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/FileManager.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/FileManager.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; import java.io.File; import java.io.FileNotFoundException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionException.java similarity index 83% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionException.java index c6dc6d6964..4e8fece145 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileExtensionException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionException.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; public class IncorrectFileExtensionException extends RuntimeException{ private static final long serialVersionUID = 1L; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileNameException.java similarity index 82% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileNameException.java index a804cadb84..f7f6a9dd8c 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/customexception/IncorrectFileNameException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/customexception/IncorrectFileNameException.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; public class IncorrectFileNameException extends Exception { private static final long serialVersionUID = 1L; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Exceptions.java similarity index 99% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Exceptions.java index 32d88cfd12..14483b3489 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Exceptions.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Exceptions.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; import java.io.File; import java.io.FileNotFoundException; diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/MyException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/MyException.java new file mode 100644 index 0000000000..bc2c6baffb --- /dev/null +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/MyException.java @@ -0,0 +1,5 @@ +package com.baeldung.exceptions.exceptionhandling; + +public class MyException extends Throwable { + +} diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Player.java similarity index 72% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Player.java index e866802fe3..1251cd58e6 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/Player.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/Player.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; public class Player { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerLoadException.java similarity index 75% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerLoadException.java index d92edeebbd..432232c23e 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerLoadException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerLoadException.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; import java.io.IOException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerScoreException.java similarity index 71% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerScoreException.java index 299370ee86..ba2a6d74e4 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/PlayerScoreException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/PlayerScoreException.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; public class PlayerScoreException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/TimeoutException.java similarity index 71% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/TimeoutException.java index 0211284e5d..0f926ccf58 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/TimeoutException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/exceptionhandling/TimeoutException.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; public class TimeoutException extends Exception { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalize/FinalizeObject.java similarity index 88% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalize/FinalizeObject.java index af0449c0da..9e5e7461ea 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalize/FinalizeObject.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalize/FinalizeObject.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finalize; +package com.baeldung.exceptions.keywords.finalize; public class FinalizeObject { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Child.java similarity index 78% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Child.java index 8615c78652..b006850199 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Child.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Child.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finalkeyword; +package com.baeldung.exceptions.keywords.finalkeyword; public final class Child extends Parent { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/GrandChild.java similarity index 56% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/GrandChild.java index 1530c5037f..f8adf27914 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/GrandChild.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/GrandChild.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finalkeyword; +package com.baeldung.exceptions.keywords.finalkeyword; /*public class GrandChild extends Child { // Compilation error diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Parent.java similarity index 87% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Parent.java index 5cd2996e7a..2a5d19a32f 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finalkeyword/Parent.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finalkeyword/Parent.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finalkeyword; +package com.baeldung.exceptions.keywords.finalkeyword; public class Parent { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finallykeyword/FinallyExample.java similarity index 92% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finallykeyword/FinallyExample.java index 3c0aee3196..8f9d9a29d2 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/keywords/finallykeyword/FinallyExample.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/keywords/finallykeyword/FinallyExample.java @@ -1,4 +1,4 @@ -package com.baeldung.keywords.finallykeyword; +package com.baeldung.exceptions.keywords.finallykeyword; public class FinallyExample { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/ClassWithInitErrors.java similarity index 55% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/ClassWithInitErrors.java index b5b357a322..a82f430959 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/ClassWithInitErrors.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/ClassWithInitErrors.java @@ -1,4 +1,4 @@ -package com.baeldung.noclassdeffounderror; +package com.baeldung.exceptions.noclassdeffounderror; public class ClassWithInitErrors { static int data = 1 / 0; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorExample.java similarity index 86% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorExample.java index 7bcefbdbd3..0dc74a9d01 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorExample.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorExample.java @@ -1,4 +1,4 @@ -package com.baeldung.noclassdeffounderror; +package com.baeldung.exceptions.noclassdeffounderror; public class NoClassDefFoundErrorExample { public ClassWithInitErrors getClassWithInitErrors() { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyRunnable.java similarity index 90% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyRunnable.java index 88a8696053..06b587d0e0 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyRunnable.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyRunnable.java @@ -1,4 +1,4 @@ -package com.baeldung.sneakythrows; +package com.baeldung.exceptions.sneakythrows; import lombok.SneakyThrows; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyThrows.java similarity index 90% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyThrows.java index 847aaa7249..e86ef53733 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/sneakythrows/SneakyThrows.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/sneakythrows/SneakyThrows.java @@ -1,4 +1,4 @@ -package com.baeldung.sneakythrows; +package com.baeldung.exceptions.sneakythrows; import java.io.IOException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/AccountHolder.java similarity index 74% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/AccountHolder.java index 91b8a3bbb0..5beac1cd04 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/AccountHolder.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/AccountHolder.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class AccountHolder { private String firstName; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassOne.java similarity index 86% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassOne.java index 3b95fd1368..e290a1fe38 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassOne.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassOne.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class ClassOne { private int oneValue; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassTwo.java similarity index 86% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassTwo.java index 0adf075b43..fc6a89e1fb 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/ClassTwo.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/ClassTwo.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class ClassTwo { private int twoValue; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java similarity index 78% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java index c67eeb30d1..858871cb9d 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationCondition.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class InfiniteRecursionWithTerminationCondition { public int calculateFactorial(final int number) { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationCondition.java similarity index 78% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationCondition.java index 8d10c65dcc..69b1c0b5ab 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationCondition.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationCondition.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class RecursionWithCorrectTerminationCondition { public int calculateFactorial(final int number) { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursion.java similarity index 75% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursion.java index 0b7fb3cf94..c07fdcb01b 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursion.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursion.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; public class UnintendedInfiniteRecursion { public int calculateFactorial(int number) { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/DataAccessException.java similarity index 78% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/DataAccessException.java index 0b371dcedb..448c8e2213 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/DataAccessException.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/DataAccessException.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; public class DataAccessException extends RuntimeException { diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/Main.java similarity index 95% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/Main.java index 17fbf5a582..dfe8fcbd5a 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/Main.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/Main.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import com.sun.mail.iap.ConnectionException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/PersonRepository.java similarity index 79% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/PersonRepository.java index 7d8345c3c1..73453f4fc0 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/PersonRepository.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/PersonRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import java.sql.SQLException; import java.util.List; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/SimpleService.java similarity index 90% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/SimpleService.java index 6bb8b90bf1..605d900633 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/SimpleService.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/SimpleService.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import java.sql.SQLException; diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/TryCatch.java similarity index 85% rename from core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/TryCatch.java index 2fd87f124d..f8a603f013 100644 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/throwsexception/TryCatch.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/throwvsthrows/TryCatch.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import com.sun.mail.iap.ConnectionException; diff --git a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/optional/PersonRepository.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/optional/PersonRepository.java deleted file mode 100644 index 46018faf80..0000000000 --- a/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/optional/PersonRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.optional; - -public class PersonRepository { - - public String findNameById(String id) { - return id == null ? null : "Name"; - } - -} diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/error/ErrorGeneratorUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/error/ErrorGeneratorUnitTest.java deleted file mode 100644 index 6dcd0d72e0..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/error/ErrorGeneratorUnitTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.exception.error; - -import org.junit.Assert; -import org.junit.Test; - -public class ErrorGeneratorUnitTest { - - @Test(expected = AssertionError.class) - public void whenError_thenIsNotCaughtByCatchException() { - try { - throw new AssertionError(); - } catch (Exception e) { - Assert.fail(); // errors are not caught by catch exception - } - } - - @Test - public void whenError_thenIsCaughtByCatchError() { - try { - throw new AssertionError(); - } catch (Error e) { - // caught! -> test pass - } - } -} \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java deleted file mode 100644 index cb26bf451a..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exception/numberformat/NumberFormatExceptionUnitTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.baeldung.exception.numberformat; - -import static org.junit.Assert.assertEquals; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.text.NumberFormat; -import java.text.ParseException; -import java.util.Locale; -import java.util.logging.Logger; - -import org.junit.Test; - -/** - * A set of examples tested to show cases where NumberFormatException is thrown and not thrown. - */ -public class NumberFormatExceptionUnitTest { - - Logger LOG = Logger.getLogger(NumberFormatExceptionUnitTest.class.getName()); - - /* ---INTEGER FAIL CASES--- */ - @Test(expected = NumberFormatException.class) - public void givenByteConstructor_whenAlphabetAsInput_thenFail() { - Byte byteInt = new Byte("one"); - } - - @Test(expected = NumberFormatException.class) - public void givenShortConstructor_whenSpaceInInput_thenFail() { - Short shortInt = new Short("2 "); - } - - @Test(expected = NumberFormatException.class) - public void givenParseIntMethod_whenSpaceInInput_thenFail() { - Integer aIntPrim = Integer.parseInt("6000 "); - } - - @Test(expected = NumberFormatException.class) - public void givenParseIntMethod_whenUnderscoreInInput_thenFail() { - int bIntPrim = Integer.parseInt("_6000"); - } - - @Test(expected = NumberFormatException.class) - public void givenIntegerValueOfMethod_whenCommaInInput_thenFail() { - Integer cIntPrim = Integer.valueOf("6,000"); - } - - @Test(expected = NumberFormatException.class) - public void givenBigIntegerConstructor_whenDecimalInInput_thenFail() { - BigInteger bigInteger = new BigInteger("4.0"); - } - - @Test(expected = NumberFormatException.class) - public void givenDecodeMethod_whenAlphabetInInput_thenFail() { - Long decodedLong = Long.decode("64403L"); - } - - /* ---INTEGER PASS CASES--- */ - @Test - public void givenInvalidNumberInputs_whenOptimized_thenPass() { - Byte byteInt = new Byte("1"); - assertEquals(1, byteInt.intValue()); - - Short shortInt = new Short("2 ".trim()); - assertEquals(2, shortInt.intValue()); - - Integer aIntObj = Integer.valueOf("6"); - assertEquals(6, aIntObj.intValue()); - - BigInteger bigInteger = new BigInteger("4"); - assertEquals(4, bigInteger.intValue()); - - int aIntPrim = Integer.parseInt("6000 ".trim()); - assertEquals(6000, aIntPrim); - - int bIntPrim = Integer.parseInt("_6000".replaceAll("_", "")); - assertEquals(6000, bIntPrim); - - int cIntPrim = Integer.parseInt("-6000"); - assertEquals(-6000, cIntPrim); - - Long decodeInteger = Long.decode("644032334"); - assertEquals(644032334L, decodeInteger.longValue()); - } - - /* ---DOUBLE FAIL CASES--- */ - @Test(expected = NumberFormatException.class) - public void givenFloatConstructor_whenAlphabetInInput_thenFail() { - Float floatDecimalObj = new Float("one.1"); - } - - @Test(expected = NumberFormatException.class) - public void givenDoubleConstructor_whenAlphabetInInput_thenFail() { - Double doubleDecimalObj = new Double("two.2"); - } - - @Test(expected = NumberFormatException.class) - public void givenBigDecimalConstructor_whenSpecialCharsInInput_thenFail() { - BigDecimal bigDecimalObj = new BigDecimal("3_0.3"); - } - - @Test(expected = NumberFormatException.class) - public void givenParseDoubleMethod_whenCommaInInput_thenFail() { - double aDoublePrim = Double.parseDouble("4000,1"); - } - - /* ---DOUBLE PASS CASES--- */ - @Test - public void givenDoubleConstructor_whenDecimalInInput_thenPass() { - Double doubleDecimalObj = new Double("2.2"); - assertEquals(2.2, doubleDecimalObj.doubleValue(), 0); - } - - @Test - public void givenDoubleValueOfMethod_whenMinusInInput_thenPass() { - Double aDoubleObj = Double.valueOf("-6000"); - assertEquals(-6000, aDoubleObj.doubleValue(), 0); - } - - @Test - public void givenUsDecimalNumber_whenParsedWithNumberFormat_thenPass() throws ParseException { - Number parsedNumber = parseNumberWithLocale("4000.1", Locale.US); - assertEquals(4000.1, parsedNumber); - assertEquals(4000.1, parsedNumber.doubleValue(), 0); - assertEquals(4000, parsedNumber.intValue()); - } - - /** - * In most European countries (for example, France), comma is used as decimal in place of period. - * @throws ParseException if the input string contains special characters other than comma or decimal. - * In this test case, anything after decimal (period) is dropped when a European locale is set. - */ - @Test - public void givenEuDecimalNumberHasComma_whenParsedWithNumberFormat_thenPass() throws ParseException { - Number parsedNumber = parseNumberWithLocale("4000,1", Locale.FRANCE); - LOG.info("Number parsed is: " + parsedNumber); - assertEquals(4000.1, parsedNumber); - assertEquals(4000.1, parsedNumber.doubleValue(), 0); - assertEquals(4000, parsedNumber.intValue()); - } - - /** - * Converts a string into a number retaining all decimals, and symbols valid in a locale. - * @param number the input string for a number. - * @param locale the locale to consider while parsing a number. - * @return the generic number object which can represent multiple number types. - * @throws ParseException when input contains invalid characters. - */ - private Number parseNumberWithLocale(String number, Locale locale) throws ParseException { - locale = locale == null ? Locale.getDefault() : locale; - NumberFormat numberFormat = NumberFormat.getInstance(locale); - return numberFormat.parse(number); - } - -} diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/CheckedUncheckedExceptionsUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/CheckedUncheckedExceptionsUnitTest.java deleted file mode 100644 index d82b1349d8..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/CheckedUncheckedExceptionsUnitTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.baeldung.exceptions; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.io.FileNotFoundException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Tests the {@link CheckedUncheckedExceptions}. - */ -public class CheckedUncheckedExceptionsUnitTest { - - @Test - public void whenFileNotExist_thenThrowException() { - assertThrows(FileNotFoundException.class, () -> { - CheckedUncheckedExceptions.checkedExceptionWithThrows(); - }); - } - - @Test - public void whenTryCatchExcetpion_thenSuccess() { - try { - CheckedUncheckedExceptions.checkedExceptionWithTryCatch(); - } catch (Exception e) { - Assertions.fail(e.getMessage()); - } - } - - @Test - public void whenDivideByZero_thenThrowException() { - assertThrows(ArithmeticException.class, () -> { - CheckedUncheckedExceptions.divideByZero(); - }); - } - - @Test - public void whenInvalidFile_thenThrowException() { - - assertThrows(IncorrectFileNameException.class, () -> { - CheckedUncheckedExceptions.checkFile("wrongFileName.txt"); - }); - } - - @Test - public void whenNullOrEmptyFile_thenThrowException() { - assertThrows(NullOrEmptyException.class, () -> { - CheckedUncheckedExceptions.checkFile(null); - }); - assertThrows(NullOrEmptyException.class, () -> { - CheckedUncheckedExceptions.checkFile(""); - }); - } -} diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java deleted file mode 100644 index 394de9c576..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/GlobalExceptionHandlerUnitTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.baeldung.exceptions; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.slf4j.LoggerFactory; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.classic.spi.LoggingEvent; -import ch.qos.logback.core.Appender; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.verify; - -@RunWith(MockitoJUnitRunner.class) -public class GlobalExceptionHandlerUnitTest { - - @Mock - private Appender mockAppender; - - @Captor - private ArgumentCaptor captorLoggingEvent; - - @Before - public void setup() { - final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - logger.addAppender(mockAppender); - - Handler globalExceptionHandler = new Handler(); - Thread.setDefaultUncaughtExceptionHandler(globalExceptionHandler); - } - - @After - public void teardown() { - final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - logger.detachAppender(mockAppender); - } - - @Test - public void whenArithmeticException_thenUseUncaughtExceptionHandler() throws InterruptedException { - - Thread globalExceptionHandlerThread = new Thread() { - public void run() { - GlobalExceptionHandler globalExceptionHandlerObj = new GlobalExceptionHandler(); - globalExceptionHandlerObj.performArithmeticOperation(99, 0); - } - }; - - globalExceptionHandlerThread.start(); - globalExceptionHandlerThread.join(); - - verify(mockAppender).doAppend(captorLoggingEvent.capture()); - LoggingEvent loggingEvent = captorLoggingEvent.getValue(); - - assertThat(loggingEvent.getLevel()).isEqualTo(Level.INFO); - assertThat(loggingEvent.getFormattedMessage()).isEqualTo("Unhandled exception caught!"); - } - -} diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java deleted file mode 100644 index 5d0f3b9c3e..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.baeldung.exceptions; - -import com.google.common.base.Throwables; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.time.LocalDate; -import java.time.format.DateTimeParseException; -import java.time.temporal.ChronoUnit; - -import static com.baeldung.exceptions.RootCauseFinder.*; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Tests the {@link RootCauseFinder}. - */ -public class RootCauseFinderUnitTest { - - @Test - public void givenBirthDate_whenCalculatingAge_thenAgeReturned() { - try { - int age = AgeCalculator.calculateAge("1990-01-01"); - Assertions.assertEquals(1990, LocalDate - .now() - .minus(age, ChronoUnit.YEARS) - .getYear()); - } catch (CalculationException e) { - Assertions.fail(e.getMessage()); - } - } - - @Test - public void givenWrongFormatDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("010102"); - } catch (CalculationException ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof DateTimeParseException); - } - } - - @Test - public void givenOutOfRangeDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("2020-04-04"); - } catch (CalculationException ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof DateOutOfRangeException); - } - } - - @Test - public void givenNullDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge(null); - } catch (Exception ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof IllegalArgumentException); - } - } - - @Test - public void givenWrongFormatDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("010102"); - } catch (CalculationException ex) { - assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateTimeParseException); - } - } - - @Test - public void givenOutOfRangeDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("2020-04-04"); - } catch (CalculationException ex) { - assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateOutOfRangeException); - } - } - - @Test - public void givenNullDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseNotFound() { - try { - AgeCalculator.calculateAge(null); - } catch (Exception ex) { - assertTrue(ExceptionUtils.getRootCause(ex) instanceof IllegalArgumentException); - } - } - - @Test - public void givenWrongFormatDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("010102"); - } catch (CalculationException ex) { - assertTrue(Throwables.getRootCause(ex) instanceof DateTimeParseException); - } - } - - @Test - public void givenOutOfRangeDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("2020-04-04"); - } catch (CalculationException ex) { - assertTrue(Throwables.getRootCause(ex) instanceof DateOutOfRangeException); - } - } - - @Test - public void givenNullDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge(null); - } catch (Exception ex) { - assertTrue(Throwables.getRootCause(ex) instanceof IllegalArgumentException); - } - } - -} diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/classnotfoundexception/ClassNotFoundExceptionUnitTest.java similarity index 84% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/classnotfoundexception/ClassNotFoundExceptionUnitTest.java index 59605fb1c9..9311a9d886 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/classnotfoundexception/ClassNotFoundExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/classnotfoundexception/ClassNotFoundExceptionUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.classnotfoundexception; +package com.baeldung.exceptions.classnotfoundexception; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionExceptionUnitTest.java similarity index 95% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionExceptionUnitTest.java index 230698f719..80787daaaa 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileExtensionExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileExtensionExceptionUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; import static org.assertj.core.api.Assertions.assertThat; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileNameExceptionUnitTest.java similarity index 92% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileNameExceptionUnitTest.java index acb05eb763..8e135c1cec 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/customexception/IncorrectFileNameExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/customexception/IncorrectFileNameExceptionUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.customexception; +package com.baeldung.exceptions.customexception; import static org.assertj.core.api.Assertions.assertThat; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/exceptionhandling/ExceptionsUnitTest.java similarity index 97% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/exceptionhandling/ExceptionsUnitTest.java index 29c690133d..3551de3631 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/exceptionhandling/ExceptionsUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/exceptionhandling/ExceptionsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptionhandling; +package com.baeldung.exceptions.exceptionhandling; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java similarity index 85% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java index 521c50098a..135a51f9dd 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/noclassdeffounderror/NoClassDefFoundErrorUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.noclassdeffounderror; +package com.baeldung.exceptions.noclassdeffounderror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyRunnableUnitTest.java similarity index 89% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyRunnableUnitTest.java index 8d8e4f14fe..086c4eaef0 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyRunnableUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyRunnableUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.sneakythrows; +package com.baeldung.exceptions.sneakythrows; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyThrowsUnitTest.java similarity index 89% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyThrowsUnitTest.java index da1b2e617b..3b70128a9b 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/sneakythrows/SneakyThrowsUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/sneakythrows/SneakyThrowsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.sneakythrows; +package com.baeldung.exceptions.sneakythrows; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/AccountHolderManualTest.java similarity index 82% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/AccountHolderManualTest.java index 180b7723ac..dac8698bf8 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/AccountHolderManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/AccountHolderManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/CyclicDependancyManualTest.java similarity index 81% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/CyclicDependancyManualTest.java index 95164ac935..db6b1d45f8 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/CyclicDependancyManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/CyclicDependancyManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java similarity index 95% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java index ccf8c25271..2c7289cd5c 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/InfiniteRecursionWithTerminationConditionManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java similarity index 89% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java index 40c2c4799e..e7fb0874ea 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/RecursionWithCorrectTerminationConditionManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java similarity index 94% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java index f4e2e5221a..0f1d71034d 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/stackoverflowerror/UnintendedInfiniteRecursionManualTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stackoverflowerror; +package com.baeldung.exceptions.stackoverflowerror; import org.junit.Test; diff --git a/core-java-modules/core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/throwvsthrows/SimpleServiceUnitTest.java similarity index 92% rename from core-java-modules/core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/throwvsthrows/SimpleServiceUnitTest.java index b9a658a960..87f6224217 100644 --- a/core-java-modules/core-java-lang/src/test/java/com/baeldung/throwsexception/SimpleServiceUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/throwvsthrows/SimpleServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.throwsexception; +package com.baeldung.exceptions.throwvsthrows; import org.junit.jupiter.api.Test; diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java deleted file mode 100644 index 32879aed0c..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/java8/JavaTryWithResourcesLongRunningUnitTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.baeldung.java8; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.Scanner; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class JavaTryWithResourcesLongRunningUnitTest { - - private static final Logger LOG = LoggerFactory.getLogger(JavaTryWithResourcesLongRunningUnitTest.class); - - private static final String TEST_STRING_HELLO_WORLD = "Hello World"; - private Date resource1Date, resource2Date; - - // tests - - /* Example for using Try_with_resources */ - @Test - public void whenWritingToStringWriter_thenCorrectlyWritten() { - final StringWriter sw = new StringWriter(); - try (PrintWriter pw = new PrintWriter(sw, true)) { - pw.print(TEST_STRING_HELLO_WORLD); - } - - Assert.assertEquals(sw.getBuffer() - .toString(), TEST_STRING_HELLO_WORLD); - } - - /* Example for using multiple resources */ - @Test - public void givenStringToScanner_whenWritingToStringWriter_thenCorrectlyWritten() { - - final StringWriter sw = new StringWriter(); - try (Scanner sc = new Scanner(TEST_STRING_HELLO_WORLD); PrintWriter pw = new PrintWriter(sw, true)) { - while (sc.hasNext()) { - pw.print(sc.nextLine()); - } - } - - Assert.assertEquals(sw.getBuffer() - .toString(), TEST_STRING_HELLO_WORLD); - } - - /* Example to show order in which the resources are closed */ - @Test - public void whenFirstAutoClosableResourceIsinitializedFirst_thenFirstAutoClosableResourceIsReleasedFirst() throws Exception { - try (AutoCloseableResourcesFirst af = new AutoCloseableResourcesFirst(); AutoCloseableResourcesSecond as = new AutoCloseableResourcesSecond()) { - af.doSomething(); - as.doSomething(); - } - Assert.assertTrue(resource1Date.after(resource2Date)); - } - - class AutoCloseableResourcesFirst implements AutoCloseable { - public AutoCloseableResourcesFirst() { - LOG.debug("Constructor -> AutoCloseableResources_First"); - } - - public void doSomething() { - LOG.debug("Something -> AutoCloseableResources_First"); - } - - @Override - public void close() throws Exception { - LOG.debug("Closed AutoCloseableResources_First"); - resource1Date = new Date(); - } - } - - class AutoCloseableResourcesSecond implements AutoCloseable { - public AutoCloseableResourcesSecond() { - LOG.debug("Constructor -> AutoCloseableResources_Second"); - } - - public void doSomething() { - LOG.debug("Something -> AutoCloseableResources_Second"); - } - - @Override - public void close() throws Exception { - LOG.debug("Closed AutoCloseableResources_Second"); - resource2Date = new Date(); - Thread.sleep(10000); - } - } - -} \ No newline at end of file diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java deleted file mode 100644 index 4efa625ccd..0000000000 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/optional/PersonRepositoryUnitTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.optional; - -import org.junit.Test; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class PersonRepositoryUnitTest { - - PersonRepository personRepository = new PersonRepository(); - - @Test - public void whenIdIsNull_thenExceptionIsThrown() { - assertThrows(IllegalArgumentException.class, - () -> - Optional - .ofNullable(personRepository.findNameById(null)) - .orElseThrow(IllegalArgumentException::new)); - } - - @Test - public void whenIdIsNonNull_thenNoExceptionIsThrown() { - assertAll( - () -> - Optional - .ofNullable(personRepository.findNameById("id")) - .orElseThrow(RuntimeException::new)); - } - - @Test - public void whenIdNonNull_thenReturnsNameUpperCase() { - String name = Optional - .ofNullable(personRepository.findNameById("id")) - .map(String::toUpperCase) - .orElseThrow(RuntimeException::new); - - assertEquals("NAME", name); - } - -} \ No newline at end of file diff --git a/core-java-modules/core-java-lang/src/test/resources/correctFileNameWithoutProperExtension b/core-java-modules/core-java-exceptions/src/test/resources/correctFileNameWithoutProperExtension similarity index 100% rename from core-java-modules/core-java-lang/src/test/resources/correctFileNameWithoutProperExtension rename to core-java-modules/core-java-exceptions/src/test/resources/correctFileNameWithoutProperExtension diff --git a/core-java-modules/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md index 096e4ee002..3d2ecc3a09 100644 --- a/core-java-modules/core-java-lang-oop-2/README.md +++ b/core-java-modules/core-java-lang-oop-2/README.md @@ -13,4 +13,5 @@ - [Immutable Objects in Java](https://www.baeldung.com/java-immutable-object) - [Inheritance and Composition (Is-a vs Has-a relationship) in Java](https://www.baeldung.com/java-inheritance-composition) - [A Guide to Constructors in Java](https://www.baeldung.com/java-constructors) -- [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods) \ No newline at end of file +- [Composition, Aggregation, and Association in Java](https://www.baeldung.com/java-composition-aggregation-association) +- [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods) diff --git a/core-java-modules/core-java-lang-operators/README.md b/core-java-modules/core-java-lang-operators/README.md new file mode 100644 index 0000000000..280c630882 --- /dev/null +++ b/core-java-modules/core-java-lang-operators/README.md @@ -0,0 +1,6 @@ +## Relevant Articles: +- [Guide to the Diamond Operator in Java](https://www.baeldung.com/java-diamond-operator) +- [Ternary Operator In Java](https://www.baeldung.com/java-ternary-operator) +- [The Modulo Operator in Java](https://www.baeldung.com/modulo-java) +- [Java instanceof Operator](https://www.baeldung.com/java-instanceof) +- [A Guide to Increment and Decrement Unary Operators in Java](https://www.baeldung.com/java-unary-operators) diff --git a/core-java-modules/core-java-lang/README.md b/core-java-modules/core-java-lang/README.md index f3b6d3d8e5..6e619c1c4e 100644 --- a/core-java-modules/core-java-lang/README.md +++ b/core-java-modules/core-java-lang/README.md @@ -4,30 +4,22 @@ ### Relevant Articles: -- [Generate equals() and hashCode() with Eclipse](http://www.baeldung.com/java-eclipse-equals-and-hashcode) -- [Chained Exceptions in Java](http://www.baeldung.com/java-chained-exceptions) -- [Iterating Over Enum Values in Java](http://www.baeldung.com/java-enum-iteration) -- [Java Double Brace Initialization](http://www.baeldung.com/java-double-brace-initialization) -- [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator) -- [Comparator and Comparable in Java](http://www.baeldung.com/java-comparator-comparable) -- [The Java continue and break Keywords](http://www.baeldung.com/java-continue-and-break) -- [Nested Classes in Java](http://www.baeldung.com/java-nested-classes) -- [A Guide to Inner Interfaces in Java](http://www.baeldung.com/java-inner-interfaces) -- [Recursion In Java](http://www.baeldung.com/java-recursion) -- [A Guide to the finalize Method in Java](http://www.baeldung.com/java-finalize) -- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java) -- [Quick Guide to java.lang.System](http://www.baeldung.com/java-lang-system) -- [Using Java Assertions](http://www.baeldung.com/java-assert) -- [ClassNotFoundException vs NoClassDefFoundError](http://www.baeldung.com/java-classnotfoundexception-and-noclassdeffounderror) -- [The StackOverflowError in Java](http://www.baeldung.com/java-stack-overflow-error) -- [Create a Custom Exception in Java](http://www.baeldung.com/java-new-custom-exception) -- [Exception Handling in Java](http://www.baeldung.com/java-exceptions) -- [Differences Between Final, Finally and Finalize in Java](https://www.baeldung.com/java-final-finally-finalize) +- [Generate equals() and hashCode() with Eclipse](https://www.baeldung.com/java-eclipse-equals-and-hashcode) +- [Iterating Over Enum Values in Java](https://www.baeldung.com/java-enum-iteration) +- [Java Double Brace Initialization](https://www.baeldung.com/java-double-brace-initialization) +- [Guide to the Diamond Operator in Java](https://www.baeldung.com/java-diamond-operator) +- [Comparator and Comparable in Java](https://www.baeldung.com/java-comparator-comparable) +- [The Java continue and break Keywords](https://www.baeldung.com/java-continue-and-break) +- [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) +- [Recursion In Java](https://www.baeldung.com/java-recursion) +- [A Guide to the finalize Method in Java](https://www.baeldung.com/java-finalize) +- [Infinite Loops in Java](https://www.baeldung.com/infinite-loops-java) +- [Quick Guide to java.lang.System](https://www.baeldung.com/java-lang-system) +- [Using Java Assertions](https://www.baeldung.com/java-assert) - [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding) -- [Difference Between Throw and Throws in Java](https://www.baeldung.com/java-throw-throws) - [Synthetic Constructs in Java](https://www.baeldung.com/java-synthetic) - [How to Separate Double into Integer and Decimal Parts](https://www.baeldung.com/java-separate-double-into-integer-decimal-parts) -- [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws) - [Retrieving a Class Name in Java](https://www.baeldung.com/java-class-name) - [Java Compound Operators](https://www.baeldung.com/java-compound-operators) - [Guide to Java Packages](https://www.baeldung.com/java-packages) @@ -38,3 +30,4 @@ - [Attaching Values to Java Enum](https://www.baeldung.com/java-enum-values) - [Variable Scope in Java](https://www.baeldung.com/java-variable-scope) - [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) +- [A Guide to Java Enums](https://www.baeldung.com/a-guide-to-java-enums) diff --git a/core-java-modules/core-java-lang/pom.xml b/core-java-modules/core-java-lang/pom.xml index 8311636873..1a2b86f872 100644 --- a/core-java-modules/core-java-lang/pom.xml +++ b/core-java-modules/core-java-lang/pom.xml @@ -43,12 +43,6 @@ log4j-over-slf4j ${org.slf4j.version} - - org.projectlombok - lombok - ${lombok.version} - provided - org.assertj @@ -56,11 +50,6 @@ ${assertj-core.version} test - - javax.mail - mail - ${javax.mail.version} - @@ -75,9 +64,6 @@ 2.8.2 - - 1.5.0-b01 - 3.10.0 diff --git a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java deleted file mode 100644 index c2908b7278..0000000000 --- a/core-java-modules/core-java-lang/src/main/java/com/baeldung/exceptionhandling/MyException.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baeldung.exceptionhandling; - -public class MyException extends Throwable { - -} diff --git a/core-java-modules/core-java-security/README.md b/core-java-modules/core-java-security/README.md index a833ca30bb..00449575b0 100644 --- a/core-java-modules/core-java-security/README.md +++ b/core-java-modules/core-java-security/README.md @@ -11,3 +11,4 @@ - [SHA-256 and SHA3-256 Hashing in Java](https://www.baeldung.com/sha-256-hashing-java) - [Enabling TLS v1.2 in Java 7](https://www.baeldung.com/java-7-tls-v12) - [The Java SecureRandom Class](https://www.baeldung.com/java-secure-random) +- [An Introduction to Java SASL](https://www.baeldung.com/java-sasl) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 082ffbef53..68ece1c473 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -15,7 +15,6 @@ pre-jpms - core-java-exceptions core-java-optional core-java-lang-operators core-java-networking-2 diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsUnitTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsUnitTest.kt new file mode 100644 index 0000000000..6fa7983689 --- /dev/null +++ b/core-kotlin-2/src/test/kotlin/com/baeldung/lists/ListsUnitTest.kt @@ -0,0 +1,34 @@ +package com.baeldung.lists + +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class ListsUnitTest { + + var batmans: List = listOf("Christian Bale", "Michael Keaton", "Ben Affleck", "George Clooney") + + @Test + fun whenFindASpecificItem_thenItemIsReturned() { + //Returns the first element matching the given predicate, or null if no such element was found. + val theFirstBatman = batmans.find { actor -> "Michael Keaton".equals(actor) } + assertEquals(theFirstBatman, "Michael Keaton") + } + + @Test + fun whenFilterWithPredicate_thenMatchingItemsAreReturned() { + //Returns a list containing only elements matching the given predicate. + val theCoolestBatmans = batmans.filter { actor -> actor.contains("a") } + assertTrue(theCoolestBatmans.contains("Christian Bale") && theCoolestBatmans.contains("Michael Keaton")) + } + + @Test + fun whenFilterNotWithPredicate_thenMatchingItemsAreReturned() { + //Returns a list containing only elements not matching the given predicate. + val theMehBatmans = batmans.filterNot { actor -> actor.contains("a") } + assertFalse(theMehBatmans.contains("Christian Bale") && theMehBatmans.contains("Michael Keaton")) + assertTrue(theMehBatmans.contains("Ben Affleck") && theMehBatmans.contains("George Clooney")) + } + +} \ No newline at end of file diff --git a/core-kotlin/README.md b/core-kotlin/README.md index 8d42a32e91..bdff95d36d 100644 --- a/core-kotlin/README.md +++ b/core-kotlin/README.md @@ -4,37 +4,37 @@ This module contains articles about core Kotlin. ### Relevant articles: -- [Introduction to the Kotlin Language](http://www.baeldung.com/kotlin) -- [Guide to the “when{}” Block in Kotlin](http://www.baeldung.com/kotlin-when) -- [Comprehensive Guide to Null Safety in Kotlin](http://www.baeldung.com/kotlin-null-safety) -- [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability) -- [Difference Between “==” and “===” operators in Kotlin](http://www.baeldung.com/kotlin-equality-operators) -- [Generics in Kotlin](http://www.baeldung.com/kotlin-generics) -- [Introduction to Kotlin Coroutines](http://www.baeldung.com/kotlin-coroutines) -- [Destructuring Declarations in Kotlin](http://www.baeldung.com/kotlin-destructuring-declarations) -- [Lazy Initialization in Kotlin](http://www.baeldung.com/kotlin-lazy-initialization) -- [Overview of Kotlin Collections API](http://www.baeldung.com/kotlin-collections-api) -- [Converting a List to Map in Kotlin](http://www.baeldung.com/kotlin-list-to-map) -- [Data Classes in Kotlin](http://www.baeldung.com/kotlin-data-classes) -- [Delegated Properties in Kotlin](http://www.baeldung.com/kotlin-delegated-properties) -- [Sealed Classes in Kotlin](http://www.baeldung.com/kotlin-sealed-classes) -- [JUnit 5 for Kotlin Developers](http://www.baeldung.com/junit-5-kotlin) -- [Extension Methods in Kotlin](http://www.baeldung.com/kotlin-extension-methods) -- [Infix Functions in Kotlin](http://www.baeldung.com/kotlin-infix-functions) -- [Try-with-resources in Kotlin](http://www.baeldung.com/kotlin-try-with-resources) -- [Regular Expressions in Kotlin](http://www.baeldung.com/kotlin-regular-expressions) -- [Objects in Kotlin](http://www.baeldung.com/kotlin-objects) -- [Reading from a File in Kotlin](http://www.baeldung.com/kotlin-read-file) -- [Guide to Kotlin @JvmField](http://www.baeldung.com/kotlin-jvm-field-annotation) -- [Filtering Kotlin Collections](http://www.baeldung.com/kotlin-filter-collection) -- [Writing to a File in Kotlin](http://www.baeldung.com/kotlin-write-file) -- [Lambda Expressions in Kotlin](http://www.baeldung.com/kotlin-lambda-expressions) -- [Kotlin String Templates](http://www.baeldung.com/kotlin-string-template) -- [Working with Enums in Kotlin](http://www.baeldung.com/kotlin-enum) -- [Create a Java and Kotlin Project with Maven](http://www.baeldung.com/kotlin-maven-java-project) -- [Reflection with Kotlin](http://www.baeldung.com/kotlin-reflection) -- [Get a Random Number in Kotlin](http://www.baeldung.com/kotlin-random-number) -- [Idiomatic Logging in Kotlin](http://www.baeldung.com/kotlin-logging) +- [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) +- [Reading from a File in Kotlin](https://www.baeldung.com/kotlin-read-file) +- [Guide to Kotlin @JvmField](https://www.baeldung.com/kotlin-jvm-field-annotation) +- [Filtering Kotlin Collections](https://www.baeldung.com/kotlin-filter-collection) +- [Writing to a File in Kotlin](https://www.baeldung.com/kotlin-write-file) +- [Lambda Expressions in Kotlin](https://www.baeldung.com/kotlin-lambda-expressions) +- [Kotlin String Templates](https://www.baeldung.com/kotlin-string-template) +- [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) diff --git a/couchbase/README.md b/couchbase/README.md index 7a99ce4299..c4c7df97da 100644 --- a/couchbase/README.md +++ b/couchbase/README.md @@ -1,11 +1,11 @@ ## Couchbase SDK Tutorial Project ### Relevant Articles: -- [Introduction to Couchbase SDK for Java](http://www.baeldung.com/java-couchbase-sdk) -- [Using Couchbase in a Spring Application](http://www.baeldung.com/couchbase-sdk-spring) -- [Asynchronous Batch Operations in Couchbase](http://www.baeldung.com/async-batch-operations-in-couchbase) -- [Querying Couchbase with MapReduce Views](http://www.baeldung.com/couchbase-query-mapreduce-view) -- [Querying Couchbase with N1QL](http://www.baeldung.com/n1ql-couchbase) +- [Introduction to Couchbase SDK for Java](https://www.baeldung.com/java-couchbase-sdk) +- [Using Couchbase in a Spring Application](https://www.baeldung.com/couchbase-sdk-spring) +- [Asynchronous Batch Operations in Couchbase](https://www.baeldung.com/async-batch-operations-in-couchbase) +- [Querying Couchbase with MapReduce Views](https://www.baeldung.com/couchbase-query-mapreduce-view) +- [Querying Couchbase with N1QL](https://www.baeldung.com/n1ql-couchbase) ### Overview This Maven project contains the Java code for the Couchbase entities and Spring services diff --git a/dagger/README.md b/dagger/README.md index 72cba3d3f2..81dc161ca1 100644 --- a/dagger/README.md +++ b/dagger/README.md @@ -1,3 +1,3 @@ ### Relevant articles: -- [Introduction to Dagger 2](http://www.baeldung.com/dagger-2) +- [Introduction to Dagger 2](https://www.baeldung.com/dagger-2) diff --git a/deeplearning4j/README.md b/deeplearning4j/README.md index 14e585cd97..eb1e19daa1 100644 --- a/deeplearning4j/README.md +++ b/deeplearning4j/README.md @@ -2,4 +2,4 @@ This is a sample project for the [deeplearning4j](https://deeplearning4j.org) library. ### Relevant Articles: -- [A Guide to Deeplearning4j](http://www.baeldung.com/deeplearning4j) +- [A Guide to Deeplearning4j](https://www.baeldung.com/deeplearning4j) diff --git a/disruptor/README.md b/disruptor/README.md index 779b1e89c4..8f977d090a 100644 --- a/disruptor/README.md +++ b/disruptor/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [Concurrency with LMAX Disruptor – An Introduction](http://www.baeldung.com/lmax-disruptor-concurrency) +- [Concurrency with LMAX Disruptor – An Introduction](https://www.baeldung.com/lmax-disruptor-concurrency) diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000000..7948b3d663 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,3 @@ +## Relevant Articles: + +- [Introduction to Docker Compose](https://www.baeldung.com/docker-compose) diff --git a/dozer/README.md b/dozer/README.md index 5e104d914c..2e610b836a 100644 --- a/dozer/README.md +++ b/dozer/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [A Guide to Mapping With Dozer](http://www.baeldung.com/dozer) +- [A Guide to Mapping With Dozer](https://www.baeldung.com/dozer) diff --git a/drools/README.MD b/drools/README.MD index 5efbe0d3c3..1ff3dfba20 100644 --- a/drools/README.MD +++ b/drools/README.MD @@ -1,4 +1,4 @@ ### Relevant Articles: -- [Introduction to Drools](http://www.baeldung.com/drools) -- [Drools Using Rules from Excel Files](http://www.baeldung.com/drools-excel) -- [An Example of Backward Chaining in Drools](http://www.baeldung.com/drools-backward-chaining) +- [Introduction to Drools](https://www.baeldung.com/drools) +- [Drools Using Rules from Excel Files](https://www.baeldung.com/drools-excel) +- [An Example of Backward Chaining in Drools](https://www.baeldung.com/drools-backward-chaining) diff --git a/dubbo/README.md b/dubbo/README.md index 0a4cd9a204..566efe28f5 100644 --- a/dubbo/README.md +++ b/dubbo/README.md @@ -1,4 +1,4 @@ ## Relevant articles: -- [Introduction to Dubbo](http://www.baeldung.com/dubbo) +- [Introduction to Dubbo](https://www.baeldung.com/dubbo) diff --git a/ethereum/README.md b/ethereum/README.md index d06ca09636..7eccea7135 100644 --- a/ethereum/README.md +++ b/ethereum/README.md @@ -1,6 +1,6 @@ ## Ethereum ### Relevant Articles: -- [Introduction to EthereumJ](http://www.baeldung.com/ethereumj) -- [Creating and Deploying Smart Contracts with Solidity](http://www.baeldung.com/smart-contracts-ethereum-solidity) -- [Lightweight Ethereum Clients Using Web3j](http://www.baeldung.com/web3j) +- [Introduction to EthereumJ](https://www.baeldung.com/ethereumj) +- [Creating and Deploying Smart Contracts with Solidity](https://www.baeldung.com/smart-contracts-ethereum-solidity) +- [Lightweight Ethereum Clients Using Web3j](https://www.baeldung.com/web3j) diff --git a/feign/README.md b/feign/README.md index da04c40cdc..5aa0e3f56f 100644 --- a/feign/README.md +++ b/feign/README.md @@ -6,5 +6,5 @@ This is the implementation of a [spring-hypermedia-api][1] client using Feign. ### Relevant Articles: -- [Intro to Feign](http://www.baeldung.com/intro-to-feign) -- [Introduction to SLF4J](http://www.baeldung.com/slf4j-with-log4j2-logback) +- [Intro to Feign](https://www.baeldung.com/intro-to-feign) +- [Introduction to SLF4J](https://www.baeldung.com/slf4j-with-log4j2-logback) diff --git a/geotools/README.md b/geotools/README.md index 188ff0fddb..98f1e2c283 100644 --- a/geotools/README.md +++ b/geotools/README.md @@ -1,3 +1,3 @@ ### Relevant Articles -[Introduction to GeoTools](http://www.baeldung.com/geo-tools) +[Introduction to GeoTools](https://www.baeldung.com/geo-tools) diff --git a/google-cloud/README.md b/google-cloud/README.md index 87ca17eac4..c6c49b88bf 100644 --- a/google-cloud/README.md +++ b/google-cloud/README.md @@ -1,7 +1,7 @@ ## Google Cloud Tutorial Project ### Relevant Article: -- [Intro to Google Cloud Storage With Java](http://www.baeldung.com/java-google-cloud-storage) +- [Intro to Google Cloud Storage With Java](https://www.baeldung.com/java-google-cloud-storage) ### Overview This Maven project contains the Java code for the article linked above. diff --git a/google-web-toolkit/README.md b/google-web-toolkit/README.md index 3526fe9962..d2a8b324ec 100644 --- a/google-web-toolkit/README.md +++ b/google-web-toolkit/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Introduction to GWT](http://www.baeldung.com/gwt) +- [Introduction to GWT](https://www.baeldung.com/gwt) diff --git a/gradle/README.md b/gradle/README.md index 14e460f225..0ad0ff3e45 100644 --- a/gradle/README.md +++ b/gradle/README.md @@ -1,6 +1,6 @@ ## Relevant articles: -- [Introduction to Gradle](http://www.baeldung.com/gradle) -- [Writing Custom Gradle Plugins](http://www.baeldung.com/gradle-create-plugin) -- [Creating a Fat Jar in Gradle](http://www.baeldung.com/gradle-fat-jar) -- [A Custom Task in Gradle](http://www.baeldung.com/gradle-custom-task) +- [Introduction to Gradle](https://www.baeldung.com/gradle) +- [Writing Custom Gradle Plugins](https://www.baeldung.com/gradle-create-plugin) +- [Creating a Fat Jar in Gradle](https://www.baeldung.com/gradle-fat-jar) +- [A Custom Task in Gradle](https://www.baeldung.com/gradle-custom-task) - [Using JUnit 5 with Gradle](https://www.baeldung.com/junit-5-gradle) diff --git a/grails/README.md b/grails/README.md index faa50a7efd..b93ac5de2e 100644 --- a/grails/README.md +++ b/grails/README.md @@ -1,3 +1,3 @@ ### Relevant articles -- [Build an MVC Web Application with Grails](http://www.baeldung.com/grails-mvc-application) +- [Build an MVC Web Application with Grails](https://www.baeldung.com/grails-mvc-application) diff --git a/graphql/graphql-java/README.md b/graphql/graphql-java/README.md index 0033524209..240b62f6b4 100644 --- a/graphql/graphql-java/README.md +++ b/graphql/graphql-java/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [Introduction to GraphQL](http://www.baeldung.com/graphql) +- [Introduction to GraphQL](https://www.baeldung.com/graphql) diff --git a/grpc/README.md b/grpc/README.md index 5a60ca2e7e..17128dd19f 100644 --- a/grpc/README.md +++ b/grpc/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Introduction to gRPC](http://www.baeldung.com/grpc-introduction) +- [Introduction to gRPC](https://www.baeldung.com/grpc-introduction) diff --git a/gson/README.md b/gson/README.md index 268116a2ac..8b882f2d3e 100644 --- a/gson/README.md +++ b/gson/README.md @@ -4,9 +4,9 @@ ### Relevant Articles: -- [Gson Deserialization Cookbook](http://www.baeldung.com/gson-deserialization-guide) -- [Jackson vs Gson](http://www.baeldung.com/jackson-vs-gson) -- [Exclude Fields from Serialization in Gson](http://www.baeldung.com/gson-exclude-fields-serialization) +- [Gson Deserialization Cookbook](https://www.baeldung.com/gson-deserialization-guide) +- [Jackson vs Gson](https://www.baeldung.com/jackson-vs-gson) +- [Exclude Fields from Serialization in Gson](https://www.baeldung.com/gson-exclude-fields-serialization) - [Save Data to a JSON File with Gson](https://www.baeldung.com/gson-save-file) - [Convert JSON to a Map Using Gson](https://www.baeldung.com/gson-json-to-map) - [Working with Primitive Values in Gson](https://www.baeldung.com/java-gson-primitives) diff --git a/guava-collections-set/README.md b/guava-collections-set/README.md index c36d9e0b61..e24552aae8 100644 --- a/guava-collections-set/README.md +++ b/guava-collections-set/README.md @@ -2,7 +2,7 @@ ## Relevant Articles: -- [Guava – Sets](http://www.baeldung.com/guava-sets) -- [Guide to Guava RangeSet](http://www.baeldung.com/guava-rangeset) -- [Guava Set + Function = Map](http://www.baeldung.com/guava-set-function-map-tutorial) +- [Guava – Sets](https://www.baeldung.com/guava-sets) +- [Guide to Guava RangeSet](https://www.baeldung.com/guava-rangeset) +- [Guava Set + Function = Map](https://www.baeldung.com/guava-set-function-map-tutorial) - [Guide to Guava Multiset](https://www.baeldung.com/guava-multiset) diff --git a/guava-collections/README.md b/guava-collections/README.md index e919a98c2b..95397f0ff0 100644 --- a/guava-collections/README.md +++ b/guava-collections/README.md @@ -4,17 +4,17 @@ ### Relevant Articles: -- [Guava Collections Cookbook](http://www.baeldung.com/guava-collections) -- [Guava Ordering Cookbook](http://www.baeldung.com/guava-order) -- [Hamcrest Collections Cookbook](http://www.baeldung.com/hamcrest-collections-arrays) -- [Partition a List in Java](http://www.baeldung.com/java-list-split) -- [Filtering and Transforming Collections in Guava](http://www.baeldung.com/guava-filter-and-transform-a-collection) -- [Guava – Join and Split Collections](http://www.baeldung.com/guava-joiner-and-splitter-tutorial) -- [Guava – Lists](http://www.baeldung.com/guava-lists) -- [Guava – Maps](http://www.baeldung.com/guava-maps) -- [Guide to Guava Multimap](http://www.baeldung.com/guava-multimap) -- [Guide to Guava RangeMap](http://www.baeldung.com/guava-rangemap) -- [Guide to Guava MinMaxPriorityQueue and EvictingQueue](http://www.baeldung.com/guava-minmax-priority-queue-and-evicting-queue) +- [Guava Collections Cookbook](https://www.baeldung.com/guava-collections) +- [Guava Ordering Cookbook](https://www.baeldung.com/guava-order) +- [Hamcrest Collections Cookbook](https://www.baeldung.com/hamcrest-collections-arrays) +- [Partition a List in Java](https://www.baeldung.com/java-list-split) +- [Filtering and Transforming Collections in Guava](https://www.baeldung.com/guava-filter-and-transform-a-collection) +- [Guava – Join and Split Collections](https://www.baeldung.com/guava-joiner-and-splitter-tutorial) +- [Guava – Lists](https://www.baeldung.com/guava-lists) +- [Guava – Maps](https://www.baeldung.com/guava-maps) +- [Guide to Guava Multimap](https://www.baeldung.com/guava-multimap) +- [Guide to Guava RangeMap](https://www.baeldung.com/guava-rangemap) +- [Guide to Guava MinMaxPriorityQueue and EvictingQueue](https://www.baeldung.com/guava-minmax-priority-queue-and-evicting-queue) - [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) -- [Guide to Guava Table](http://www.baeldung.com/guava-table) -- [Guide to Guava ClassToInstanceMap](http://www.baeldung.com/guava-class-to-instance-map) \ No newline at end of file +- [Guide to Guava Table](https://www.baeldung.com/guava-table) +- [Guide to Guava ClassToInstanceMap](https://www.baeldung.com/guava-class-to-instance-map) diff --git a/guava-io/README.md b/guava-io/README.md index df7775a36d..0737accbed 100644 --- a/guava-io/README.md +++ b/guava-io/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: -- [Using Guava CountingOutputStream](http://www.baeldung.com/guava-counting-outputstream) -- [Guava – Write to File, Read from File](http://www.baeldung.com/guava-write-to-file-read-from-file) +- [Using Guava CountingOutputStream](https://www.baeldung.com/guava-counting-outputstream) +- [Guava – Write to File, Read from File](https://www.baeldung.com/guava-write-to-file-read-from-file) diff --git a/guava/README.md b/guava/README.md index d3bbbf6de5..a9694daf0b 100644 --- a/guava/README.md +++ b/guava/README.md @@ -2,14 +2,14 @@ ## Guava Examples ### Relevant Articles: -- [Guava Functional Cookbook](http://www.baeldung.com/guava-functions-predicates) -- [Guide to Guava’s Ordering](http://www.baeldung.com/guava-ordering) -- [Guide to Guava’s PreConditions](http://www.baeldung.com/guava-preconditions) -- [Introduction to Guava CacheLoader](http://www.baeldung.com/guava-cacheloader) -- [Introduction to Guava Memoizer](http://www.baeldung.com/guava-memoizer) -- [Guide to Guava’s EventBus](http://www.baeldung.com/guava-eventbus) -- [Guide to Guava’s Reflection Utilities](http://www.baeldung.com/guava-reflection) -- [Guide to Mathematical Utilities in Guava](http://www.baeldung.com/guava-math) -- [Bloom Filter in Java using Guava](http://www.baeldung.com/guava-bloom-filter) -- [Quick Guide to the Guava RateLimiter](http://www.baeldung.com/guava-rate-limiter) +- [Guava Functional Cookbook](https://www.baeldung.com/guava-functions-predicates) +- [Guide to Guava’s Ordering](https://www.baeldung.com/guava-ordering) +- [Guide to Guava’s PreConditions](https://www.baeldung.com/guava-preconditions) +- [Introduction to Guava CacheLoader](https://www.baeldung.com/guava-cacheloader) +- [Introduction to Guava Memoizer](https://www.baeldung.com/guava-memoizer) +- [Guide to Guava’s EventBus](https://www.baeldung.com/guava-eventbus) +- [Guide to Guava’s Reflection Utilities](https://www.baeldung.com/guava-reflection) +- [Guide to Mathematical Utilities in Guava](https://www.baeldung.com/guava-math) +- [Bloom Filter in Java using Guava](https://www.baeldung.com/guava-bloom-filter) +- [Quick Guide to the Guava RateLimiter](https://www.baeldung.com/guava-rate-limiter) diff --git a/guice/README.md b/guice/README.md index 77c788c363..cc3a8755c0 100644 --- a/guice/README.md +++ b/guice/README.md @@ -1,5 +1,5 @@ ## Google Guice Tutorials Project ### Relevant Articles -- [Guide to Google Guice](http://www.baeldung.com/guice) +- [Guide to Google Guice](https://www.baeldung.com/guice) - [Guice vs Spring – Dependency Injection](https://www.baeldung.com/guice-spring-dependency-injection) diff --git a/hazelcast/README.md b/hazelcast/README.md index 7adb13f2af..8ba6dc122b 100644 --- a/hazelcast/README.md +++ b/hazelcast/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Guide to Hazelcast with Java](http://www.baeldung.com/java-hazelcast) +- [Guide to Hazelcast with Java](https://www.baeldung.com/java-hazelcast) - [Introduction to Hazelcast Jet](https://www.baeldung.com/hazelcast-jet) diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index e3535a133e..13a539d794 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -1,12 +1,12 @@ ========= ## This module contains articles that are part of the HTTPClient Ebook -- [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) -- [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl) -- [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout) -- [HttpClient 4 – Send Custom Cookie](http://www.baeldung.com/httpclient-4-cookies) -- [Custom HTTP Header with the HttpClient](http://www.baeldung.com/httpclient-custom-http-header) -- [HttpClient Basic Authentication](http://www.baeldung.com/httpclient-4-basic-authentication) +- [HttpClient 4 – Get the Status Code](https://www.baeldung.com/httpclient-status-code) +- [HttpClient with SSL](https://www.baeldung.com/httpclient-ssl) +- [HttpClient Timeout](https://www.baeldung.com/httpclient-timeout) +- [HttpClient 4 – Send Custom Cookie](https://www.baeldung.com/httpclient-4-cookies) +- [Custom HTTP Header with the HttpClient](https://www.baeldung.com/httpclient-custom-http-header) +- [HttpClient Basic Authentication](https://www.baeldung.com/httpclient-4-basic-authentication) - [Posting with HttpClient](https://www.baeldung.com/httpclient-post-http-request) diff --git a/httpclient/README.md b/httpclient/README.md index a5fc29b089..6bce5567ec 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -7,13 +7,13 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [HttpClient 4 – Cancel Request](http://www.baeldung.com/httpclient-cancel-request) -- [HttpClient 4 Cookbook](http://www.baeldung.com/httpclient4) -- [Unshorten URLs with HttpClient](http://www.baeldung.com/unshorten-url-httpclient) -- [HttpClient 4 – Follow Redirects for POST](http://www.baeldung.com/httpclient-redirect-on-http-post) -- [Multipart Upload with HttpClient 4](http://www.baeldung.com/httpclient-multipart-upload) -- [HttpAsyncClient Tutorial](http://www.baeldung.com/httpasyncclient-tutorial) -- [HttpClient 4 Tutorial](http://www.baeldung.com/httpclient-guide) -- [Advanced HttpClient Configuration](http://www.baeldung.com/httpclient-advanced-config) -- [HttpClient 4 – Do Not Follow Redirects](http://www.baeldung.com/httpclient-stop-follow-redirect) -- [Custom User-Agent in HttpClient 4](http://www.baeldung.com/httpclient-user-agent-header) +- [HttpClient 4 – Cancel Request](https://www.baeldung.com/httpclient-cancel-request) +- [HttpClient 4 Cookbook](https://www.baeldung.com/httpclient4) +- [Unshorten URLs with HttpClient](https://www.baeldung.com/unshorten-url-httpclient) +- [HttpClient 4 – Follow Redirects for POST](https://www.baeldung.com/httpclient-redirect-on-http-post) +- [Multipart Upload with HttpClient 4](https://www.baeldung.com/httpclient-multipart-upload) +- [HttpAsyncClient Tutorial](https://www.baeldung.com/httpasyncclient-tutorial) +- [HttpClient 4 Tutorial](https://www.baeldung.com/httpclient-guide) +- [Advanced HttpClient Configuration](https://www.baeldung.com/httpclient-advanced-config) +- [HttpClient 4 – Do Not Follow Redirects](https://www.baeldung.com/httpclient-stop-follow-redirect) +- [Custom User-Agent in HttpClient 4](https://www.baeldung.com/httpclient-user-agent-header) diff --git a/hystrix/README.md b/hystrix/README.md index cc5c8a197f..f35518bce3 100644 --- a/hystrix/README.md +++ b/hystrix/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Hystrix Integration with Existing Spring Application](http://www.baeldung.com/hystrix-integration-with-spring-aop) -- [Introduction to Hystrix](http://www.baeldung.com/introduction-to-hystrix) +- [Hystrix Integration with Existing Spring Application](https://www.baeldung.com/hystrix-integration-with-spring-aop) +- [Introduction to Hystrix](https://www.baeldung.com/introduction-to-hystrix) diff --git a/image-processing/README.md b/image-processing/README.md index 48604bdb1f..2dd74d7c47 100644 --- a/image-processing/README.md +++ b/image-processing/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Working with Images in Java](http://www.baeldung.com/java-images) +- [Working with Images in Java](https://www.baeldung.com/java-images) diff --git a/immutables/README.md b/immutables/README.md index b69a14f035..2ea4f4fe50 100644 --- a/immutables/README.md +++ b/immutables/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Introduction to Immutables](http://www.baeldung.com/immutables) +- [Introduction to Immutables](https://www.baeldung.com/immutables) diff --git a/jackson-simple/README.md b/jackson-simple/README.md index be647e22d5..79538c6929 100644 --- a/jackson-simple/README.md +++ b/jackson-simple/README.md @@ -5,9 +5,9 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Jackson Ignore Properties on Marshalling](http://www.baeldung.com/jackson-ignore-properties-on-serialization) -- [Jackson Unmarshalling json with Unknown Properties](http://www.baeldung.com/jackson-deserialize-json-unknown-properties) -- [Jackson Annotation Examples](http://www.baeldung.com/jackson-annotations) -- [Intro to the Jackson ObjectMapper](http://www.baeldung.com/jackson-object-mapper-tutorial) -- [Ignore Null Fields with Jackson](http://www.baeldung.com/jackson-ignore-null-fields) -- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) +- [Jackson Ignore Properties on Marshalling](https://www.baeldung.com/jackson-ignore-properties-on-serialization) +- [Jackson Unmarshalling json with Unknown Properties](https://www.baeldung.com/jackson-deserialize-json-unknown-properties) +- [Jackson Annotation Examples](https://www.baeldung.com/jackson-annotations) +- [Intro to the Jackson ObjectMapper](https://www.baeldung.com/jackson-object-mapper-tutorial) +- [Ignore Null Fields with Jackson](https://www.baeldung.com/jackson-ignore-null-fields) +- [Jackson – Change Name of Field](https://www.baeldung.com/jackson-name-of-property) diff --git a/jackson/README.md b/jackson/README.md index 01d9419a27..fb7f6c4127 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -6,29 +6,29 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) -- [Jackson – Custom Serializer](http://www.baeldung.com/jackson-custom-serialization) -- [Getting Started with Custom Deserialization in Jackson](http://www.baeldung.com/jackson-deserialization) -- [Jackson Exceptions – Problems and Solutions](http://www.baeldung.com/jackson-exception) -- [Jackson Date](http://www.baeldung.com/jackson-serialize-dates) -- [Jackson – Bidirectional Relationships](http://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion) -- [Jackson JSON Tutorial](http://www.baeldung.com/jackson) -- [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) -- [Jackson – Decide What Fields Get Serialized/Deserialized](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) -- [Jackson vs Gson](http://www.baeldung.com/jackson-vs-gson) -- [XML Serialization and Deserialization with Jackson](http://www.baeldung.com/jackson-xml-serialization-and-deserialization) -- [More Jackson Annotations](http://www.baeldung.com/jackson-advanced-annotations) -- [Inheritance with Jackson](http://www.baeldung.com/jackson-inheritance) -- [Guide to @JsonFormat in Jackson](http://www.baeldung.com/jackson-jsonformat) -- [Using Optional with Jackson](http://www.baeldung.com/jackson-optional) -- [Map Serialization and Deserialization with Jackson](http://www.baeldung.com/jackson-map) -- [Jackson Streaming API](http://www.baeldung.com/jackson-streaming-api) -- [Jackson – JsonMappingException (No serializer found for class)](http://www.baeldung.com/jackson-jsonmappingexception) -- [How To Serialize Enums as JSON Objects with Jackson](http://www.baeldung.com/jackson-serialize-enums) -- [Jackson – Marshall String to JsonNode](http://www.baeldung.com/jackson-json-to-jsonnode) -- [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) -- [Serialize Only Fields that meet a Custom Criteria with Jackson](http://www.baeldung.com/jackson-serialize-field-custom-criteria) -- [Mapping Nested Values with Jackson](http://www.baeldung.com/jackson-nested-values) +- [Jackson – Unmarshall to Collection/Array](https://www.baeldung.com/jackson-collection-array) +- [Jackson – Custom Serializer](https://www.baeldung.com/jackson-custom-serialization) +- [Getting Started with Custom Deserialization in Jackson](https://www.baeldung.com/jackson-deserialization) +- [Jackson Exceptions – Problems and Solutions](https://www.baeldung.com/jackson-exception) +- [Jackson Date](https://www.baeldung.com/jackson-serialize-dates) +- [Jackson – Bidirectional Relationships](https://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion) +- [Jackson JSON Tutorial](https://www.baeldung.com/jackson) +- [Jackson – Working with Maps and nulls](https://www.baeldung.com/jackson-map-null-values-or-null-key) +- [Jackson – Decide What Fields Get Serialized/Deserialized](https://www.baeldung.com/jackson-field-serializable-deserializable-or-not) +- [Jackson vs Gson](https://www.baeldung.com/jackson-vs-gson) +- [XML Serialization and Deserialization with Jackson](https://www.baeldung.com/jackson-xml-serialization-and-deserialization) +- [More Jackson Annotations](https://www.baeldung.com/jackson-advanced-annotations) +- [Inheritance with Jackson](https://www.baeldung.com/jackson-inheritance) +- [Guide to @JsonFormat in Jackson](https://www.baeldung.com/jackson-jsonformat) +- [Using Optional with Jackson](https://www.baeldung.com/jackson-optional) +- [Map Serialization and Deserialization with Jackson](https://www.baeldung.com/jackson-map) +- [Jackson Streaming API](https://www.baeldung.com/jackson-streaming-api) +- [Jackson – JsonMappingException (No serializer found for class)](https://www.baeldung.com/jackson-jsonmappingexception) +- [How To Serialize Enums as JSON Objects with Jackson](https://www.baeldung.com/jackson-serialize-enums) +- [Jackson – Marshall String to JsonNode](https://www.baeldung.com/jackson-json-to-jsonnode) +- [Jackson – Unmarshall to Collection/Array](https://www.baeldung.com/jackson-collection-array) +- [Serialize Only Fields that meet a Custom Criteria with Jackson](https://www.baeldung.com/jackson-serialize-field-custom-criteria) +- [Mapping Nested Values with Jackson](https://www.baeldung.com/jackson-nested-values) - [Convert XML to JSON Using Jackson](https://www.baeldung.com/jackson-convert-xml-json) - [Deserialize Immutable Objects with Jackson](https://www.baeldung.com/jackson-deserialize-immutable-objects) - [Mapping a Dynamic JSON Object with Jackson](https://www.baeldung.com/jackson-mapping-dynamic-object) diff --git a/java-blockchain/README.md b/java-blockchain/README.md index 600f4dd610..5afd0d356b 100644 --- a/java-blockchain/README.md +++ b/java-blockchain/README.md @@ -1,6 +1,7 @@ -========= +## Java Blockchain -## Basic Implementation of Blockchian in Java +This module contains articles about Blockchain in Java ### Relevant Articles: -- []() + +- [Implementing a Simple Blockchain in Java](https://www.baeldung.com/java-blockchain) diff --git a/java-collections-conversions/README.md b/java-collections-conversions/README.md index 614f20f186..e80f29f519 100644 --- a/java-collections-conversions/README.md +++ b/java-collections-conversions/README.md @@ -3,12 +3,12 @@ ## Java Collections Cookbooks and Examples ### Relevant Articles: -- [Converting between an Array and a List in Java](http://www.baeldung.com/convert-array-to-list-and-list-to-array) -- [Converting between an Array and a Set in Java](http://www.baeldung.com/convert-array-to-set-and-set-to-array) -- [Converting between a List and a Set in Java](http://www.baeldung.com/convert-list-to-set-and-set-to-list) -- [Convert a Map to an Array, List or Set in Java](http://www.baeldung.com/convert-map-values-to-array-list-set) -- [Converting a List to String in Java](http://www.baeldung.com/java-list-to-string) -- [How to Convert List to Map in Java](http://www.baeldung.com/java-list-to-map) +- [Converting between an Array and a List in Java](https://www.baeldung.com/convert-array-to-list-and-list-to-array) +- [Converting between an Array and a Set in Java](https://www.baeldung.com/convert-array-to-set-and-set-to-array) +- [Converting between a List and a Set in Java](https://www.baeldung.com/convert-list-to-set-and-set-to-list) +- [Convert a Map to an Array, List or Set in Java](https://www.baeldung.com/convert-map-values-to-array-list-set) +- [Converting a List to String in Java](https://www.baeldung.com/java-list-to-string) +- [How to Convert List to Map in Java](https://www.baeldung.com/java-list-to-map) - [Array to String Conversions](https://www.baeldung.com/java-array-to-string) - [Converting a Collection to ArrayList in Java](https://www.baeldung.com/java-convert-collection-arraylist) - [Java 8 Collectors toMap](https://www.baeldung.com/java-collectors-tomap) diff --git a/java-collections-maps-2/README.md b/java-collections-maps-2/README.md index 7aef942ff0..09c4b4fbb3 100644 --- a/java-collections-maps-2/README.md +++ b/java-collections-maps-2/README.md @@ -1,6 +1,7 @@ ## Relevant Articles: - [Map of Primitives in Java](https://www.baeldung.com/java-map-primitives) - [Copying a HashMap in Java](https://www.baeldung.com/java-copy-hashmap) +- [Guide to Java HashMap]() - [Guide to WeakHashMap in Java](https://www.baeldung.com/java-weakhashmap) - [Map to String Conversion in Java](https://www.baeldung.com/java-map-to-string-conversion) - [Iterate over a Map in Java](https://www.baeldung.com/java-iterate-map) diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/Product.java b/java-collections-maps-2/src/main/java/com/baeldung/map/Product.java new file mode 100644 index 0000000000..5559895730 --- /dev/null +++ b/java-collections-maps-2/src/main/java/com/baeldung/map/Product.java @@ -0,0 +1,133 @@ +package com.baeldung.map; + +import java.util.*; + +public class Product { + + private String name; + private String description; + private List tags; + + public Product(String name, String description) { + this.name = name; + this.description = description; + this.tags = new ArrayList<>(); + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public List getTags() { + return tags; + } + + public Product addTagsOfOtherProdcut(Product product) { + this.tags.addAll(product.getTags()); + return this; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Product product = (Product) o; + return Objects.equals(name, product.name) && + Objects.equals(description, product.description); + } + + @Override + public int hashCode() { + return Objects.hash(name, description); + } + + public static void forEach() { + + HashMap productsByName = new HashMap<>(); + productsByName.forEach( (key, product) + -> System.out.println("Key: " + key + " Product:" + product.getDescription()) + //do something with the key and value + ); + + //Prior to Java 8: + for(Map.Entry entry : productsByName.entrySet()) { + Product product = entry.getValue(); + String key = entry.getKey(); + //do something with the key and value + } + } + + public static void getOrDefault() { + + HashMap productsByName = new HashMap<>(); + Product chocolate = new Product("chocolate", "something sweet"); + Product defaultProduct = productsByName.getOrDefault("horse carriage", chocolate); + Product bike = productsByName.getOrDefault("E-Bike", chocolate); + + //Prior to Java 8: + Product bike2 = productsByName.containsKey("E-Bike") + ? productsByName.get("E-Bike") + : chocolate; + Product defaultProduct2 = productsByName.containsKey("horse carriage") + ? productsByName.get("horse carriage") + : chocolate; + } + + public static void putIfAbsent() { + + HashMap productsByName = new HashMap<>(); + Product chocolate = new Product("chocolate", "something sweet"); + productsByName.putIfAbsent("E-Bike", chocolate); + + //Prior to Java 8: + if(productsByName.containsKey("E-Bike")) { + productsByName.put("E-Bike", chocolate); + } + } + + public static void merge() { + + HashMap productsByName = new HashMap<>(); + Product eBike2 = new Product("E-Bike", "A bike with a battery"); + eBike2.getTags().add("sport"); + productsByName.merge("E-Bike", eBike2, Product::addTagsOfOtherProdcut); + + //Prior to Java 8: + if(productsByName.containsKey("E-Bike")) { + productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2); + } else { + productsByName.put("E-Bike", eBike2); + } + } + + public static void compute() { + + HashMap productsByName = new HashMap<>(); + Product eBike2 = new Product("E-Bike", "A bike with a battery"); + + productsByName.compute("E-Bike", (k,v) -> { + if(v != null) { + return v.addTagsOfOtherProdcut(eBike2); + } else { + return eBike2; + } + }); + + //Prior to Java 8: + if(productsByName.containsKey("E-Bike")) { + productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2); + } else { + productsByName.put("E-Bike", eBike2); + } + } +} diff --git a/java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java b/java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java new file mode 100644 index 0000000000..2015909870 --- /dev/null +++ b/java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java @@ -0,0 +1,124 @@ +package com.baeldung.map; + +import org.junit.jupiter.api.Test; + +import java.util.HashMap; + +import static org.junit.jupiter.api.Assertions.*; + +class ProductUnitTest { + + + @Test + public void getExistingValue() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + Product roadBike = new Product("Road bike", "A bike for competition"); + + productsByName.put(eBike.getName(), eBike); + productsByName.put(roadBike.getName(), roadBike); + + Product nextPurchase = productsByName.get("E-Bike"); + + assertEquals("A bike with a battery", nextPurchase.getDescription()); + } + + @Test + public void getNonExistingValue() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + Product roadBike = new Product("Road bike", "A bike for competition"); + + productsByName.put(eBike.getName(), eBike); + productsByName.put(roadBike.getName(), roadBike); + + Product nextPurchase = productsByName.get("Car"); + + assertNull(nextPurchase); + } + + @Test + public void getExistingValueAfterSameKeyInsertedTwice() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + Product roadBike = new Product("Road bike", "A bike for competition"); + Product newEBike = new Product("E-Bike", "A bike with a better battery"); + + productsByName.put(eBike.getName(), eBike); + productsByName.put(roadBike.getName(), roadBike); + productsByName.put(newEBike.getName(), newEBike); + + Product nextPurchase = productsByName.get("E-Bike"); + + assertEquals("A bike with a better battery", nextPurchase.getDescription()); + } + + @Test + public void getExistingValueWithNullKey() { + HashMap productsByName = new HashMap<>(); + + Product defaultProduct = new Product("Chocolate", "At least buy chocolate"); + + productsByName.put(null, defaultProduct); + productsByName.put(defaultProduct.getName(), defaultProduct); + + Product nextPurchase = productsByName.get(null); + assertEquals("At least buy chocolate", nextPurchase.getDescription()); + + nextPurchase = productsByName.get("Chocolate"); + assertEquals("At least buy chocolate", nextPurchase.getDescription()); + } + + @Test + public void insertSameObjectWithDifferentKey() { + HashMap productsByName = new HashMap<>(); + + Product defaultProduct = new Product("Chocolate", "At least buy chocolate"); + + productsByName.put(null, defaultProduct); + productsByName.put(defaultProduct.getName(), defaultProduct); + + assertSame(productsByName.get(null), productsByName.get("Chocolate")); + } + + @Test + public void checkIfKeyExists() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + + productsByName.put(eBike.getName(), eBike); + + assertTrue(productsByName.containsKey("E-Bike")); + } + + @Test + public void checkIfValueExists() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + + productsByName.put(eBike.getName(), eBike); + + assertTrue(productsByName.containsValue(eBike)); + } + + @Test + public void removeExistingKey() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + Product roadBike = new Product("Road bike", "A bike for competition"); + + productsByName.put(eBike.getName(), eBike); + productsByName.put(roadBike.getName(), roadBike); + + productsByName.remove("E-Bike"); + + assertNull(productsByName.get("E-Bike")); + } + +} diff --git a/java-dates/README.md b/java-dates/README.md index 7da309924d..3a215f9094 100644 --- a/java-dates/README.md +++ b/java-dates/README.md @@ -3,25 +3,25 @@ ## Java Dates Cookbooks and Examples ### Relevant Articles: -- [TemporalAdjuster in Java](http://www.baeldung.com/java-temporal-adjuster) -- [Handling Daylight Savings Time in Java](http://www.baeldung.com/java-daylight-savings) -- [Period and Duration in Java](http://www.baeldung.com/java-period-duration) -- [Difference Between Two Dates in Java](http://www.baeldung.com/java-date-difference) -- [RegEx for matching Date Pattern in Java](http://www.baeldung.com/java-date-regular-expressions) -- [Migrating to the New Java 8 Date Time API](http://www.baeldung.com/migrating-to-java-8-date-time-api) -- [Introduction to the Java 8 Date/Time API](http://www.baeldung.com/java-8-date-time-intro) -- [Get the Current Date, Time and Timestamp in Java 8](http://www.baeldung.com/current-date-time-and-timestamp-in-java-8) -- [Get Date Without Time in Java](http://www.baeldung.com/java-date-without-time) -- [How to Get All Dates Between Two Dates?](http://www.baeldung.com/java-between-dates) -- [Convert Date to LocalDate or LocalDateTime and Back](http://www.baeldung.com/java-date-to-localdate-and-localdatetime) -- [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones) -- [Extracting Year, Month and Day from Date in Java](http://www.baeldung.com/java-year-month-day) -- [Guide to java.util.GregorianCalendar](http://www.baeldung.com/java-gregorian-calendar) -- [Measure Elapsed Time in Java](http://www.baeldung.com/java-measure-elapsed-time) -- [How to Get the Start and the End of a Day using Java](http://www.baeldung.com/java-day-start-end) -- [Calculate Age in Java](http://www.baeldung.com/java-get-age) -- [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) +- [TemporalAdjuster in Java](https://www.baeldung.com/java-temporal-adjuster) +- [Handling Daylight Savings Time in Java](https://www.baeldung.com/java-daylight-savings) +- [Period and Duration in Java](https://www.baeldung.com/java-period-duration) +- [Difference Between Two Dates in Java](https://www.baeldung.com/java-date-difference) +- [RegEx for matching Date Pattern in Java](https://www.baeldung.com/java-date-regular-expressions) +- [Migrating to the New Java 8 Date Time API](https://www.baeldung.com/migrating-to-java-8-date-time-api) +- [Introduction to the Java 8 Date/Time API](https://www.baeldung.com/java-8-date-time-intro) +- [Get the Current Date, Time and Timestamp in Java 8](https://www.baeldung.com/current-date-time-and-timestamp-in-java-8) +- [Get Date Without Time in Java](https://www.baeldung.com/java-date-without-time) +- [How to Get All Dates Between Two Dates?](https://www.baeldung.com/java-between-dates) +- [Convert Date to LocalDate or LocalDateTime and Back](https://www.baeldung.com/java-date-to-localdate-and-localdatetime) +- [Display All Time Zones With GMT And UTC in Java](https://www.baeldung.com/java-time-zones) +- [Extracting Year, Month and Day from Date in Java](https://www.baeldung.com/java-year-month-day) +- [Guide to java.util.GregorianCalendar](https://www.baeldung.com/java-gregorian-calendar) +- [Measure Elapsed Time in Java](https://www.baeldung.com/java-measure-elapsed-time) +- [How to Get the Start and the End of a Day using Java](https://www.baeldung.com/java-day-start-end) +- [Calculate Age in Java](https://www.baeldung.com/java-get-age) +- [Increment Date in Java](https://www.baeldung.com/java-increment-date) +- [Add Hours To a Date In Java](https://www.baeldung.com/java-add-hours-date) - [Guide to DateTimeFormatter](https://www.baeldung.com/java-datetimeformatter) - [Format ZonedDateTime to String](https://www.baeldung.com/java-format-zoned-datetime-string) - [Convert Between java.time.Instant and java.sql.Timestamp](https://www.baeldung.com/java-time-instant-to-java-sql-timestamp) @@ -29,4 +29,4 @@ - [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format) - [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset) - [Differences Between ZonedDateTime and OffsetDateTime](https://www.baeldung.com/java-zoneddatetime-offsetdatetime) -- [Introduction to Joda-Time](http://www.baeldung.com/joda-time) +- [Introduction to Joda-Time](https://www.baeldung.com/joda-time) diff --git a/java-ee-8-security-api/README.md b/java-ee-8-security-api/README.md index 1735419236..5ecce2b4cc 100644 --- a/java-ee-8-security-api/README.md +++ b/java-ee-8-security-api/README.md @@ -1,3 +1,3 @@ ### Relevant articles - - [Java EE 8 Security API](http://www.baeldung.com/java-ee-8-security) + - [Java EE 8 Security API](https://www.baeldung.com/java-ee-8-security) diff --git a/java-lite/README.md b/java-lite/README.md index a4e2edd49f..5221b832f9 100644 --- a/java-lite/README.md +++ b/java-lite/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: -- [A Guide to JavaLite – Building a RESTful CRUD application](http://www.baeldung.com/javalite-rest) -- [Introduction to ActiveWeb](http://www.baeldung.com/activeweb) +- [A Guide to JavaLite – Building a RESTful CRUD application](https://www.baeldung.com/javalite-rest) +- [Introduction to ActiveWeb](https://www.baeldung.com/activeweb) diff --git a/java-numbers-2/README.md b/java-numbers-2/README.md index 1d2919aa63..5c6f46b05b 100644 --- a/java-numbers-2/README.md +++ b/java-numbers-2/README.md @@ -2,9 +2,10 @@ - [Lossy Conversion in Java](https://www.baeldung.com/java-lossy-conversion) - [A Guide to the Java Math Class](https://www.baeldung.com/java-lang-math) - [Calculate the Area of a Circle in Java](https://www.baeldung.com/java-calculate-circle-area) -- [NaN in Java](http://www.baeldung.com/java-not-a-number) -- [Generating Prime Numbers in Java](http://www.baeldung.com/java-generate-prime-numbers) -- [Using Math.pow in Java](http://www.baeldung.com/java-math-pow) -- [Check If a Number Is Prime in Java](http://www.baeldung.com/java-prime-numbers) +- [NaN in Java](https://www.baeldung.com/java-not-a-number) +- [Generating Prime Numbers in Java](https://www.baeldung.com/java-generate-prime-numbers) +- [Using Math.pow in Java](https://www.baeldung.com/java-math-pow) +- [Check If a Number Is Prime in Java](https://www.baeldung.com/java-prime-numbers) - [Binary Numbers in Java](https://www.baeldung.com/java-binary-numbers) - [Finding the Least Common Multiple in Java](https://www.baeldung.com/java-least-common-multiple) +- [Binary Numbers in Java](https://www.baeldung.com/java-binary-numbers) diff --git a/java-rmi/README.md b/java-rmi/README.md index 4d12060395..201c4c8e66 100644 --- a/java-rmi/README.md +++ b/java-rmi/README.md @@ -1,3 +1,3 @@ ### Relevant articles -- [Getting Started with Java RMI](http://www.baeldung.com/java-rmi) +- [Getting Started with Java RMI](https://www.baeldung.com/java-rmi) diff --git a/java-spi/README.md b/java-spi/README.md index d2658c42fe..25e2d10da4 100644 --- a/java-spi/README.md +++ b/java-spi/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: -- [Java Service Provider Interface](http://www.baeldung.com/java-spi) +- [Java Service Provider Interface](https://www.baeldung.com/java-spi) diff --git a/java-streams/README.md b/java-streams/README.md index 0c9588c47e..0d26c182ba 100644 --- a/java-streams/README.md +++ b/java-streams/README.md @@ -3,15 +3,15 @@ ## Java Streams Cookbooks and Examples ### Relevant Articles: -- [The Java 8 Stream API Tutorial](http://www.baeldung.com/java-8-streams) -- [Introduction to Java 8 Streams](http://www.baeldung.com/java-8-streams-introduction) -- [Java 8 and Infinite Streams](http://www.baeldung.com/java-inifinite-streams) -- [Java 8 Stream findFirst() vs. findAny()](http://www.baeldung.com/java-stream-findfirst-vs-findany) -- [How to Get the Last Element of a Stream in Java?](http://www.baeldung.com/java-stream-last-element) -- [“Stream has already been operated upon or closed” Exception in Java](http://www.baeldung.com/java-stream-operated-upon-or-closed-exception) -- [Iterable to Stream in Java](http://www.baeldung.com/java-iterable-to-stream) -- [How to Iterate Over a Stream With Indices](http://www.baeldung.com/java-stream-indices) -- [Primitive Type Streams in Java 8](http://www.baeldung.com/java-8-primitive-streams) +- [The Java 8 Stream API Tutorial](https://www.baeldung.com/java-8-streams) +- [Introduction to Java 8 Streams](https://www.baeldung.com/java-8-streams-introduction) +- [Java 8 and Infinite Streams](https://www.baeldung.com/java-inifinite-streams) +- [Java 8 Stream findFirst() vs. findAny()](https://www.baeldung.com/java-stream-findfirst-vs-findany) +- [How to Get the Last Element of a Stream in Java?](https://www.baeldung.com/java-stream-last-element) +- [“Stream has already been operated upon or closed” Exception in Java](https://www.baeldung.com/java-stream-operated-upon-or-closed-exception) +- [Iterable to Stream in Java](https://www.baeldung.com/java-iterable-to-stream) +- [How to Iterate Over a Stream With Indices](https://www.baeldung.com/java-stream-indices) +- [Primitive Type Streams in Java 8](https://www.baeldung.com/java-8-primitive-streams) - [Stream Ordering in Java](https://www.baeldung.com/java-stream-ordering) - [Introduction to Protonpack](https://www.baeldung.com/java-protonpack) - [Java Stream Filter with Lambda Expression](https://www.baeldung.com/java-stream-filter-lambda) diff --git a/java-strings-2/README.md b/java-strings-2/README.md index ad0a46fd96..166a8a2b1f 100644 --- a/java-strings-2/README.md +++ b/java-strings-2/README.md @@ -3,8 +3,8 @@ - [Java Localization – Formatting Messages](https://www.baeldung.com/java-localization-messages-formatting) - [Check If a String Contains a Substring](https://www.baeldung.com/java-string-contains-substring) - [Removing Stopwords from a String in Java](https://www.baeldung.com/java-string-remove-stopwords) -- [Java – Generate Random String](http://www.baeldung.com/java-random-string) -- [Image to Base64 String Conversion](http://www.baeldung.com/java-base64-image-string) +- [Java – Generate Random String](https://www.baeldung.com/java-random-string) +- [Image to Base64 String Conversion](https://www.baeldung.com/java-base64-image-string) - [Java Base64 Encoding and Decoding](https://www.baeldung.com/java-base64-encode-and-decode) - [Generate a Secure Random Password in Java](https://www.baeldung.com/java-generate-secure-password) - [Removing Repeated Characters from a String](https://www.baeldung.com/java-remove-repeated-char) @@ -12,7 +12,7 @@ - [Pad a String with Zeros or Spaces in Java](https://www.baeldung.com/java-pad-string) - [Remove Emojis from a Java String](https://www.baeldung.com/java-string-remove-emojis) - [Convert a Comma Separated String to a List in Java](https://www.baeldung.com/java-string-with-separator-to-list) -- [Guide to java.util.Formatter](http://www.baeldung.com/java-string-formatter) +- [Guide to java.util.Formatter](https://www.baeldung.com/java-string-formatter) - [Remove Leading and Trailing Characters from a String](https://www.baeldung.com/java-remove-trailing-characters) - [Concatenating Strings In Java](https://www.baeldung.com/java-strings-concatenation) - [Java String Interview Questions and Answers](https://www.baeldung.com/java-string-interview-questions) @@ -24,3 +24,4 @@ - [Checking If a String Is a Repeated Substring](https://www.baeldung.com/java-repeated-substring) - [How to Reverse a String in Java](https://www.baeldung.com/java-reverse-string) - [String toLowerCase and toUpperCase Methods in Java](https://www.baeldung.com/java-string-convert-case) +- [Guide to StreamTokenizer](https://www.baeldung.com/java-streamtokenizer) diff --git a/java-strings-ops/README.md b/java-strings-ops/README.md index d909f171a7..d9c28dab0d 100644 --- a/java-strings-ops/README.md +++ b/java-strings-ops/README.md @@ -3,20 +3,20 @@ ## Java Strings Cookbooks and Examples ### Relevant Articles: -- [Convert char to String in Java](http://www.baeldung.com/java-convert-char-to-string) -- [Convert String to int or Integer in Java](http://www.baeldung.com/java-convert-string-to-int-or-integer) +- [Convert char to String in Java](https://www.baeldung.com/java-convert-char-to-string) +- [Convert String to int or Integer in Java](https://www.baeldung.com/java-convert-string-to-int-or-integer) - [Java String Conversions](https://www.baeldung.com/java-string-conversions) -- [Check if a String is a Palindrome](http://www.baeldung.com/java-palindrome) -- [Comparing Strings in Java](http://www.baeldung.com/java-compare-strings) -- [Check If a String Is Numeric in Java](http://www.baeldung.com/java-check-string-number) +- [Check if a String is a Palindrome](https://www.baeldung.com/java-palindrome) +- [Comparing Strings in Java](https://www.baeldung.com/java-compare-strings) +- [Check If a String Is Numeric in Java](https://www.baeldung.com/java-check-string-number) - [Get Substring from String in Java](https://www.baeldung.com/java-substring) -- [How to Remove the Last Character of a String?](http://www.baeldung.com/java-remove-last-character-of-string) +- [How to Remove the Last Character of a String?](https://www.baeldung.com/java-remove-last-character-of-string) - [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) -- [Count Occurrences of a Char in a String](http://www.baeldung.com/java-count-chars) -- [Guide to Java String Pool](http://www.baeldung.com/java-string-pool) -- [Split a String in Java](http://www.baeldung.com/java-split-string) +- [Count Occurrences of a Char in a String](https://www.baeldung.com/java-count-chars) +- [Guide to Java String Pool](https://www.baeldung.com/java-string-pool) +- [Split a String in Java](https://www.baeldung.com/java-split-string) - [Common String Operations in Java](https://www.baeldung.com/java-string-operations) - [Convert String to Byte Array and Reverse in Java](https://www.baeldung.com/java-string-to-byte-array) - [Java toString() Method](https://www.baeldung.com/java-tostring) -- [CharSequence vs. String in Java](http://www.baeldung.com/java-char-sequence-string) -- [StringBuilder and StringBuffer in Java](http://www.baeldung.com/java-string-builder-string-buffer) \ No newline at end of file +- [CharSequence vs. String in Java](https://www.baeldung.com/java-char-sequence-string) +- [StringBuilder and StringBuffer in Java](https://www.baeldung.com/java-string-builder-string-buffer) diff --git a/java-strings/README.md b/java-strings/README.md index ef536b4099..5b2a327877 100644 --- a/java-strings/README.md +++ b/java-strings/README.md @@ -3,14 +3,14 @@ ## Java Strings Cookbooks and Examples ### Relevant Articles: -- [String Operations with Java Streams](http://www.baeldung.com/java-stream-operations-on-strings) -- [Converting String to Stream of chars](http://www.baeldung.com/java-string-to-stream) -- [Java 8 StringJoiner](http://www.baeldung.com/java-string-joiner) -- [Converting Strings to Enums in Java](http://www.baeldung.com/java-string-to-enum) -- [Quick Guide to the Java StringTokenizer](http://www.baeldung.com/java-stringtokenizer) -- [Use char[] Array Over a String for Manipulating Passwords in Java?](http://www.baeldung.com/java-storing-passwords) -- [Convert a String to Title Case](http://www.baeldung.com/java-string-title-case) -- [Compact Strings in Java 9](http://www.baeldung.com/java-9-compact-string) +- [String Operations with Java Streams](https://www.baeldung.com/java-stream-operations-on-strings) +- [Converting String to Stream of chars](https://www.baeldung.com/java-string-to-stream) +- [Java 8 StringJoiner](https://www.baeldung.com/java-string-joiner) +- [Converting Strings to Enums in Java](https://www.baeldung.com/java-string-to-enum) +- [Quick Guide to the Java StringTokenizer](https://www.baeldung.com/java-stringtokenizer) +- [Use char[] Array Over a String for Manipulating Passwords in Java?](https://www.baeldung.com/java-storing-passwords) +- [Convert a String to Title Case](https://www.baeldung.com/java-string-title-case) +- [Compact Strings in Java 9](https://www.baeldung.com/java-9-compact-string) - [Java Check a String for Lowercase/Uppercase Letter, Special Character and Digit](https://www.baeldung.com/java-lowercase-uppercase-special-character-digit-regex) - [Convert java.util.Date to String](https://www.baeldung.com/java-util-date-to-string) - [Converting a Stack Trace to a String in Java](https://www.baeldung.com/java-stacktrace-to-string) @@ -20,4 +20,4 @@ - [Using indexOf to Find All Occurrences of a Word in a String](https://www.baeldung.com/java-indexOf-find-string-occurrences) - [Adding a Newline Character to a String in Java](https://www.baeldung.com/java-string-newline) - [Remove or Replace part of a String in Java](https://www.baeldung.com/java-remove-replace-string-part) -- [Replace a Character at a Specific Index in a String in Java](https://www.baeldung.com/java-replace-character-at-index) \ No newline at end of file +- [Replace a Character at a Specific Index in a String in Java](https://www.baeldung.com/java-replace-character-at-index) diff --git a/java-vavr-stream/README.md b/java-vavr-stream/README.md index 64299cde11..901978a1d8 100644 --- a/java-vavr-stream/README.md +++ b/java-vavr-stream/README.md @@ -1,5 +1,5 @@ ### Relevant Articles: -- [Java Streams vs Vavr Streams](http://www.baeldung.com/vavr-java-streams) +- [Java Streams vs Vavr Streams](https://www.baeldung.com/vavr-java-streams) diff --git a/java-websocket/README.md b/java-websocket/README.md index f9f0784043..87cbb3fa5c 100644 --- a/java-websocket/README.md +++ b/java-websocket/README.md @@ -1,3 +1,3 @@ ### Relevant articles -- [A Guide to the Java API for WebSocket](http://www.baeldung.com/java-websockets) +- [A Guide to the Java API for WebSocket](https://www.baeldung.com/java-websockets) diff --git a/javafx/README.md b/javafx/README.md index 66c81f17ad..7214321141 100644 --- a/javafx/README.md +++ b/javafx/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: --[Introduction to JavaFX](http://www.baeldung.com/javafx) +-[Introduction to JavaFX](https://www.baeldung.com/javafx) diff --git a/javax-servlets/README.md b/javax-servlets/README.md index 3c3b17996b..8254a78c4c 100644 --- a/javax-servlets/README.md +++ b/javax-servlets/README.md @@ -1,9 +1,10 @@ ### Relevant Articles: -- [Introduction to Java Servlets](http://www.baeldung.com/intro-to-servlets) -- [An MVC Example with Servlets and JSP](http://www.baeldung.com/mvc-servlet-jsp) -- [Handling Cookies and a Session in a Java Servlet](http://www.baeldung.com/java-servlet-cookies-session) -- [Uploading Files with Servlets and JSP](http://www.baeldung.com/upload-file-servlet) -- [Example of Downloading File in a Servlet](http://www.baeldung.com/servlet-download-file) -- [Returning a JSON Response from a Servlet](http://www.baeldung.com/servlet-json-response) -- [Java EE Servlet Exception Handling](http://www.baeldung.com/servlet-exceptions) -- [Context and Servlet Initialization Parameters](http://www.baeldung.com/context-servlet-initialization-param) +- [Introduction to Java Servlets](https://www.baeldung.com/intro-to-servlets) +- [An MVC Example with Servlets and JSP](https://www.baeldung.com/mvc-servlet-jsp) +- [Handling Cookies and a Session in a Java Servlet](https://www.baeldung.com/java-servlet-cookies-session) +- [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) +- [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/README.md b/javaxval/README.md index fadd174166..b141bc7859 100644 --- a/javaxval/README.md +++ b/javaxval/README.md @@ -3,7 +3,8 @@ ## Java Bean Validation Examples ### Relevant Articles: -- [Java Bean Validation Basics](http://www.baeldung.com/javax-validation) -- [Validating Container Elements with Bean Validation 2.0](http://www.baeldung.com/bean-validation-container-elements) -- [Method Constraints with Bean Validation 2.0](http://www.baeldung.com/javax-validation-method-constraints) +- [Java Bean Validation Basics](https://www.baeldung.com/javax-validation) +- [Validating Container Elements with Bean Validation 2.0](https://www.baeldung.com/bean-validation-container-elements) +- [Method Constraints with Bean Validation 2.0](https://www.baeldung.com/javax-validation-method-constraints) - [Difference Between @NotNull, @NotEmpty, and @NotBlank Constraints in Bean Validation](https://www.baeldung.com/java-bean-validation-not-null-empty-blank) +- [Javax BigDecimal Validation](https://www.baeldung.com/javax-bigdecimal-validation) diff --git a/jaxb/README.md b/jaxb/README.md index 4b603fca00..bdaef90279 100644 --- a/jaxb/README.md +++ b/jaxb/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Guide to JAXB](http://www.baeldung.com/jaxb) +- [Guide to JAXB](https://www.baeldung.com/jaxb) diff --git a/jee-7-security/README.md b/jee-7-security/README.md index 314de6d957..70d451382c 100644 --- a/jee-7-security/README.md +++ b/jee-7-security/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Securing Java EE with Spring Security](http://www.baeldung.com/java-ee-spring-security) +- [Securing Java 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 c57863651d..2ae7335ce0 100644 --- a/jee-7/README.md +++ b/jee-7/README.md @@ -1,9 +1,9 @@ ### Relevant Articles: -- [Scheduling in Java EE](http://www.baeldung.com/scheduling-in-java-enterprise-edition) -- [JSON Processing in Java EE 7](http://www.baeldung.com/jee7-json) -- [Converters, Listeners and Validators in Java EE 7](http://www.baeldung.com/java-ee7-converter-listener-validator) -- [Introduction to JAX-WS](http://www.baeldung.com/jax-ws) -- [A Guide to Java EE Web-Related Annotations](http://www.baeldung.com/javaee-web-annotations) -- [Introduction to Testing with Arquillian](http://www.baeldung.com/arquillian) +- [Scheduling in Java 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) +- [A Guide to Java EE Web-Related Annotations](https://www.baeldung.com/javaee-web-annotations) +- [Introduction to Testing with Arquillian](https://www.baeldung.com/arquillian) - [Java EE 7 Batch Processing](https://www.baeldung.com/java-ee-7-batch-processing) - [The Difference Between CDI and EJB Singleton](https://www.baeldung.com/jee-cdi-vs-ejb-singleton) diff --git a/jersey/README.md b/jersey/README.md index 126dc542ba..1db89ec723 100644 --- a/jersey/README.md +++ b/jersey/README.md @@ -1,4 +1,4 @@ -- [Jersey Filters and Interceptors](http://www.baeldung.com/jersey-filters-interceptors) +- [Jersey Filters and Interceptors](https://www.baeldung.com/jersey-filters-interceptors) - [Jersey MVC Support](https://www.baeldung.com/jersey-mvc) - [Bean Validation in Jersey](https://www.baeldung.com/jersey-bean-validation) - [Set a Response Body in JAX-RS](https://www.baeldung.com/jax-rs-response) diff --git a/jgit/README.md b/jgit/README.md index 5c65f1101b..d89104293d 100644 --- a/jgit/README.md +++ b/jgit/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [A Guide to JGit](http://www.baeldung.com/jgit) +- [A Guide to JGit](https://www.baeldung.com/jgit) diff --git a/jgroups/README.md b/jgroups/README.md index 0921fa98a1..128007bb7e 100644 --- a/jgroups/README.md +++ b/jgroups/README.md @@ -1,7 +1,7 @@ ## Reliable Messaging with JGroups Tutorial Project ### Relevant Article: -- [Reliable Messaging with JGroups](http://www.baeldung.com/jgroups) +- [Reliable Messaging with JGroups](https://www.baeldung.com/jgroups) ### Overview This Maven project contains the Java code for the article linked above. diff --git a/jhipster/jhipster-monolithic/README.md b/jhipster/jhipster-monolithic/README.md index 65cc51ad88..de7c6ded74 100644 --- a/jhipster/jhipster-monolithic/README.md +++ b/jhipster/jhipster-monolithic/README.md @@ -1,6 +1,7 @@ ## Relevant Articles - [Intro to JHipster](https://www.baeldung.com/jhipster) +- [Creating New Roles and Authorities in JHipster](https://www.baeldung.com/jhipster-new-roles) # baeldung diff --git a/jjwt/README.md b/jjwt/README.md index ed18363dfc..04a85f3ded 100644 --- a/jjwt/README.md +++ b/jjwt/README.md @@ -45,4 +45,4 @@ Available commands (assumes httpie - https://github.com/jkbrzt/httpie): ## Relevant articles: -- [Supercharge Java Authentication with JSON Web Tokens (JWTs)](http://www.baeldung.com/java-json-web-tokens-jjwt) +- [Supercharge Java Authentication with JSON Web Tokens (JWTs)](https://www.baeldung.com/java-json-web-tokens-jjwt) diff --git a/jmeter/README.md b/jmeter/README.md index e3f9d1a4db..58522067b2 100644 --- a/jmeter/README.md +++ b/jmeter/README.md @@ -42,5 +42,5 @@ Enjoy it :) ### Relevant Articles: -- [Intro to Performance Testing using JMeter](http://www.baeldung.com/jmeter) -- [Configure Jenkins to Run and Show JMeter Tests](http://www.baeldung.com/jenkins-and-jmeter) +- [Intro to Performance Testing using JMeter](https://www.baeldung.com/jmeter) +- [Configure Jenkins to Run and Show JMeter Tests](https://www.baeldung.com/jenkins-and-jmeter) diff --git a/jmh/README.md b/jmh/README.md index 9c5a70e3c2..6876615328 100644 --- a/jmh/README.md +++ b/jmh/README.md @@ -1,4 +1,4 @@ ## Relevant articles: -- [Microbenchmarking with Java](http://www.baeldung.com/java-microbenchmark-harness) +- [Microbenchmarking with Java](https://www.baeldung.com/java-microbenchmark-harness) diff --git a/jni/README.md b/jni/README.md index 663cafb0c0..daaeb7819f 100644 --- a/jni/README.md +++ b/jni/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: -- [Guide to JNI (Java Native Interface)](http://www.baeldung.com/jni) +- [Guide to JNI (Java Native Interface)](https://www.baeldung.com/jni) diff --git a/jooby/README.md b/jooby/README.md index aa867b2c56..bf8c580633 100644 --- a/jooby/README.md +++ b/jooby/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [Introduction to Jooby](http://www.baeldung.com/jooby) +- [Introduction to Jooby](https://www.baeldung.com/jooby) diff --git a/jsf/README.md b/jsf/README.md index d96c1eb8e3..65735cc406 100644 --- a/jsf/README.md +++ b/jsf/README.md @@ -1,5 +1,5 @@ ### Relevant Articles: -- [Guide to JSF Expression Language 3.0](http://www.baeldung.com/jsf-expression-language-el-3) -- [Introduction to JSF EL 2](http://www.baeldung.com/intro-to-jsf-expression-language) -- [JavaServer Faces (JSF) with Spring](http://www.baeldung.com/spring-jsf) -- [Introduction to Primefaces](http://www.baeldung.com/jsf-primefaces) +- [Guide to JSF Expression Language 3.0](https://www.baeldung.com/jsf-expression-language-el-3) +- [Introduction to JSF EL 2](https://www.baeldung.com/intro-to-jsf-expression-language) +- [JavaServer Faces (JSF) with Spring](https://www.baeldung.com/spring-jsf) +- [Introduction to Primefaces](https://www.baeldung.com/jsf-primefaces) diff --git a/json-path/README.md b/json-path/README.md index 7a84ea7bde..41cc72a842 100644 --- a/json-path/README.md +++ b/json-path/README.md @@ -1,4 +1,4 @@ ## Relevant articles: -- [Introduction to JsonPath](http://www.baeldung.com/guide-to-jayway-jsonpath) -- [Count with JsonPath](http://www.baeldung.com/jsonpath-count) +- [Introduction to JsonPath](https://www.baeldung.com/guide-to-jayway-jsonpath) +- [Count with JsonPath](https://www.baeldung.com/jsonpath-count) diff --git a/json/README.md b/json/README.md index 7ef4cc9b01..96acedd0b1 100644 --- a/json/README.md +++ b/json/README.md @@ -3,13 +3,13 @@ ## Fast-Json ### Relevant Articles: -- [Introduction to JSON Schema in Java](http://www.baeldung.com/introduction-to-json-schema-in-java) -- [A Guide to FastJson](http://www.baeldung.com/fastjson) -- [Introduction to JSONForms](http://www.baeldung.com/introduction-to-jsonforms) -- [Introduction to JsonPath](http://www.baeldung.com/guide-to-jayway-jsonpath) -- [Introduction to JSON-Java (org.json)](http://www.baeldung.com/java-org-json) +- [Introduction to JSON Schema in Java](https://www.baeldung.com/introduction-to-json-schema-in-java) +- [A Guide to FastJson](https://www.baeldung.com/fastjson) +- [Introduction to JSONForms](https://www.baeldung.com/introduction-to-jsonforms) +- [Introduction to JsonPath](https://www.baeldung.com/guide-to-jayway-jsonpath) +- [Introduction to JSON-Java (org.json)](https://www.baeldung.com/java-org-json) - [Overview of JSON Pointer](https://www.baeldung.com/json-pointer) -- [Introduction to the JSON Binding API (JSR 367) in Java](http://www.baeldung.com/java-json-binding-api) +- [Introduction to the JSON Binding API (JSR 367) in Java](https://www.baeldung.com/java-json-binding-api) - [Get a Value by Key in a JSONArray](https://www.baeldung.com/java-jsonarray-get-value-by-key) - [Iterating Over an Instance of org.json.JSONObject](https://www.baeldung.com/jsonobject-iteration) - [Escape JSON String in Java](https://www.baeldung.com/java-json-escaping) diff --git a/jsoup/README.md b/jsoup/README.md index 8728cc7c4e..7624ce77bf 100644 --- a/jsoup/README.md +++ b/jsoup/README.md @@ -3,7 +3,7 @@ ## jsoup Example Project ### Relevant Articles: -- [Parsing HTML in Java with Jsoup](http://www.baeldung.com/java-with-jsoup) +- [Parsing HTML in Java with Jsoup](https://www.baeldung.com/java-with-jsoup) ### Build the Project diff --git a/jws/README.md b/jws/README.md index 5916efad24..c7cddb11ac 100644 --- a/jws/README.md +++ b/jws/README.md @@ -4,4 +4,4 @@ This module contains articles about Java Web Start. ### Relevant articles -- [A Guide to the Java Web Start](http://www.baeldung.com/java-web-start) +- [A Guide to the Java Web Start](https://www.baeldung.com/java-web-start) diff --git a/kotlin-js/README.md b/kotlin-js/README.md index 445ad6da9a..84d0c70427 100644 --- a/kotlin-js/README.md +++ b/kotlin-js/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Kotlin and Javascript](http://www.baeldung.com/kotlin-javascript) +- [Kotlin and Javascript](https://www.baeldung.com/kotlin-javascript) diff --git a/kotlin-libraries/README.md b/kotlin-libraries/README.md index 94359193b6..6ad90c1cd2 100644 --- a/kotlin-libraries/README.md +++ b/kotlin-libraries/README.md @@ -1,14 +1,14 @@ ## Relevant articles: -- [Kotlin with Mockito](http://www.baeldung.com/kotlin-mockito) -- [HTTP Requests with Kotlin and khttp](http://www.baeldung.com/kotlin-khttp) -- [Kotlin Dependency Injection with Kodein](http://www.baeldung.com/kotlin-kodein-dependency-injection) -- [Writing Specifications with Kotlin and Spek](http://www.baeldung.com/kotlin-spek) -- [Processing JSON with Kotlin and Klaxson](http://www.baeldung.com/kotlin-json-klaxson) +- [Kotlin with Mockito](https://www.baeldung.com/kotlin-mockito) +- [HTTP Requests with Kotlin and khttp](https://www.baeldung.com/kotlin-khttp) +- [Kotlin Dependency Injection with Kodein](https://www.baeldung.com/kotlin-kodein-dependency-injection) +- [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) - [MockK: A Mocking Library for Kotlin](https://www.baeldung.com/kotlin-mockk) -- [Kotlin Immutable Collections](https://www.baeldung.com/kotlin-immutable-collections) \ No newline at end of file +- [Kotlin Immutable Collections](https://www.baeldung.com/kotlin-immutable-collections) diff --git a/lagom/README.md b/lagom/README.md index 909fe0dff4..a8070c047c 100644 --- a/lagom/README.md +++ b/lagom/README.md @@ -1,6 +1,6 @@ ### Relevant articles -- [Guide to Reactive Microservices Using Lagom Framework](http://www.baeldung.com/lagom-reactive-microservices) +- [Guide to Reactive Microservices Using Lagom Framework](https://www.baeldung.com/lagom-reactive-microservices) diff --git a/libraries-apache-commons-collections/README.md b/libraries-apache-commons-collections/README.md new file mode 100644 index 0000000000..998ad1da09 --- /dev/null +++ b/libraries-apache-commons-collections/README.md @@ -0,0 +1,13 @@ +## Apache Commons Collections + +This module contains articles about Apache Commons Collections + +### Relevant articles + +- [Apache Commons Collections SetUtils](https://www.baeldung.com/apache-commons-setutils) +- [Apache Commons Collections OrderedMap](https://www.baeldung.com/apache-commons-ordered-map) +- [Guide to Apache Commons CircularFifoQueue](https://www.baeldung.com/commons-circular-fifo-queue) +- [Apache Commons Collections Bag](https://www.baeldung.com/apache-commons-bag) +- [A Guide to Apache Commons Collections CollectionUtils](https://www.baeldung.com/apache-commons-collection-utils) +- [Apache Commons Collections BidiMap](https://www.baeldung.com/commons-collections-bidi-map) +- [Apache Commons Collections MapUtils](https://www.baeldung.com/apache-commons-map-utils) \ No newline at end of file diff --git a/libraries-apache-commons-collections/pom.xml b/libraries-apache-commons-collections/pom.xml new file mode 100644 index 0000000000..eba0ad331e --- /dev/null +++ b/libraries-apache-commons-collections/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + libraries-apache-commons-collections + libraries-apache-commons-collections + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + + org.apache.commons + commons-collections4 + ${commons.collections.version} + + + org.hamcrest + java-hamcrest + ${org.hamcrest.java-hamcrest.version} + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + 4.1 + 3.6.2 + 2.0.0.0 + + + diff --git a/libraries-apache-commons/src/main/java/com/baeldung/commons/collectionutil/Address.java b/libraries-apache-commons-collections/src/main/java/com/baeldung/commons/collections/collectionutils/Address.java similarity index 94% rename from libraries-apache-commons/src/main/java/com/baeldung/commons/collectionutil/Address.java rename to libraries-apache-commons-collections/src/main/java/com/baeldung/commons/collections/collectionutils/Address.java index a1e231ec85..02c36a46f9 100644 --- a/libraries-apache-commons/src/main/java/com/baeldung/commons/collectionutil/Address.java +++ b/libraries-apache-commons-collections/src/main/java/com/baeldung/commons/collections/collectionutils/Address.java @@ -1,4 +1,4 @@ -package com.baeldung.commons.collectionutil; +package com.baeldung.commons.collections.collectionutils; public class Address { diff --git a/libraries-apache-commons/src/main/java/com/baeldung/commons/collectionutil/Customer.java b/libraries-apache-commons-collections/src/main/java/com/baeldung/commons/collections/collectionutils/Customer.java similarity index 97% rename from libraries-apache-commons/src/main/java/com/baeldung/commons/collectionutil/Customer.java rename to libraries-apache-commons-collections/src/main/java/com/baeldung/commons/collections/collectionutils/Customer.java index 1c6a8dc4f1..7d6db68474 100644 --- a/libraries-apache-commons/src/main/java/com/baeldung/commons/collectionutil/Customer.java +++ b/libraries-apache-commons-collections/src/main/java/com/baeldung/commons/collections/collectionutils/Customer.java @@ -1,4 +1,4 @@ -package com.baeldung.commons.collectionutil; +package com.baeldung.commons.collections.collectionutils; public class Customer implements Comparable { diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/collections4/BagUnitTest.java b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/BagUnitTest.java similarity index 98% rename from libraries-apache-commons/src/test/java/com/baeldung/commons/collections4/BagUnitTest.java rename to libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/BagUnitTest.java index ebad4093f0..0877e6d4ac 100644 --- a/libraries-apache-commons/src/test/java/com/baeldung/commons/collections4/BagUnitTest.java +++ b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/BagUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.commons.collections4; +package com.baeldung.commons.collections; import org.apache.commons.collections4.Bag; import org.apache.commons.collections4.SortedBag; diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/collections/BidiMapUnitTest.java b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/BidiMapUnitTest.java similarity index 100% rename from libraries-apache-commons/src/test/java/com/baeldung/commons/collections/BidiMapUnitTest.java rename to libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/BidiMapUnitTest.java diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/collections/MapUtilsUnitTest.java b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/MapUtilsUnitTest.java similarity index 100% rename from libraries-apache-commons/src/test/java/com/baeldung/commons/collections/MapUtilsUnitTest.java rename to libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/MapUtilsUnitTest.java diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/collections/SetUtilsUnitTest.java b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/SetUtilsUnitTest.java similarity index 100% rename from libraries-apache-commons/src/test/java/com/baeldung/commons/collections/SetUtilsUnitTest.java rename to libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/SetUtilsUnitTest.java diff --git a/libraries-apache-commons/src/test/java/com/baeldung/circularfifoqueue/CircularFifoQueueUnitTest.java b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/circularfifoqueue/CircularFifoQueueUnitTest.java similarity index 98% rename from libraries-apache-commons/src/test/java/com/baeldung/circularfifoqueue/CircularFifoQueueUnitTest.java rename to libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/circularfifoqueue/CircularFifoQueueUnitTest.java index 39384a7442..5664c7b44e 100644 --- a/libraries-apache-commons/src/test/java/com/baeldung/circularfifoqueue/CircularFifoQueueUnitTest.java +++ b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/circularfifoqueue/CircularFifoQueueUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.circularfifoqueue; +package com.baeldung.commons.collections.circularfifoqueue; import java.util.ArrayList; import java.util.List; diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideUnitTest.java b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/collectionutils/CollectionUtilsGuideUnitTest.java similarity index 96% rename from libraries-apache-commons/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideUnitTest.java rename to libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/collectionutils/CollectionUtilsGuideUnitTest.java index 448c5b0729..e9a4612280 100644 --- a/libraries-apache-commons/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideUnitTest.java +++ b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/collectionutils/CollectionUtilsGuideUnitTest.java @@ -1,7 +1,7 @@ -package com.baeldung.commons.collections; +package com.baeldung.commons.collections.collectionutils; -import com.baeldung.commons.collectionutil.Address; -import com.baeldung.commons.collectionutil.Customer; +import com.baeldung.commons.collections.collectionutils.Address; +import com.baeldung.commons.collections.collectionutils.Customer; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.Transformer; diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java similarity index 97% rename from libraries-apache-commons/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java rename to libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java index c64143cba7..1ffc4a825f 100644 --- a/libraries-apache-commons/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java +++ b/libraries-apache-commons-collections/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java @@ -1,211 +1,211 @@ -package com.baeldung.commons.collections.orderedmap; - -import org.apache.commons.collections4.OrderedMap; -import org.apache.commons.collections4.OrderedMapIterator; -import org.apache.commons.collections4.map.LinkedMap; -import org.apache.commons.collections4.map.ListOrderedMap; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -public class OrderedMapUnitTest { - - private String[] names = { "Emily", "Mathew", "Rose", "John", "Anna" }; - private Integer[] ages = { 37, 28, 40, 36, 21 }; - - private int RUNNERS_COUNT = names.length; - - private OrderedMap runnersLinkedMap; - private OrderedMap runnersListOrderedMap; - - @Before - public void createRunners() { - // First implementation: ListOrderedMap - this.runnersListOrderedMap = new ListOrderedMap<>(); - this.loadOrderedMapOfRunners(this.runnersListOrderedMap); - - // Second implementation: LinkedMap - this.runnersLinkedMap = new LinkedMap<>(); - this.loadOrderedMapOfRunners(this.runnersLinkedMap); - } - - private void loadOrderedMapOfRunners(OrderedMap runners) { - for (int i = 0; i < RUNNERS_COUNT; i++) { - runners.put(this.names[i], this.ages[i]); - } - } - - @Test - public void givenALinkedMap_whenIteratedWithMapIterator_thenPreservesOrder() { - // Tests that the order in map iterator is the same - // as defined in the constant arrays of names and ages: - - OrderedMapIterator runnersIterator = this.runnersLinkedMap.mapIterator(); - int i = 0; - while (runnersIterator.hasNext()) { - runnersIterator.next(); - assertEquals(runnersIterator.getKey(), this.names[i]); - assertEquals(runnersIterator.getValue(), this.ages[i]); - i++; - } - } - - @Test - public void givenAListOrderedMap_whenIteratedWithMapIterator_thenPreservesOrder() { - // Tests that the order in map iterator is the same - // as defined in the constant arrays of names and ages: - - OrderedMapIterator runnersIterator = this.runnersListOrderedMap.mapIterator(); - int i = 0; - while (runnersIterator.hasNext()) { - runnersIterator.next(); - assertEquals(runnersIterator.getKey(), this.names[i]); - assertEquals(runnersIterator.getValue(), this.ages[i]); - i++; - } - } - - @Test - public void givenALinkedMap_whenIteratedForwards_thenPreservesOrder() { - // Tests that the order in the forward iteration is the same - // as defined in the constant arrays of names and ages - - String name = this.runnersLinkedMap.firstKey(); - int i = 0; - while (name != null) { - assertEquals(name, this.names[i]); - name = this.runnersLinkedMap.nextKey(name); - i++; - } - } - - @Test - public void givenAListOrderedMap_whenIteratedForwards_thenPreservesOrder() { - // Tests that the order in the forward iteration is the same - // as defined in the constant arrays of names and ages - - String name = this.runnersListOrderedMap.firstKey(); - int i = 0; - while (name != null) { - assertEquals(name, this.names[i]); - name = this.runnersListOrderedMap.nextKey(name); - i++; - } - } - - @Test - public void givenALinkedMap_whenIteratedBackwards_thenPreservesOrder() { - // Tests that the order in the backwards iteration is the same - // as defined in the constant arrays of names and ages - - String name = this.runnersLinkedMap.lastKey(); - int i = RUNNERS_COUNT - 1; - while (name != null) { - assertEquals(name, this.names[i]); - name = this.runnersLinkedMap.previousKey(name); - i--; - } - } - - @Test - public void givenAListOrderedMap_whenIteratedBackwards_thenPreservesOrder() { - // Tests that the order in the backwards iteration is the same - // as defined in the constant arrays of names and ages - - String name = this.runnersListOrderedMap.lastKey(); - int i = RUNNERS_COUNT - 1; - while (name != null) { - assertEquals(name, this.names[i]); - name = this.runnersListOrderedMap.previousKey(name); - i--; - } - } - - @Test - public void givenALinkedMap_whenObjectIsSearched_thenMatchesConstantArray() { - assertEquals(ages[4], this.runnersLinkedMap.get("Anna")); - } - - @Test - public void givenALinkedMap_whenConvertedToList_thenMatchesKeySet() { - // Casting the OrderedMap to a LinkedMap we can use asList() method - - LinkedMap lmap = (LinkedMap) this.runnersLinkedMap; - List listKeys = new ArrayList<>(); - listKeys.addAll(this.runnersLinkedMap.keySet()); - List linkedMap = lmap.asList(); - assertEquals(listKeys, linkedMap); - } - - @Test - public void givenALinkedMap_whenSearchByIndexIsUsed_thenMatchesConstantArray() { - LinkedMap lmap = (LinkedMap) this.runnersLinkedMap; - - for (int i = 0; i < RUNNERS_COUNT; i++) { - // accessed by index: - String name = lmap.get(i); - assertEquals(name, this.names[i]); - - // index of key concides with position in array - assertEquals(lmap.indexOf(this.names[i]), i); - } - } - - @Test - public void givenALinkedMap_whenElementRemoved_thenSizeDecrease() { - LinkedMap lmap = (LinkedMap) this.runnersLinkedMap; - Integer johnAge = lmap.remove("John");// by object - assertEquals(johnAge, new Integer(36)); - assertEquals(lmap.size(), RUNNERS_COUNT - 1); - - Integer emilyAge = lmap.remove(0);// by index - assertEquals(emilyAge, new Integer(37)); - assertEquals(lmap.size(), RUNNERS_COUNT - 2); - } - - @Test - public void givenAListOrderedMap_whenObjectIsSearched_thenMatchesConstantArray() { - assertEquals(ages[4], this.runnersListOrderedMap.get("Anna")); - } - - @Test - public void givenAListOrderedMap_whenConvertedToList_thenMatchesKeySet() { - ListOrderedMap lomap = (ListOrderedMap) this.runnersListOrderedMap; - List listKeys = new ArrayList<>(); - listKeys.addAll(this.runnersListOrderedMap.keySet()); - List lomapList = lomap.asList(); - assertEquals(listKeys, lomapList); - } - - @Test - public void givenAListOrderedMap_whenSearchByIndexIsUsed_thenMatchesConstantArray() { - ListOrderedMap lomap = (ListOrderedMap) this.runnersListOrderedMap; - - for (int i = 0; i < RUNNERS_COUNT; i++) { - // accessed by index: - String name = lomap.get(i); - assertEquals(name, this.names[i]); - - // index of key concides with position in array - assertEquals(lomap.indexOf(this.names[i]), i); - } - } - - @Test - public void givenAListOrderedMap_whenElementRemoved_thenSizeDecrease() { - ListOrderedMap lomap = (ListOrderedMap) this.runnersListOrderedMap; - - Integer johnAge = lomap.remove("John");// by object - - assertEquals(johnAge, new Integer(36)); - assertEquals(lomap.size(), RUNNERS_COUNT - 1); - - Integer emilyAge = lomap.remove(0);// by index - assertEquals(emilyAge, new Integer(37)); - assertEquals(lomap.size(), RUNNERS_COUNT - 2); - } -} +package com.baeldung.commons.collections.orderedmap; + +import org.apache.commons.collections4.OrderedMap; +import org.apache.commons.collections4.OrderedMapIterator; +import org.apache.commons.collections4.map.LinkedMap; +import org.apache.commons.collections4.map.ListOrderedMap; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +public class OrderedMapUnitTest { + + private String[] names = { "Emily", "Mathew", "Rose", "John", "Anna" }; + private Integer[] ages = { 37, 28, 40, 36, 21 }; + + private int RUNNERS_COUNT = names.length; + + private OrderedMap runnersLinkedMap; + private OrderedMap runnersListOrderedMap; + + @Before + public void createRunners() { + // First implementation: ListOrderedMap + this.runnersListOrderedMap = new ListOrderedMap<>(); + this.loadOrderedMapOfRunners(this.runnersListOrderedMap); + + // Second implementation: LinkedMap + this.runnersLinkedMap = new LinkedMap<>(); + this.loadOrderedMapOfRunners(this.runnersLinkedMap); + } + + private void loadOrderedMapOfRunners(OrderedMap runners) { + for (int i = 0; i < RUNNERS_COUNT; i++) { + runners.put(this.names[i], this.ages[i]); + } + } + + @Test + public void givenALinkedMap_whenIteratedWithMapIterator_thenPreservesOrder() { + // Tests that the order in map iterator is the same + // as defined in the constant arrays of names and ages: + + OrderedMapIterator runnersIterator = this.runnersLinkedMap.mapIterator(); + int i = 0; + while (runnersIterator.hasNext()) { + runnersIterator.next(); + assertEquals(runnersIterator.getKey(), this.names[i]); + assertEquals(runnersIterator.getValue(), this.ages[i]); + i++; + } + } + + @Test + public void givenAListOrderedMap_whenIteratedWithMapIterator_thenPreservesOrder() { + // Tests that the order in map iterator is the same + // as defined in the constant arrays of names and ages: + + OrderedMapIterator runnersIterator = this.runnersListOrderedMap.mapIterator(); + int i = 0; + while (runnersIterator.hasNext()) { + runnersIterator.next(); + assertEquals(runnersIterator.getKey(), this.names[i]); + assertEquals(runnersIterator.getValue(), this.ages[i]); + i++; + } + } + + @Test + public void givenALinkedMap_whenIteratedForwards_thenPreservesOrder() { + // Tests that the order in the forward iteration is the same + // as defined in the constant arrays of names and ages + + String name = this.runnersLinkedMap.firstKey(); + int i = 0; + while (name != null) { + assertEquals(name, this.names[i]); + name = this.runnersLinkedMap.nextKey(name); + i++; + } + } + + @Test + public void givenAListOrderedMap_whenIteratedForwards_thenPreservesOrder() { + // Tests that the order in the forward iteration is the same + // as defined in the constant arrays of names and ages + + String name = this.runnersListOrderedMap.firstKey(); + int i = 0; + while (name != null) { + assertEquals(name, this.names[i]); + name = this.runnersListOrderedMap.nextKey(name); + i++; + } + } + + @Test + public void givenALinkedMap_whenIteratedBackwards_thenPreservesOrder() { + // Tests that the order in the backwards iteration is the same + // as defined in the constant arrays of names and ages + + String name = this.runnersLinkedMap.lastKey(); + int i = RUNNERS_COUNT - 1; + while (name != null) { + assertEquals(name, this.names[i]); + name = this.runnersLinkedMap.previousKey(name); + i--; + } + } + + @Test + public void givenAListOrderedMap_whenIteratedBackwards_thenPreservesOrder() { + // Tests that the order in the backwards iteration is the same + // as defined in the constant arrays of names and ages + + String name = this.runnersListOrderedMap.lastKey(); + int i = RUNNERS_COUNT - 1; + while (name != null) { + assertEquals(name, this.names[i]); + name = this.runnersListOrderedMap.previousKey(name); + i--; + } + } + + @Test + public void givenALinkedMap_whenObjectIsSearched_thenMatchesConstantArray() { + assertEquals(ages[4], this.runnersLinkedMap.get("Anna")); + } + + @Test + public void givenALinkedMap_whenConvertedToList_thenMatchesKeySet() { + // Casting the OrderedMap to a LinkedMap we can use asList() method + + LinkedMap lmap = (LinkedMap) this.runnersLinkedMap; + List listKeys = new ArrayList<>(); + listKeys.addAll(this.runnersLinkedMap.keySet()); + List linkedMap = lmap.asList(); + assertEquals(listKeys, linkedMap); + } + + @Test + public void givenALinkedMap_whenSearchByIndexIsUsed_thenMatchesConstantArray() { + LinkedMap lmap = (LinkedMap) this.runnersLinkedMap; + + for (int i = 0; i < RUNNERS_COUNT; i++) { + // accessed by index: + String name = lmap.get(i); + assertEquals(name, this.names[i]); + + // index of key concides with position in array + assertEquals(lmap.indexOf(this.names[i]), i); + } + } + + @Test + public void givenALinkedMap_whenElementRemoved_thenSizeDecrease() { + LinkedMap lmap = (LinkedMap) this.runnersLinkedMap; + Integer johnAge = lmap.remove("John");// by object + assertEquals(johnAge, new Integer(36)); + assertEquals(lmap.size(), RUNNERS_COUNT - 1); + + Integer emilyAge = lmap.remove(0);// by index + assertEquals(emilyAge, new Integer(37)); + assertEquals(lmap.size(), RUNNERS_COUNT - 2); + } + + @Test + public void givenAListOrderedMap_whenObjectIsSearched_thenMatchesConstantArray() { + assertEquals(ages[4], this.runnersListOrderedMap.get("Anna")); + } + + @Test + public void givenAListOrderedMap_whenConvertedToList_thenMatchesKeySet() { + ListOrderedMap lomap = (ListOrderedMap) this.runnersListOrderedMap; + List listKeys = new ArrayList<>(); + listKeys.addAll(this.runnersListOrderedMap.keySet()); + List lomapList = lomap.asList(); + assertEquals(listKeys, lomapList); + } + + @Test + public void givenAListOrderedMap_whenSearchByIndexIsUsed_thenMatchesConstantArray() { + ListOrderedMap lomap = (ListOrderedMap) this.runnersListOrderedMap; + + for (int i = 0; i < RUNNERS_COUNT; i++) { + // accessed by index: + String name = lomap.get(i); + assertEquals(name, this.names[i]); + + // index of key concides with position in array + assertEquals(lomap.indexOf(this.names[i]), i); + } + } + + @Test + public void givenAListOrderedMap_whenElementRemoved_thenSizeDecrease() { + ListOrderedMap lomap = (ListOrderedMap) this.runnersListOrderedMap; + + Integer johnAge = lomap.remove("John");// by object + + assertEquals(johnAge, new Integer(36)); + assertEquals(lomap.size(), RUNNERS_COUNT - 1); + + Integer emilyAge = lomap.remove(0);// by index + assertEquals(emilyAge, new Integer(37)); + assertEquals(lomap.size(), RUNNERS_COUNT - 2); + } +} diff --git a/libraries-apache-commons-io/README.md b/libraries-apache-commons-io/README.md new file mode 100644 index 0000000000..d5f29499d2 --- /dev/null +++ b/libraries-apache-commons-io/README.md @@ -0,0 +1,7 @@ +## Apache Commons Collections + +This module contains articles about Apache Commons IO + +### Relevant articles +- [Apache Commons IO](https://www.baeldung.com/apache-commons-io) +- [Introduction to Apache Commons CSV](https://www.baeldung.com/apache-commons-csv) diff --git a/libraries-apache-commons-io/pom.xml b/libraries-apache-commons-io/pom.xml new file mode 100644 index 0000000000..7ec71d8264 --- /dev/null +++ b/libraries-apache-commons-io/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + libraries-apache-commons-io + libraries-apache-commons-io + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + + org.apache.commons + commons-csv + ${commons-csv.version} + + + commons-io + commons-io + ${commons-io.version} + + + + + 1.4 + + + diff --git a/libraries-apache-commons/src/main/java/com/baeldung/commons/io/FileMonitor.java b/libraries-apache-commons-io/src/main/java/com/baeldung/commons/io/FileMonitor.java similarity index 100% rename from libraries-apache-commons/src/main/java/com/baeldung/commons/io/FileMonitor.java rename to libraries-apache-commons-io/src/main/java/com/baeldung/commons/io/FileMonitor.java diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/io/CommonsIOUnitTest.java b/libraries-apache-commons-io/src/test/java/com/baeldung/commons/io/CommonsIOUnitTest.java similarity index 100% rename from libraries-apache-commons/src/test/java/com/baeldung/commons/io/CommonsIOUnitTest.java rename to libraries-apache-commons-io/src/test/java/com/baeldung/commons/io/CommonsIOUnitTest.java diff --git a/libraries-apache-commons/src/test/java/com/baeldung/commons/csv/CSVReaderWriterUnitTest.java b/libraries-apache-commons-io/src/test/java/com/baeldung/commons/io/csv/CSVReaderWriterUnitTest.java similarity index 98% rename from libraries-apache-commons/src/test/java/com/baeldung/commons/csv/CSVReaderWriterUnitTest.java rename to libraries-apache-commons-io/src/test/java/com/baeldung/commons/io/csv/CSVReaderWriterUnitTest.java index f93e59ed75..b99f4e8bc3 100644 --- a/libraries-apache-commons/src/test/java/com/baeldung/commons/csv/CSVReaderWriterUnitTest.java +++ b/libraries-apache-commons-io/src/test/java/com/baeldung/commons/io/csv/CSVReaderWriterUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.commons.csv; +package com.baeldung.commons.io.csv; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; diff --git a/libraries-apache-commons/src/test/resources/aaa.txt b/libraries-apache-commons-io/src/test/resources/aaa.txt similarity index 100% rename from libraries-apache-commons/src/test/resources/aaa.txt rename to libraries-apache-commons-io/src/test/resources/aaa.txt diff --git a/libraries-apache-commons/src/test/resources/book.csv b/libraries-apache-commons-io/src/test/resources/book.csv similarity index 100% rename from libraries-apache-commons/src/test/resources/book.csv rename to libraries-apache-commons-io/src/test/resources/book.csv diff --git a/libraries-apache-commons/src/test/resources/fileTest.txt b/libraries-apache-commons-io/src/test/resources/fileTest.txt similarity index 100% rename from libraries-apache-commons/src/test/resources/fileTest.txt rename to libraries-apache-commons-io/src/test/resources/fileTest.txt diff --git a/libraries-apache-commons/src/test/resources/sample.txt b/libraries-apache-commons-io/src/test/resources/sample.txt similarity index 100% rename from libraries-apache-commons/src/test/resources/sample.txt rename to libraries-apache-commons-io/src/test/resources/sample.txt diff --git a/libraries-apache-commons/.gitignore b/libraries-apache-commons/.gitignore deleted file mode 100644 index e594daf27a..0000000000 --- a/libraries-apache-commons/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.class - -# Folders # -/gensrc -/target - -# Packaged files # -*.jar -/bin/ diff --git a/libraries-apache-commons/README.md b/libraries-apache-commons/README.md index 01f2379588..7d1f5b8333 100644 --- a/libraries-apache-commons/README.md +++ b/libraries-apache-commons/README.md @@ -1,20 +1,11 @@ ### Relevant articles -- [Array Processing with Apache Commons Lang 3](http://www.baeldung.com/array-processing-commons-lang) -- [String Processing with Apache Commons Lang 3](http://www.baeldung.com/string-processing-commons-lang) -- [Introduction to Apache Commons Math](http://www.baeldung.com/apache-commons-math) -- [Apache Commons Collections SetUtils](http://www.baeldung.com/apache-commons-setutils) -- [Apache Commons Collections OrderedMap](http://www.baeldung.com/apache-commons-ordered-map) -- [Introduction to Apache Commons Text](http://www.baeldung.com/java-apache-commons-text) -- [A Guide to Apache Commons DbUtils](http://www.baeldung.com/apache-commons-dbutils) -- [Guide to Apache Commons CircularFifoQueue](http://www.baeldung.com/commons-circular-fifo-queue) -- [Apache Commons Chain](http://www.baeldung.com/apache-commons-chain) -- [Introduction to Apache Commons CSV](http://www.baeldung.com/apache-commons-csv) -- [Apache Commons IO](http://www.baeldung.com/apache-commons-io) -- [Apache Commons Collections Bag](http://www.baeldung.com/apache-commons-bag) -- [A Guide to Apache Commons Collections CollectionUtils](http://www.baeldung.com/apache-commons-collection-utils) -- [Apache Commons BeanUtils](http://www.baeldung.com/apache-commons-beanutils) -- [Apache Commons Collections BidiMap](http://www.baeldung.com/commons-collections-bidi-map) -- [Apache Commons Collections MapUtils](http://www.baeldung.com/apache-commons-map-utils) -- [Histograms with Apache Commons Frequency](http://www.baeldung.com/apache-commons-frequency) -- [An Introduction to Apache Commons Lang 3](https://www.baeldung.com/java-commons-lang-3) \ No newline at end of file +- [Array Processing with Apache Commons Lang 3](https://www.baeldung.com/array-processing-commons-lang) +- [String Processing with Apache Commons Lang 3](https://www.baeldung.com/string-processing-commons-lang) +- [Introduction to Apache Commons Math](https://www.baeldung.com/apache-commons-math) +- [Introduction to Apache Commons Text](https://www.baeldung.com/java-apache-commons-text) +- [A Guide to Apache Commons DbUtils](https://www.baeldung.com/apache-commons-dbutils) +- [Apache Commons Chain](https://www.baeldung.com/apache-commons-chain) +- [Apache Commons BeanUtils](https://www.baeldung.com/apache-commons-beanutils) +- [Histograms with Apache Commons Frequency](https://www.baeldung.com/apache-commons-frequency) +- [An Introduction to Apache Commons Lang 3](https://www.baeldung.com/java-commons-lang-3) diff --git a/libraries-apache-commons/pom.xml b/libraries-apache-commons/pom.xml index 05d11d83fe..f83a8c7304 100644 --- a/libraries-apache-commons/pom.xml +++ b/libraries-apache-commons/pom.xml @@ -32,21 +32,11 @@ commons-text ${commons-text.version} - - commons-io - commons-io - ${commons-io.version} - commons-chain commons-chain ${commons-chain.version} - - org.apache.commons - commons-csv - ${commons-csv.version} - commons-dbutils commons-dbutils @@ -72,18 +62,6 @@ xchart ${xchart-version} - - org.apache.commons - commons-collections4 - ${commons.collections.version} - - - org.hamcrest - java-hamcrest - ${org.hamcrest.java-hamcrest.version} - test - - @@ -91,11 +69,8 @@ 1.1 1.9.3 1.2 - 1.4 3.6.2 1.6 - 4.1 - 2.0.0.0 1.10.L001 3.5.2 3.6 diff --git a/libraries-data-2/README.md b/libraries-data-2/README.md index 8101138c0e..ae113e7f70 100644 --- a/libraries-data-2/README.md +++ b/libraries-data-2/README.md @@ -1,11 +1,11 @@ ### Relevant articles -- [Introduction to Apache Flink with Java](http://www.baeldung.com/apache-flink) -- [Guide to the HyperLogLog Algorithm](http://www.baeldung.com/java-hyperloglog) -- [Introduction to Conflict-Free Replicated Data Types](http://www.baeldung.com/java-conflict-free-replicated-data-types) -- [Introduction to javax.measure](http://www.baeldung.com/javax-measure) -- [Introduction To Docx4J](http://www.baeldung.com/docx4j) -- [Interact with Google Sheets from Java](http://www.baeldung.com/google-sheets-java-client) -- [Introduction To OpenCSV](http://www.baeldung.com/opencsv) -- [Introduction to Smooks](http://www.baeldung.com/smooks) -- [A Guide to Infinispan in Java](http://www.baeldung.com/infinispan) +- [Introduction to Apache Flink with Java](https://www.baeldung.com/apache-flink) +- [Guide to the HyperLogLog Algorithm](https://www.baeldung.com/java-hyperloglog) +- [Introduction to Conflict-Free Replicated Data Types](https://www.baeldung.com/java-conflict-free-replicated-data-types) +- [Introduction to javax.measure](https://www.baeldung.com/javax-measure) +- [Introduction To Docx4J](https://www.baeldung.com/docx4j) +- [Interact with Google Sheets from Java](https://www.baeldung.com/google-sheets-java-client) +- [Introduction To OpenCSV](https://www.baeldung.com/opencsv) +- [Introduction to Smooks](https://www.baeldung.com/smooks) +- [A Guide to Infinispan in Java](https://www.baeldung.com/infinispan) diff --git a/libraries-data-3/README.md b/libraries-data-3/README.md index 7f939e7909..6be6eae4a8 100644 --- a/libraries-data-3/README.md +++ b/libraries-data-3/README.md @@ -1,5 +1,5 @@ ### Relevant articles -- [Parsing YAML with SnakeYAML](http://www.baeldung.com/java-snake-yaml) +- [Parsing YAML with SnakeYAML](https://www.baeldung.com/java-snake-yaml) - [Guide to JMapper](https://www.baeldung.com/jmapper) - [An Introduction to SuanShu](https://www.baeldung.com/suanshu) - [Intro to Derive4J](https://www.baeldung.com/derive4j) diff --git a/libraries-data/README.md b/libraries-data/README.md index 92c546c258..e1d3c40222 100644 --- a/libraries-data/README.md +++ b/libraries-data/README.md @@ -1,16 +1,17 @@ ### Relevant articles -- [Introduction to Reladomo](http://www.baeldung.com/reladomo) -- [Introduction to ORMLite](http://www.baeldung.com/ormlite) -- [Introduction To Kryo](http://www.baeldung.com/kryo) -- [Introduction to KafkaStreams in Java](http://www.baeldung.com/java-kafka-streams) -- [Guide to Java Data Objects](http://www.baeldung.com/jdo) -- [Intro to JDO Queries 2/2](http://www.baeldung.com/jdo-queries) -- [Introduction to HikariCP](http://www.baeldung.com/hikaricp) -- [Introduction to JCache](http://www.baeldung.com/jcache) -- [A Guide to Apache Ignite](http://www.baeldung.com/apache-ignite) -- [Apache Ignite with Spring Data](http://www.baeldung.com/apache-ignite-spring-data) +- [Introduction to Reladomo](https://www.baeldung.com/reladomo) +- [Introduction to ORMLite](https://www.baeldung.com/ormlite) +- [Introduction To Kryo](https://www.baeldung.com/kryo) +- [Introduction to KafkaStreams in Java](https://www.baeldung.com/java-kafka-streams) +- [Guide to Java Data Objects](https://www.baeldung.com/jdo) +- [Intro to JDO Queries 2/2](https://www.baeldung.com/jdo-queries) +- [Introduction to HikariCP](https://www.baeldung.com/hikaricp) +- [Introduction to JCache](https://www.baeldung.com/jcache) +- [A Guide to Apache Ignite](https://www.baeldung.com/apache-ignite) +- [Apache Ignite with Spring Data](https://www.baeldung.com/apache-ignite-spring-data) - [A Guide to Apache Crunch](https://www.baeldung.com/apache-crunch) - [Intro to Apache Storm](https://www.baeldung.com/apache-storm) - [Guide to Ebean ORM](https://www.baeldung.com/ebean-orm) - [Introduction to Kafka Connectors](https://www.baeldung.com/kafka-connectors-guide) - [Kafka Connect Example with MQTT and MongoDB](https://www.baeldung.com/kafka-connect-mqtt-mongodb) +- [Building a Data Pipeline with Flink and Kafka](https://www.baeldung.com/kafka-flink-data-pipeline) diff --git a/libraries-http/README.md b/libraries-http/README.md index d5eaed0736..436268e707 100644 --- a/libraries-http/README.md +++ b/libraries-http/README.md @@ -1,11 +1,11 @@ ### Relevant Articles: -- [A Guide to OkHttp](http://www.baeldung.com/guide-to-okhttp) -- [A Guide to Google-Http-Client](http://www.baeldung.com/google-http-client) -- [Asynchronous HTTP with async-http-client in Java](http://www.baeldung.com/async-http-client) -- [WebSockets with AsyncHttpClient](http://www.baeldung.com/async-http-client-websockets) -- [Integrating Retrofit with RxJava](http://www.baeldung.com/retrofit-rxjava) -- [Introduction to Retrofit](http://www.baeldung.com/retrofit) -- [A Guide to Unirest](http://www.baeldung.com/unirest) -- [Creating REST Microservices with Javalin](http://www.baeldung.com/javalin-rest-microservices) \ No newline at end of file +- [A Guide to OkHttp](https://www.baeldung.com/guide-to-okhttp) +- [A Guide to Google-Http-Client](https://www.baeldung.com/google-http-client) +- [Asynchronous HTTP with async-http-client in Java](https://www.baeldung.com/async-http-client) +- [WebSockets with AsyncHttpClient](https://www.baeldung.com/async-http-client-websockets) +- [Integrating Retrofit with RxJava](https://www.baeldung.com/retrofit-rxjava) +- [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) diff --git a/libraries-server/README.md b/libraries-server/README.md index b5392f5883..5245b98139 100644 --- a/libraries-server/README.md +++ b/libraries-server/README.md @@ -1,11 +1,11 @@ ## Relevant Articles: -- [Embedded Jetty Server in Java](http://www.baeldung.com/jetty-embedded) -- [Introduction to Netty](http://www.baeldung.com/netty) -- [Exceptions in Netty](http://www.baeldung.com/netty-exception-handling) -- [Programmatically Create, Configure and Run a Tomcat Server](http://www.baeldung.com/tomcat-programmatic-setup) -- [Creating and Configuring Jetty 9 Server in Java](http://www.baeldung.com/jetty-java-programmatic) -- [Testing Netty with EmbeddedChannel](http://www.baeldung.com/testing-netty-embedded-channel) +- [Embedded Jetty Server in Java](https://www.baeldung.com/jetty-embedded) +- [Introduction to Netty](https://www.baeldung.com/netty) +- [Exceptions in Netty](https://www.baeldung.com/netty-exception-handling) +- [Programmatically Create, Configure and Run a Tomcat Server](https://www.baeldung.com/tomcat-programmatic-setup) +- [Creating and Configuring Jetty 9 Server in Java](https://www.baeldung.com/jetty-java-programmatic) +- [Testing Netty with EmbeddedChannel](https://www.baeldung.com/testing-netty-embedded-channel) - [MQTT Client in Java](https://www.baeldung.com/java-mqtt-client) - [Guide to XMPP Smack Client](https://www.baeldung.com/xmpp-smack-chat-client) - [A Guide to NanoHTTPD](https://www.baeldung.com/nanohttpd) diff --git a/libraries-testing/README.md b/libraries-testing/README.md index fb2c7123a3..3f1904dc50 100644 --- a/libraries-testing/README.md +++ b/libraries-testing/README.md @@ -1,9 +1,9 @@ ### Relevant articles -- [Introduction to Serenity BDD](http://www.baeldung.com/serenity-bdd) -- [Introduction to JSONassert](http://www.baeldung.com/jsonassert) -- [Serenity BDD and Screenplay](http://www.baeldung.com/serenity-screenplay) -- [Serenity BDD with Spring and JBehave](http://www.baeldung.com/serenity-spring-jbehave) -- [Introduction to Awaitlity](http://www.baeldung.com/awaitlity-testing) -- [Introduction to Hoverfly in Java](http://www.baeldung.com/hoverfly) -- [Testing with Hamcrest](http://www.baeldung.com/java-junit-hamcrest-guide) \ No newline at end of file +- [Introduction to Serenity BDD](https://www.baeldung.com/serenity-bdd) +- [Introduction to JSONassert](https://www.baeldung.com/jsonassert) +- [Serenity BDD and Screenplay](https://www.baeldung.com/serenity-screenplay) +- [Serenity BDD with Spring and JBehave](https://www.baeldung.com/serenity-spring-jbehave) +- [Introduction to Awaitlity](https://www.baeldung.com/awaitlity-testing) +- [Introduction to Hoverfly in Java](https://www.baeldung.com/hoverfly) +- [Testing with Hamcrest](https://www.baeldung.com/java-junit-hamcrest-guide) diff --git a/libraries-testing/pom.xml b/libraries-testing/pom.xml index 7cc5a8f775..a2fbed31b2 100644 --- a/libraries-testing/pom.xml +++ b/libraries-testing/pom.xml @@ -43,6 +43,12 @@ serenity-rest-assured ${serenity.version} test + + + io.rest-assured + rest-assured + + net.serenity-bdd @@ -162,15 +168,15 @@ - 1.9.26 - 1.41.0 + 1.9.9 + 1.9.0 1.9.0 1.9.27 1.5.0 3.0.0 0.8.1 4.3.8.RELEASE - 3.0.3 + 4.1.1 3.6.2 2.0.0.0 diff --git a/libraries-testing/src/test/java/com/baeldung/hamcrest/Animal.java b/libraries-testing/src/test/java/com/baeldung/hamcrest/Animal.java index 1a0266f5a3..1d37eef59b 100644 --- a/libraries-testing/src/test/java/com/baeldung/hamcrest/Animal.java +++ b/libraries-testing/src/test/java/com/baeldung/hamcrest/Animal.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; public class Animal { String name; diff --git a/libraries-testing/src/test/java/com/baeldung/hamcrest/Cat.java b/libraries-testing/src/test/java/com/baeldung/hamcrest/Cat.java index 892e5b6e30..b15a3628da 100644 --- a/libraries-testing/src/test/java/com/baeldung/hamcrest/Cat.java +++ b/libraries-testing/src/test/java/com/baeldung/hamcrest/Cat.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; public class Cat extends Animal { diff --git a/libraries-testing/src/test/java/com/baeldung/hamcrest/HamcrestMatcherUnitTest.java b/libraries-testing/src/test/java/com/baeldung/hamcrest/HamcrestMatcherUnitTest.java index cf9fde7114..f5887ba79b 100644 --- a/libraries-testing/src/test/java/com/baeldung/hamcrest/HamcrestMatcherUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/hamcrest/HamcrestMatcherUnitTest.java @@ -1,10 +1,10 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; import org.junit.Test; import java.util.*; -import static org.baeldung.hamcrest.IsPositiveInteger.isAPositiveInteger; +import static com.baeldung.hamcrest.IsPositiveInteger.isAPositiveInteger; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.hamcrest.beans.HasProperty.hasProperty; diff --git a/libraries-testing/src/test/java/com/baeldung/hamcrest/IsPositiveInteger.java b/libraries-testing/src/test/java/com/baeldung/hamcrest/IsPositiveInteger.java index 0d8d262538..4d2ef8a8e5 100644 --- a/libraries-testing/src/test/java/com/baeldung/hamcrest/IsPositiveInteger.java +++ b/libraries-testing/src/test/java/com/baeldung/hamcrest/IsPositiveInteger.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; import org.hamcrest.Description; import org.hamcrest.Factory; diff --git a/libraries-testing/src/test/java/com/baeldung/hamcrest/Person.java b/libraries-testing/src/test/java/com/baeldung/hamcrest/Person.java index 0053c98043..417daa866e 100644 --- a/libraries-testing/src/test/java/com/baeldung/hamcrest/Person.java +++ b/libraries-testing/src/test/java/com/baeldung/hamcrest/Person.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; public class Person { String name; diff --git a/libraries/README.md b/libraries/README.md index 5d44247728..627c30e75a 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -9,41 +9,41 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m ### Relevant articles -- [Introduction to Javatuples](http://www.baeldung.com/java-tuples) -- [Introduction to Javassist](http://www.baeldung.com/javassist) -- [Introduction to Apache Flink with Java](http://www.baeldung.com/apache-flink) -- [Intro to JaVers](http://www.baeldung.com/javers) -- [Merging Streams in Java](http://www.baeldung.com/java-merge-streams) -- [Introduction to Quartz](http://www.baeldung.com/quartz) -- [How to Warm Up the JVM](http://www.baeldung.com/java-jvm-warmup) -- [Software Transactional Memory in Java Using Multiverse](http://www.baeldung.com/java-multiverse-stm) -- [Locality-Sensitive Hashing in Java Using Java-LSH](http://www.baeldung.com/locality-sensitive-hashing) -- [Introduction to Neuroph](http://www.baeldung.com/neuroph) -- [Quick Guide to RSS with Rome](http://www.baeldung.com/rome-rss) -- [Introduction to PCollections](http://www.baeldung.com/java-pcollections) -- [Introduction to Eclipse Collections](http://www.baeldung.com/eclipse-collections) -- [DistinctBy in the Java Stream API](http://www.baeldung.com/java-streams-distinct-by) -- [Introduction to NoException](http://www.baeldung.com/no-exception) -- [Spring Yarg Integration](http://www.baeldung.com/spring-yarg) -- [Delete a Directory Recursively in Java](http://www.baeldung.com/java-delete-directory) -- [Guide to JDeferred](http://www.baeldung.com/jdeferred) -- [Introduction to MBassador](http://www.baeldung.com/mbassador) -- [Using Pairs in Java](http://www.baeldung.com/java-pairs) -- [Introduction to Caffeine](http://www.baeldung.com/java-caching-caffeine) -- [Introduction to StreamEx](http://www.baeldung.com/streamex) -- [A Docker Guide for Java](http://www.baeldung.com/docker-java-api) -- [Introduction to Akka Actors in Java](http://www.baeldung.com/akka-actors-java) -- [A Guide to Byte Buddy](http://www.baeldung.com/byte-buddy) -- [Introduction to jOOL](http://www.baeldung.com/jool) -- [Consumer Driven Contracts with Pact](http://www.baeldung.com/pact-junit-consumer-driven-contracts) -- [Introduction to Atlassian Fugue](http://www.baeldung.com/java-fugue) -- [Publish and Receive Messages with Nats Java Client](http://www.baeldung.com/nats-java-client) -- [Java Concurrency Utility with JCTools](http://www.baeldung.com/java-concurrency-jc-tools) -- [Introduction to JavaPoet](http://www.baeldung.com/java-poet) -- [Convert String to Date in Java](http://www.baeldung.com/java-string-to-date) -- [Guide to Resilience4j](http://www.baeldung.com/resilience4j) +- [Introduction to Javatuples](https://www.baeldung.com/java-tuples) +- [Introduction to Javassist](https://www.baeldung.com/javassist) +- [Introduction to Apache Flink with Java](https://www.baeldung.com/apache-flink) +- [Intro to JaVers](https://www.baeldung.com/javers) +- [Merging Streams in Java](https://www.baeldung.com/java-merge-streams) +- [Introduction to Quartz](https://www.baeldung.com/quartz) +- [How to Warm Up the JVM](https://www.baeldung.com/java-jvm-warmup) +- [Software Transactional Memory in Java Using Multiverse](https://www.baeldung.com/java-multiverse-stm) +- [Locality-Sensitive Hashing in Java Using Java-LSH](https://www.baeldung.com/locality-sensitive-hashing) +- [Introduction to Neuroph](https://www.baeldung.com/neuroph) +- [Quick Guide to RSS with Rome](https://www.baeldung.com/rome-rss) +- [Introduction to PCollections](https://www.baeldung.com/java-pcollections) +- [Introduction to Eclipse Collections](https://www.baeldung.com/eclipse-collections) +- [DistinctBy in the Java Stream API](https://www.baeldung.com/java-streams-distinct-by) +- [Introduction to NoException](https://www.baeldung.com/no-exception) +- [Spring Yarg Integration](https://www.baeldung.com/spring-yarg) +- [Delete a Directory Recursively in Java](https://www.baeldung.com/java-delete-directory) +- [Guide to JDeferred](https://www.baeldung.com/jdeferred) +- [Introduction to MBassador](https://www.baeldung.com/mbassador) +- [Using Pairs in Java](https://www.baeldung.com/java-pairs) +- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine) +- [Introduction to StreamEx](https://www.baeldung.com/streamex) +- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api) +- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java) +- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy) +- [Introduction to jOOL](https://www.baeldung.com/jool) +- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts) +- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue) +- [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client) +- [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools) +- [Introduction to JavaPoet](https://www.baeldung.com/java-poet) +- [Convert String to Date in Java](https://www.baeldung.com/java-string-to-date) +- [Guide to Resilience4j](https://www.baeldung.com/resilience4j) - [Exactly Once Processing in Kafka](https://www.baeldung.com/kafka-exactly-once) -- [Implementing a FTP-Client in Java](http://www.baeldung.com/java-ftp-client) +- [Implementing a FTP-Client in Java](https://www.baeldung.com/java-ftp-client) - [Introduction to Functional Java](https://www.baeldung.com/java-functional-library) - [A Guide to the Reflections Library](https://www.baeldung.com/reflections-library) - More articles [[next -->]](/libraries-2) diff --git a/linkrest/README.md b/linkrest/README.md index 33cf930b18..8297b14bb5 100644 --- a/linkrest/README.md +++ b/linkrest/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [Guide to LinkRest](http://www.baeldung.com/linkrest) +- [Guide to LinkRest](https://www.baeldung.com/linkrest) diff --git a/linux-bash/text/src/main/bash/remove_characters.sh b/linux-bash/text/src/main/bash/remove_characters.sh new file mode 100755 index 0000000000..a8f51468f4 --- /dev/null +++ b/linux-bash/text/src/main/bash/remove_characters.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +my_var="Hola Mundo" +echo ${my_var} + +my_filename="interesting-text-file.txt" +echo ${my_filename:0:21} + +echo ${my_filename%.*} + +complicated_filename="hello-world.tar.gz" +echo ${complicated_filename%%.*} + +echo ${my_filename/.*/} + +echo 'interesting-text-file.txt' | sed 's/.txt*//' + +echo 'interesting-text-file.txt' | cut -f1 -d"." +echo ${complicated_filename} | cut -f1 -d"." diff --git a/logging-modules/README.md b/logging-modules/README.md index 17405847b1..f5a1acaac1 100644 --- a/logging-modules/README.md +++ b/logging-modules/README.md @@ -3,5 +3,5 @@ ### Relevant Articles: -- [Creating a Custom Logback Appender](http://www.baeldung.com/custom-logback-appender) -- [A Guide To Logback](http://www.baeldung.com/logback) +- [Creating a Custom Logback Appender](https://www.baeldung.com/custom-logback-appender) +- [A Guide To Logback](https://www.baeldung.com/logback) diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2ComparisonSysout.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2ComparisonSysout.java new file mode 100644 index 0000000000..53592082b6 --- /dev/null +++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2ComparisonSysout.java @@ -0,0 +1,18 @@ +package com.baeldung.logging.log4j2; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintStream; + +public class Log4j2ComparisonSysout { + + public static void main(String[] args) throws FileNotFoundException { + PrintStream outStream = new PrintStream(new File("outFile.txt")); + System.setOut(outStream); + System.out.println("This is a baeldung article"); + + PrintStream errStream = new PrintStream(new File("errFile.txt")); + System.setErr(errStream); + System.err.println("This is a baeldung article error"); + } +} diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2Example.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2Example.java new file mode 100644 index 0000000000..b870924cf3 --- /dev/null +++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2Example.java @@ -0,0 +1,19 @@ +package com.baeldung.logging.log4j2; + +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +public class Log4j2Example { + + private static final Logger logger = LogManager.getLogger(Log4j2Example.class); + + public static void main(String[] args) { + logger.debug("Debug log message"); + logger.info("Info log message"); + logger.error("Error log message"); + logger.warn("Warn log message"); + logger.fatal("Fatal log message"); + logger.trace("Trace log message"); + } + +} diff --git a/logging-modules/log4j2/src/test/resources/log4j2.xml b/logging-modules/log4j2/src/test/resources/log4j2.xml index 246ffb0707..ee26bcecf2 100644 --- a/logging-modules/log4j2/src/test/resources/log4j2.xml +++ b/logging-modules/log4j2/src/test/resources/log4j2.xml @@ -5,8 +5,7 @@ - + diff --git a/lombok/README.md b/lombok/README.md index 4ff7ca7921..54a0984159 100644 --- a/lombok/README.md +++ b/lombok/README.md @@ -1,6 +1,6 @@ ## Relevant Articles: -- [Introduction to Project Lombok](http://www.baeldung.com/intro-to-project-lombok) -- [Using Lombok’s @Builder Annotation](http://www.baeldung.com/lombok-builder) +- [Introduction to Project Lombok](https://www.baeldung.com/intro-to-project-lombok) +- [Using Lombok’s @Builder Annotation](https://www.baeldung.com/lombok-builder) - [Using Lombok’s @Getter for Boolean Fields](https://www.baeldung.com/lombok-getter-boolean) - [Lombok @Builder with Inheritance](https://www.baeldung.com/lombok-builder-inheritance) - [Lombok Builder with Default Value](https://www.baeldung.com/lombok-builder-default-value) diff --git a/lucene/README.md b/lucene/README.md index ea7f715480..2bfd8bf4e1 100644 --- a/lucene/README.md +++ b/lucene/README.md @@ -1,5 +1,5 @@ ### Relevant Articles: -- [Introduction to Apache Lucene](http://www.baeldung.com/lucene) -- [A Simple File Search with Lucene](http://www.baeldung.com/lucene-file-search) +- [Introduction to Apache Lucene](https://www.baeldung.com/lucene) +- [A Simple File Search with Lucene](https://www.baeldung.com/lucene-file-search) - [Guide to Lucene Analyzers](https://www.baeldung.com/lucene-analyzers) diff --git a/mapstruct/README.md b/mapstruct/README.md index e279a48f7a..92c55a131d 100644 --- a/mapstruct/README.md +++ b/mapstruct/README.md @@ -1,2 +1,2 @@ ###Relevant Articles: -- [Quick Guide to MapStruct](http://www.baeldung.com/mapstruct) +- [Quick Guide to MapStruct](https://www.baeldung.com/mapstruct) diff --git a/mapstruct/pom.xml b/mapstruct/pom.xml index 2613dcf083..e98c4a318b 100644 --- a/mapstruct/pom.xml +++ b/mapstruct/pom.xml @@ -35,6 +35,12 @@ lombok ${org.projectlombok.version} + + org.assertj + assertj-core + ${assertj.version} + test + @@ -70,6 +76,7 @@ 1.8 1.8 1.18.4 + 3.11.1 diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/dto/CarDTO.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/dto/CarDTO.java new file mode 100644 index 0000000000..8f324f5a15 --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/dto/CarDTO.java @@ -0,0 +1,23 @@ +package com.baeldung.unmappedproperties.dto; + +public class CarDTO { + private int id; + private String 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; + } + +} \ No newline at end of file diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/dto/DocumentDTO.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/dto/DocumentDTO.java new file mode 100644 index 0000000000..8df306eb13 --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/dto/DocumentDTO.java @@ -0,0 +1,52 @@ +package com.baeldung.unmappedproperties.dto; + +import java.util.List; + +public class DocumentDTO { + private int id; + private String title; + private String text; + private List comments; + private String author; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public List getComments() { + return comments; + } + + public void setComments(List comments) { + this.comments = comments; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + +} \ No newline at end of file diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/entity/Car.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/entity/Car.java new file mode 100644 index 0000000000..c23ced3a6a --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/entity/Car.java @@ -0,0 +1,23 @@ +package com.baeldung.unmappedproperties.entity; + +public class Car { + private int id; + private String 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; + } + +} \ No newline at end of file diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/entity/Document.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/entity/Document.java new file mode 100644 index 0000000000..89457133a3 --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/entity/Document.java @@ -0,0 +1,42 @@ +package com.baeldung.unmappedproperties.entity; + +import java.util.Date; + +public class Document { + private int id; + private String title; + private String text; + private Date modificationTime; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getModificationTime() { + return modificationTime; + } + + public void setModificationTime(Date modificationTime) { + this.modificationTime = modificationTime; + } +} \ No newline at end of file diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/CarMapper.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/CarMapper.java new file mode 100644 index 0000000000..714301b811 --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/CarMapper.java @@ -0,0 +1,13 @@ +package com.baeldung.unmappedproperties.mapper; + +import com.baeldung.unmappedproperties.dto.CarDTO; +import com.baeldung.unmappedproperties.entity.Car; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface CarMapper { + CarMapper INSTANCE = Mappers.getMapper(CarMapper.class); + + CarDTO carToCarDTO(Car car); +} \ No newline at end of file diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapper.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapper.java new file mode 100644 index 0000000000..fe233ed172 --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapper.java @@ -0,0 +1,16 @@ +package com.baeldung.unmappedproperties.mapper; + +import com.baeldung.unmappedproperties.dto.DocumentDTO; +import com.baeldung.unmappedproperties.entity.Document; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface DocumentMapper { + + DocumentMapper INSTANCE = Mappers.getMapper(DocumentMapper.class); + + DocumentDTO documentToDocumentDTO(Document entity); + + Document documentDTOToDocument(DocumentDTO dto); +} \ No newline at end of file diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapperMappingIgnore.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapperMappingIgnore.java new file mode 100644 index 0000000000..bf3b0b49c4 --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapperMappingIgnore.java @@ -0,0 +1,20 @@ +package com.baeldung.unmappedproperties.mapper; + +import com.baeldung.unmappedproperties.dto.DocumentDTO; +import com.baeldung.unmappedproperties.entity.Document; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface DocumentMapperMappingIgnore { + + DocumentMapperMappingIgnore INSTANCE = Mappers.getMapper(DocumentMapperMappingIgnore.class); + + @Mapping(target = "comments", ignore = true) + DocumentDTO documentToDocumentDTO(Document entity); + + @Mapping(target = "modificationTime", ignore = true) + Document documentDTOToDocument(DocumentDTO dto); + +} \ No newline at end of file diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapperUnmappedPolicy.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapperUnmappedPolicy.java new file mode 100644 index 0000000000..b44f714774 --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapperUnmappedPolicy.java @@ -0,0 +1,17 @@ +package com.baeldung.unmappedproperties.mapper; + +import com.baeldung.unmappedproperties.dto.DocumentDTO; +import com.baeldung.unmappedproperties.entity.Document; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; + +@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface DocumentMapperUnmappedPolicy { + + DocumentMapperUnmappedPolicy INSTANCE = Mappers.getMapper(DocumentMapperUnmappedPolicy.class); + + DocumentDTO documentToDocumentDTO(Document entity); + + Document documentDTOToDocument(DocumentDTO dto); +} \ No newline at end of file diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapperWithConfig.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapperWithConfig.java new file mode 100644 index 0000000000..dfaab7e1a1 --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/DocumentMapperWithConfig.java @@ -0,0 +1,16 @@ +package com.baeldung.unmappedproperties.mapper; + +import com.baeldung.unmappedproperties.dto.DocumentDTO; +import com.baeldung.unmappedproperties.entity.Document; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper(config = IgnoreUnmappedMapperConfig.class) +public interface DocumentMapperWithConfig { + + DocumentMapperWithConfig INSTANCE = Mappers.getMapper(DocumentMapperWithConfig.class); + + DocumentDTO documentToDocumentDTO(Document entity); + + Document documentDTOToDocument(DocumentDTO dto); +} \ No newline at end of file diff --git a/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/IgnoreUnmappedMapperConfig.java b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/IgnoreUnmappedMapperConfig.java new file mode 100644 index 0000000000..804ce9c03a --- /dev/null +++ b/mapstruct/src/main/java/com/baeldung/unmappedproperties/mapper/IgnoreUnmappedMapperConfig.java @@ -0,0 +1,8 @@ +package com.baeldung.unmappedproperties.mapper; + +import org.mapstruct.MapperConfig; +import org.mapstruct.ReportingPolicy; + +@MapperConfig(unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface IgnoreUnmappedMapperConfig { +} \ No newline at end of file diff --git a/mapstruct/src/test/java/com/baeldung/mapper/DeliveryAddressMapperUnitTest.java b/mapstruct/src/test/java/com/baeldung/mapper/DeliveryAddressMapperUnitTest.java index e2c12fcba3..7d1e432546 100644 --- a/mapstruct/src/test/java/com/baeldung/mapper/DeliveryAddressMapperUnitTest.java +++ b/mapstruct/src/test/java/com/baeldung/mapper/DeliveryAddressMapperUnitTest.java @@ -17,48 +17,51 @@ public class DeliveryAddressMapperUnitTest { @Test public void testGivenCustomerAndAddress_mapsToDeliveryAddress() { - // given + // given a customer Customer customer = new Customer().setFirstName("Max") .setLastName("Powers"); + // and some address Address homeAddress = new Address().setStreet("123 Some Street") .setCounty("Nevada") .setPostalcode("89123"); - // when + // when calling DeliveryAddressMapper::from DeliveryAddress deliveryAddress = deliveryAddressMapper.from(customer, homeAddress); - // then + // then a new DeliveryAddress is created, based on the given customer and his home address assertEquals(deliveryAddress.getForename(), customer.getFirstName()); assertEquals(deliveryAddress.getSurname(), customer.getLastName()); assertEquals(deliveryAddress.getStreet(), homeAddress.getStreet()); assertEquals(deliveryAddress.getCounty(), homeAddress.getCounty()); assertEquals(deliveryAddress.getPostalcode(), homeAddress.getPostalcode()); + } @Test public void testGivenDeliveryAddressAndSomeOtherAddress_updatesDeliveryAddress() { - // given - Customer customer = new Customer().setFirstName("Max") - .setLastName("Powers"); - - DeliveryAddress deliveryAddress = new DeliveryAddress().setStreet("123 Some Street") + // given a delivery address + DeliveryAddress deliveryAddress = new DeliveryAddress().setForename("Max") + .setSurname("Powers") + .setStreet("123 Some Street") .setCounty("Nevada") .setPostalcode("89123"); - Address otherAddress = new Address().setStreet("456 Some other street") + // and some new address + Address newAddress = new Address().setStreet("456 Some other street") .setCounty("Arizona") .setPostalcode("12345"); - // when - DeliveryAddress updatedDeliveryAddress = deliveryAddressMapper.updateAddress(deliveryAddress, otherAddress); + // when calling DeliveryAddressMapper::updateAddress + DeliveryAddress updatedDeliveryAddress = deliveryAddressMapper.updateAddress(deliveryAddress, newAddress); - // then + // then the *existing* delivery address is updated assertSame(deliveryAddress, updatedDeliveryAddress); - assertEquals(deliveryAddress.getStreet(), otherAddress.getStreet()); - assertEquals(deliveryAddress.getCounty(), otherAddress.getCounty()); - assertEquals(deliveryAddress.getPostalcode(), otherAddress.getPostalcode()); + assertEquals(deliveryAddress.getStreet(), newAddress.getStreet()); + assertEquals(deliveryAddress.getCounty(), newAddress.getCounty()); + assertEquals(deliveryAddress.getPostalcode(), newAddress.getPostalcode()); + } } diff --git a/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/CarMapperUnitTest.java b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/CarMapperUnitTest.java new file mode 100644 index 0000000000..4ce04015f1 --- /dev/null +++ b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/CarMapperUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.mapper.unmappedproperties; + +import com.baeldung.unmappedproperties.dto.CarDTO; +import com.baeldung.unmappedproperties.entity.Car; +import com.baeldung.unmappedproperties.mapper.CarMapper; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CarMapperUnitTest { + + @Test + public void givenCarEntitytoCar_whenMaps_thenCorrect() { + Car entity = new Car(); + entity.setId(1); + entity.setName("Toyota"); + + CarDTO carDto = CarMapper.INSTANCE.carToCarDTO(entity); + + assertThat(carDto.getId()).isEqualTo(entity.getId()); + assertThat(carDto.getName()).isEqualTo(entity.getName()); + } +} diff --git a/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperMappingIgnoreUnitTest.java b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperMappingIgnoreUnitTest.java new file mode 100644 index 0000000000..493c7f8686 --- /dev/null +++ b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperMappingIgnoreUnitTest.java @@ -0,0 +1,45 @@ +package com.baeldung.mapper.unmappedproperties; + +import com.baeldung.unmappedproperties.dto.DocumentDTO; +import com.baeldung.unmappedproperties.entity.Document; +import com.baeldung.unmappedproperties.mapper.DocumentMapperMappingIgnore; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Date; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DocumentMapperMappingIgnoreUnitTest { + + @Test + public void givenDocumentEntityToDocumentDto_whenMaps_thenCorrect() { + Document entity = new Document(); + entity.setId(1); + entity.setTitle("Price 13-42"); + entity.setText("List of positions......."); + entity.setModificationTime(new Date()); + + DocumentDTO dto = DocumentMapperMappingIgnore.INSTANCE.documentToDocumentDTO(entity); + + assertThat(dto.getId()).isEqualTo(entity.getId()); + assertThat(dto.getTitle()).isEqualTo(entity.getTitle()); + assertThat(dto.getText()).isEqualTo(entity.getText()); + } + + @Test + public void givenDocumentDtoToDocumentEntity_whenMaps_thenCorrect() { + DocumentDTO dto = new DocumentDTO(); + dto.setId(1); + dto.setTitle("Price 13-42"); + dto.setText("List of positions......."); + dto.setComments(Arrays.asList("Not all positions", "Wrong price values")); + dto.setAuthor("Author1"); + + Document entity = DocumentMapperMappingIgnore.INSTANCE.documentDTOToDocument(dto); + + assertThat(entity.getId()).isEqualTo(dto.getId()); + assertThat(entity.getTitle()).isEqualTo(dto.getTitle()); + assertThat(entity.getText()).isEqualTo(dto.getText()); + } +} \ No newline at end of file diff --git a/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperUnitTest.java b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperUnitTest.java new file mode 100644 index 0000000000..1d3645ca96 --- /dev/null +++ b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperUnitTest.java @@ -0,0 +1,45 @@ +package com.baeldung.mapper.unmappedproperties; + +import com.baeldung.unmappedproperties.dto.DocumentDTO; +import com.baeldung.unmappedproperties.entity.Document; +import com.baeldung.unmappedproperties.mapper.DocumentMapper; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Date; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DocumentMapperUnitTest { + + @Test + public void givenDocumentEntityToDocumentDto_whenMaps_thenCorrect() { + Document entity = new Document(); + entity.setId(1); + entity.setTitle("Price 13-42"); + entity.setText("List of positions......."); + entity.setModificationTime(new Date()); + + DocumentDTO dto = DocumentMapper.INSTANCE.documentToDocumentDTO(entity); + + assertThat(dto.getId()).isEqualTo(entity.getId()); + assertThat(dto.getTitle()).isEqualTo(entity.getTitle()); + assertThat(dto.getText()).isEqualTo(entity.getText()); + } + + @Test + public void givenDocumentDtoToDocumentEntity_whenMaps_thenCorrect() { + DocumentDTO dto = new DocumentDTO(); + dto.setId(1); + dto.setTitle("Price 13-42"); + dto.setText("List of positions......."); + dto.setComments(Arrays.asList("Not all positions", "Wrong price values")); + dto.setAuthor("Author1"); + + Document entity = DocumentMapper.INSTANCE.documentDTOToDocument(dto); + + assertThat(entity.getId()).isEqualTo(dto.getId()); + assertThat(entity.getTitle()).isEqualTo(dto.getTitle()); + assertThat(entity.getText()).isEqualTo(dto.getText()); + } +} \ No newline at end of file diff --git a/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperUnmappedPolicyUnitTest.java b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperUnmappedPolicyUnitTest.java new file mode 100644 index 0000000000..f6666a52ec --- /dev/null +++ b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperUnmappedPolicyUnitTest.java @@ -0,0 +1,45 @@ +package com.baeldung.mapper.unmappedproperties; + +import com.baeldung.unmappedproperties.dto.DocumentDTO; +import com.baeldung.unmappedproperties.entity.Document; +import com.baeldung.unmappedproperties.mapper.DocumentMapperUnmappedPolicy; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Date; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DocumentMapperUnmappedPolicyUnitTest { + + @Test + public void givenDocumentEntityToDocumentDto_whenMaps_thenCorrect() { + Document entity = new Document(); + entity.setId(1); + entity.setTitle("Price 13-42"); + entity.setText("List of positions......."); + entity.setModificationTime(new Date()); + + DocumentDTO dto = DocumentMapperUnmappedPolicy.INSTANCE.documentToDocumentDTO(entity); + + assertThat(dto.getId()).isEqualTo(entity.getId()); + assertThat(dto.getTitle()).isEqualTo(entity.getTitle()); + assertThat(dto.getText()).isEqualTo(entity.getText()); + } + + @Test + public void givenDocumentDtoToDocumentEntity_whenMaps_thenCorrect() { + DocumentDTO dto = new DocumentDTO(); + dto.setId(1); + dto.setTitle("Price 13-42"); + dto.setText("List of positions......."); + dto.setComments(Arrays.asList("Not all positions", "Wrong price values")); + dto.setAuthor("Author1"); + + Document entity = DocumentMapperUnmappedPolicy.INSTANCE.documentDTOToDocument(dto); + + assertThat(entity.getId()).isEqualTo(dto.getId()); + assertThat(entity.getTitle()).isEqualTo(dto.getTitle()); + assertThat(entity.getText()).isEqualTo(dto.getText()); + } +} \ No newline at end of file diff --git a/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperWithConfigUnitTest.java b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperWithConfigUnitTest.java new file mode 100644 index 0000000000..c9409225f5 --- /dev/null +++ b/mapstruct/src/test/java/com/baeldung/mapper/unmappedproperties/DocumentMapperWithConfigUnitTest.java @@ -0,0 +1,45 @@ +package com.baeldung.mapper.unmappedproperties; + +import com.baeldung.unmappedproperties.dto.DocumentDTO; +import com.baeldung.unmappedproperties.entity.Document; +import com.baeldung.unmappedproperties.mapper.DocumentMapperWithConfig; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Date; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DocumentMapperWithConfigUnitTest { + + @Test + public void givenDocumentEntityToDocumentDto_whenMaps_thenCorrect() { + Document entity = new Document(); + entity.setId(1); + entity.setTitle("Price 13-42"); + entity.setText("List of positions......."); + entity.setModificationTime(new Date()); + + DocumentDTO dto = DocumentMapperWithConfig.INSTANCE.documentToDocumentDTO(entity); + + assertThat(dto.getId()).isEqualTo(entity.getId()); + assertThat(dto.getTitle()).isEqualTo(entity.getTitle()); + assertThat(dto.getText()).isEqualTo(entity.getText()); + } + + @Test + public void givenDocumentDtoToDocumentEntity_whenMaps_thenCorrect() { + DocumentDTO dto = new DocumentDTO(); + dto.setId(1); + dto.setTitle("Price 13-42"); + dto.setText("List of positions......."); + dto.setComments(Arrays.asList("Not all positions", "Wrong price values")); + dto.setAuthor("Author1"); + + Document entity = DocumentMapperWithConfig.INSTANCE.documentDTOToDocument(dto); + + assertThat(entity.getId()).isEqualTo(dto.getId()); + assertThat(entity.getTitle()).isEqualTo(dto.getTitle()); + assertThat(entity.getText()).isEqualTo(dto.getText()); + } +} \ No newline at end of file diff --git a/maven-all/README.md b/maven-all/README.md new file mode 100644 index 0000000000..d014f323d2 --- /dev/null +++ b/maven-all/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Apache Maven Tutorial](https://www.baeldung.com/maven) \ No newline at end of file diff --git a/maven-all/compiler-plugin-java-9/README.md b/maven-all/compiler-plugin-java-9/README.md new file mode 100644 index 0000000000..d0b7b72acc --- /dev/null +++ b/maven-all/compiler-plugin-java-9/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Maven Compiler Plugin](http://www.baeldung.com/maven-compiler-plugin) \ No newline at end of file diff --git a/maven/compiler-plugin-java-9/pom.xml b/maven-all/compiler-plugin-java-9/pom.xml similarity index 100% rename from maven/compiler-plugin-java-9/pom.xml rename to maven-all/compiler-plugin-java-9/pom.xml diff --git a/maven/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java b/maven-all/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java similarity index 100% rename from maven/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java rename to maven-all/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java diff --git a/maven/compiler-plugin-java-9/src/main/java/module-info.java b/maven-all/compiler-plugin-java-9/src/main/java/module-info.java similarity index 100% rename from maven/compiler-plugin-java-9/src/main/java/module-info.java rename to maven-all/compiler-plugin-java-9/src/main/java/module-info.java diff --git a/maven-all/maven-war-plugin/README.md b/maven-all/maven-war-plugin/README.md new file mode 100644 index 0000000000..d559fea80b --- /dev/null +++ b/maven-all/maven-war-plugin/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Eclipse Error: web.xml is missing and failOnMissingWebXml is set to true](https://www.baeldung.com/eclipse-error-web-xml-missing) \ No newline at end of file diff --git a/maven/maven-war-plugin/pom.xml b/maven-all/maven-war-plugin/pom.xml similarity index 89% rename from maven/maven-war-plugin/pom.xml rename to maven-all/maven-war-plugin/pom.xml index 517c08978f..25c2e1ba1b 100644 --- a/maven/maven-war-plugin/pom.xml +++ b/maven-all/maven-war-plugin/pom.xml @@ -1,29 +1,29 @@ - - 4.0.0 - com.baeldung - maven-war-plugin-property - 0.0.1-SNAPSHOT - war - maven-war-plugin-property - - - - - maven-war-plugin - - 3.1.0 - - - false - - - - - - - - false - + + 4.0.0 + com.baeldung + maven-war-plugin + 0.0.1-SNAPSHOT + war + maven-war-plugin + + + + + maven-war-plugin + + 3.1.0 + + + false + + + + + + + + false + \ No newline at end of file diff --git a/maven/.gitignore b/maven-all/maven/.gitignore similarity index 100% rename from maven/.gitignore rename to maven-all/maven/.gitignore diff --git a/maven-all/maven/README.md b/maven-all/maven/README.md new file mode 100644 index 0000000000..acf7dfc47b --- /dev/null +++ b/maven-all/maven/README.md @@ -0,0 +1,14 @@ +### Relevant Articles + +- [Guide to the Core Maven Plugins](https://www.baeldung.com/core-maven-plugins) +- [Maven Resources Plugin](https://www.baeldung.com/maven-resources-plugin) +- [Maven Compiler Plugin](https://www.baeldung.com/maven-compiler-plugin) +- [Quick Guide to the Maven Surefire Plugin](https://www.baeldung.com/maven-surefire-plugin) +- [The Maven Failsafe Plugin](https://www.baeldung.com/maven-failsafe-plugin) +- [The Maven Verifier Plugin](https://www.baeldung.com/maven-verifier-plugin) +- [The Maven Clean Plugin](https://www.baeldung.com/maven-clean-plugin) +- [Build a Jar with Maven and Ignore the Test Results](https://www.baeldung.com/maven-ignore-test-results) +- [Maven Project with Multiple Source Directories](https://www.baeldung.com/maven-project-multiple-src-directories) +- [Integration Testing with Maven](https://www.baeldung.com/maven-integration-test) +- [Apache Maven Standard Directory Layout](https://www.baeldung.com/maven-directory-structure) +- [Multi-Module Project with Maven](https://www.baeldung.com/maven-multi-module) diff --git a/maven/custom-rule/pom.xml b/maven-all/maven/custom-rule/pom.xml similarity index 100% rename from maven/custom-rule/pom.xml rename to maven-all/maven/custom-rule/pom.xml diff --git a/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 similarity index 100% rename from maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java rename to maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java diff --git a/maven/input-resources/baeldung.png b/maven-all/maven/input-resources/baeldung.png similarity index 100% rename from maven/input-resources/baeldung.png rename to maven-all/maven/input-resources/baeldung.png diff --git a/maven/input-resources/baeldung.txt b/maven-all/maven/input-resources/baeldung.txt similarity index 100% rename from maven/input-resources/baeldung.txt rename to maven-all/maven/input-resources/baeldung.txt diff --git a/maven/input-resources/verifications.xml b/maven-all/maven/input-resources/verifications.xml similarity index 100% rename from maven/input-resources/verifications.xml rename to maven-all/maven/input-resources/verifications.xml diff --git a/maven-all/maven/maven-enforcer/README.md b/maven-all/maven/maven-enforcer/README.md new file mode 100644 index 0000000000..7515647a3d --- /dev/null +++ b/maven-all/maven/maven-enforcer/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Maven Enforcer Plugin](https://www.baeldung.com/maven-enforcer-plugin) \ No newline at end of file diff --git a/maven/maven-enforcer/pom.xml b/maven-all/maven/maven-enforcer/pom.xml similarity index 100% rename from maven/maven-enforcer/pom.xml rename to maven-all/maven/maven-enforcer/pom.xml diff --git a/maven/pom.xml b/maven-all/maven/pom.xml similarity index 99% rename from maven/pom.xml rename to maven-all/maven/pom.xml index ef6e7b7d93..d34be04fcf 100644 --- a/maven/pom.xml +++ b/maven-all/maven/pom.xml @@ -11,6 +11,7 @@ parent-modules com.baeldung 1.0.0-SNAPSHOT + ../.. diff --git a/maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java b/maven-all/maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java similarity index 100% rename from maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java rename to maven-all/maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java diff --git a/maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java b/maven-all/maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java similarity index 100% rename from maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java rename to maven-all/maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java diff --git a/maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java b/maven-all/maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java similarity index 100% rename from maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java rename to maven-all/maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java diff --git a/maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java b/maven-all/maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java similarity index 100% rename from maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java rename to maven-all/maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java diff --git a/maven/src/main/java/com/baeldung/maven/plugins/Data.java b/maven-all/maven/src/main/java/com/baeldung/maven/plugins/Data.java similarity index 100% rename from maven/src/main/java/com/baeldung/maven/plugins/Data.java rename to maven-all/maven/src/main/java/com/baeldung/maven/plugins/Data.java diff --git a/maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java b/maven-all/maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java similarity index 100% rename from maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java rename to maven-all/maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java diff --git a/maven/src/main/resources/logback.xml b/maven-all/maven/src/main/resources/logback.xml similarity index 100% rename from maven/src/main/resources/logback.xml rename to maven-all/maven/src/main/resources/logback.xml diff --git a/maven/src/main/webapp/WEB-INF/web.xml b/maven-all/maven/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from maven/src/main/webapp/WEB-INF/web.xml rename to maven-all/maven/src/main/webapp/WEB-INF/web.xml diff --git a/maven/src/test/java/com/baeldung/maven/it/Integration.java b/maven-all/maven/src/test/java/com/baeldung/maven/it/Integration.java similarity index 100% rename from maven/src/test/java/com/baeldung/maven/it/Integration.java rename to maven-all/maven/src/test/java/com/baeldung/maven/it/Integration.java diff --git a/maven/src/test/java/com/baeldung/maven/it/RestIT.java b/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIT.java similarity index 100% rename from maven/src/test/java/com/baeldung/maven/it/RestIT.java rename to maven-all/maven/src/test/java/com/baeldung/maven/it/RestIT.java diff --git a/maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java b/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java similarity index 100% rename from maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java rename to maven-all/maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java diff --git a/maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java b/maven-all/maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java similarity index 100% rename from maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java rename to maven-all/maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java diff --git a/maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java b/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java similarity index 100% rename from maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java rename to maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java diff --git a/maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java b/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java similarity index 100% rename from maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java rename to maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java diff --git a/maven/src/test/java/testfail/TestFail.java b/maven-all/maven/src/test/java/testfail/TestFail.java similarity index 100% rename from maven/src/test/java/testfail/TestFail.java rename to maven-all/maven/src/test/java/testfail/TestFail.java diff --git a/maven-all/profiles/README.md b/maven-all/profiles/README.md new file mode 100644 index 0000000000..22d5d7f70c --- /dev/null +++ b/maven-all/profiles/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Guide to Maven Profiles](https://www.baeldung.com/maven-profiles) \ No newline at end of file diff --git a/maven/profiles/pom.xml b/maven-all/profiles/pom.xml similarity index 100% rename from maven/profiles/pom.xml rename to maven-all/profiles/pom.xml diff --git a/maven-all/versions-maven-plugin/README.md b/maven-all/versions-maven-plugin/README.md new file mode 100644 index 0000000000..8f5670f802 --- /dev/null +++ b/maven-all/versions-maven-plugin/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Use the Latest Version of a Dependency in Maven](https://www.baeldung.com/maven-dependency-latest-version) \ No newline at end of file diff --git a/maven/versions-maven-plugin/original/pom.xml b/maven-all/versions-maven-plugin/original/pom.xml similarity index 100% rename from maven/versions-maven-plugin/original/pom.xml rename to maven-all/versions-maven-plugin/original/pom.xml diff --git a/maven/versions-maven-plugin/pom.xml b/maven-all/versions-maven-plugin/pom.xml similarity index 98% rename from maven/versions-maven-plugin/pom.xml rename to maven-all/versions-maven-plugin/pom.xml index e0714bf0e0..c9f63a46f1 100644 --- a/maven/versions-maven-plugin/pom.xml +++ b/maven-all/versions-maven-plugin/pom.xml @@ -36,7 +36,7 @@ commons-beanutils commons-beanutils - 1.9.1-SNAPSHOT + 1.9.1 diff --git a/maven/versions-maven-plugin/run-the-demo.sh b/maven-all/versions-maven-plugin/run-the-demo.sh old mode 100755 new mode 100644 similarity index 100% rename from maven/versions-maven-plugin/run-the-demo.sh rename to maven-all/versions-maven-plugin/run-the-demo.sh diff --git a/maven-archetype/README.md b/maven-archetype/README.md index 71821e3348..b707150854 100644 --- a/maven-archetype/README.md +++ b/maven-archetype/README.md @@ -1,4 +1,4 @@ ### Relevant Articles: ================================ -- [Guide to Maven Archetype](http://www.baeldung.com/maven-archetype) +- [Guide to Maven Archetype](https://www.baeldung.com/maven-archetype) diff --git a/maven/README.md b/maven/README.md deleted file mode 100644 index 6d1a7081b7..0000000000 --- a/maven/README.md +++ /dev/null @@ -1,19 +0,0 @@ -### Relevant Articles - -- [Guide to the Core Maven Plugins](http://www.baeldung.com/core-maven-plugins) -- [Maven Resources Plugin](http://www.baeldung.com/maven-resources-plugin) -- [Maven Compiler Plugin](http://www.baeldung.com/maven-compiler-plugin) -- [Quick Guide to the Maven Surefire Plugin](http://www.baeldung.com/maven-surefire-plugin) -- [The Maven Failsafe Plugin](http://www.baeldung.com/maven-failsafe-plugin) -- [The Maven Verifier Plugin](http://www.baeldung.com/maven-verifier-plugin) -- [The Maven Clean Plugin](http://www.baeldung.com/maven-clean-plugin) -- [Build a Jar with Maven and Ignore the Test Results](http://www.baeldung.com/maven-ignore-test-results) -- [Maven Project with Multiple Source Directories](https://www.baeldung.com/maven-project-multiple-src-directories) -- [Integration Testing with Maven](https://www.baeldung.com/maven-integration-test) -- [Apache Maven Standard Directory Layout](https://www.baeldung.com/maven-directory-structure) -- [Apache Maven Tutorial](https://www.baeldung.com/maven) -- [Use the Latest Version of a Dependency in Maven](https://www.baeldung.com/maven-dependency-latest-version) -- [Multi-Module Project with Maven](https://www.baeldung.com/maven-multi-module) -- [Maven Enforcer Plugin](https://www.baeldung.com/maven-enforcer-plugin) -- [Eclipse Error: web.xml is missing and failOnMissingWebXml is set to true](https://www.baeldung.com/eclipse-error-web-xml-missing) -- [Guide to Maven Profiles](https://www.baeldung.com/maven-profiles) diff --git a/mesos-marathon/README.md b/mesos-marathon/README.md index 1d4d4995a8..09467ebfcb 100644 --- a/mesos-marathon/README.md +++ b/mesos-marathon/README.md @@ -1,5 +1,5 @@ ### Relevant articles -- [Simple Jenkins Pipeline with Marathon and Mesos](http://www.baeldung.com/jenkins-pipeline-with-marathon-mesos) +- [Simple Jenkins Pipeline with Marathon and Mesos](https://www.baeldung.com/jenkins-pipeline-with-marathon-mesos) To run the pipeline, please modify the dockerise.sh file with your own useranema and password for docker login. diff --git a/metrics/README.md b/metrics/README.md index c7772bffa0..d344a2707f 100644 --- a/metrics/README.md +++ b/metrics/README.md @@ -1,5 +1,5 @@ ## Relevant articles: -- [Intro to Dropwizard Metrics](http://www.baeldung.com/dropwizard-metrics) -- [Introduction to Netflix Servo](http://www.baeldung.com/netflix-servo) -- [Quick Guide to Micrometer](http://www.baeldung.com/micrometer) +- [Intro to Dropwizard Metrics](https://www.baeldung.com/dropwizard-metrics) +- [Introduction to Netflix Servo](https://www.baeldung.com/netflix-servo) +- [Quick Guide to Micrometer](https://www.baeldung.com/micrometer) diff --git a/micronaut/README.md b/micronaut/README.md index 10a68ff2f8..0a39cf9e33 100644 --- a/micronaut/README.md +++ b/micronaut/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Introduction to Micronaut Framework](http://www.baeldung.com/micronaut) +- [Introduction to Micronaut Framework](https://www.baeldung.com/micronaut) diff --git a/microprofile/README.md b/microprofile/README.md index 1a28487e89..7525ee5bff 100644 --- a/microprofile/README.md +++ b/microprofile/README.md @@ -1,3 +1,3 @@ ### Relevant articles: -- [Building Microservices with Eclipse MicroProfile](http://www.baeldung.com/eclipse-microprofile) +- [Building Microservices with Eclipse MicroProfile](https://www.baeldung.com/eclipse-microprofile) diff --git a/ml/README.md b/ml/README.md index f4712a94da..1362f2840c 100644 --- a/ml/README.md +++ b/ml/README.md @@ -2,4 +2,4 @@ This is a soft introduction to ML using [deeplearning4j](https://deeplearning4j.org) library ### Relevant Articles: -- [Logistic Regression in Java](http://www.baeldung.com/) +- [Logistic Regression in Java](https://www.baeldung.com/) diff --git a/msf4j/README.md b/msf4j/README.md index 7c66b8dc5f..b7f2c5a546 100644 --- a/msf4j/README.md +++ b/msf4j/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Introduction to Java Microservices with MSF4J](http://www.baeldung.com/msf4j) +- [Introduction to Java Microservices with MSF4J](https://www.baeldung.com/msf4j) diff --git a/muleesb/README.md b/muleesb/README.md index 8da4e595e3..555a10b5cc 100644 --- a/muleesb/README.md +++ b/muleesb/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Getting Started With Mule ESB](http://www.baeldung.com/mule-esb) +- [Getting Started With Mule ESB](https://www.baeldung.com/mule-esb) diff --git a/mustache/README.md b/mustache/README.md index fa41eb4f4d..c36080b56f 100644 --- a/mustache/README.md +++ b/mustache/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Introduction to Mustache](http://www.baeldung.com/mustache) -- [Guide to Mustache with Spring Boot](http://www.baeldung.com/spring-boot-mustache) +- [Introduction to Mustache](https://www.baeldung.com/mustache) +- [Guide to Mustache with Spring Boot](https://www.baeldung.com/spring-boot-mustache) diff --git a/mybatis/README.md b/mybatis/README.md index 7c366aeab6..57687d3da1 100644 --- a/mybatis/README.md +++ b/mybatis/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Quick Guide to MyBatis](http://www.baeldung.com/mybatis) +- [Quick Guide to MyBatis](https://www.baeldung.com/mybatis) diff --git a/orika/README.md b/orika/README.md index 4ed033c170..0096793507 100644 --- a/orika/README.md +++ b/orika/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Mapping with Orika](http://www.baeldung.com/orika-mapping) +- [Mapping with Orika](https://www.baeldung.com/orika-mapping) diff --git a/osgi/readme.md b/osgi/readme.md index e380ae06c3..ee5d7d66c4 100644 --- a/osgi/readme.md +++ b/osgi/readme.md @@ -87,7 +87,7 @@ org.eclipse.osgi_3.12.1.v20170821-1548.jar = = NOT GOOD = = ## Relevant articles: - - [Introduction to OSGi](http://www.baeldung.com/osgi) + - [Introduction to OSGi](https://www.baeldung.com/osgi) diff --git a/parent-boot-1/README.md b/parent-boot-1/README.md index 8b312c348a..5ad14c6519 100644 --- a/parent-boot-1/README.md +++ b/parent-boot-1/README.md @@ -1,2 +1,3 @@ +## Parent Boot 1 This is a parent module for all projects using Spring Boot 1. diff --git a/parent-boot-2/README.md b/parent-boot-2/README.md index 3f18bdf38e..7afe447a66 100644 --- a/parent-boot-2/README.md +++ b/parent-boot-2/README.md @@ -1,2 +1,3 @@ +## Parent Boot 2 This is a parent module for all projects using Spring Boot 2. diff --git a/parent-java/README.md b/parent-java/README.md index 729105e3fd..1b14b7cfc1 100644 --- a/parent-java/README.md +++ b/parent-java/README.md @@ -1 +1,3 @@ -## Relevant Articles: +## Parent Java + +This is a parent module for all projects using Java \ No newline at end of file diff --git a/parent-kotlin/README.md b/parent-kotlin/README.md index 6c17a6ac29..c78ecbac42 100644 --- a/parent-kotlin/README.md +++ b/parent-kotlin/README.md @@ -1,2 +1,3 @@ +## Parent Kotlin -Parent module for Kotlin projects. +This is a parent module for all projects using Kotlin diff --git a/parent-spring-4/README.md b/parent-spring-4/README.md index 729105e3fd..f14d003dd5 100644 --- a/parent-spring-4/README.md +++ b/parent-spring-4/README.md @@ -1 +1,3 @@ -## Relevant Articles: +## Parent Spring 4 + +This is a parent module for all projects using Spring 4 diff --git a/parent-spring-5/README.md b/parent-spring-5/README.md index 729105e3fd..791a6ca197 100644 --- a/parent-spring-5/README.md +++ b/parent-spring-5/README.md @@ -1 +1,3 @@ -## Relevant Articles: +## Parent Spring 5 + +This is a parent module for all projects using Spring 5 diff --git a/patterns/dipmodular/README.md b/patterns/dipmodular/README.md new file mode 100644 index 0000000000..ba46158b8c --- /dev/null +++ b/patterns/dipmodular/README.md @@ -0,0 +1,3 @@ +## Relevant Articles: + +- [The Dependency Inversion Principle in Java](https://www.baeldung.com/java-dependency-inversion-principle) diff --git a/pdf/README.md b/pdf/README.md index 5454d2b2de..8525dc4f69 100644 --- a/pdf/README.md +++ b/pdf/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [PDF Conversions in Java](http://www.baeldung.com/pdf-conversions-java) -- [Creating PDF Files in Java](http://www.baeldung.com/java-pdf-creation) +- [PDF Conversions in Java](https://www.baeldung.com/pdf-conversions-java) +- [Creating PDF Files in Java](https://www.baeldung.com/java-pdf-creation) diff --git a/performance-tests/README.md b/performance-tests/README.md index 0064157966..918c81bb69 100644 --- a/performance-tests/README.md +++ b/performance-tests/README.md @@ -1,10 +1,10 @@ ### Relevant Articles: -- [Performance of Java Mapping Frameworks](http://www.baeldung.com/java-performance-mapping-frameworks) +- [Performance of Java Mapping Frameworks](https://www.baeldung.com/java-performance-mapping-frameworks) ### Running To run the performance benchmarks: 1: `mvn clean install` -2: `java -jar target/benchmarks.jar` \ No newline at end of file +2: `java -jar target/benchmarks.jar` diff --git a/persistence-modules/java-jpa-2/README.md b/persistence-modules/java-jpa-2/README.md index c3be046fc0..1b4a175008 100644 --- a/persistence-modules/java-jpa-2/README.md +++ b/persistence-modules/java-jpa-2/README.md @@ -4,6 +4,10 @@ This module contains articles about the Java Persistence API (JPA) in Java. ### Relevant Articles -- [JPA Query Parameters Usage](http://www.baeldung.com/jpa-query-parameters-usage) +- [JPA Query Parameters Usage](https://www.baeldung.com/jpa-query-parameters-usage) - [Mapping Entitiy Class Names to SQL Table Names with JPA](https://www.baeldung.com/jpa-entity-table-names) -- More articles: [[<-- prev]](/java-jpa) +- [Default Column Values in JPA](https://www.baeldung.com/jpa-default-column-values) +- [Types of JPA Queries](https://www.baeldung.com/jpa-queries) +- [JPA/Hibernate Projections](https://www.baeldung.com/jpa-hibernate-projections) +- [Combining JPA And/Or Criteria Predicates](https://www.baeldung.com/jpa-and-or-criteria-predicates) +- More articles: [[<-- prev]](/java-jpa) \ No newline at end of file diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/criteria/repository/CustomItemRepository.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/criteria/CustomItemRepository.java similarity index 59% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/criteria/repository/CustomItemRepository.java rename to persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/criteria/CustomItemRepository.java index c55dc4a592..c85ac53ac2 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/criteria/repository/CustomItemRepository.java +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/criteria/CustomItemRepository.java @@ -1,12 +1,10 @@ -package com.baeldung.jpa.criteria.repository; - -import java.util.List; - -import com.baeldung.jpa.criteria.entity.Item; - -public interface CustomItemRepository { - - List findItemsByColorAndGrade(); - - List findItemByColorOrGrade(); -} +package com.baeldung.jpa.criteria; + +import java.util.List; + +public interface CustomItemRepository { + + List findItemsByColorAndGrade(); + + List findItemByColorOrGrade(); +} diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/criteria/repository/impl/CustomItemRepositoryImpl.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/criteria/CustomItemRepositoryImpl.java similarity index 91% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/criteria/repository/impl/CustomItemRepositoryImpl.java rename to persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/criteria/CustomItemRepositoryImpl.java index bf1d3eed0b..c64cd14ca5 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/criteria/repository/impl/CustomItemRepositoryImpl.java +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/criteria/CustomItemRepositoryImpl.java @@ -1,77 +1,72 @@ -package com.baeldung.jpa.criteria.repository.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; - -import com.baeldung.jpa.criteria.entity.Item; -import com.baeldung.jpa.criteria.repository.CustomItemRepository; - -public class CustomItemRepositoryImpl implements CustomItemRepository { - - private EntityManager entityManager; - - public CustomItemRepositoryImpl() { - super(); - EntityManagerFactory factory = Persistence.createEntityManagerFactory("jpa-h2-criteria"); - entityManager = factory.createEntityManager(); - } - - @Override - public List findItemsByColorAndGrade() { - - CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); - CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Item.class); - Root itemRoot = criteriaQuery.from(Item.class); - - Predicate predicateForBlueColor = criteriaBuilder.equal(itemRoot.get("color"), "blue"); - Predicate predicateForRedColor = criteriaBuilder.equal(itemRoot.get("color"), "red"); - Predicate predicateForColor = criteriaBuilder.or(predicateForBlueColor, predicateForRedColor); - - Predicate predicateForGradeA = criteriaBuilder.equal(itemRoot.get("grade"), "A"); - Predicate predicateForGradeB = criteriaBuilder.equal(itemRoot.get("grade"), "B"); - Predicate predicateForGrade = criteriaBuilder.or(predicateForGradeA, predicateForGradeB); - - // final search filter - Predicate finalPredicate = criteriaBuilder.and(predicateForColor, predicateForGrade); - - criteriaQuery.where(finalPredicate); - - List items = entityManager.createQuery(criteriaQuery) - .getResultList(); - return items; - } - - @Override - public List findItemByColorOrGrade() { - - CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); - CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Item.class); - Root itemRoot = criteriaQuery.from(Item.class); - - Predicate predicateForBlueColor = criteriaBuilder.equal(itemRoot.get("color"), "red"); - Predicate predicateForGradeA = criteriaBuilder.equal(itemRoot.get("grade"), "D"); - Predicate predicateForBlueColorAndGradeA = criteriaBuilder.and(predicateForBlueColor, predicateForGradeA); - - Predicate predicateForRedColor = criteriaBuilder.equal(itemRoot.get("color"), "blue"); - Predicate predicateForGradeB = criteriaBuilder.equal(itemRoot.get("grade"), "B"); - Predicate predicateForRedColorAndGradeB = criteriaBuilder.and(predicateForRedColor, predicateForGradeB); - - // final search filter - Predicate finalPredicate = criteriaBuilder.or(predicateForBlueColorAndGradeA, predicateForRedColorAndGradeB); - - criteriaQuery.where(finalPredicate); - - List items = entityManager.createQuery(criteriaQuery) - .getResultList(); - return items; - } -} +package com.baeldung.jpa.criteria; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +public class CustomItemRepositoryImpl implements CustomItemRepository { + + private EntityManager entityManager; + + public CustomItemRepositoryImpl() { + super(); + EntityManagerFactory factory = Persistence.createEntityManagerFactory("jpa-h2-criteria"); + entityManager = factory.createEntityManager(); + } + + @Override + public List findItemsByColorAndGrade() { + + CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Item.class); + Root itemRoot = criteriaQuery.from(Item.class); + + Predicate predicateForBlueColor = criteriaBuilder.equal(itemRoot.get("color"), "blue"); + Predicate predicateForRedColor = criteriaBuilder.equal(itemRoot.get("color"), "red"); + Predicate predicateForColor = criteriaBuilder.or(predicateForBlueColor, predicateForRedColor); + + Predicate predicateForGradeA = criteriaBuilder.equal(itemRoot.get("grade"), "A"); + Predicate predicateForGradeB = criteriaBuilder.equal(itemRoot.get("grade"), "B"); + Predicate predicateForGrade = criteriaBuilder.or(predicateForGradeA, predicateForGradeB); + + // final search filter + Predicate finalPredicate = criteriaBuilder.and(predicateForColor, predicateForGrade); + + criteriaQuery.where(finalPredicate); + + List items = entityManager.createQuery(criteriaQuery) + .getResultList(); + return items; + } + + @Override + public List findItemByColorOrGrade() { + + CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); + CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Item.class); + Root itemRoot = criteriaQuery.from(Item.class); + + Predicate predicateForBlueColor = criteriaBuilder.equal(itemRoot.get("color"), "red"); + Predicate predicateForGradeA = criteriaBuilder.equal(itemRoot.get("grade"), "D"); + Predicate predicateForBlueColorAndGradeA = criteriaBuilder.and(predicateForBlueColor, predicateForGradeA); + + Predicate predicateForRedColor = criteriaBuilder.equal(itemRoot.get("color"), "blue"); + Predicate predicateForGradeB = criteriaBuilder.equal(itemRoot.get("grade"), "B"); + Predicate predicateForRedColorAndGradeB = criteriaBuilder.and(predicateForRedColor, predicateForGradeB); + + // final search filter + Predicate finalPredicate = criteriaBuilder.or(predicateForBlueColorAndGradeA, predicateForRedColorAndGradeB); + + criteriaQuery.where(finalPredicate); + + List items = entityManager.createQuery(criteriaQuery) + .getResultList(); + return items; + } +} diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/criteria/entity/Item.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/criteria/Item.java similarity index 89% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/criteria/entity/Item.java rename to persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/criteria/Item.java index 64ef46f265..f6093e5735 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/criteria/entity/Item.java +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/criteria/Item.java @@ -1,49 +1,49 @@ -package com.baeldung.jpa.criteria.entity; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Table(name = "item") -@Entity -public class Item { - - @Id - private Long id; - private String color; - private String grade; - private String name; - - public String getColor() { - return color; - } - - public String getGrade() { - return grade; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setColor(String color) { - this.color = color; - } - - public void setGrade(String grade) { - this.grade = grade; - } - - public void setId(Long id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } - -} +package com.baeldung.jpa.criteria; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Table(name = "item") +@Entity +public class Item { + + @Id + private Long id; + private String color; + private String grade; + private String name; + + public String getColor() { + return color; + } + + public String getGrade() { + return grade; + } + + public Long getId() { + return id; + } + + public String getName() { + return name; + } + + public void setColor(String color) { + this.color = color; + } + + public void setGrade(String grade) { + this.grade = grade; + } + + public void setId(Long id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/User.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/defaultvalues/User.java similarity index 100% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/User.java rename to persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/defaultvalues/User.java diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/UserRepository.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/defaultvalues/UserRepository.java similarity index 100% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/defaultvalues/UserRepository.java rename to persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/defaultvalues/UserRepository.java diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/projections/Product.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/projections/Product.java similarity index 100% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/projections/Product.java rename to persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/projections/Product.java diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/projections/ProductRepository.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/projections/ProductRepository.java similarity index 100% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/projections/ProductRepository.java rename to persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/projections/ProductRepository.java diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/querytypes/QueryTypesExamples.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/querytypes/QueryTypesExamples.java similarity index 100% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/querytypes/QueryTypesExamples.java rename to persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/querytypes/QueryTypesExamples.java diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/querytypes/UserEntity.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/querytypes/UserEntity.java similarity index 100% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/querytypes/UserEntity.java rename to persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/querytypes/UserEntity.java diff --git a/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml b/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml index 560a75070c..62d7ce0f5e 100644 --- a/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml @@ -32,4 +32,91 @@ value="queryparams.sql" /> + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.defaultvalues.User + true + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.querytypes.UserEntity + true + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.projections.Product + true + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.criteria.Item + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/java-jpa/src/test/resources/item.sql b/persistence-modules/java-jpa-2/src/main/resources/item.sql similarity index 98% rename from persistence-modules/java-jpa/src/test/resources/item.sql rename to persistence-modules/java-jpa-2/src/main/resources/item.sql index faf50f6829..871dcee017 100644 --- a/persistence-modules/java-jpa/src/test/resources/item.sql +++ b/persistence-modules/java-jpa-2/src/main/resources/item.sql @@ -1,4 +1,4 @@ -insert into item(id,grade,color) values (10,'C','blue'); -insert into item(id,grade,color) values (11,'C','red'); -insert into item(id,grade,color) values (12,'A','blue'); +insert into item(id,grade,color) values (10,'C','blue'); +insert into item(id,grade,color) values (11,'C','red'); +insert into item(id,grade,color) values (12,'A','blue'); insert into item(id,grade,color) values (13,'D','red'); \ No newline at end of file diff --git a/persistence-modules/java-jpa/src/main/resources/products_jpa.sql b/persistence-modules/java-jpa-2/src/main/resources/products_jpa.sql similarity index 100% rename from persistence-modules/java-jpa/src/main/resources/products_jpa.sql rename to persistence-modules/java-jpa-2/src/main/resources/products_jpa.sql diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/criteria/repository/impl/CustomItemRepositoryIntegrationTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/criteria/CustomItemRepositoryIntegrationTest.java similarity index 86% rename from persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/criteria/repository/impl/CustomItemRepositoryIntegrationTest.java rename to persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/criteria/CustomItemRepositoryIntegrationTest.java index 169fb44618..8d6bf3c4a7 100644 --- a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/criteria/repository/impl/CustomItemRepositoryIntegrationTest.java +++ b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/criteria/CustomItemRepositoryIntegrationTest.java @@ -1,44 +1,44 @@ -package com.baeldung.jpa.criteria.repository.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -import java.util.List; - -import org.junit.Test; - -import com.baeldung.jpa.criteria.entity.Item; -import com.baeldung.jpa.criteria.repository.CustomItemRepository; - -public class CustomItemRepositoryIntegrationTest { - - CustomItemRepository customItemRepository = new CustomItemRepositoryImpl(); - - @Test - public void givenItems_whenFindItemsByColorAndGrade_thenReturnItems() { - - List items = customItemRepository.findItemsByColorAndGrade(); - - assertFalse("No items found", items.isEmpty()); - assertEquals("There should be only one item", 1, items.size()); - - Item item = items.get(0); - - assertEquals("this item do not have blue color", "blue", item.getColor()); - assertEquals("this item does not belong to A grade", "A", item.getGrade()); - } - - @Test - public void givenItems_whenFindItemByColorOrGrade_thenReturnItems() { - - List items = customItemRepository.findItemByColorOrGrade(); - - assertFalse("No items found", items.isEmpty()); - assertEquals("There should be only one item", 1, items.size()); - - Item item = items.get(0); - - assertEquals("this item do not have red color", "red", item.getColor()); - assertEquals("this item does not belong to D grade", "D", item.getGrade()); - } -} +package com.baeldung.jpa.criteria; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.util.List; + +import org.junit.Test; + +import com.baeldung.jpa.criteria.Item; +import com.baeldung.jpa.criteria.CustomItemRepository; + +public class CustomItemRepositoryIntegrationTest { + + CustomItemRepository customItemRepository = new CustomItemRepositoryImpl(); + + @Test + public void givenItems_whenFindItemsByColorAndGrade_thenReturnItems() { + + List items = customItemRepository.findItemsByColorAndGrade(); + + assertFalse("No items found", items.isEmpty()); + assertEquals("There should be only one item", 1, items.size()); + + Item item = items.get(0); + + assertEquals("this item do not have blue color", "blue", item.getColor()); + assertEquals("this item does not belong to A grade", "A", item.getGrade()); + } + + @Test + public void givenItems_whenFindItemByColorOrGrade_thenReturnItems() { + + List items = customItemRepository.findItemByColorOrGrade(); + + assertFalse("No items found", items.isEmpty()); + assertEquals("There should be only one item", 1, items.size()); + + Item item = items.get(0); + + assertEquals("this item do not have red color", "red", item.getColor()); + assertEquals("this item does not belong to D grade", "D", item.getGrade()); + } +} diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/defaultvalues/UserDefaultValuesUnitTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/defaultvalues/UserDefaultValuesUnitTest.java similarity index 100% rename from persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/defaultvalues/UserDefaultValuesUnitTest.java rename to persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/defaultvalues/UserDefaultValuesUnitTest.java diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/projections/HibernateProjectionsIntegrationTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/projections/HibernateProjectionsIntegrationTest.java similarity index 100% rename from persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/projections/HibernateProjectionsIntegrationTest.java rename to persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/projections/HibernateProjectionsIntegrationTest.java diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/projections/ProductRepositoryIntegrationTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/projections/ProductRepositoryIntegrationTest.java similarity index 100% rename from persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/projections/ProductRepositoryIntegrationTest.java rename to persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/projections/ProductRepositoryIntegrationTest.java diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/querytypes/QueryTypesExamplesIntegrationTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/querytypes/QueryTypesExamplesIntegrationTest.java similarity index 100% rename from persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/querytypes/QueryTypesExamplesIntegrationTest.java rename to persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/querytypes/QueryTypesExamplesIntegrationTest.java diff --git a/persistence-modules/java-jpa/src/test/resources/products.sql b/persistence-modules/java-jpa-2/src/test/resources/products.sql similarity index 100% rename from persistence-modules/java-jpa/src/test/resources/products.sql rename to persistence-modules/java-jpa-2/src/test/resources/products.sql diff --git a/persistence-modules/java-jpa/src/test/resources/users.sql b/persistence-modules/java-jpa-2/src/test/resources/users.sql similarity index 100% rename from persistence-modules/java-jpa/src/test/resources/users.sql rename to persistence-modules/java-jpa-2/src/test/resources/users.sql diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index b28aec5afb..be4c7fb79a 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -4,18 +4,14 @@ This module contains articles about the Java Persistence API (JPA) in Java. ### Relevant Articles -- [A Guide to SqlResultSetMapping](http://www.baeldung.com/jpa-sql-resultset-mapping) -- [A Guide to Stored Procedures with JPA](http://www.baeldung.com/jpa-stored-procedures) +- [A Guide to SqlResultSetMapping](https://www.baeldung.com/jpa-sql-resultset-mapping) +- [A Guide to Stored Procedures with JPA](https://www.baeldung.com/jpa-stored-procedures) - [Fixing the JPA error “java.lang.String cannot be cast to Ljava.lang.String;”](https://www.baeldung.com/jpa-error-java-lang-string-cannot-be-cast) - [JPA Entity Graph](https://www.baeldung.com/jpa-entity-graph) - [JPA 2.2 Support for Java 8 Date/Time Types](https://www.baeldung.com/jpa-java-time) - [Converting Between LocalDate and SQL Date](https://www.baeldung.com/java-convert-localdate-sql-date) -- [Combining JPA And/Or Criteria Predicates](https://www.baeldung.com/jpa-and-or-criteria-predicates) -- [Types of JPA Queries](https://www.baeldung.com/jpa-queries) -- [JPA/Hibernate Projections](https://www.baeldung.com/jpa-hibernate-projections) - [Composite Primary Keys in JPA](https://www.baeldung.com/jpa-composite-primary-keys) - [Defining JPA Entities](https://www.baeldung.com/jpa-entities) - [JPA @Basic Annotation](https://www.baeldung.com/jpa-basic-annotation) -- [Default Column Values in JPA](https://www.baeldung.com/jpa-default-column-values) - [Persisting Enums in JPA](https://www.baeldung.com/jpa-persisting-enums-in-jpa) - More articles: [[next -->]](/java-jpa-2) diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/util/LocalDateConverter.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/convertdates/LocalDateConverter.java similarity index 94% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/util/LocalDateConverter.java rename to persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/convertdates/LocalDateConverter.java index 00fd378b05..de6ada2361 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/util/LocalDateConverter.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/convertdates/LocalDateConverter.java @@ -1,4 +1,4 @@ -package com.baeldung.util; +package com.baeldung.jpa.convertdates; import javax.persistence.AttributeConverter; import javax.persistence.Converter; diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/util/Gender.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Gender.java similarity index 54% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/util/Gender.java rename to persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Gender.java index 13f08d995c..8f808f539d 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/util/Gender.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Gender.java @@ -1,4 +1,4 @@ -package com.baeldung.util; +package com.baeldung.jpa.entity; public enum Gender { MALE, diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java index 531bae40c5..64e7ab586c 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Student.java @@ -14,8 +14,6 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; -import com.baeldung.util.Gender; - @Entity @Table(name="STUDENT") public class Student { diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Account.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/Account.java similarity index 95% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Account.java rename to persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/Account.java index 48a98512fa..915c605e65 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Account.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/Account.java @@ -1,4 +1,4 @@ -package com.baeldung.jpa.entity; +package com.baeldung.jpa.primarykeys; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/AccountId.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/AccountId.java similarity index 97% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/AccountId.java rename to persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/AccountId.java index 091c326367..1e8a06be63 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/AccountId.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/AccountId.java @@ -1,4 +1,4 @@ -package com.baeldung.jpa.entity; +package com.baeldung.jpa.primarykeys; import java.io.Serializable; diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Book.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/Book.java similarity index 93% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Book.java rename to persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/Book.java index 460f302e28..a84eb3ef01 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/Book.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/Book.java @@ -1,4 +1,4 @@ -package com.baeldung.jpa.entity; +package com.baeldung.jpa.primarykeys; import javax.persistence.EmbeddedId; import javax.persistence.Entity; diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/BookId.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/BookId.java similarity index 97% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/BookId.java rename to persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/BookId.java index ff587beaf2..d8c925c148 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/entity/BookId.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/primarykeys/BookId.java @@ -1,4 +1,4 @@ -package com.baeldung.jpa.entity; +package com.baeldung.jpa.primarykeys; import java.io.Serializable; diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/sqlresultsetmapping/Employee.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/sqlresultsetmapping/Employee.java similarity index 85% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/sqlresultsetmapping/Employee.java rename to persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/sqlresultsetmapping/Employee.java index bec1b8845a..b62a21d481 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/sqlresultsetmapping/Employee.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/sqlresultsetmapping/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.sqlresultsetmapping; +package com.baeldung.jpa.sqlresultsetmapping; import javax.persistence.*; @@ -7,7 +7,7 @@ import javax.persistence.*; name="EmployeeResult", entities={ @EntityResult( - entityClass = com.baeldung.sqlresultsetmapping.Employee.class, + entityClass = com.baeldung.jpa.sqlresultsetmapping.Employee.class, fields={@FieldResult(name="id",column="employeeNumber"), @FieldResult(name="name", column="name")} ) diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/sqlresultsetmapping/ScheduledDay.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/sqlresultsetmapping/ScheduledDay.java similarity index 89% rename from persistence-modules/java-jpa/src/main/java/com/baeldung/sqlresultsetmapping/ScheduledDay.java rename to persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/sqlresultsetmapping/ScheduledDay.java index 7e332bc67a..a7ca59ab3f 100644 --- a/persistence-modules/java-jpa/src/main/java/com/baeldung/sqlresultsetmapping/ScheduledDay.java +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/sqlresultsetmapping/ScheduledDay.java @@ -1,18 +1,18 @@ -package com.baeldung.sqlresultsetmapping; +package com.baeldung.jpa.sqlresultsetmapping; import javax.persistence.*; @SqlResultSetMappings(value = { @SqlResultSetMapping(name = "ScheduleResult", - classes = { @ConstructorResult(targetClass = com.baeldung.sqlresultsetmapping.ScheduledDay.class, + classes = { @ConstructorResult(targetClass = com.baeldung.jpa.sqlresultsetmapping.ScheduledDay.class, columns = { @ColumnResult(name = "id", type = Long.class), @ColumnResult(name = "employeeId", type = Long.class), @ColumnResult(name = "dayOfWeek") }) }), @SqlResultSetMapping(name = "FridayEmployeeResult", columns = { @ColumnResult(name = "employeeId") }), @SqlResultSetMapping(name = "EmployeeScheduleResults", - entities = { @EntityResult(entityClass = com.baeldung.sqlresultsetmapping.Employee.class), - @EntityResult(entityClass = com.baeldung.sqlresultsetmapping.ScheduledDay.class) + entities = { @EntityResult(entityClass = com.baeldung.jpa.sqlresultsetmapping.Employee.class), + @EntityResult(entityClass = com.baeldung.jpa.sqlresultsetmapping.ScheduledDay.class) }) }) @NamedNativeQuery(name = "FridayEmployees", query = "SELECT employeeId FROM schedule_days WHERE dayOfWeek = 'FRIDAY'", diff --git a/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml b/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml index 1f16bee3ba..b780a6f569 100644 --- a/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/java-jpa/src/main/resources/META-INF/persistence.xml @@ -7,8 +7,8 @@ org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.sqlresultsetmapping.ScheduledDay - com.baeldung.sqlresultsetmapping.Employee + com.baeldung.jpa.sqlresultsetmapping.ScheduledDay + com.baeldung.jpa.sqlresultsetmapping.Employee com.baeldung.jpa.basicannotation.Course true @@ -115,77 +115,13 @@ - - org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.jpa.criteria.entity.Item - true - - - - - - - - - - - - - - - org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.jpa.querytypes.UserEntity - true - - - - - - - - - - - - - - - org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.jpa.defaultvalues.User - true - - - - - - - - - - - - org.hibernate.jpa.HibernatePersistenceProvider com.baeldung.jpa.entity.Student - com.baeldung.jpa.entity.Book - com.baeldung.jpa.entity.BookId - com.baeldung.jpa.entity.Account - com.baeldung.jpa.entity.AccountId + com.baeldung.jpa.primarykeys.Book + com.baeldung.jpa.primarykeys.BookId + com.baeldung.jpa.primarykeys.Account + com.baeldung.jpa.primarykeys.AccountId true - - org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.jpa.projections.Product - true - - - - - - - - - - - - \ No newline at end of file diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java index fdaaba5439..3c7a82edc3 100644 --- a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java +++ b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/StudentEntityIntegrationTest.java @@ -16,8 +16,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import com.baeldung.util.Gender; - public class StudentEntityIntegrationTest { private EntityManagerFactory emf; diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/CompositeKeysIntegrationTest.java b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/primarykeys/CompositeKeysIntegrationTest.java similarity index 93% rename from persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/CompositeKeysIntegrationTest.java rename to persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/primarykeys/CompositeKeysIntegrationTest.java index 2d30ebab5e..be529ab81c 100644 --- a/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/entity/CompositeKeysIntegrationTest.java +++ b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/primarykeys/CompositeKeysIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jpa.entity; +package com.baeldung.jpa.primarykeys; import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -7,6 +7,10 @@ import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; +import com.baeldung.jpa.primarykeys.Account; +import com.baeldung.jpa.primarykeys.AccountId; +import com.baeldung.jpa.primarykeys.Book; +import com.baeldung.jpa.primarykeys.BookId; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; diff --git a/persistence-modules/java-jpa/src/test/java/com/baeldung/sqlresultsetmapping/SqlResultSetMappingUnitTest.java b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/sqlresultsetmapping/SqlResultSetMappingUnitTest.java similarity index 98% rename from persistence-modules/java-jpa/src/test/java/com/baeldung/sqlresultsetmapping/SqlResultSetMappingUnitTest.java rename to persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/sqlresultsetmapping/SqlResultSetMappingUnitTest.java index 4e01095278..f318df3747 100644 --- a/persistence-modules/java-jpa/src/test/java/com/baeldung/sqlresultsetmapping/SqlResultSetMappingUnitTest.java +++ b/persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/sqlresultsetmapping/SqlResultSetMappingUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.sqlresultsetmapping; +package com.baeldung.jpa.sqlresultsetmapping; import static org.junit.Assert.*; diff --git a/persistence-modules/spring-data-eclipselink/README.md b/persistence-modules/spring-data-eclipselink/README.md index 7981470488..a2518fdb99 100644 --- a/persistence-modules/spring-data-eclipselink/README.md +++ b/persistence-modules/spring-data-eclipselink/README.md @@ -1,3 +1,4 @@ ### Relevant articles - [A Guide to EclipseLink with Spring](http://www.baeldung.com/spring-eclipselink) +- [Pessimistic Locking in JPA](https://www.baeldung.com/jpa-pessimistic-locking) diff --git a/play-framework/README.md b/play-framework/README.md index 0fd13fba27..2309b67422 100644 --- a/play-framework/README.md +++ b/play-framework/README.md @@ -1,4 +1,4 @@ ###Relevant Articles: -- [REST API with Play Framework in Java](http://www.baeldung.com/rest-api-with-play) -- [Routing In Play Applications in Java](http://www.baeldung.com/routing-in-play) -- [Introduction To Play In Java](http://www.baeldung.com/java-intro-to-the-play-framework) +- [REST API with Play Framework in Java](https://www.baeldung.com/rest-api-with-play) +- [Routing In Play Applications in Java](https://www.baeldung.com/routing-in-play) +- [Introduction To Play In Java](https://www.baeldung.com/java-intro-to-the-play-framework) diff --git a/pom.xml b/pom.xml index 6972736288..733aaad056 100644 --- a/pom.xml +++ b/pom.xml @@ -401,6 +401,8 @@ 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 @@ -413,6 +415,7 @@ core-java-modules/core-java-io-files core-java-modules/core-java-nio 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 @@ -528,6 +531,8 @@ libraries-data libraries-data-2 libraries-apache-commons + libraries-apache-commons-collections + libraries-apache-commons-io libraries-primitive libraries-testing libraries-security @@ -540,7 +545,11 @@ lucene mapstruct - maven + + maven-all/maven + maven-all/maven-war-plugin + maven-all/profiles + maven-all/versions-maven-plugin maven-archetype maven-polyglot/maven-polyglot-json-extension @@ -667,7 +676,6 @@ spring-boot spring-boot-admin spring-boot-angular - spring-boot-angular-ecommerce spring-boot-autoconfiguration spring-boot-bootstrap spring-boot-camel @@ -1141,6 +1149,8 @@ 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 @@ -1153,6 +1163,7 @@ core-java-modules/core-java-io-files core-java-modules/core-java-nio 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 @@ -1262,6 +1273,8 @@ libraries-data libraries-data-2 libraries-apache-commons + libraries-apache-commons-collections + libraries-apache-commons-io libraries-testing libraries-security libraries-server @@ -1272,7 +1285,11 @@ lucene mapstruct - maven + + maven-all/maven + maven-all/maven-war-plugin + maven-all/profiles + maven-all/versions-maven-plugin maven-archetype @@ -1381,7 +1398,6 @@ spring-boot spring-boot-admin spring-boot-angular - spring-boot-angular-ecommerce spring-boot-autoconfiguration spring-boot-bootstrap spring-boot-camel diff --git a/protobuffer/README.md b/protobuffer/README.md index 4dcdb3cf52..4302418a8b 100644 --- a/protobuffer/README.md +++ b/protobuffer/README.md @@ -1,3 +1,3 @@ ### Relevant articles -- [Introduction to Google Protocol Buffer](http://www.baeldung.com/google-protocol-buffer) +- [Introduction to Google Protocol Buffer](https://www.baeldung.com/google-protocol-buffer) diff --git a/rabbitmq/README.md b/rabbitmq/README.md index 11300b047f..01e51bd784 100644 --- a/rabbitmq/README.md +++ b/rabbitmq/README.md @@ -1,3 +1,3 @@ ### Relevant articles -- [Introduction to RabbitMQ](http://www.baeldung.com/rabbitmq) +- [Introduction to RabbitMQ](https://www.baeldung.com/rabbitmq) diff --git a/raml/README.MD b/raml/README.MD index 2a87b46021..fcf0b41a18 100644 --- a/raml/README.MD +++ b/raml/README.MD @@ -1,2 +1,2 @@ ###The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring +The "REST With Spring" Classes: https://bit.ly/restwithspring diff --git a/ratpack/README.md b/ratpack/README.md index 78e2f8ccfc..706fd0c8c3 100644 --- a/ratpack/README.md +++ b/ratpack/README.md @@ -1,9 +1,9 @@ ### Relevant articles -- [Introduction to Ratpack](http://www.baeldung.com/ratpack) -- [Ratpack Google Guice Integration](http://www.baeldung.com/ratpack-google-guice) +- [Introduction to Ratpack](https://www.baeldung.com/ratpack) +- [Ratpack Google Guice Integration](https://www.baeldung.com/ratpack-google-guice) - [Ratpack Integration with Spring Boot](http://www.baeldung.com/ratpack-spring-boot) -- [Ratpack with Hystrix](http://www.baeldung.com/ratpack-hystrix) +- [Ratpack with Hystrix](https://www.baeldung.com/ratpack-hystrix) - [Ratpack HTTP Client](https://www.baeldung.com/ratpack-http-client) - [Ratpack with RxJava](https://www.baeldung.com/ratpack-rxjava) - [Ratpack with Groovy](https://www.baeldung.com/ratpack-groovy) diff --git a/reactor-core/README.md b/reactor-core/README.md index 5f9d2d1bc2..ba5b355d02 100644 --- a/reactor-core/README.md +++ b/reactor-core/README.md @@ -1,5 +1,5 @@ ### Relevant articles -- [Intro To Reactor Core](http://www.baeldung.com/reactor-core) -- [Combining Publishers in Project Reactor](http://www.baeldung.com/reactor-combine-streams) +- [Intro To Reactor Core](https://www.baeldung.com/reactor-core) +- [Combining Publishers in Project Reactor](https://www.baeldung.com/reactor-combine-streams) - [Programmatically Creating Sequences with Project Reactor](https://www.baeldung.com/flux-sequences-reactor) diff --git a/resteasy/README.md b/resteasy/README.md index 83051037d2..3f3c833256 100644 --- a/resteasy/README.md +++ b/resteasy/README.md @@ -4,6 +4,6 @@ ### Relevant Articles: -- [A Guide to RESTEasy](http://www.baeldung.com/resteasy-tutorial) -- [RESTEasy Client API](http://www.baeldung.com/resteasy-client-tutorial) -- [CORS in JAX-RS](http://www.baeldung.com/cors-in-jax-rs) +- [A Guide to RESTEasy](https://www.baeldung.com/resteasy-tutorial) +- [RESTEasy Client API](https://www.baeldung.com/resteasy-client-tutorial) +- [CORS in JAX-RS](https://www.baeldung.com/cors-in-jax-rs) diff --git a/rule-engines/README.md b/rule-engines/README.md index 6d3c0e93b4..37d419daf5 100644 --- a/rule-engines/README.md +++ b/rule-engines/README.md @@ -1,3 +1,3 @@ ## Relevant articles: -- [List of Rules Engines in Java](http://www.baeldung.com/java-rule-engines) +- [List of Rules Engines in Java](https://www.baeldung.com/java-rule-engines) diff --git a/rxjava-2/README.md b/rxjava-2/README.md index 4182f3fa00..43c1a9942b 100644 --- a/rxjava-2/README.md +++ b/rxjava-2/README.md @@ -1,9 +1,9 @@ ## Relevant articles: -- [RxJava and Error Handling](http://www.baeldung.com/rxjava-error-handling) -- [RxJava 2 – Flowable](http://www.baeldung.com/rxjava-2-flowable) -- [RxJava Maybe](http://www.baeldung.com/rxjava-maybe) -- [Introduction to RxRelay for RxJava](http://www.baeldung.com/rx-relay) +- [RxJava and Error Handling](https://www.baeldung.com/rxjava-error-handling) +- [RxJava 2 – Flowable](https://www.baeldung.com/rxjava-2-flowable) +- [RxJava Maybe](https://www.baeldung.com/rxjava-maybe) +- [Introduction to RxRelay for RxJava](https://www.baeldung.com/rx-relay) - [Combining RxJava Completables](https://www.baeldung.com/rxjava-completable) - [Converting Synchronous and Asynchronous APIs to Observables using RxJava2](https://www.baeldung.com/rxjava-apis-to-observables) - [RxJava Hooks](https://www.baeldung.com/rxjava-hooks) diff --git a/rxjava/README.md b/rxjava/README.md index f8a4ca1dbe..f9b7e2ba0d 100644 --- a/rxjava/README.md +++ b/rxjava/README.md @@ -1,15 +1,15 @@ ## Relevant articles: -- [Dealing with Backpressure with RxJava](http://www.baeldung.com/rxjava-backpressure) -- [How to Test RxJava?](http://www.baeldung.com/rxjava-testing) -- [Implementing Custom Operators in RxJava](http://www.baeldung.com/rxjava-custom-operators) -- [Introduction to RxJava](http://www.baeldung.com/rx-java) -- [Observable Utility Operators in RxJava](http://www.baeldung.com/rxjava-observable-operators) -- [Introduction to rxjava-jdbc](http://www.baeldung.com/rxjava-jdbc) -- [Schedulers in RxJava](http://www.baeldung.com/rxjava-schedulers) -- [Mathematical and Aggregate Operators in RxJava](http://www.baeldung.com/rxjava-math) -- [Combining Observables in RxJava](http://www.baeldung.com/rxjava-combine-observables) -- [RxJava StringObservable](http://www.baeldung.com/rxjava-string) -- [Filtering Observables in RxJava](http://www.baeldung.com/rxjava-filtering) -- [RxJava One Observable, Multiple Subscribers](http://www.baeldung.com/rxjava-multiple-subscribers-observable) +- [Dealing with Backpressure with RxJava](https://www.baeldung.com/rxjava-backpressure) +- [How to Test RxJava?](https://www.baeldung.com/rxjava-testing) +- [Implementing Custom Operators in RxJava](https://www.baeldung.com/rxjava-custom-operators) +- [Introduction to RxJava](https://www.baeldung.com/rx-java) +- [Observable Utility Operators in RxJava](https://www.baeldung.com/rxjava-observable-operators) +- [Introduction to rxjava-jdbc](https://www.baeldung.com/rxjava-jdbc) +- [Schedulers in RxJava](https://www.baeldung.com/rxjava-schedulers) +- [Mathematical and Aggregate Operators in RxJava](https://www.baeldung.com/rxjava-math) +- [Combining Observables in RxJava](https://www.baeldung.com/rxjava-combine-observables) +- [RxJava StringObservable](https://www.baeldung.com/rxjava-string) +- [Filtering Observables in RxJava](https://www.baeldung.com/rxjava-filtering) +- [RxJava One Observable, Multiple Subscribers](https://www.baeldung.com/rxjava-multiple-subscribers-observable) - [Difference Between Flatmap and Switchmap in RxJava](https://www.baeldung.com/rxjava-flatmap-switchmap) diff --git a/saas/README.md b/saas/README.md index 4e0eeea974..4effb2afa9 100644 --- a/saas/README.md +++ b/saas/README.md @@ -1,3 +1,7 @@ +## SAAS + +This module contains articles about software as a service (SAAS) + ## Relevant articles: -- [JIRA REST API Integration](http://www.baeldung.com/jira-rest-api) +- [JIRA REST API Integration](https://www.baeldung.com/jira-rest-api) diff --git a/spark-java/README.md b/spark-java/README.md index 5abe78263c..b3ef62e631 100644 --- a/spark-java/README.md +++ b/spark-java/README.md @@ -1,6 +1,6 @@ -========= +## Spark Java -## Spark Java Framework Tutorial Sample Project +This module contains articles about Spark ### Relevant Articles -- [Building an API With the Spark Java Framework](http://www.baeldung.com/spark-framework-rest-api) +- [Building an API With the Spark Java Framework](https://www.baeldung.com/spark-framework-rest-api) diff --git a/spring-4/README.md b/spring-4/README.md index 57cb8c3eeb..d44eed915e 100644 --- a/spring-4/README.md +++ b/spring-4/README.md @@ -1,4 +1,8 @@ +## Spring 4 + +This module contains articles about Spring 4 + ### Relevant Articles: -- [A Guide to Flips for Spring](http://www.baeldung.com/flips-spring) +- [A Guide to Flips for Spring](https://www.baeldung.com/flips-spring) - [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari) -- [Spring JSON-P with Jackson](http://www.baeldung.com/spring-jackson-jsonp) +- [Spring JSON-P with Jackson](https://www.baeldung.com/spring-jackson-jsonp) diff --git a/spring-5-data-reactive/README.md b/spring-5-data-reactive/README.md index 982704e11c..683b493317 100644 --- a/spring-5-data-reactive/README.md +++ b/spring-5-data-reactive/README.md @@ -6,7 +6,7 @@ This module contains articles about reactive Spring 5 Data The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles -- [Reactive Flow with MongoDB, Kotlin, and Spring WebFlux](http://www.baeldung.com/kotlin-mongodb-spring-webflux) -- [Spring Data Reactive Repositories with MongoDB](http://www.baeldung.com/spring-data-mongodb-reactive) +- [Reactive Flow with MongoDB, Kotlin, and Spring WebFlux](https://www.baeldung.com/kotlin-mongodb-spring-webflux) +- [Spring Data Reactive Repositories with MongoDB](https://www.baeldung.com/spring-data-mongodb-reactive) - [Spring Data MongoDB Tailable Cursors](https://www.baeldung.com/spring-data-mongodb-tailable-cursors) - [A Quick Look at R2DBC with Spring Data](https://www.baeldung.com/spring-data-r2dbc) diff --git a/spring-5-mvc/README.md b/spring-5-mvc/README.md index 2b57df3b71..e98012c047 100644 --- a/spring-5-mvc/README.md +++ b/spring-5-mvc/README.md @@ -3,5 +3,6 @@ This module contains articles about Spring 5 model-view-controller (MVC) pattern ### Relevant Articles: -- [Spring Boot and Kotlin](http://www.baeldung.com/spring-boot-kotlin) +- [Spring Boot and Kotlin](https://www.baeldung.com/spring-boot-kotlin) - [Spring MVC Streaming and SSE Request Processing](https://www.baeldung.com/spring-mvc-sse-streams) +- [Interface Driven Controllers in Spring](https://www.baeldung.com/spring-interface-driven-controllers) diff --git a/spring-5-reactive-2/README.md b/spring-5-reactive-2/README.md index 1d21425fb8..8d1d9e1f8e 100644 --- a/spring-5-reactive-2/README.md +++ b/spring-5-reactive-2/README.md @@ -3,4 +3,5 @@ This module contains articles about reactive Spring 5 - [Spring WebClient vs. RestTemplate](https://www.baeldung.com/spring-webclient-resttemplate) +- [Spring WebClient Filters](https://www.baeldung.com/spring-webclient-filters) - More articles: [[<-- prev]](/spring-5-reactive) diff --git a/spring-5-reactive-client/pom.xml b/spring-5-reactive-client/pom.xml index 9e574b2196..994239fa9b 100644 --- a/spring-5-reactive-client/pom.xml +++ b/spring-5-reactive-client/pom.xml @@ -88,6 +88,12 @@ spring-boot-starter-test test + + com.github.tomakehurst + wiremock + 2.24.1 + test + org.apache.commons diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java new file mode 100644 index 0000000000..9afe50af58 --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java @@ -0,0 +1,68 @@ +package com.baeldung.reactive.webclient.simultaneous; + +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Mono; +import reactor.core.publisher.Flux; +import reactor.core.scheduler.Schedulers; + +import java.util.List; +import java.util.logging.Logger; + +public class Client { + + private static final Logger LOG = Logger.getLogger(Client.class.getName()); + + private WebClient webClient; + + public Client(String uri) { + this.webClient = WebClient.create(uri); + } + + public Mono getUser(int id) { + LOG.info(String.format("Calling getUser(%d)", id)); + + return webClient.get() + .uri("/user/{id}", id) + .retrieve() + .bodyToMono(User.class); + } + + public Mono getItem(int id) { + return webClient.get() + .uri("/item/{id}", id) + .retrieve() + .bodyToMono(Item.class); + } + + public Mono getOtherUser(int id) { + return webClient.get() + .uri("/otheruser/{id}", id) + .retrieve() + .bodyToMono(User.class); + } + + public List fetchUsers(List userIds) { + return Flux.fromIterable(userIds) + .parallel() + .runOn(Schedulers.elastic()) + .flatMap(this::getUser) + .collectSortedList((u1, u2) -> u2.id() - u1.id()) + .block(); + } + + public List fetchUserAndOtherUser(int id) { + return Flux.merge(getUser(id), getOtherUser(id)) + .parallel() + .runOn(Schedulers.elastic()) + .collectSortedList((u1, u2) -> u2.id() - u1.id()) + .block(); + } + + public UserWithItem fetchUserAndItem(int userId, int itemId) { + Mono user = getUser(userId).subscribeOn(Schedulers.elastic()); + Mono item = getItem(itemId).subscribeOn(Schedulers.elastic()); + + return Mono.zip(user, item, UserWithItem::new) + .block(); + } +} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Item.java b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Item.java new file mode 100644 index 0000000000..5b8260743b --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Item.java @@ -0,0 +1,17 @@ +package com.baeldung.reactive.webclient.simultaneous; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Item { + private int id; + + @JsonCreator + public Item(@JsonProperty("id") int id) { + this.id = id; + } + + public int id() { + return id; + } +} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/User.java b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/User.java new file mode 100644 index 0000000000..0e1cc2cd76 --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/User.java @@ -0,0 +1,17 @@ +package com.baeldung.reactive.webclient.simultaneous; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class User { + private int id; + + @JsonCreator + public User(@JsonProperty("id") int id) { + this.id = id; + } + + public int id() { + return id; + } +} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/UserWithItem.java b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/UserWithItem.java new file mode 100644 index 0000000000..96dcfe994e --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/UserWithItem.java @@ -0,0 +1,19 @@ +package com.baeldung.reactive.webclient.simultaneous; + +public class UserWithItem { + private User user; + private Item item; + + public UserWithItem(User user, Item item) { + this.user = user; + this.item = item; + } + + public User user() { + return user; + } + + public Item item() { + return item; + } +} diff --git a/spring-5-reactive-client/src/test/java/com/baeldung/reactive/webclient/simultaneous/ClientIntegrationTest.java b/spring-5-reactive-client/src/test/java/com/baeldung/reactive/webclient/simultaneous/ClientIntegrationTest.java new file mode 100644 index 0000000000..0acedf15b0 --- /dev/null +++ b/spring-5-reactive-client/src/test/java/com/baeldung/reactive/webclient/simultaneous/ClientIntegrationTest.java @@ -0,0 +1,68 @@ +package com.baeldung.reactive.webclient.simultaneous; + +import org.junit.Test; +import org.junit.Before; +import org.junit.After; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import com.github.tomakehurst.wiremock.WireMockServer; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ClientIntegrationTest { + + private WireMockServer wireMockServer; + + @Before + public void setup() { + wireMockServer = new WireMockServer(wireMockConfig().port(8089)); + wireMockServer.start(); + configureFor("localhost", wireMockServer.port()); + } + + @After + public void tearDown() { + wireMockServer.stop(); + } + + @Test + public void givenClient_whenFetchingUsers_thenExecutionTimeIsLessThanDouble() { + // Arrange + int requestsNumber = 5; + int singleRequestTime = 1000; + + for (int i = 1; i <= requestsNumber; i++) { + stubFor(get(urlEqualTo("/user/" + i)).willReturn(aResponse().withFixedDelay(singleRequestTime) + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody(String.format("{ \"id\": %d }", i)))); + } + + List userIds = IntStream.rangeClosed(1, requestsNumber) + .boxed() + .collect(Collectors.toList()); + + Client client = new Client("http://localhost:8089"); + + // Act + long start = System.currentTimeMillis(); + List users = client.fetchUsers(userIds); + long end = System.currentTimeMillis(); + + // Assert + long totalExecutionTime = end - start; + + assertEquals("Unexpected number of users", requestsNumber, users.size()); + assertTrue("Execution time is too big", 2 * singleRequestTime > totalExecutionTime); + } +} diff --git a/spring-5-reactive-security/README.md b/spring-5-reactive-security/README.md index ebb107645b..4ea6fb644f 100644 --- a/spring-5-reactive-security/README.md +++ b/spring-5-reactive-security/README.md @@ -7,7 +7,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles -- [Spring Boot Actuator](http://www.baeldung.com/spring-boot-actuators) -- [Spring Security 5 for Reactive Applications](http://www.baeldung.com/spring-security-5-reactive) -- [Guide to Spring 5 WebFlux](http://www.baeldung.com/spring-webflux) +- [Spring Boot Actuator](https://www.baeldung.com/spring-boot-actuators) +- [Spring Security 5 for Reactive Applications](https://www.baeldung.com/spring-security-5-reactive) +- [Guide to Spring 5 WebFlux](https://www.baeldung.com/spring-webflux) - [Introduction to the Functional Web Framework in Spring 5](https://www.baeldung.com/spring-5-functional-web) diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md index 89ff4fea9f..2bef8ee6d4 100644 --- a/spring-5-reactive/README.md +++ b/spring-5-reactive/README.md @@ -7,14 +7,14 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles -- [Introduction to the Functional Web Framework in Spring 5](http://www.baeldung.com/spring-5-functional-web) -- [Spring 5 WebClient](http://www.baeldung.com/spring-5-webclient) -- [Exploring the Spring 5 WebFlux URL Matching](http://www.baeldung.com/spring-5-mvc-url-matching) -- [Reactive WebSockets with Spring 5](http://www.baeldung.com/spring-5-reactive-websockets) -- [Spring Webflux Filters](http://www.baeldung.com/spring-webflux-filters) -- [How to Set a Header on a Response with Spring 5](http://www.baeldung.com/spring-response-header) -- [Spring Webflux and CORS](http://www.baeldung.com/spring-webflux-cors) -- [Handling Errors in Spring WebFlux](http://www.baeldung.com/spring-webflux-errors) +- [Introduction to the Functional Web Framework in Spring 5](https://www.baeldung.com/spring-5-functional-web) +- [Spring 5 WebClient](https://www.baeldung.com/spring-5-webclient) +- [Exploring the Spring 5 WebFlux URL Matching](https://www.baeldung.com/spring-5-mvc-url-matching) +- [Reactive WebSockets with Spring 5](https://www.baeldung.com/spring-5-reactive-websockets) +- [Spring Webflux Filters](httpss://www.baeldung.com/spring-webflux-filters) +- [How to Set a Header on a Response with Spring 5](https://www.baeldung.com/spring-response-header) +- [Spring Webflux and CORS](https://www.baeldung.com/spring-webflux-cors) +- [Handling Errors in Spring WebFlux](https://www.baeldung.com/spring-webflux-errors) - [Server-Sent Events in Spring](https://www.baeldung.com/spring-server-sent-events) - [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) - [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) @@ -22,4 +22,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) - [Debugging Reactive Streams in Spring 5](https://www.baeldung.com/spring-debugging-reactive-streams) - [Static Content in Spring WebFlux](https://www.baeldung.com/spring-webflux-static-content) -- More articles: [[next -->]](/spring-5-reactive-2) \ No newline at end of file +- More articles: [[next -->]](/spring-5-reactive-2) diff --git a/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java index 42da90ecd5..3bbbed0d77 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java @@ -12,11 +12,13 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.http.MediaType; import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.reactive.server.WebTestClient; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@DirtiesContext @WithMockUser @AutoConfigureWebTestClient(timeout = "10000") public class ErrorHandlingIntegrationTest { diff --git a/spring-5-security-cognito/README.md b/spring-5-security-cognito/README.md index 0825882c05..ff2784f410 100644 --- a/spring-5-security-cognito/README.md +++ b/spring-5-security-cognito/README.md @@ -1,3 +1,7 @@ +## Spring 5 Security Cognito + +This module contains articles about Spring 5 with Amazon Cognito + ## Relevant articles: - [Authenticating with Amazon Cognito Using Spring Security](https://www.baeldung.com/spring-security-oauth-cognito) diff --git a/spring-5-security-oauth/README.md b/spring-5-security-oauth/README.md index 4e080fc517..43cab33598 100644 --- a/spring-5-security-oauth/README.md +++ b/spring-5-security-oauth/README.md @@ -4,6 +4,6 @@ This module contains articles about Spring 5 OAuth Security ## Relevant articles: -- [Spring Security 5 – OAuth2 Login](http://www.baeldung.com/spring-security-5-oauth2-login) +- [Spring Security 5 – OAuth2 Login](https://www.baeldung.com/spring-security-5-oauth2-login) - [Extracting Principal and Authorities using Spring Security OAuth](https://www.baeldung.com/spring-security-oauth-principal-authorities-extractor) - [Customizing Authorization and Token Requests with Spring Security 5.1 Client](https://www.baeldung.com/spring-security-custom-oauth-requests) diff --git a/spring-5-security/README.md b/spring-5-security/README.md index 23b46f4dc9..4cace0db8d 100644 --- a/spring-5-security/README.md +++ b/spring-5-security/README.md @@ -4,8 +4,8 @@ This module contains articles about Spring Security 5 ## Relevant articles: -- [Extra Login Fields with Spring Security](http://www.baeldung.com/spring-security-extra-login-fields) -- [A Custom Spring SecurityConfigurer](http://www.baeldung.com/spring-security-custom-configurer) -- [New Password Storage In Spring Security 5](http://www.baeldung.com/spring-security-5-password-storage) +- [Extra Login Fields with Spring Security](https://www.baeldung.com/spring-security-extra-login-fields) +- [A Custom Spring SecurityConfigurer](https://www.baeldung.com/spring-security-custom-configurer) +- [New Password Storage In Spring Security 5](https://www.baeldung.com/spring-security-5-password-storage) - [Default Password Encoder in Spring Security 5](https://www.baeldung.com/spring-security-5-default-password-encoder) diff --git a/spring-5/README.md b/spring-5/README.md index d3c1decbc7..7588d23304 100644 --- a/spring-5/README.md +++ b/spring-5/README.md @@ -1,16 +1,18 @@ -## Spring REST Example Project +## Spring 5 + +This module contains articles about Spring 5 ### The Course The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles -- [Concurrent Test Execution in Spring 5](http://www.baeldung.com/spring-5-concurrent-tests) -- [Spring 5 Functional Bean Registration](http://www.baeldung.com/spring-5-functional-beans) -- [The SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring 5](http://www.baeldung.com/spring-5-junit-config) -- [Spring 5 Testing with @EnabledIf Annotation](http://www.baeldung.com/spring-5-enabledIf) -- [Introduction to Spring REST Docs](http://www.baeldung.com/spring-rest-docs) -- [Spring ResponseStatusException](http://www.baeldung.com/spring-response-status-exception) -- [Spring Assert Statements](http://www.baeldung.com/spring-assert) +- [Concurrent Test Execution in Spring 5](https://www.baeldung.com/spring-5-concurrent-tests) +- [Spring 5 Functional Bean Registration](https://www.baeldung.com/spring-5-functional-beans) +- [The SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring 5](https://www.baeldung.com/spring-5-junit-config) +- [Spring 5 Testing with @EnabledIf Annotation](https://www.baeldung.com/spring-5-enabledIf) +- [Introduction to Spring REST Docs](https://www.baeldung.com/spring-rest-docs) +- [Spring ResponseStatusException](https://www.baeldung.com/spring-response-status-exception) +- [Spring Assert Statements](https://www.baeldung.com/spring-assert) - [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari) diff --git a/spring-activiti/README.md b/spring-activiti/README.md index 703dfeec52..f4e788492b 100644 --- a/spring-activiti/README.md +++ b/spring-activiti/README.md @@ -1,6 +1,10 @@ +## Spring Activiti + +This module contains articles about Spring with Activiti + ### Relevant articles -- [A Guide to Activiti with Java](http://www.baeldung.com/java-activiti) -- [Introduction to Activiti with Spring](http://www.baeldung.com/spring-activiti) -- [Activiti with Spring Security](http://www.baeldung.com/activiti-spring-security) -- [ProcessEngine Configuration in Activiti](http://www.baeldung.com/activiti-process-engine) +- [A Guide to Activiti with Java](https://www.baeldung.com/java-activiti) +- [Introduction to Activiti with Spring](https://www.baeldung.com/spring-activiti) +- [Activiti with Spring Security](https://www.baeldung.com/activiti-spring-security) +- [ProcessEngine Configuration in Activiti](https://www.baeldung.com/activiti-process-engine) diff --git a/spring-akka/README.md b/spring-akka/README.md index 0f1c013214..c7db5d5c01 100644 --- a/spring-akka/README.md +++ b/spring-akka/README.md @@ -1,2 +1,6 @@ +## Spring Akka + +This module contains articles about Spring with Akka + ### Relevant Articles: -- [Introduction to Spring with Akka](http://www.baeldung.com/akka-with-spring) +- [Introduction to Spring with Akka](https://www.baeldung.com/akka-with-spring) diff --git a/spring-all/README.md b/spring-all/README.md index c5825b47fb..1d6cb0bfad 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -1,5 +1,3 @@ -========= - ## Spring General Example Project This project is used to replicate Spring Exceptions only. @@ -10,26 +8,26 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant articles: -- [Guide to Spring @Autowired](http://www.baeldung.com/spring-autowire) -- [Spring Profiles](http://www.baeldung.com/spring-profiles) -- [A Spring Custom Annotation for a Better DAO](http://www.baeldung.com/spring-annotation-bean-pre-processor) -- [What’s New in Spring 4.3?](http://www.baeldung.com/whats-new-in-spring-4-3) -- [Running Setup Data on Startup in Spring](http://www.baeldung.com/running-setup-logic-on-startup-in-spring) -- [Quick Guide to Spring Controllers](http://www.baeldung.com/spring-controllers) -- [Quick Guide to Spring Bean Scopes](http://www.baeldung.com/spring-bean-scopes) -- [Introduction To Ehcache](http://www.baeldung.com/ehcache) -- [A Guide to the Spring Task Scheduler](http://www.baeldung.com/spring-task-scheduler) -- [Guide to Spring Retry](http://www.baeldung.com/spring-retry) -- [Custom Scope in Spring](http://www.baeldung.com/spring-custom-scope) -- [A CLI with Spring Shell](http://www.baeldung.com/spring-shell-cli) -- [JasperReports with Spring](http://www.baeldung.com/spring-jasper) -- [Model, ModelMap, and ModelView in Spring MVC](http://www.baeldung.com/spring-mvc-model-model-map-model-view) -- [A Guide To Caching in Spring](http://www.baeldung.com/spring-cache-tutorial) -- [How To Do @Async in Spring](http://www.baeldung.com/spring-async) -- [@Order in Spring](http://www.baeldung.com/spring-order) -- [Spring Web Contexts](http://www.baeldung.com/spring-web-contexts) -- [Spring Cache – Creating a Custom KeyGenerator](http://www.baeldung.com/spring-cache-custom-keygenerator) -- [Spring @Primary Annotation](http://www.baeldung.com/spring-primary) +- [Guide to Spring @Autowired](https://www.baeldung.com/spring-autowire) +- [Spring Profiles](https://www.baeldung.com/spring-profiles) +- [A Spring Custom Annotation for a Better DAO](https://www.baeldung.com/spring-annotation-bean-pre-processor) +- [What’s New in Spring 4.3?](https://www.baeldung.com/whats-new-in-spring-4-3) +- [Running Setup Data on Startup in Spring](https://www.baeldung.com/running-setup-logic-on-startup-in-spring) +- [Quick Guide to Spring Controllers](https://www.baeldung.com/spring-controllers) +- [Quick Guide to Spring Bean Scopes](https://www.baeldung.com/spring-bean-scopes) +- [Introduction To Ehcache](https://www.baeldung.com/ehcache) +- [A Guide to the Spring Task Scheduler](https://www.baeldung.com/spring-task-scheduler) +- [Guide to Spring Retry](https://www.baeldung.com/spring-retry) +- [Custom Scope in Spring](https://www.baeldung.com/spring-custom-scope) +- [A CLI with Spring Shell](https://www.baeldung.com/spring-shell-cli) +- [JasperReports with Spring](https://www.baeldung.com/spring-jasper) +- [Model, ModelMap, and ModelView in Spring MVC](https://www.baeldung.com/spring-mvc-model-model-map-model-view) +- [A Guide To Caching in Spring](https://www.baeldung.com/spring-cache-tutorial) +- [How To Do @Async in Spring](https://www.baeldung.com/spring-async) +- [@Order in Spring](https://www.baeldung.com/spring-order) +- [Spring Web Contexts](https://www.baeldung.com/spring-web-contexts) +- [Spring Cache – Creating a Custom KeyGenerator](https://www.baeldung.com/spring-cache-custom-keygenerator) +- [Spring @Primary Annotation](https://www.baeldung.com/spring-primary) - [Spring Events](https://www.baeldung.com/spring-events) - [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) diff --git a/spring-amqp/README.md b/spring-amqp/README.md index 5e29011995..0ae4eda12e 100644 --- a/spring-amqp/README.md +++ b/spring-amqp/README.md @@ -1,3 +1,7 @@ +## Spring AMQP + +This module contains articles about Spring with the AMQP messaging system + ## Relevant articles: - [Messaging With Spring AMQP](https://www.baeldung.com/spring-amqp) diff --git a/spring-aop/README.md b/spring-aop/README.md index af8ab71da0..061e736d31 100644 --- a/spring-aop/README.md +++ b/spring-aop/README.md @@ -1,6 +1,10 @@ +## Spring AOP + +This module contains articles about Spring aspect oriented programming (AOP) + ### Relevant articles -- [Implementing a Custom Spring AOP Annotation](http://www.baeldung.com/spring-aop-annotation) -- [Intro to AspectJ](http://www.baeldung.com/aspectj) -- [Spring Performance Logging](http://www.baeldung.com/spring-performance-logging) -- [Introduction to Spring AOP](http://www.baeldung.com/spring-aop) +- [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) diff --git a/spring-apache-camel/README.md b/spring-apache-camel/README.md index e72e18b198..e89eb4fe6c 100644 --- a/spring-apache-camel/README.md +++ b/spring-apache-camel/README.md @@ -1,35 +1,26 @@ +## Spring Apache Camel -

Configure and Use Apache Camel with Spring

+This module contains articles about Spring with Apache Camel -This article will demonstrate how to configure and use Apache Camel with Spring Framework. +### Relevant Articles -

Relevant Articles

+- [Apache Camel](http://camel.apache.org/) +- [Enterprise Integration Patterns](http://www.enterpriseintegrationpatterns.com/patterns/messaging/toc.html) +- [Introduction To Apache Camel](http://www.baeldung.com/apache-camel-intro) +- [Integration Patterns With Apache Camel](http://www.baeldung.com/camel-integration-patterns) +- [Using Apache Camel with Spring](http://www.baeldung.com/spring-apache-camel-tutorial) - +### Framework Versions: -

Framework Versions:

+- Spring 4.2.4 +- Apache Camel 2.16.1 -
    -
  • Spring 4.2.4
  • -
  • Apache Camel 2.16.1
  • -
+### Build and Run Application -

Build and Run Application

+To build this application execute: -To build this application execute following maven command in ApacheCamelFileProcessor directory. - -mvn clean install +`mvn clean install` To run this application you can either run our main class App from your IDE or you can execute following maven command: -mvn exec:java -Dexec.mainClass="App" - -

Relevant Articles on Baeldung

- +`mvn exec:java -Dexec.mainClass="com.baeldung.camel.main.App"` \ No newline at end of file diff --git a/spring-batch/README.md b/spring-batch/README.md index ddd830cd47..95abbaf931 100644 --- a/spring-batch/README.md +++ b/spring-batch/README.md @@ -1,10 +1,9 @@ -========= - ## Spring Batch +This module contains articles about Spring Batch ### Relevant Articles: -- [Introduction to Spring Batch](http://www.baeldung.com/introduction-to-spring-batch) -- [Spring Batch using Partitioner](http://www.baeldung.com/spring-batch-partitioner) -- [Spring Batch – Tasklets vs Chunks](http://www.baeldung.com/spring-batch-tasklet-chunk) -- [How to Trigger and Stop a Scheduled Spring Batch Job](http://www.baeldung.com/spring-batch-start-stop-job) +- [Introduction to Spring Batch](https://www.baeldung.com/introduction-to-spring-batch) +- [Spring Batch using Partitioner](https://www.baeldung.com/spring-batch-partitioner) +- [Spring Batch – Tasklets vs Chunks](https://www.baeldung.com/spring-batch-tasklet-chunk) +- [How to Trigger and Stop a Scheduled Spring Batch Job](https://www.baeldung.com/spring-batch-start-stop-job) diff --git a/spring-bom/README.md b/spring-bom/README.md index d056216a2e..0866582fb2 100644 --- a/spring-bom/README.md +++ b/spring-bom/README.md @@ -1,3 +1,6 @@ +## Spring BOM + +This module contains articles about Spring with Maven BOM (Bill Of Materials) ### Relevant Articles: -- [Spring with Maven BOM](http://www.baeldung.com/spring-maven-bom) +- [Spring with Maven BOM](https://www.baeldung.com/spring-maven-bom) diff --git a/spring-boot-admin/README.md b/spring-boot-admin/README.md index 61010819fd..ac4d781d0e 100644 --- a/spring-boot-admin/README.md +++ b/spring-boot-admin/README.md @@ -23,4 +23,4 @@ and the mail configuration from application.properties ### Relevant Articles: -- [A Guide to Spring Boot Admin](http://www.baeldung.com/spring-boot-admin) +- [A Guide to Spring Boot Admin](https://www.baeldung.com/spring-boot-admin) diff --git a/spring-boot-admin/pom.xml b/spring-boot-admin/pom.xml index b2ced767eb..1c933723e7 100644 --- a/spring-boot-admin/pom.xml +++ b/spring-boot-admin/pom.xml @@ -30,7 +30,7 @@ - 2.1.7.RELEASE + 2.1.8.RELEASE
\ No newline at end of file diff --git a/spring-boot-angular-ecommerce/README.md b/spring-boot-angular-ecommerce/README.md deleted file mode 100644 index 9b592de9cc..0000000000 --- a/spring-boot-angular-ecommerce/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Spring Boot Angular Ecommerce - -This module contains articles about Spring Boot with Angular in regards to ecommerce applications. - -### Relevant Articles: -- [A Simple E-Commerce Implementation with Spring](https://www.baeldung.com/spring-angular-ecommerce) diff --git a/spring-boot-angular-ecommerce/pom.xml b/spring-boot-angular-ecommerce/pom.xml deleted file mode 100644 index 510e6c6ec3..0000000000 --- a/spring-boot-angular-ecommerce/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - 4.0.0 - spring-boot-angular-ecommerce - 0.0.1-SNAPSHOT - spring-boot-angular-ecommerce - jar - Spring Boot Angular E-commerce Appliciation - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-starter-data-jpa - ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-web - ${spring.boot.version} - - - org.springframework.boot - spring-boot-devtools - ${spring.boot.version} - runtime - - - com.h2database - h2 - 1.4.197 - runtime - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - 2.9.6 - - - org.springframework.boot - spring-boot-starter-test - ${spring.boot.version} - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot-maven-plugin.version} - - - - - - UTF-8 - UTF-8 - 2.0.3.RELEASE - 2.0.4.RELEASE - - diff --git a/spring-boot-angular/README.md b/spring-boot-angular/README.md index a1904c2c17..027b23202e 100644 --- a/spring-boot-angular/README.md +++ b/spring-boot-angular/README.md @@ -1,7 +1,8 @@ ## Spring Boot Angular -This module contains articles about Spring Boot with Angular +This module contains articles about Spring Boot with Angular ### Relevant Articles: -- [Building a Web Application with Spring Boot and Angular](https://www.baeldung.com/spring-boot-angular-web) +- [Building a Web Application with Spring Boot and Angular](https://www.baeldung.com/spring-boot-angular-web) +- [A Simple E-Commerce Implementation with Spring](https://www.baeldung.com/spring-angular-ecommerce) diff --git a/spring-boot-angular/pom.xml b/spring-boot-angular/pom.xml index 71c46cb7f5..8c26668752 100644 --- a/spring-boot-angular/pom.xml +++ b/spring-boot-angular/pom.xml @@ -7,11 +7,12 @@ 1.0 jar + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../../parent-boot-2 + ../parent-boot-2 diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/EcommerceApplication.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/EcommerceApplication.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/EcommerceApplication.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/EcommerceApplication.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/controller/OrderController.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/OrderController.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/controller/OrderController.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/OrderController.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/controller/ProductController.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/ProductController.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/controller/ProductController.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/controller/ProductController.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/dto/OrderProductDto.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/dto/OrderProductDto.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/dto/OrderProductDto.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/dto/OrderProductDto.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/exception/ApiExceptionHandler.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ApiExceptionHandler.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/exception/ApiExceptionHandler.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ApiExceptionHandler.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/exception/ResourceNotFoundException.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ResourceNotFoundException.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/exception/ResourceNotFoundException.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/exception/ResourceNotFoundException.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/Order.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Order.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/Order.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Order.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/OrderProduct.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProduct.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/OrderProduct.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProduct.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/OrderProductPK.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProductPK.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/OrderProductPK.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderProductPK.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/OrderStatus.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderStatus.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/OrderStatus.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/OrderStatus.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/Product.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Product.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/model/Product.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/model/Product.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/repository/OrderProductRepository.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderProductRepository.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/repository/OrderProductRepository.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderProductRepository.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/repository/OrderRepository.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderRepository.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/repository/OrderRepository.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/OrderRepository.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/repository/ProductRepository.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/ProductRepository.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/repository/ProductRepository.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/repository/ProductRepository.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/OrderProductService.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductService.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/OrderProductService.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductService.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/OrderProductServiceImpl.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductServiceImpl.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/OrderProductServiceImpl.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderProductServiceImpl.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/OrderService.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderService.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/OrderService.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderService.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/OrderServiceImpl.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderServiceImpl.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/OrderServiceImpl.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/OrderServiceImpl.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/ProductService.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductService.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/ProductService.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductService.java diff --git a/spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/ProductServiceImpl.java b/spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductServiceImpl.java similarity index 100% rename from spring-boot-angular-ecommerce/src/main/java/com/baeldung/ecommerce/service/ProductServiceImpl.java rename to spring-boot-angular/src/main/java/com/baeldung/ecommerce/service/ProductServiceImpl.java diff --git a/spring-boot-angular/angularclient/.angular-cli.json b/spring-boot-angular/src/main/js/application/.angular-cli.json similarity index 100% rename from spring-boot-angular/angularclient/.angular-cli.json rename to spring-boot-angular/src/main/js/application/.angular-cli.json diff --git a/spring-boot-angular/angularclient/.editorconfig b/spring-boot-angular/src/main/js/application/.editorconfig similarity index 100% rename from spring-boot-angular/angularclient/.editorconfig rename to spring-boot-angular/src/main/js/application/.editorconfig diff --git a/spring-boot-angular/angularclient/.gitignore b/spring-boot-angular/src/main/js/application/.gitignore similarity index 82% rename from spring-boot-angular/angularclient/.gitignore rename to spring-boot-angular/src/main/js/application/.gitignore index eabf65e51a..0537fca516 100644 --- a/spring-boot-angular/angularclient/.gitignore +++ b/spring-boot-angular/src/main/js/application/.gitignore @@ -36,8 +36,8 @@ testem.log /typings # e2e -/e2e/*.js -/e2e/*.map +/spring-boot-angular/src/main/js/application/e2e/*.js +/spring-boot-angular/src/main/js/application/e2e/*.map # System Files .DS_Store diff --git a/spring-boot-angular/angularclient/README.md b/spring-boot-angular/src/main/js/application/README.md similarity index 100% rename from spring-boot-angular/angularclient/README.md rename to spring-boot-angular/src/main/js/application/README.md diff --git a/spring-boot-angular/angularclient/e2e/app.e2e-spec.ts b/spring-boot-angular/src/main/js/application/e2e/app.e2e-spec.ts similarity index 100% rename from spring-boot-angular/angularclient/e2e/app.e2e-spec.ts rename to spring-boot-angular/src/main/js/application/e2e/app.e2e-spec.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/e2e/src/app.po.ts b/spring-boot-angular/src/main/js/application/e2e/app.po.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/e2e/src/app.po.ts rename to spring-boot-angular/src/main/js/application/e2e/app.po.ts diff --git a/spring-boot-angular/angularclient/e2e/tsconfig.e2e.json b/spring-boot-angular/src/main/js/application/e2e/tsconfig.e2e.json similarity index 100% rename from spring-boot-angular/angularclient/e2e/tsconfig.e2e.json rename to spring-boot-angular/src/main/js/application/e2e/tsconfig.e2e.json diff --git a/spring-boot-angular/angularclient/karma.conf.js b/spring-boot-angular/src/main/js/application/karma.conf.js similarity index 100% rename from spring-boot-angular/angularclient/karma.conf.js rename to spring-boot-angular/src/main/js/application/karma.conf.js diff --git a/spring-boot-angular/angularclient/package-lock.json b/spring-boot-angular/src/main/js/application/package-lock.json similarity index 100% rename from spring-boot-angular/angularclient/package-lock.json rename to spring-boot-angular/src/main/js/application/package-lock.json diff --git a/spring-boot-angular/angularclient/package.json b/spring-boot-angular/src/main/js/application/package.json similarity index 100% rename from spring-boot-angular/angularclient/package.json rename to spring-boot-angular/src/main/js/application/package.json diff --git a/spring-boot-angular/angularclient/protractor.conf.js b/spring-boot-angular/src/main/js/application/protractor.conf.js similarity index 100% rename from spring-boot-angular/angularclient/protractor.conf.js rename to spring-boot-angular/src/main/js/application/protractor.conf.js diff --git a/spring-boot-angular/angularclient/src/app/app-routing.module.ts b/spring-boot-angular/src/main/js/application/src/app/app-routing.module.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/app-routing.module.ts rename to spring-boot-angular/src/main/js/application/src/app/app-routing.module.ts diff --git a/spring-boot-angular/angularclient/src/app/app.component.css b/spring-boot-angular/src/main/js/application/src/app/app.component.css similarity index 100% rename from spring-boot-angular/angularclient/src/app/app.component.css rename to spring-boot-angular/src/main/js/application/src/app/app.component.css diff --git a/spring-boot-angular/angularclient/src/app/app.component.html b/spring-boot-angular/src/main/js/application/src/app/app.component.html similarity index 100% rename from spring-boot-angular/angularclient/src/app/app.component.html rename to spring-boot-angular/src/main/js/application/src/app/app.component.html diff --git a/spring-boot-angular/angularclient/src/app/app.component.spec.ts b/spring-boot-angular/src/main/js/application/src/app/app.component.spec.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/app.component.spec.ts rename to spring-boot-angular/src/main/js/application/src/app/app.component.spec.ts diff --git a/spring-boot-angular/angularclient/src/app/app.component.ts b/spring-boot-angular/src/main/js/application/src/app/app.component.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/app.component.ts rename to spring-boot-angular/src/main/js/application/src/app/app.component.ts diff --git a/spring-boot-angular/angularclient/src/app/app.module.ts b/spring-boot-angular/src/main/js/application/src/app/app.module.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/app.module.ts rename to spring-boot-angular/src/main/js/application/src/app/app.module.ts diff --git a/spring-boot-angular/angularclient/src/app/model/user.ts b/spring-boot-angular/src/main/js/application/src/app/model/user.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/model/user.ts rename to spring-boot-angular/src/main/js/application/src/app/model/user.ts diff --git a/spring-boot-angular/angularclient/src/app/service/user.service.spec.ts b/spring-boot-angular/src/main/js/application/src/app/service/user.service.spec.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/service/user.service.spec.ts rename to spring-boot-angular/src/main/js/application/src/app/service/user.service.spec.ts diff --git a/spring-boot-angular/angularclient/src/app/service/user.service.ts b/spring-boot-angular/src/main/js/application/src/app/service/user.service.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/service/user.service.ts rename to spring-boot-angular/src/main/js/application/src/app/service/user.service.ts diff --git a/spring-boot-angular/angularclient/src/app/user-form/user-form.component.css b/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.css similarity index 100% rename from spring-boot-angular/angularclient/src/app/user-form/user-form.component.css rename to spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.css diff --git a/spring-boot-angular/angularclient/src/app/user-form/user-form.component.html b/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.html similarity index 100% rename from spring-boot-angular/angularclient/src/app/user-form/user-form.component.html rename to spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.html diff --git a/spring-boot-angular/angularclient/src/app/user-form/user-form.component.spec.ts b/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.spec.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/user-form/user-form.component.spec.ts rename to spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.spec.ts diff --git a/spring-boot-angular/angularclient/src/app/user-form/user-form.component.ts b/spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/user-form/user-form.component.ts rename to spring-boot-angular/src/main/js/application/src/app/user-form/user-form.component.ts diff --git a/spring-boot-angular/angularclient/src/app/user-list/user-list.component.css b/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.css similarity index 100% rename from spring-boot-angular/angularclient/src/app/user-list/user-list.component.css rename to spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.css diff --git a/spring-boot-angular/angularclient/src/app/user-list/user-list.component.html b/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.html similarity index 100% rename from spring-boot-angular/angularclient/src/app/user-list/user-list.component.html rename to spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.html diff --git a/spring-boot-angular/angularclient/src/app/user-list/user-list.component.spec.ts b/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.spec.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/user-list/user-list.component.spec.ts rename to spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.spec.ts diff --git a/spring-boot-angular/angularclient/src/app/user-list/user-list.component.ts b/spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.ts similarity index 100% rename from spring-boot-angular/angularclient/src/app/user-list/user-list.component.ts rename to spring-boot-angular/src/main/js/application/src/app/user-list/user-list.component.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/assets/.gitkeep b/spring-boot-angular/src/main/js/application/src/assets/.gitkeep similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/assets/.gitkeep rename to spring-boot-angular/src/main/js/application/src/assets/.gitkeep diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/environments/environment.prod.ts b/spring-boot-angular/src/main/js/application/src/environments/environment.prod.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/environments/environment.prod.ts rename to spring-boot-angular/src/main/js/application/src/environments/environment.prod.ts diff --git a/spring-boot-angular/angularclient/src/environments/environment.ts b/spring-boot-angular/src/main/js/application/src/environments/environment.ts similarity index 100% rename from spring-boot-angular/angularclient/src/environments/environment.ts rename to spring-boot-angular/src/main/js/application/src/environments/environment.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/favicon.ico b/spring-boot-angular/src/main/js/application/src/favicon.ico similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/favicon.ico rename to spring-boot-angular/src/main/js/application/src/favicon.ico diff --git a/spring-boot-angular/angularclient/src/index.html b/spring-boot-angular/src/main/js/application/src/index.html similarity index 100% rename from spring-boot-angular/angularclient/src/index.html rename to spring-boot-angular/src/main/js/application/src/index.html diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/main.ts b/spring-boot-angular/src/main/js/application/src/main.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/main.ts rename to spring-boot-angular/src/main/js/application/src/main.ts diff --git a/spring-boot-angular/angularclient/src/polyfills.ts b/spring-boot-angular/src/main/js/application/src/polyfills.ts similarity index 100% rename from spring-boot-angular/angularclient/src/polyfills.ts rename to spring-boot-angular/src/main/js/application/src/polyfills.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/styles.css b/spring-boot-angular/src/main/js/application/src/styles.css similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/styles.css rename to spring-boot-angular/src/main/js/application/src/styles.css diff --git a/spring-boot-angular/angularclient/src/tsconfig.app.json b/spring-boot-angular/src/main/js/application/src/tsconfig.app.json similarity index 100% rename from spring-boot-angular/angularclient/src/tsconfig.app.json rename to spring-boot-angular/src/main/js/application/src/tsconfig.app.json diff --git a/spring-boot-angular/angularclient/src/tsconfig.spec.json b/spring-boot-angular/src/main/js/application/src/tsconfig.spec.json similarity index 100% rename from spring-boot-angular/angularclient/src/tsconfig.spec.json rename to spring-boot-angular/src/main/js/application/src/tsconfig.spec.json diff --git a/spring-boot-angular/angularclient/src/typings.d.ts b/spring-boot-angular/src/main/js/application/src/typings.d.ts similarity index 100% rename from spring-boot-angular/angularclient/src/typings.d.ts rename to spring-boot-angular/src/main/js/application/src/typings.d.ts diff --git a/spring-boot-angular/angularclient/tsconfig.json b/spring-boot-angular/src/main/js/application/tsconfig.json similarity index 100% rename from spring-boot-angular/angularclient/tsconfig.json rename to spring-boot-angular/src/main/js/application/tsconfig.json diff --git a/spring-boot-angular/angularclient/tslint.json b/spring-boot-angular/src/main/js/application/tslint.json similarity index 100% rename from spring-boot-angular/angularclient/tslint.json rename to spring-boot-angular/src/main/js/application/tslint.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/.editorconfig b/spring-boot-angular/src/main/js/ecommerce/.editorconfig similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/.editorconfig rename to spring-boot-angular/src/main/js/ecommerce/.editorconfig diff --git a/spring-boot-angular-ecommerce/src/main/frontend/README.md b/spring-boot-angular/src/main/js/ecommerce/README.md similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/README.md rename to spring-boot-angular/src/main/js/ecommerce/README.md diff --git a/spring-boot-angular-ecommerce/src/main/frontend/angular.json b/spring-boot-angular/src/main/js/ecommerce/angular.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/angular.json rename to spring-boot-angular/src/main/js/ecommerce/angular.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/e2e/protractor.conf.js b/spring-boot-angular/src/main/js/ecommerce/e2e/protractor.conf.js similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/e2e/protractor.conf.js rename to spring-boot-angular/src/main/js/ecommerce/e2e/protractor.conf.js diff --git a/spring-boot-angular-ecommerce/src/main/frontend/e2e/src/app.e2e-spec.ts b/spring-boot-angular/src/main/js/ecommerce/e2e/src/app.e2e-spec.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/e2e/src/app.e2e-spec.ts rename to spring-boot-angular/src/main/js/ecommerce/e2e/src/app.e2e-spec.ts diff --git a/spring-boot-angular/angularclient/e2e/app.po.ts b/spring-boot-angular/src/main/js/ecommerce/e2e/src/app.po.ts similarity index 100% rename from spring-boot-angular/angularclient/e2e/app.po.ts rename to spring-boot-angular/src/main/js/ecommerce/e2e/src/app.po.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/e2e/tsconfig.e2e.json b/spring-boot-angular/src/main/js/ecommerce/e2e/tsconfig.e2e.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/e2e/tsconfig.e2e.json rename to spring-boot-angular/src/main/js/ecommerce/e2e/tsconfig.e2e.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/package-lock.json b/spring-boot-angular/src/main/js/ecommerce/package-lock.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/package-lock.json rename to spring-boot-angular/src/main/js/ecommerce/package-lock.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/package.json b/spring-boot-angular/src/main/js/ecommerce/package.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/package.json rename to spring-boot-angular/src/main/js/ecommerce/package.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/proxy-conf.json b/spring-boot-angular/src/main/js/ecommerce/proxy-conf.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/proxy-conf.json rename to spring-boot-angular/src/main/js/ecommerce/proxy-conf.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/app.component.css b/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.css similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/app.component.css rename to spring-boot-angular/src/main/js/ecommerce/src/app/app.component.css diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/app.component.html b/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.html similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/app.component.html rename to spring-boot-angular/src/main/js/ecommerce/src/app/app.component.html diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/app.component.spec.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.spec.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/app.component.spec.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/app.component.spec.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/app.component.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/app.component.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/app.component.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/app.component.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/app.module.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/app.module.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/app.module.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/app.module.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/ecommerce.component.css b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.css similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/ecommerce.component.css rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.css diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/ecommerce.component.html b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.html similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/ecommerce.component.html rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.html diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/ecommerce.component.spec.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.spec.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/ecommerce.component.spec.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.spec.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/ecommerce.component.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/ecommerce.component.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/ecommerce.component.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/models/product-order.model.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-order.model.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/models/product-order.model.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-order.model.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/models/product-orders.model.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-orders.model.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/models/product-orders.model.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product-orders.model.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/models/product.model.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product.model.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/models/product.model.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/models/product.model.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/orders/orders.component.css b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.css similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/orders/orders.component.css rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.css diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/orders/orders.component.html b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.html similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/orders/orders.component.html rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.html diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/orders/orders.component.spec.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.spec.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/orders/orders.component.spec.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.spec.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/orders/orders.component.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/orders/orders.component.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/orders/orders.component.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/products/products.component.css b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.css similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/products/products.component.css rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.css diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/products/products.component.html b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.html similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/products/products.component.html rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.html diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/products/products.component.spec.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.spec.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/products/products.component.spec.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.spec.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/products/products.component.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/products/products.component.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/products/products.component.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/services/EcommerceService.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/services/EcommerceService.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/services/EcommerceService.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/services/EcommerceService.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/shopping-cart/shopping-cart.component.css b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.css similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/shopping-cart/shopping-cart.component.css rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.css diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/shopping-cart/shopping-cart.component.html b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.html similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/shopping-cart/shopping-cart.component.html rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.html diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/shopping-cart/shopping-cart.component.spec.ts b/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-ecommerce/src/main/frontend/src/app/ecommerce/shopping-cart/shopping-cart.component.spec.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.spec.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/shopping-cart/shopping-cart.component.ts b/spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/app/ecommerce/shopping-cart/shopping-cart.component.ts rename to spring-boot-angular/src/main/js/ecommerce/src/app/ecommerce/shopping-cart/shopping-cart.component.ts diff --git a/spring-boot-angular/angularclient/src/assets/.gitkeep b/spring-boot-angular/src/main/js/ecommerce/src/assets/.gitkeep similarity index 100% rename from spring-boot-angular/angularclient/src/assets/.gitkeep rename to spring-boot-angular/src/main/js/ecommerce/src/assets/.gitkeep diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/browserslist b/spring-boot-angular/src/main/js/ecommerce/src/browserslist similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/browserslist rename to spring-boot-angular/src/main/js/ecommerce/src/browserslist diff --git a/spring-boot-angular/angularclient/src/environments/environment.prod.ts b/spring-boot-angular/src/main/js/ecommerce/src/environments/environment.prod.ts similarity index 100% rename from spring-boot-angular/angularclient/src/environments/environment.prod.ts rename to spring-boot-angular/src/main/js/ecommerce/src/environments/environment.prod.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/environments/environment.ts b/spring-boot-angular/src/main/js/ecommerce/src/environments/environment.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/environments/environment.ts rename to spring-boot-angular/src/main/js/ecommerce/src/environments/environment.ts diff --git a/spring-boot-angular/angularclient/src/favicon.ico b/spring-boot-angular/src/main/js/ecommerce/src/favicon.ico similarity index 100% rename from spring-boot-angular/angularclient/src/favicon.ico rename to spring-boot-angular/src/main/js/ecommerce/src/favicon.ico diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/index.html b/spring-boot-angular/src/main/js/ecommerce/src/index.html similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/index.html rename to spring-boot-angular/src/main/js/ecommerce/src/index.html diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/karma.conf.js b/spring-boot-angular/src/main/js/ecommerce/src/karma.conf.js similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/karma.conf.js rename to spring-boot-angular/src/main/js/ecommerce/src/karma.conf.js diff --git a/spring-boot-angular/angularclient/src/main.ts b/spring-boot-angular/src/main/js/ecommerce/src/main.ts similarity index 100% rename from spring-boot-angular/angularclient/src/main.ts rename to spring-boot-angular/src/main/js/ecommerce/src/main.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/polyfills.ts b/spring-boot-angular/src/main/js/ecommerce/src/polyfills.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/polyfills.ts rename to spring-boot-angular/src/main/js/ecommerce/src/polyfills.ts diff --git a/spring-boot-angular/angularclient/src/styles.css b/spring-boot-angular/src/main/js/ecommerce/src/styles.css similarity index 100% rename from spring-boot-angular/angularclient/src/styles.css rename to spring-boot-angular/src/main/js/ecommerce/src/styles.css diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/test.ts b/spring-boot-angular/src/main/js/ecommerce/src/test.ts similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/test.ts rename to spring-boot-angular/src/main/js/ecommerce/src/test.ts diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/tsconfig.app.json b/spring-boot-angular/src/main/js/ecommerce/src/tsconfig.app.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/tsconfig.app.json rename to spring-boot-angular/src/main/js/ecommerce/src/tsconfig.app.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/tsconfig.spec.json b/spring-boot-angular/src/main/js/ecommerce/src/tsconfig.spec.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/tsconfig.spec.json rename to spring-boot-angular/src/main/js/ecommerce/src/tsconfig.spec.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/src/tslint.json b/spring-boot-angular/src/main/js/ecommerce/src/tslint.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/src/tslint.json rename to spring-boot-angular/src/main/js/ecommerce/src/tslint.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/tsconfig.json b/spring-boot-angular/src/main/js/ecommerce/tsconfig.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/tsconfig.json rename to spring-boot-angular/src/main/js/ecommerce/tsconfig.json diff --git a/spring-boot-angular-ecommerce/src/main/frontend/tslint.json b/spring-boot-angular/src/main/js/ecommerce/tslint.json similarity index 100% rename from spring-boot-angular-ecommerce/src/main/frontend/tslint.json rename to spring-boot-angular/src/main/js/ecommerce/tslint.json diff --git a/spring-boot-angular-ecommerce/src/main/resources/application.properties b/spring-boot-angular/src/main/resources/application.properties similarity index 100% rename from spring-boot-angular-ecommerce/src/main/resources/application.properties rename to spring-boot-angular/src/main/resources/application.properties diff --git a/spring-boot-angular-ecommerce/src/main/resources/logback.xml b/spring-boot-angular/src/main/resources/logback.xml similarity index 100% rename from spring-boot-angular-ecommerce/src/main/resources/logback.xml rename to spring-boot-angular/src/main/resources/logback.xml diff --git a/spring-boot-angular-ecommerce/src/test/java/com/baeldung/ecommerce/EcommerceApplicationIntegrationTest.java b/spring-boot-angular/src/test/java/com/baeldung/ecommerce/EcommerceApplicationIntegrationTest.java similarity index 100% rename from spring-boot-angular-ecommerce/src/test/java/com/baeldung/ecommerce/EcommerceApplicationIntegrationTest.java rename to spring-boot-angular/src/test/java/com/baeldung/ecommerce/EcommerceApplicationIntegrationTest.java diff --git a/spring-boot-angular-ecommerce/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-boot-angular/src/test/java/org/baeldung/SpringContextIntegrationTest.java similarity index 100% rename from spring-boot-angular-ecommerce/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-boot-angular/src/test/java/org/baeldung/SpringContextIntegrationTest.java diff --git a/spring-boot-angular-ecommerce/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-angular-ecommerce/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-boot-autoconfiguration/README.md b/spring-boot-autoconfiguration/README.md index 920c378139..67311eed50 100644 --- a/spring-boot-autoconfiguration/README.md +++ b/spring-boot-autoconfiguration/README.md @@ -7,5 +7,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration) +- [Create a Custom Auto-Configuration with Spring Boot](https://www.baeldung.com/spring-boot-custom-auto-configuration) - [Guide to ApplicationContextRunner in Spring Boot](https://www.baeldung.com/spring-boot-context-runner) diff --git a/spring-boot-bootstrap/README.md b/spring-boot-bootstrap/README.md index 82ec384c86..5fb8fd4a84 100644 --- a/spring-boot-bootstrap/README.md +++ b/spring-boot-bootstrap/README.md @@ -3,9 +3,10 @@ This module contains articles about bootstrapping Spring Boot applications. ### Relevant Articles: -- [Spring Boot Tutorial – Bootstrap a Simple Application](http://www.baeldung.com/spring-boot-start) -- [Thin JARs with Spring Boot](http://www.baeldung.com/spring-boot-thin-jar) +- [Spring Boot Tutorial – Bootstrap a Simple Application](https://www.baeldung.com/spring-boot-start) +- [Thin JARs with Spring Boot](https://www.baeldung.com/spring-boot-thin-jar) - [Deploying a Spring Boot Application to Cloud Foundry](https://www.baeldung.com/spring-boot-app-deploy-to-cloud-foundry) - [Deploy a Spring Boot Application to Google App Engine](https://www.baeldung.com/spring-boot-google-app-engine) - [Deploy a Spring Boot Application to OpenShift](https://www.baeldung.com/spring-boot-deploy-openshift) - [Deploy a Spring Boot Application to AWS Beanstalk](https://www.baeldung.com/spring-boot-deploy-aws-beanstalk) +- [Guide to @SpringBootConfiguration in Spring Boot](https://www.baeldung.com/springbootconfiguration-annotation) diff --git a/spring-boot-camel/README.md b/spring-boot-camel/README.md index 194b7ea9c7..f9594a95a6 100644 --- a/spring-boot-camel/README.md +++ b/spring-boot-camel/README.md @@ -24,4 +24,4 @@ or return code of 201 and the response: `{"id": 10,"name": "Hello, World"}` - if ## Relevant articles: -- [Apache Camel with Spring Boot](http://www.baeldung.com/apache-camel-spring-boot) +- [Apache Camel with Spring Boot](https://www.baeldung.com/apache-camel-spring-boot) diff --git a/spring-boot-cli/README.md b/spring-boot-cli/README.md index 8c8a0c99c1..79e259c855 100644 --- a/spring-boot-cli/README.md +++ b/spring-boot-cli/README.md @@ -3,4 +3,4 @@ This module contains articles about Spring Boot CLI ### Relevant Articles: -- [Introduction to Spring Boot CLI](http://www.baeldung.com/spring-boot-cli) +- [Introduction to Spring Boot CLI](https://www.baeldung.com/spring-boot-cli) diff --git a/spring-boot-client/README.MD b/spring-boot-client/README.MD index c8b9e1cd6e..b5a4c78446 100644 --- a/spring-boot-client/README.MD +++ b/spring-boot-client/README.MD @@ -7,5 +7,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Quick Guide to @RestClientTest in Spring Boot](http://www.baeldung.com/restclienttest-in-spring-boot) -- [A Java Client for a WebSockets API](http://www.baeldung.com/websockets-api-java-spring-client) \ No newline at end of file +- [Quick Guide to @RestClientTest in Spring Boot](https://www.baeldung.com/restclienttest-in-spring-boot) +- [A Java Client for a WebSockets API](https://www.baeldung.com/websockets-api-java-spring-client) diff --git a/spring-boot-ctx-fluent/README.md b/spring-boot-ctx-fluent/README.md index 646ad0f7d1..2d7ba7f2c0 100644 --- a/spring-boot-ctx-fluent/README.md +++ b/spring-boot-ctx-fluent/README.md @@ -4,4 +4,4 @@ This module contains articles about Spring Boot Fluent Builder ### Relevant Articles: -- [Context Hierarchy with the Spring Boot Fluent Builder API](http://www.baeldung.com/spring-boot-context-hierarchy) +- [Context Hierarchy with the Spring Boot Fluent Builder API](https://www.baeldung.com/spring-boot-context-hierarchy) diff --git a/spring-boot-custom-starter/README.md b/spring-boot-custom-starter/README.md index f983441ca0..c22aab7a2b 100644 --- a/spring-boot-custom-starter/README.md +++ b/spring-boot-custom-starter/README.md @@ -1,5 +1,9 @@ +## Spring Boot Custom Starter + +This module contains articles about writing Spring Boot [starters](https://www.baeldung.com/spring-boot-starters). + ### Relevant Articles: -- [Creating a Custom Starter with Spring Boot](http://www.baeldung.com/spring-boot-custom-starter) +- [Creating a Custom Starter with Spring Boot](https://www.baeldung.com/spring-boot-custom-starter) - **greeter-library**: The sample library that we're creating the starter for. @@ -9,4 +13,4 @@ - **greeter-spring-boot-sample-app**: The sample project that uses the custom starter. -- [Multi-Module Project With Spring Boot](http://www.baeldung.com/spring-boot-multiple-modules) +- [Multi-Module Project With Spring Boot](https://www.baeldung.com/spring-boot-multiple-modules) diff --git a/spring-boot-data/README.md b/spring-boot-data/README.md index 6f0b8c8123..513c5fed18 100644 --- a/spring-boot-data/README.md +++ b/spring-boot-data/README.md @@ -1,3 +1,7 @@ +## Spring Boot Data + +This module contains articles about Spring Boot with Spring Data + ## Relevant Articles: - [Formatting JSON Dates in Spring Boot](https://www.baeldung.com/spring-boot-formatting-json-dates) diff --git a/spring-boot-di/README.MD b/spring-boot-di/README.MD index 78cd163668..6e2c495b88 100644 --- a/spring-boot-di/README.MD +++ b/spring-boot-di/README.MD @@ -1,3 +1,7 @@ +## Spring Boot Dependency Inject + +This module contains articles about dependency injection with Spring Boot + ### The Course The "REST With Spring" Classes: http://bit.ly/restwithspring diff --git a/spring-boot-di/pom.xml b/spring-boot-di/pom.xml index c0faf44335..31ccff03da 100644 --- a/spring-boot-di/pom.xml +++ b/spring-boot-di/pom.xml @@ -36,6 +36,11 @@ tomcat-embed-jasper provided + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/Animal.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/Animal.java index 73bd0e3673..7ec076abc7 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/Animal.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/Animal.java @@ -7,4 +7,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) -public @interface Animal { } +public @interface Animal { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/ComponentScanAnnotationFilterApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/ComponentScanAnnotationFilterApp.java index 7e89870d4b..7849e4e10a 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/ComponentScanAnnotationFilterApp.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/ComponentScanAnnotationFilterApp.java @@ -1,21 +1,13 @@ package com.baeldung.componentscan.filter.annotation; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; -import java.util.Arrays; - @Configuration @ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Animal.class)) public class ComponentScanAnnotationFilterApp { - private static ApplicationContext applicationContext; public static void main(String[] args) { - applicationContext = new AnnotationConfigApplicationContext(ComponentScanAnnotationFilterApp.class); - Arrays.stream(applicationContext.getBeanDefinitionNames()) - .forEach(System.out::println); } } diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/Elephant.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/Elephant.java index 8ad8111d6b..758775a737 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/Elephant.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/annotation/Elephant.java @@ -1,4 +1,5 @@ package com.baeldung.componentscan.filter.annotation; @Animal -public class Elephant { } +public class Elephant { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Cat.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Cat.java index b34a2d7112..ababe4fea9 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Cat.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Cat.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.aspectj; -public class Cat { } +public class Cat { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/ComponentScanAspectJFilterApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/ComponentScanAspectJFilterApp.java new file mode 100644 index 0000000000..aea7c0a2cd --- /dev/null +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/ComponentScanAspectJFilterApp.java @@ -0,0 +1,15 @@ +package com.baeldung.componentscan.filter.aspectj; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; + +@Configuration +@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ASPECTJ, +pattern = "com.baeldung.componentscan.filter.aspectj.* " + + "&& !(com.baeldung.componentscan.filter.aspectj.L* " + + "|| com.baeldung.componentscan.filter.aspectj.C*)")) +public class ComponentScanAspectJFilterApp { + public static void main(String[] args) { + } +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/ComponentScanCustomFilterApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/ComponentScanCustomFilterApp.java deleted file mode 100644 index 3674c09531..0000000000 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/ComponentScanCustomFilterApp.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.componentscan.filter.aspectj; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.FilterType; - -import java.util.Arrays; - -@Configuration -@ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ASPECTJ, - pattern = "com.baeldung.componentscan.filter.aspectj.* " - + "&& !(com.baeldung.componentscan.filter.aspectj.L* " - + "|| com.baeldung.componentscan.filter.aspectj.E*)")) -public class ComponentScanCustomFilterApp { - private static ApplicationContext applicationContext; - - public static void main(String[] args) { - applicationContext = new AnnotationConfigApplicationContext(ComponentScanCustomFilterApp.class); - Arrays.stream(applicationContext.getBeanDefinitionNames()) - .forEach(System.out::println); - } -} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Elephant.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Elephant.java index 30abc9dcd4..ade1b5903c 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Elephant.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Elephant.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.aspectj; -public class Elephant { } +public class Elephant { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Loin.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Loin.java index cf442e981e..6bfdfeb321 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Loin.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/aspectj/Loin.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.aspectj; -public class Loin { } +public class Loin { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Animal.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Animal.java index 77cf2e72f0..faf4121834 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Animal.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Animal.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.assignable; -public interface Animal { } +public interface Animal { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Cat.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Cat.java index 262ae154f8..568ac8045f 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Cat.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Cat.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.assignable; -public class Cat implements Animal { } +public class Cat implements Animal { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/ComponentScanAssignableTypeFilterApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/ComponentScanAssignableTypeFilterApp.java index a5fa2b0942..b0155a882b 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/ComponentScanAssignableTypeFilterApp.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/ComponentScanAssignableTypeFilterApp.java @@ -1,21 +1,13 @@ package com.baeldung.componentscan.filter.assignable; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; -import java.util.Arrays; - @Configuration @ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = Animal.class)) public class ComponentScanAssignableTypeFilterApp { - private static ApplicationContext applicationContext; public static void main(String[] args) { - applicationContext = new AnnotationConfigApplicationContext(ComponentScanAssignableTypeFilterApp.class); - Arrays.stream(applicationContext.getBeanDefinitionNames()) - .forEach(System.out::println); } } diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Elephant.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Elephant.java index 815e0d762a..74637c86ba 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Elephant.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/assignable/Elephant.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.assignable; -public class Elephant implements Animal { } +public class Elephant implements Animal { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Cat.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Cat.java index 282d6bb641..17a8e87b7a 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Cat.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Cat.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.custom; -public class Cat extends Pet { } +public class Cat extends Pet { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilter.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilter.java index ebaccf7838..30ccb19276 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilter.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilter.java @@ -10,11 +10,11 @@ import java.io.IOException; public class ComponentScanCustomFilter implements TypeFilter { @Override - public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) - throws IOException { + public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { ClassMetadata classMetadata = metadataReader.getClassMetadata(); String superClass = classMetadata.getSuperClassName(); - if (Pet.class.getName().equalsIgnoreCase(superClass)) { + if (Pet.class.getName() + .equalsIgnoreCase(superClass)) { return true; } return false; diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilterApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilterApp.java index 1a4f5dbf4e..3a87b6a807 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilterApp.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilterApp.java @@ -1,21 +1,13 @@ package com.baeldung.componentscan.filter.custom; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; -import java.util.Arrays; - @Configuration @ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.CUSTOM, classes = ComponentScanCustomFilter.class)) public class ComponentScanCustomFilterApp { - private static ApplicationContext applicationContext; public static void main(String[] args) { - applicationContext = new AnnotationConfigApplicationContext(ComponentScanCustomFilterApp.class); - Arrays.stream(applicationContext.getBeanDefinitionNames()) - .forEach(System.out::println); } } diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Loin.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Loin.java index 0e2f9e0692..5deb4af9f3 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Loin.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Loin.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.custom; -public class Loin { } +public class Loin { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Pet.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Pet.java index 9b4497221d..c9be5a39c2 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Pet.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/custom/Pet.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.custom; -public class Pet { } +public class Pet { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Cat.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Cat.java index 87341cae9d..4569f91787 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Cat.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Cat.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.regex; -public class Cat { } +public class Cat { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/ComponentScanRegexFilterApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/ComponentScanRegexFilterApp.java index 36e94446b2..d2b7bd03fb 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/ComponentScanRegexFilterApp.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/ComponentScanRegexFilterApp.java @@ -1,20 +1,13 @@ package com.baeldung.componentscan.filter.regex; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; -import java.util.Arrays; - @Configuration @ComponentScan(includeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*[t]")) public class ComponentScanRegexFilterApp { - private static ApplicationContext applicationContext; public static void main(String[] args) { - applicationContext = new AnnotationConfigApplicationContext(ComponentScanRegexFilterApp.class); - Arrays.stream(applicationContext.getBeanDefinitionNames()).forEach(System.out::println); } } diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Elephant.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Elephant.java index 314dca5b77..4910be41ad 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Elephant.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Elephant.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.regex; -public class Elephant { } +public class Elephant { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Loin.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Loin.java index 1b75fc1b43..5b7949be38 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Loin.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/filter/regex/Loin.java @@ -1,3 +1,4 @@ package com.baeldung.componentscan.filter.regex; -public class Loin { } +public class Loin { +} diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java index 83b91f7860..8873f1214c 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java @@ -10,10 +10,10 @@ import org.springframework.context.annotation.Configuration; @Configuration @ComponentScan -//@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = Rose.class)) -//@ComponentScan(basePackages = "com.baeldung.componentscan.springapp") -//@ComponentScan(basePackages = "com.baeldung.componentscan.springapp.animals") -//@ComponentScan (excludeFilters = @ComponentScan.Filter(type=FilterType.REGEX,pattern="com\\.baeldung\\.componentscan\\.springapp\\.flowers\\..*")) +// @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = Rose.class)) +// @ComponentScan(basePackages = "com.baeldung.componentscan.springapp") +// @ComponentScan(basePackages = "com.baeldung.componentscan.springapp.animals") +// @ComponentScan (excludeFilters = @ComponentScan.Filter(type=FilterType.REGEX,pattern="com\\.baeldung\\.componentscan\\.springapp\\.flowers\\..*")) public class SpringComponentScanApp { private static ApplicationContext applicationContext; diff --git a/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java index 4362caefbb..c48f8c5e54 100644 --- a/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java @@ -8,9 +8,9 @@ import org.springframework.context.annotation.Bean; import com.baeldung.componentscan.ExampleBean; @SpringBootApplication -//@ComponentScan(basePackages = "com.baeldung.componentscan.springbootapp.animals") -//@ComponentScan ( excludeFilters = @ComponentScan.Filter(type=FilterType.REGEX,pattern="com\\.baeldung\\.componentscan\\.springbootapp\\.flowers\\..*")) -//@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = Rose.class)) +// @ComponentScan(basePackages = "com.baeldung.componentscan.springbootapp.animals") +// @ComponentScan ( excludeFilters = @ComponentScan.Filter(type=FilterType.REGEX,pattern="com\\.baeldung\\.componentscan\\.springbootapp\\.flowers\\..*")) +// @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = Rose.class)) public class SpringBootComponentScanApp { private static ApplicationContext applicationContext; diff --git a/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/annotation/ComponentScanAnnotationFilterAppIntegrationTest.java b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/annotation/ComponentScanAnnotationFilterAppIntegrationTest.java new file mode 100644 index 0000000000..9eb0b67c21 --- /dev/null +++ b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/annotation/ComponentScanAnnotationFilterAppIntegrationTest.java @@ -0,0 +1,30 @@ +package com.baeldung.componentscan.filter.annotation; + +import static org.junit.Assert.assertThat; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.test.context.junit4.SpringRunner; +import static org.hamcrest.CoreMatchers.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ComponentScanAnnotationFilterApp.class) +public class ComponentScanAnnotationFilterAppIntegrationTest { + + @Test + public void whenAnnotationFilterIsUsed_thenComponentScanShouldRegisterBeanAnnotatedWithAnimalAnootation() { + ApplicationContext applicationContext = new AnnotationConfigApplicationContext(ComponentScanAnnotationFilterApp.class); + List beans = Arrays.stream(applicationContext.getBeanDefinitionNames()) + .filter(bean -> !bean.contains("org.springframework") && !bean.contains("componentScanAnnotationFilterApp")) + .collect(Collectors.toList()); + assertThat(beans.size(), equalTo(1)); + assertThat(beans.get(0), equalTo("elephant")); + } +} diff --git a/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/aspectj/ComponentScanAspectJFilterAppIntegrationTest.java b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/aspectj/ComponentScanAspectJFilterAppIntegrationTest.java new file mode 100644 index 0000000000..945a0085f6 --- /dev/null +++ b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/aspectj/ComponentScanAspectJFilterAppIntegrationTest.java @@ -0,0 +1,30 @@ +package com.baeldung.componentscan.filter.aspectj; + +import static org.junit.Assert.assertThat; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.test.context.junit4.SpringRunner; +import static org.hamcrest.CoreMatchers.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ComponentScanAspectJFilterApp.class) +public class ComponentScanAspectJFilterAppIntegrationTest { + + @Test + public void whenAspectJFilterIsUsed_thenComponentScanShouldRegisterBeanMatchingAspectJCreteria() { + ApplicationContext applicationContext = new AnnotationConfigApplicationContext(ComponentScanAspectJFilterApp.class); + List beans = Arrays.stream(applicationContext.getBeanDefinitionNames()) + .filter(bean -> !bean.contains("org.springframework") && !bean.contains("componentScanAspectJFilterApp")) + .collect(Collectors.toList()); + assertThat(beans.size(), equalTo(1)); + assertThat(beans.get(0), equalTo("elephant")); + } +} diff --git a/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/assignable/ComponentScanAssignableTypeFilterAppIntegrationTest.java b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/assignable/ComponentScanAssignableTypeFilterAppIntegrationTest.java new file mode 100644 index 0000000000..3e5c7ee4f7 --- /dev/null +++ b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/assignable/ComponentScanAssignableTypeFilterAppIntegrationTest.java @@ -0,0 +1,31 @@ +package com.baeldung.componentscan.filter.assignable; + +import static org.junit.Assert.assertThat; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.test.context.junit4.SpringRunner; +import static org.hamcrest.CoreMatchers.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ComponentScanAssignableTypeFilterApp.class) +public class ComponentScanAssignableTypeFilterAppIntegrationTest { + + @Test + public void whenAssignableTypeFilterIsUsed_thenComponentScanShouldRegisterBeanOfAssignableTypeAndItsSubClass() { + ApplicationContext applicationContext = new AnnotationConfigApplicationContext(ComponentScanAssignableTypeFilterApp.class); + List beans = Arrays.stream(applicationContext.getBeanDefinitionNames()) + .filter(bean -> !bean.contains("org.springframework") && !bean.contains("componentScanAssignableTypeFilterApp")) + .collect(Collectors.toList()); + assertThat(beans.size(), equalTo(2)); + assertThat(beans.contains("cat"), equalTo(true)); + assertThat(beans.contains("elephant"), equalTo(true)); + } +} diff --git a/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilterAppIntegrationTest.java b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilterAppIntegrationTest.java new file mode 100644 index 0000000000..097214a2cf --- /dev/null +++ b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/custom/ComponentScanCustomFilterAppIntegrationTest.java @@ -0,0 +1,30 @@ +package com.baeldung.componentscan.filter.custom; + +import static org.junit.Assert.assertThat; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.test.context.junit4.SpringRunner; +import static org.hamcrest.CoreMatchers.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ComponentScanCustomFilterApp.class) +public class ComponentScanCustomFilterAppIntegrationTest { + + @Test + public void whenCustomFilterIsUsed_thenComponentScanShouldRegisterBeanMatchingCustomFilter() { + ApplicationContext applicationContext = new AnnotationConfigApplicationContext(ComponentScanCustomFilterApp.class); + List beans = Arrays.stream(applicationContext.getBeanDefinitionNames()) + .filter(bean -> !bean.contains("org.springframework") && !bean.contains("componentScanCustomFilterApp")) + .collect(Collectors.toList()); + assertThat(beans.size(), equalTo(1)); + assertThat(beans.get(0), equalTo("cat")); + } +} diff --git a/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/regex/ComponentScanRegexFilterAppIntegrationTest.java b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/regex/ComponentScanRegexFilterAppIntegrationTest.java new file mode 100644 index 0000000000..3163581c37 --- /dev/null +++ b/spring-boot-di/src/test/java/com/baeldung/componentscan/filter/regex/ComponentScanRegexFilterAppIntegrationTest.java @@ -0,0 +1,31 @@ +package com.baeldung.componentscan.filter.regex; + +import static org.junit.Assert.assertThat; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.test.context.junit4.SpringRunner; +import static org.hamcrest.CoreMatchers.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ComponentScanRegexFilterApp.class) +public class ComponentScanRegexFilterAppIntegrationTest { + + @Test + public void whenRegexFilterIsUsed_thenComponentScanShouldRegisterBeanMatchingRegex() { + ApplicationContext applicationContext = new AnnotationConfigApplicationContext(ComponentScanRegexFilterApp.class); + List beans = Arrays.stream(applicationContext.getBeanDefinitionNames()) + .filter(bean -> !bean.contains("org.springframework") && !bean.contains("componentScanRegexFilterApp")) + .collect(Collectors.toList()); + assertThat(beans.size(), equalTo(2)); + assertThat(beans.contains("cat"), equalTo(true)); + assertThat(beans.contains("elephant"), equalTo(true)); + } +} diff --git a/spring-boot-disable-console-logging/README.md b/spring-boot-disable-console-logging/README.md index 3d75fddc8e..7f1c06042f 100644 --- a/spring-boot-disable-console-logging/README.md +++ b/spring-boot-disable-console-logging/README.md @@ -1,2 +1,6 @@ +## Spring Boot Disable Console Logging + +This module contains articles about disabling Spring Boot console logging. + ### Relevant Articles: - [How to Disable Console Logging in Spring Boot](https://www.baeldung.com/spring-boot-disable-console-logging) diff --git a/spring-boot-flowable/README.md b/spring-boot-flowable/README.md index 8fb90d953b..1a8fb28a5e 100644 --- a/spring-boot-flowable/README.md +++ b/spring-boot-flowable/README.md @@ -1,3 +1,7 @@ +## Spring Boot Flowable + +This module contains articles about Flowable in Boot applications + ### Relevant articles -- [Introduction to Flowable](http://www.baeldung.com/flowable) +- [Introduction to Flowable](https://www.baeldung.com/flowable) diff --git a/spring-boot-gradle/README.md b/spring-boot-gradle/README.md index 76b82dce02..859c5d8199 100644 --- a/spring-boot-gradle/README.md +++ b/spring-boot-gradle/README.md @@ -1,4 +1,8 @@ +## Spring Boot Gradle + +This module contains articles about Gradle in Spring Boot projects. + ### Relevant Articles: -- [Spring Boot: Configuring a Main Class](http://www.baeldung.com/spring-boot-main-class) -- [Thin JARs with Spring Boot](http://www.baeldung.com/spring-boot-thin-jar) +- [Spring Boot: Configuring a Main Class](https://www.baeldung.com/spring-boot-main-class) +- [Thin JARs with Spring Boot](https://www.baeldung.com/spring-boot-thin-jar) diff --git a/spring-boot-jasypt/README.md b/spring-boot-jasypt/README.md index 5df2a4a6e5..c76339119a 100644 --- a/spring-boot-jasypt/README.md +++ b/spring-boot-jasypt/README.md @@ -1,4 +1,7 @@ +## Spring Boot Jasypt + +This module contains articles about Jasypt in Spring Boot projects. ### Relevant Articles: -- [Spring Boot Configuration with Jasypt](http://www.baeldung.com/spring-boot-jasypt) +- [Spring Boot Configuration with Jasypt](https://www.baeldung.com/spring-boot-jasypt) diff --git a/spring-boot-keycloak/README.md b/spring-boot-keycloak/README.md index cfe82c6cf7..2dfe3fc331 100644 --- a/spring-boot-keycloak/README.md +++ b/spring-boot-keycloak/README.md @@ -1,2 +1,6 @@ +## Spring Boot Keycloak + +This module contains articles about Keycloak in Spring Boot projects. + ## Relevant articles: -- [A Quick Guide to Using Keycloak with Spring Boot](http://www.baeldung.com/spring-boot-keycloak) +- [A Quick Guide to Using Keycloak with Spring Boot](https://www.baeldung.com/spring-boot-keycloak) diff --git a/spring-boot-kotlin/README.md b/spring-boot-kotlin/README.md index dc50c24aa0..d393805ed1 100644 --- a/spring-boot-kotlin/README.md +++ b/spring-boot-kotlin/README.md @@ -1,2 +1,6 @@ +## Spring Boot Kotlin + +This module contains articles about Kotlin in Spring Boot projects. + ### Relevant Articles: -- [Non-blocking Spring Boot with Kotlin Coroutines](http://www.baeldung.com/non-blocking-spring-boot-with-kotlin-coroutines) +- [Non-blocking Spring Boot with Kotlin Coroutines](https://www.baeldung.com/non-blocking-spring-boot-with-kotlin-coroutines) diff --git a/spring-boot-libraries/README.MD b/spring-boot-libraries/README.md similarity index 74% rename from spring-boot-libraries/README.MD rename to spring-boot-libraries/README.md index f3706e0fa4..f0bc3c9e89 100644 --- a/spring-boot-libraries/README.MD +++ b/spring-boot-libraries/README.md @@ -1,3 +1,7 @@ +## Spring Boot Libraries + +This module contains articles about various Spring Boot libraries + ### The Course The "REST With Spring" Classes: http://bit.ly/restwithspring diff --git a/spring-boot-logging-log4j2/README.md b/spring-boot-logging-log4j2/README.md index ea968d7fae..76029caef8 100644 --- a/spring-boot-logging-log4j2/README.md +++ b/spring-boot-logging-log4j2/README.md @@ -1,4 +1,8 @@ +## Spring Boot Logging with Log4j 2 + +This module contains articles about logging in Spring Boot projects with Log4j 2. + ### Relevant Articles: -- [Logging in Spring Boot](http://www.baeldung.com/spring-boot-logging) +- [Logging in Spring Boot](https://www.baeldung.com/spring-boot-logging) - [Logging to Graylog with Spring Boot](https://www.baeldung.com/graylog-with-spring-boot) diff --git a/spring-boot-management/README.md b/spring-boot-management/README.md new file mode 100644 index 0000000000..53d4c439ff --- /dev/null +++ b/spring-boot-management/README.md @@ -0,0 +1,7 @@ +## Spring Boot Logging HTTP Requests + +This module contains articles about the management of Spring Boot applications. + +### Relevant Articles: +- [Logging HTTP Requests with Spring Boot Actuator HTTP Tracing](https://www.baeldung.com/spring-boot-actuator-http) + diff --git a/spring-boot-mvc-2/README.md b/spring-boot-mvc-2/README.md index f8e26f218b..0ff0f1f156 100644 --- a/spring-boot-mvc-2/README.md +++ b/spring-boot-mvc-2/README.md @@ -1,3 +1,8 @@ +## Spring Boot MVC + +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) +- More articles: [[prev -->]](/spring-boot-mvc) diff --git a/spring-boot-mvc-birt/README.md b/spring-boot-mvc-birt/README.md index 9fe3d94e2a..2c3804c745 100644 --- a/spring-boot-mvc-birt/README.md +++ b/spring-boot-mvc-birt/README.md @@ -1,3 +1,7 @@ +## Spring Boot MVC BIRT + +This module contains articles about BIRT Reporting in Spring Boot MVC projects. + ### Relevant Articles - [BIRT Reporting with Spring Boot](https://www.baeldung.com/birt-reports-spring-boot) diff --git a/spring-boot-mvc/README.md b/spring-boot-mvc/README.md index e3e3dbdb74..a83ea3ee25 100644 --- a/spring-boot-mvc/README.md +++ b/spring-boot-mvc/README.md @@ -1,16 +1,21 @@ +## Spring Boot MVC + +This module contains articles about Spring Web MVC in Spring Boot projects. + ### Relevant Articles: -- [Guide to the Favicon in Spring Boot](http://www.baeldung.com/spring-boot-favicon) +- [Guide to the Favicon in Spring Boot](https://www.baeldung.com/spring-boot-favicon) - [Custom Validation MessageSource in Spring Boot](https://www.baeldung.com/spring-custom-validation-message-source) -- [Spring Boot Annotations](http://www.baeldung.com/spring-boot-annotations) -- [Spring Scheduling Annotations](http://www.baeldung.com/spring-scheduling-annotations) -- [Spring Web Annotations](http://www.baeldung.com/spring-mvc-annotations) -- [Spring Core Annotations](http://www.baeldung.com/spring-core-annotations) -- [Display RSS Feed with Spring MVC](http://www.baeldung.com/spring-mvc-rss-feed) +- [Spring Boot Annotations](https://www.baeldung.com/spring-boot-annotations) +- [Spring Scheduling Annotations](https://www.baeldung.com/spring-scheduling-annotations) +- [Spring Web Annotations](https://www.baeldung.com/spring-mvc-annotations) +- [Spring Core Annotations](https://www.baeldung.com/spring-core-annotations) +- [Display RSS Feed with Spring MVC](https://www.baeldung.com/spring-mvc-rss-feed) - [A Controller, Service and DAO Example with Spring Boot and JSF](https://www.baeldung.com/jsf-spring-boot-controller-service-dao) - [Cache Eviction in Spring Boot](https://www.baeldung.com/spring-boot-evict-cache) -- [Setting Up Swagger 2 with a Spring REST API](http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) +- [Setting Up Swagger 2 with a Spring REST API](https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) - [Conditionally Enable Scheduled Jobs in Spring](https://www.baeldung.com/spring-scheduled-enabled-conditionally) - [Accessing Spring MVC Model Objects in JavaScript](https://www.baeldung.com/spring-mvc-model-objects-js) -- [Using Spring ResponseEntity to Manipulate the HTTP Response](http://www.baeldung.com/spring-response-entity) -- [Spring Bean Annotations](http://www.baeldung.com/spring-bean-annotations) +- [Using Spring ResponseEntity to Manipulate the HTTP Response](https://www.baeldung.com/spring-response-entity) +- [Spring Bean Annotations](https://www.baeldung.com/spring-bean-annotations) +- More articles: [[next -->]](/spring-boot-mvc-2) diff --git a/spring-boot-nashorn/README.md b/spring-boot-nashorn/README.md index 1ca43927ee..f24adfe8e8 100644 --- a/spring-boot-nashorn/README.md +++ b/spring-boot-nashorn/README.md @@ -1,3 +1,8 @@ -### Relevant Articles: -- []() +## Spring Boot Nashorn + +This module contains articles about Spring Boot with Nashorn + +### Relevant Articles: + +- [Isomorphic Application with React and Nashorn](https://www.baeldung.com/react-nashorn-isomorphic-app) diff --git a/spring-boot-ops-2/README.MD b/spring-boot-ops-2/README.md similarity index 61% rename from spring-boot-ops-2/README.MD rename to spring-boot-ops-2/README.md index b4218dc395..0925b099b1 100644 --- a/spring-boot-ops-2/README.MD +++ b/spring-boot-ops-2/README.md @@ -1,4 +1,9 @@ +## Spring Boot Operations + +This module contains articles about Spring Boot Operations + ### Relevant Articles - [How to Configure Spring Boot Tomcat](https://www.baeldung.com/spring-boot-configure-tomcat) - [Spring Boot Embedded Tomcat Logs](https://www.baeldung.com/spring-boot-embedded-tomcat-logs) +- More articles: [[<-- prev]](/spring-boot-ops) diff --git a/spring-boot-ops-2/src/main/java/com/baeldung/gracefulshutdown/GracefulShutdownApplication.java b/spring-boot-ops-2/src/main/java/com/baeldung/gracefulshutdown/GracefulShutdownApplication.java new file mode 100644 index 0000000000..dd0d0f920c --- /dev/null +++ b/spring-boot-ops-2/src/main/java/com/baeldung/gracefulshutdown/GracefulShutdownApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.gracefulshutdown; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class GracefulShutdownApplication { + + public static void main(String args[]) { + SpringApplication.run(GracefulShutdownApplication.class, args); + } +} diff --git a/spring-boot-ops-2/src/main/java/com/baeldung/gracefulshutdown/beans/LongRunningProcessBean.java b/spring-boot-ops-2/src/main/java/com/baeldung/gracefulshutdown/beans/LongRunningProcessBean.java new file mode 100644 index 0000000000..e21ddfe021 --- /dev/null +++ b/spring-boot-ops-2/src/main/java/com/baeldung/gracefulshutdown/beans/LongRunningProcessBean.java @@ -0,0 +1,36 @@ +package com.baeldung.gracefulshutdown.beans; + +import javax.annotation.PostConstruct; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.task.TaskExecutor; +import org.springframework.stereotype.Component; + +@Component +public class LongRunningProcessBean { + + private static final Logger LOG = LoggerFactory.getLogger(LongRunningProcessBean.class); + + @Autowired + private TaskExecutor taskExecutor; + + @PostConstruct + public void runTaskOnStartup() { + LOG.info("runTaskOnStartup entering"); + for (int i = 0; i < 3; i++) { + final int processNumber = i; + taskExecutor.execute(() -> { + try { + LOG.info("Long running process {} using threadpool started", processNumber); + Thread.sleep(60_000); + LOG.info("Long running process {} using threadpool completed", processNumber); + } catch (Exception e) { + LOG.error("Error while executing task", e); + } + }); + } + LOG.info("runTaskOnStartup exiting"); + } +} diff --git a/spring-boot-ops-2/src/main/java/com/baeldung/gracefulshutdown/config/SpringConfiguration.java b/spring-boot-ops-2/src/main/java/com/baeldung/gracefulshutdown/config/SpringConfiguration.java new file mode 100644 index 0000000000..b458f16206 --- /dev/null +++ b/spring-boot-ops-2/src/main/java/com/baeldung/gracefulshutdown/config/SpringConfiguration.java @@ -0,0 +1,32 @@ +package com.baeldung.gracefulshutdown.config; + +import javax.annotation.PreDestroy; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.task.TaskExecutor; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +@Configuration +public class SpringConfiguration { + + private static final Logger LOG = LoggerFactory.getLogger(SpringConfiguration.class); + + @Bean + public TaskExecutor taskExecutor() { + ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); + taskExecutor.setCorePoolSize(2); + taskExecutor.setMaxPoolSize(2); + taskExecutor.setWaitForTasksToCompleteOnShutdown(true); + taskExecutor.setAwaitTerminationSeconds(30); + taskExecutor.initialize(); + return taskExecutor; + } + + @PreDestroy + public void destroy() { + LOG.info("Shutdown initiated"); + } +} diff --git a/spring-boot-ops/README.md b/spring-boot-ops/README.md index 5be5c974d3..2720bc5ae2 100644 --- a/spring-boot-ops/README.md +++ b/spring-boot-ops/README.md @@ -1,14 +1,20 @@ +## Spring Boot Operations + +This module contains articles about Spring Boot Operations + ### Relevant Articles: - - [Deploy a Spring Boot WAR into a Tomcat Server](http://www.baeldung.com/spring-boot-war-tomcat-deploy) - - [Spring Boot Dependency Management with a Custom Parent](http://www.baeldung.com/spring-boot-dependency-management-custom-parent) - - [A Custom Data Binder in Spring MVC](http://www.baeldung.com/spring-mvc-custom-data-binder) - - [Create a Fat Jar App with Spring Boot](http://www.baeldung.com/deployable-fat-jar-spring-boot) - - [Introduction to WebJars](http://www.baeldung.com/maven-webjars) - - [Intro to Spring Boot Starters](http://www.baeldung.com/spring-boot-starters) - - [A Quick Guide to Maven Wrapper](http://www.baeldung.com/maven-wrapper) - - [Shutdown a Spring Boot Application](http://www.baeldung.com/spring-boot-shutdown) - - [Spring Boot Console Application](http://www.baeldung.com/spring-boot-console-app) - - [Comparing Embedded Servlet Containers in Spring Boot](http://www.baeldung.com/spring-boot-servlet-containers) + - [Deploy a Spring Boot WAR into a Tomcat Server](https://www.baeldung.com/spring-boot-war-tomcat-deploy) + - [Spring Boot Dependency Management with a Custom Parent](https://www.baeldung.com/spring-boot-dependency-management-custom-parent) + - [A Custom Data Binder in Spring MVC](https://www.baeldung.com/spring-mvc-custom-data-binder) + - [Create a Fat Jar App with Spring Boot](https://www.baeldung.com/deployable-fat-jar-spring-boot) + - [Introduction to WebJars](https://www.baeldung.com/maven-webjars) + - [Intro to Spring Boot Starters](https://www.baeldung.com/spring-boot-starters) + - [A Quick Guide to Maven Wrapper](https://www.baeldung.com/maven-wrapper) + - [Shutdown a Spring Boot Application](https://www.baeldung.com/spring-boot-shutdown) + - [Spring Boot Console Application](https://www.baeldung.com/spring-boot-console-app) + - [Comparing Embedded Servlet Containers in Spring Boot](https://www.baeldung.com/spring-boot-servlet-containers) - [Programmatically Restarting a Spring Boot Application](https://www.baeldung.com/java-restart-spring-boot-app) - [Spring Properties File Outside jar](https://www.baeldung.com/spring-properties-file-outside-jar) - [EnvironmentPostProcessor in Spring Boot](https://www.baeldung.com/spring-boot-environmentpostprocessor) + - [Running a Spring Boot App with Maven vs an Executable War/Jar](https://www.baeldung.com/spring-boot-run-maven-vs-executable-jar) + - More articles: [[next -->]](/spring-boot-ops-2) diff --git a/spring-boot-parent/README.md b/spring-boot-parent/README.md index c3bb4c700d..b48a286d62 100644 --- a/spring-boot-parent/README.md +++ b/spring-boot-parent/README.md @@ -1,3 +1,7 @@ +## Spring Boot Parent + +This module contains articles about Spring Boot Starter Parent + ### Relevant Articles - [The Spring Boot Starter Parent](https://www.baeldung.com/spring-boot-starter-parent) diff --git a/spring-boot-properties/README.md b/spring-boot-properties/README.md index 9aea5b4871..48ff79537c 100644 --- a/spring-boot-properties/README.md +++ b/spring-boot-properties/README.md @@ -1,10 +1,10 @@ ### Relevant Articles: - [Reloading Properties Files in Spring](https://www.baeldung.com/spring-reloading-properties) -- [Guide to @ConfigurationProperties in Spring Boot](http://www.baeldung.com/configuration-properties-in-spring-boot) +- [Guide to @ConfigurationProperties in Spring Boot](https://www.baeldung.com/configuration-properties-in-spring-boot) - [Load Spring Boot Properties From a JSON File](https://www.baeldung.com/spring-boot-json-properties) - [Guide to @EnableConfigurationProperties](https://www.baeldung.com/spring-enable-config-properties) -- [Properties with Spring and Spring Boot](http://www.baeldung.com/properties-with-spring) - checkout the `com.baeldung.properties` package for all scenarios of properties injection and usage -- [A Quick Guide to Spring @Value](http://www.baeldung.com/spring-value-annotation) -- [Spring YAML Configuration](http://www.baeldung.com/spring-yaml) -- [Using Spring @Value with Defaults](http://www.baeldung.com/spring-value-defaults) -- [How to Inject a Property Value Into a Class Not Managed by Spring?](http://www.baeldung.com/inject-properties-value-non-spring-class) +- [Properties with Spring and Spring Boot](https://www.baeldung.com/properties-with-spring) - checkout the `com.baeldung.properties` package for all scenarios of properties injection and usage +- [A Quick Guide to Spring @Value](https://www.baeldung.com/spring-value-annotation) +- [Spring YAML Configuration](https://www.baeldung.com/spring-yaml) +- [Using Spring @Value with Defaults](https://www.baeldung.com/spring-value-defaults) +- [How to Inject a Property Value Into a Class Not Managed by Spring?](https://www.baeldung.com/inject-properties-value-non-spring-class) diff --git a/spring-boot-properties/extra.properties b/spring-boot-properties/extra.properties index 51874a0415..8e28a6f889 100644 --- a/spring-boot-properties/extra.properties +++ b/spring-boot-properties/extra.properties @@ -1 +1 @@ -application.theme.color=red \ No newline at end of file +application.theme.color=blue \ No newline at end of file diff --git a/spring-boot-property-exp/README.md b/spring-boot-property-exp/README.md index 70cf6bdfac..23af5995e2 100644 --- a/spring-boot-property-exp/README.md +++ b/spring-boot-property-exp/README.md @@ -1,18 +1,27 @@ -## The Module Holds Sources for the Following Articles - - [Automatic Property Expansion with Spring Boot](http://www.baeldung.com/spring-boot-auto-property-expansion) +## Spring Boot Property Expansion + +This module contains articles about Spring Boot Property Expansion + +### Relevant Articles + + - [Automatic Property Expansion with Spring Boot](https://www.baeldung.com/spring-boot-auto-property-expansion) -### Module property-exp-default-config - This module contains both a standard Maven Spring Boot build and the Gradle build which is Maven compatible. +## SubModules - In order to execute the Maven example, run the following command: +### property-exp-default-config + +This module contains both a standard Maven Spring Boot build and the Gradle build which is Maven compatible. - `mvn spring-boot:run` +In order to execute the Maven example, run the following command: - To execute the Gradle example: +`mvn spring-boot:run` + +To execute the Gradle example: `gradle bootRun` - ### Module property-exp-custom-config - This project is not using the standard Spring Boot parent and is configured manually. Run the following command: +### property-exp-custom-config - `mvn exec:java` +This project is not using the standard Spring Boot parent and is configured manually. Run the following command: + +`mvn exec:java` diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index 6f365bd465..ffac9335fd 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -1,19 +1,27 @@ -Module for the articles that are part of the Spring REST E-book: +## Spring Boot REST -1. [Bootstrap a Web Application with Spring 5](https://www.baeldung.com/bootstraping-a-web-application-with-spring-and-java-based-configuration) -2. [Build a REST API with Spring and Java Config](http://www.baeldung.com/building-a-restful-web-service-with-spring-and-java-based-configuration) -3. [Http Message Converters with the Spring Framework](http://www.baeldung.com/spring-httpmessageconverter-rest) -4. [Spring’s RequestBody and ResponseBody Annotations](https://www.baeldung.com/spring-request-response-body) -5. [Entity To DTO Conversion for a Spring REST API](https://www.baeldung.com/entity-to-and-from-dto-for-a-java-spring-application) -6. [Error Handling for REST with Spring](http://www.baeldung.com/exception-handling-for-rest-with-spring) -7. [REST API Discoverability and HATEOAS](http://www.baeldung.com/restful-web-service-discoverability) -8. [An Intro to Spring HATEOAS](http://www.baeldung.com/spring-hateoas-tutorial) -9. [REST Pagination in Spring](http://www.baeldung.com/rest-api-pagination-in-spring) -10. [Test a REST API with Java](http://www.baeldung.com/integration-testing-a-rest-api) +This module contains articles about Spring Boot RESTful APIs. -- [HATEOAS for a Spring REST Service](http://www.baeldung.com/rest-api-discoverability-with-spring) -- [Versioning a REST API](http://www.baeldung.com/rest-versioning) -- [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) -- [Testing REST with multiple MIME types](http://www.baeldung.com/testing-rest-api-with-multiple-media-types) +### Relevant Articles + +- [HATEOAS for a Spring REST Service](https://www.baeldung.com/rest-api-discoverability-with-spring) +- [Versioning a REST API](https://www.baeldung.com/rest-versioning) +- [ETags for REST with Spring](https://www.baeldung.com/etags-for-rest-with-spring) +- [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) + +### E-book + +These articles are part of the Spring REST E-book: + +1. [Bootstrap a Web Application with Spring 5](https://www.baeldung.com/bootstraping-a-web-application-with-spring-and-java-based-configuration) +2. [Build a REST API with Spring and Java Config](https://www.baeldung.com/building-a-restful-web-service-with-spring-and-java-based-configuration) +3. [Http Message Converters with the Spring Framework](https://www.baeldung.com/spring-httpmessageconverter-rest) +4. [Spring’s RequestBody and ResponseBody Annotations](https://www.baeldung.com/spring-request-response-body) +5. [Entity To DTO Conversion for a Spring REST API](https://www.baeldung.com/entity-to-and-from-dto-for-a-java-spring-application) +6. [Error Handling for REST with Spring](https://www.baeldung.com/exception-handling-for-rest-with-spring) +7. [REST API Discoverability and HATEOAS](https://www.baeldung.com/restful-web-service-discoverability) +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) diff --git a/spring-boot-security/README.md b/spring-boot-security/README.md index 30a3218672..be4690f321 100644 --- a/spring-boot-security/README.md +++ b/spring-boot-security/README.md @@ -1,3 +1,13 @@ +## Spring Boot Security + +This module contains articles about Spring Boot Security + +### Relevant Articles: + +- [Spring Boot Security Auto-Configuration](https://www.baeldung.com/spring-boot-security-autoconfiguration) +- [Spring Security for Spring Boot Integration Tests](https://www.baeldung.com/spring-security-integration-tests) +- [Introduction to Spring Security Taglibs](https://www.baeldung.com/spring-security-taglibs) + ### Spring Boot Security Auto-Configuration - mvn clean install @@ -5,9 +15,5 @@ - uncomment security properties for easy testing. If not random will be generated. ### CURL commands -- curl -X POST -u baeldung-admin:baeldung -d grant_type=client_credentials -d username=baeldung-admin -d password=baeldung http://localhost:8080/oauth/token -### Relevant Articles: -- [Spring Boot Security Auto-Configuration](http://www.baeldung.com/spring-boot-security-autoconfiguration) -- [Spring Security for Spring Boot Integration Tests](https://www.baeldung.com/spring-security-integration-tests) -- [Introduction to Spring Security Taglibs](https://www.baeldung.com/spring-security-taglibs) +- curl -X POST -u baeldung-admin:baeldung -d grant_type=client_credentials -d username=baeldung-admin -d password=baeldung http://localhost:8080/oauth/token diff --git a/spring-boot-testing/README.MD b/spring-boot-testing/README.md similarity index 86% rename from spring-boot-testing/README.MD rename to spring-boot-testing/README.md index 7a4c4f53a1..0b2533e6bc 100644 --- a/spring-boot-testing/README.MD +++ b/spring-boot-testing/README.md @@ -1,4 +1,9 @@ +## Spring Boot Testing + +This module contains articles about Spring Boot testing + ### The Course + The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: diff --git a/spring-boot-vue/README.md b/spring-boot-vue/README.md index e68f961e51..de473c0d36 100644 --- a/spring-boot-vue/README.md +++ b/spring-boot-vue/README.md @@ -1,2 +1,6 @@ +## Spring Boot Vue + +This module contains articles about Spring Boot with Vue.js + ### Relevant Articles: -- [Vue.js Frontend with a Spring Boot Backend](http://www.baeldung.com/spring-boot-vue-js) +- [Vue.js Frontend with a Spring Boot Backend](https://www.baeldung.com/spring-boot-vue-js) diff --git a/spring-boot/README.MD b/spring-boot/README.MD index 04d76e438e..2423d6d331 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -1,32 +1,36 @@ +## Spring Boot + +This module contains articles about Spring Boot + ### The Course The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [A Guide to Spring in Eclipse STS](http://www.baeldung.com/eclipse-sts-spring) -- [The @ServletComponentScan Annotation in Spring Boot](http://www.baeldung.com/spring-servletcomponentscan) -- [How to Register a Servlet in Java](http://www.baeldung.com/register-servlet) -- [Guide to Spring WebUtils and ServletRequestUtils](http://www.baeldung.com/spring-webutils-servletrequestutils) -- [Using Custom Banners in Spring Boot](http://www.baeldung.com/spring-boot-custom-banners) -- [Guide to Internationalization in Spring Boot](http://www.baeldung.com/spring-boot-internationalization) -- [Create a Custom FailureAnalyzer with Spring Boot](http://www.baeldung.com/spring-boot-failure-analyzer) -- [Dynamic DTO Validation Config Retrieved from the Database](http://www.baeldung.com/spring-dynamic-dto-validation) -- [Custom Information in Spring Boot Info Endpoint](http://www.baeldung.com/spring-boot-info-actuator-custom) -- [Using @JsonComponent in Spring Boot](http://www.baeldung.com/spring-boot-jsoncomponent) -- [Testing in Spring Boot](http://www.baeldung.com/spring-boot-testing) -- [How to Get All Spring-Managed Beans?](http://www.baeldung.com/spring-show-all-beans) -- [Spring Boot and Togglz Aspect](http://www.baeldung.com/spring-togglz) -- [Getting Started with GraphQL and Spring Boot](http://www.baeldung.com/spring-graphql) -- [Guide to Spring Type Conversions](http://www.baeldung.com/spring-type-conversions) -- [An Introduction to Kong](http://www.baeldung.com/kong) -- [Spring Boot: Customize Whitelabel Error Page](http://www.baeldung.com/spring-boot-custom-error-page) -- [Spring Boot: Configuring a Main Class](http://www.baeldung.com/spring-boot-main-class) -- [A Quick Intro to the SpringBootServletInitializer](http://www.baeldung.com/spring-boot-servlet-initializer) -- [How to Define a Spring Boot Filter?](http://www.baeldung.com/spring-boot-add-filter) -- [Spring Boot Exit Codes](http://www.baeldung.com/spring-boot-exit-codes) -- [Guide to the Favicon in Spring Boot](http://www.baeldung.com/spring-boot-favicon) -- [Spring Shutdown Callbacks](http://www.baeldung.com/spring-shutdown-callbacks) -- [Container Configuration in Spring Boot 2](http://www.baeldung.com/embeddedservletcontainercustomizer-configurableembeddedservletcontainer-spring-boot) +- [A Guide to Spring in Eclipse STS](https://www.baeldung.com/eclipse-sts-spring) +- [The @ServletComponentScan Annotation in Spring Boot](https://www.baeldung.com/spring-servletcomponentscan) +- [How to Register a Servlet in Java](https://www.baeldung.com/register-servlet) +- [Guide to Spring WebUtils and ServletRequestUtils](https://www.baeldung.com/spring-webutils-servletrequestutils) +- [Using Custom Banners in Spring Boot](https://www.baeldung.com/spring-boot-custom-banners) +- [Guide to Internationalization in Spring Boot](https://www.baeldung.com/spring-boot-internationalization) +- [Create a Custom FailureAnalyzer with Spring Boot](https://www.baeldung.com/spring-boot-failure-analyzer) +- [Dynamic DTO Validation Config Retrieved from the Database](https://www.baeldung.com/spring-dynamic-dto-validation) +- [Custom Information in Spring Boot Info Endpoint](https://www.baeldung.com/spring-boot-info-actuator-custom) +- [Using @JsonComponent in Spring Boot](https://www.baeldung.com/spring-boot-jsoncomponent) +- [Testing in Spring Boot](https://www.baeldung.com/spring-boot-testing) +- [How to Get All Spring-Managed Beans?](https://www.baeldung.com/spring-show-all-beans) +- [Spring Boot and Togglz Aspect](https://www.baeldung.com/spring-togglz) +- [Getting Started with GraphQL and Spring Boot](https://www.baeldung.com/spring-graphql) +- [Guide to Spring Type Conversions](https://www.baeldung.com/spring-type-conversions) +- [An Introduction to Kong](https://www.baeldung.com/kong) +- [Spring Boot: Customize Whitelabel Error Page](https://www.baeldung.com/spring-boot-custom-error-page) +- [Spring Boot: Configuring a Main Class](https://www.baeldung.com/spring-boot-main-class) +- [A Quick Intro to the SpringBootServletInitializer](https://www.baeldung.com/spring-boot-servlet-initializer) +- [How to Define a Spring Boot Filter?](https://www.baeldung.com/spring-boot-add-filter) +- [Spring Boot Exit Codes](https://www.baeldung.com/spring-boot-exit-codes) +- [Guide to the Favicon in Spring Boot](https://www.baeldung.com/spring-boot-favicon) +- [Spring Shutdown Callbacks](https://www.baeldung.com/spring-shutdown-callbacks) +- [Container Configuration in Spring Boot 2](https://www.baeldung.com/embeddedservletcontainercustomizer-configurableembeddedservletcontainer-spring-boot) - [Introduction to Chaos Monkey](https://www.baeldung.com/spring-boot-chaos-monkey) - [Display Auto-Configuration Report in Spring Boot](https://www.baeldung.com/spring-boot-auto-configuration-report) - [Injecting Git Information Into Spring](https://www.baeldung.com/spring-git-information) diff --git a/spring-cloud-bus/README.md b/spring-cloud-bus/README.md index c5410ca4e2..dbbb8d7156 100644 --- a/spring-cloud-bus/README.md +++ b/spring-cloud-bus/README.md @@ -1,3 +1,7 @@ +## Spring Cloud Bus + +This module contains articles about Spring Cloud Bus + ### Relevant articles -- [Spring Cloud Bus](http://www.baeldung.com/spring-cloud-bus) +- [Spring Cloud Bus](https://www.baeldung.com/spring-cloud-bus) diff --git a/spring-cloud-cli/README.md b/spring-cloud-cli/README.md index 7f29be3f07..46b47e0e08 100644 --- a/spring-cloud-cli/README.md +++ b/spring-cloud-cli/README.md @@ -1,6 +1,6 @@ -========= - ## Spring Cloud CLI +This module contains articles about Spring Cloud CLI + ### Relevant Articles: -- [Introduction to Spring Cloud CLI](http://www.baeldung.com/spring-cloud-cli) +- [Introduction to Spring Cloud CLI](https://www.baeldung.com/spring-cloud-cli) diff --git a/spring-cloud-data-flow/README.MD b/spring-cloud-data-flow/README.MD deleted file mode 100644 index f2ab96de2c..0000000000 --- a/spring-cloud-data-flow/README.MD +++ /dev/null @@ -1,2 +0,0 @@ - -This is an aggregator module for Spring Cloud Data Flow modules. diff --git a/spring-cloud-data-flow/README.md b/spring-cloud-data-flow/README.md new file mode 100644 index 0000000000..40e1db6840 --- /dev/null +++ b/spring-cloud-data-flow/README.md @@ -0,0 +1,4 @@ +## Spring Cloud Data Flow + +This module contains modules about Spring Cloud Data Flow + diff --git a/spring-cloud/README.md b/spring-cloud/README.md new file mode 100644 index 0000000000..2727aec08c --- /dev/null +++ b/spring-cloud/README.md @@ -0,0 +1,3 @@ +## Spring Cloud + +This module contains modules about Spring Cloud \ No newline at end of file diff --git a/spring-cloud/spring-cloud-archaius/README.md b/spring-cloud/spring-cloud-archaius/README.md index ae853c6ef0..3b5ed16373 100644 --- a/spring-cloud/spring-cloud-archaius/README.md +++ b/spring-cloud/spring-cloud-archaius/README.md @@ -1,10 +1,12 @@ +# Spring Cloud Archaius + +This module contains articles about Spring Cloud with Netflix Archaius + # Relevant Articles - [Introduction to Netflix Archaius with Spring Cloud](https://www.baeldung.com/netflix-archaius-spring-cloud-integration) - [Netflix Archaius with Various Database Configurations](https://www.baeldung.com/netflix-archaius-database-configurations) -# Spring Cloud Archaius - #### Basic Config This service has the basic, out-of-the-box Spring Cloud Netflix Archaius configuration. diff --git a/spring-cloud/spring-cloud-bootstrap/README.MD b/spring-cloud/spring-cloud-bootstrap/README.md similarity index 87% rename from spring-cloud/spring-cloud-bootstrap/README.MD rename to spring-cloud/spring-cloud-bootstrap/README.md index 7a3a94c8e3..01998ccf51 100644 --- a/spring-cloud/spring-cloud-bootstrap/README.MD +++ b/spring-cloud/spring-cloud-bootstrap/README.md @@ -1,3 +1,7 @@ +## Spring Cloud Bootstrap + +This module contains articles about bootstrapping Spring Cloud applications + ### Relevant Articles: - [Spring Cloud – Bootstrapping](http://www.baeldung.com/spring-cloud-bootstrapping) - [Spring Cloud – Securing Services](http://www.baeldung.com/spring-cloud-securing-services) @@ -5,6 +9,8 @@ - [Spring Cloud Series – The Gateway Pattern](http://www.baeldung.com/spring-cloud-gateway-pattern) - [Spring Cloud – Adding Angular 4](http://www.baeldung.com/spring-cloud-angular) +### Running the Project + - To run the project: - copy the appliction-config folder to c:\Users\{username}\ on Windows or /home/{username}/ on *nix. Then open a git bash terminal in application-config and run: - git init diff --git a/spring-cloud/spring-cloud-contract/README.md b/spring-cloud/spring-cloud-contract/README.md index 70e056757b..72a3627e30 100644 --- a/spring-cloud/spring-cloud-contract/README.md +++ b/spring-cloud/spring-cloud-contract/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Contract + +This module contains articles about Spring Cloud Contract + ### Relevant Articles: - [An Intro to Spring Cloud Contract](http://www.baeldung.com/spring-cloud-contract) diff --git a/spring-cloud/spring-cloud-gateway/README.MD b/spring-cloud/spring-cloud-gateway/README.md similarity index 57% rename from spring-cloud/spring-cloud-gateway/README.MD rename to spring-cloud/spring-cloud-gateway/README.md index d945ae949c..e87bc547e1 100644 --- a/spring-cloud/spring-cloud-gateway/README.MD +++ b/spring-cloud/spring-cloud-gateway/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Gateway + +This module contains articles about Spring Cloud Gateway + ### Relevant Articles: - [Exploring the new Spring Cloud Gateway](http://www.baeldung.com/spring-cloud-gateway) diff --git a/spring-cloud/spring-cloud-kubernetes/README.md b/spring-cloud/spring-cloud-kubernetes/README.md index 32bcbc59b8..b64ad65ef9 100644 --- a/spring-cloud/spring-cloud-kubernetes/README.md +++ b/spring-cloud/spring-cloud-kubernetes/README.md @@ -1,3 +1,7 @@ +## Spring Cloud Kubernetes + +This moudle contains articles about Spring Cloud Kubernetes + ### Relevant Articles: - [Running Spring Boot Applications With Minikube](https://www.baeldung.com/spring-boot-minikube) diff --git a/spring-cloud/spring-cloud-rest/README.md b/spring-cloud/spring-cloud-rest/README.md index a650004708..25d62007b6 100644 --- a/spring-cloud/spring-cloud-rest/README.md +++ b/spring-cloud/spring-cloud-rest/README.md @@ -1,2 +1,5 @@ +## Spring Cloud REST + +This module contains articles about RESTful APIs with Spring Cloud Code for an ebook - "A REST API with Spring Boot and Spring Cloud" diff --git a/spring-cloud/spring-cloud-ribbon-client/README.md b/spring-cloud/spring-cloud-ribbon-client/README.md index 596b3226c8..d22b8ec8f8 100644 --- a/spring-cloud/spring-cloud-ribbon-client/README.md +++ b/spring-cloud/spring-cloud-ribbon-client/README.md @@ -1,2 +1,6 @@ +## Spring Cloud Ribbon Client + +This module contains articles about Spring Cloud with Netflix Ribbon + ### Relevant Articles: - [Introduction to Spring Cloud Rest Client with Netflix Ribbon](http://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon) diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 113bbe9c83..910d27583f 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -1,6 +1,11 @@ +## Spring Core + +This module contains articles about core Spring functionality + ## Relevant Articles: - [Understanding getBean() in Spring](https://www.baeldung.com/spring-getbean) -- [Exploring the Spring BeanFactory API](http://www.baeldung.com/spring-beanfactory) -- [How to use the Spring FactoryBean?](http://www.baeldung.com/spring-factorybean) -- [Spring – Injecting Collections](http://www.baeldung.com/spring-injecting-collections) +- [Exploring the Spring BeanFactory API](https://www.baeldung.com/spring-beanfactory) +- [How to use the Spring FactoryBean?](https://www.baeldung.com/spring-factorybean) +- [Spring – Injecting Collections](https://www.baeldung.com/spring-injecting-collections) +- More articles: [[<-- prev]](/spring-core) diff --git a/spring-core/README.md b/spring-core/README.md index 3ff3f1ea41..6d274e89f0 100644 --- a/spring-core/README.md +++ b/spring-core/README.md @@ -1,12 +1,17 @@ +## Spring Core + +This module contains articles about core Spring functionality + ### Relevant Articles: -- [Wiring in Spring: @Autowired, @Resource and @Inject](http://www.baeldung.com/spring-annotations-resource-inject-autowire) -- [Constructor Injection in Spring with Lombok](http://www.baeldung.com/spring-injection-lombok) -- [Introduction to Spring’s StreamUtils](http://www.baeldung.com/spring-stream-utils) -- [XML-Based Injection in Spring](http://www.baeldung.com/spring-xml-injection) -- [A Quick Guide to the Spring @Lazy Annotation](http://www.baeldung.com/spring-lazy-annotation) -- [BeanNameAware and BeanFactoryAware Interfaces in Spring](http://www.baeldung.com/spring-bean-name-factory-aware) -- [Access a File from the Classpath in a Spring Application](http://www.baeldung.com/spring-classpath-file-access) +- [Wiring in Spring: @Autowired, @Resource and @Inject](https://www.baeldung.com/spring-annotations-resource-inject-autowire) +- [Constructor Injection in Spring with Lombok](httsp://www.baeldung.com/spring-injection-lombok) +- [Introduction to Spring’s StreamUtils](https://www.baeldung.com/spring-stream-utils) +- [XML-Based Injection in Spring](httsp://www.baeldung.com/spring-xml-injection) +- [A Quick Guide to the Spring @Lazy Annotation](https://www.baeldung.com/spring-lazy-annotation) +- [BeanNameAware and BeanFactoryAware Interfaces in Spring](https://www.baeldung.com/spring-bean-name-factory-aware) +- [Access a File from the Classpath in a Spring Application](https://www.baeldung.com/spring-classpath-file-access) - [Spring Application Context Events](https://www.baeldung.com/spring-context-events) - [What is a Spring Bean?](https://www.baeldung.com/spring-bean) - [Spring PostConstruct and PreDestroy Annotations](https://www.baeldung.com/spring-postconstruct-predestroy) +- More articles: [[next -->]](/spring-core-2) diff --git a/spring-cucumber/README.md b/spring-cucumber/README.md index 1e506f3a09..85bc1f65d5 100644 --- a/spring-cucumber/README.md +++ b/spring-cucumber/README.md @@ -1,2 +1,6 @@ +## Spring Cucumber + +This module contains articles about Spring testing with Cucumber + ### Relevant Articles: -- [Cucumber Spring Integration](http://www.baeldung.com/cucumber-spring-integration) +- [Cucumber Spring Integration](https://www.baeldung.com/cucumber-spring-integration) diff --git a/spring-data-rest-querydsl/README.md b/spring-data-rest-querydsl/README.md index 03b5fee06a..05ae03ab87 100644 --- a/spring-data-rest-querydsl/README.md +++ b/spring-data-rest-querydsl/README.md @@ -1,2 +1,6 @@ +## Spring Data REST Querydsl + +This module contains articles about Querydsl with Spring Data REST + ### Relevant Articles: -- [REST Query Language Over Multiple Tables with Querydsl Web Support](http://www.baeldung.com/rest-querydsl-multiple-tables) +- [REST Query Language Over Multiple Tables with Querydsl Web Support](https://www.baeldung.com/rest-querydsl-multiple-tables) diff --git a/spring-data-rest/README.md b/spring-data-rest/README.md index 4b89a24bbc..bae2fe8eaf 100644 --- a/spring-data-rest/README.md +++ b/spring-data-rest/README.md @@ -1,9 +1,21 @@ +## Spring Data REST + +This module contains articles about Spring Data REST + +### Relevant Articles: +- [Introduction to Spring Data REST](https://www.baeldung.com/spring-data-rest-intro) +- [Guide to Spring Data REST Validators](https://www.baeldung.com/spring-data-rest-validators) +- [Working with Relationships in Spring Data REST](https://www.baeldung.com/spring-data-rest-relationships) +- [AngularJS CRUD Application with Spring Data REST](https://www.baeldung.com/angularjs-crud-with-spring-data-rest) +- [Projections and Excerpts in Spring Data REST](https://www.baeldung.com/spring-data-rest-projections-excerpts) +- [Spring Data REST Events with @RepositoryEventHandler](https://www.baeldung.com/spring-data-rest-events) +- [Customizing HTTP Endpoints in Spring Data REST](https://www.baeldung.com/spring-data-rest-customize-http-endpoints) +- [Spring Boot with SQLite](https://www.baeldung.com/spring-boot-sqlite) +- [Spring Data Web Support](https://www.baeldung.com/spring-data-web-support) + ### The Course The "REST With Spring" Classes: http://bit.ly/restwithspring -# About this project -This project contains examples from the [Introduction to Spring Data REST](http://www.baeldung.com/spring-data-rest-intro) article from Baeldung. - # Running the project The application uses [Spring Boot](http://projects.spring.io/spring-boot/), so it is easy to run. You can start it any of a few ways: * Run the `main` method from `SpringDataRestApplication` @@ -12,13 +24,3 @@ The application uses [Spring Boot](http://projects.spring.io/spring-boot/), so i # Viewing the running application To view the running application, visit [http://localhost:8080](http://localhost:8080) in your browser - -### Relevant Articles: -- [Guide to Spring Data REST Validators](http://www.baeldung.com/spring-data-rest-validators) -- [Working with Relationships in Spring Data REST](http://www.baeldung.com/spring-data-rest-relationships) -- [AngularJS CRUD Application with Spring Data REST](http://www.baeldung.com/angularjs-crud-with-spring-data-rest) -- [Projections and Excerpts in Spring Data REST](http://www.baeldung.com/spring-data-rest-projections-excerpts) -- [Spring Data REST Events with @RepositoryEventHandler](http://www.baeldung.com/spring-data-rest-events) -- [Customizing HTTP Endpoints in Spring Data REST](https://www.baeldung.com/spring-data-rest-customize-http-endpoints) -- [Spring Boot with SQLite](https://www.baeldung.com/spring-boot-sqlite) -- [Spring Data Web Support](https://www.baeldung.com/spring-data-web-support) diff --git a/spring-di/README.md b/spring-di/README.md index 59651751ee..7571b12916 100644 --- a/spring-di/README.md +++ b/spring-di/README.md @@ -1,11 +1,15 @@ +## Spring Dependency Injection + +This module contains articles about dependency injection with Spring + ### Relevant Articles - [The Spring @Qualifier Annotation](https://www.baeldung.com/spring-qualifier-annotation) -- [Constructor Dependency Injection in Spring](http://www.baeldung.com/constructor-injection-in-spring) +- [Constructor Dependency Injection in Spring](https://www.baeldung.com/constructor-injection-in-spring) - [Spring Autowiring of Generic Types](https://www.baeldung.com/spring-autowire-generics) - [Guice vs Spring – Dependency Injection](https://www.baeldung.com/guice-spring-dependency-injection) -- [Injecting Prototype Beans into a Singleton Instance in Spring](http://www.baeldung.com/spring-inject-prototype-bean-into-singleton) -- [@Lookup Annotation in Spring](http://www.baeldung.com/spring-lookup) -- [Controlling Bean Creation Order with @DependsOn Annotation](http://www.baeldung.com/spring-depends-on) +- [Injecting Prototype Beans into a Singleton Instance in Spring](https://www.baeldung.com/spring-inject-prototype-bean-into-singleton) +- [@Lookup Annotation in Spring](https://www.baeldung.com/spring-lookup) +- [Controlling Bean Creation Order with @DependsOn Annotation](https://www.baeldung.com/spring-depends-on) - [Unsatisfied Dependency in Spring](https://www.baeldung.com/spring-unsatisfied-dependency) -- [Circular Dependencies in Spring](http://www.baeldung.com/circular-dependencies-in-spring) +- [Circular Dependencies in Spring](https://www.baeldung.com/circular-dependencies-in-spring) diff --git a/spring-dispatcher-servlet/README.md b/spring-dispatcher-servlet/README.md index a93993679f..3027546152 100644 --- a/spring-dispatcher-servlet/README.md +++ b/spring-dispatcher-servlet/README.md @@ -1,3 +1,7 @@ +## Spring DispatcherServlet + +This module contains articles about Spring DispatcherServlet + ## Relevant articles: -- [An Intro to the Spring DispatcherServlet](http://www.baeldung.com/spring-dispatcherservlet) +- [An Intro to the Spring DispatcherServlet](https://www.baeldung.com/spring-dispatcherservlet) diff --git a/spring-drools/README.md b/spring-drools/README.md index 00b35a4624..08ab4de465 100644 --- a/spring-drools/README.md +++ b/spring-drools/README.md @@ -1,3 +1,7 @@ +## Spring Drools + +This modules contains articles about Spring with Drools + ## Relevant articles: -- [Drools Spring Integration](http://www.baeldung.com/drools-spring-integration) +- [Drools Spring Integration](https://www.baeldung.com/drools-spring-integration) diff --git a/spring-ehcache/README.md b/spring-ehcache/README.md index ecf96cd7c7..da7376e476 100644 --- a/spring-ehcache/README.md +++ b/spring-ehcache/README.md @@ -1,7 +1,8 @@ -## Spring Ehcache Example Project +## Spring Ehcache -A simple example of using ehcache with spring-boot. +This module contains articles about Spring with Ehcache ### Relevant Articles: + - [Spring Boot Ehcache Example](https://www.baeldung.com/spring-boot-ehcache) diff --git a/spring-ejb/README.md b/spring-ejb/README.md index 58ccb20e70..6c63c2709f 100644 --- a/spring-ejb/README.md +++ b/spring-ejb/README.md @@ -1,9 +1,13 @@ +## Spring EJB + +This module contains articles about Spring with EJB + ### Relevant Articles -- [Guide to EJB Set-up](http://www.baeldung.com/ejb-intro) -- [Java EE Session Beans](http://www.baeldung.com/ejb-session-beans) -- [Introduction to EJB JNDI Lookup on WildFly Application Server](http://www.baeldung.com/wildfly-ejb-jndi) -- [A Guide to Message Driven Beans in EJB](http://www.baeldung.com/ejb-message-driven-beans) -- [Integration Guide for Spring and EJB](http://www.baeldung.com/spring-ejb) -- [Singleton Session Bean in Java EE](http://www.baeldung.com/java-ee-singleton-session-bean) +- [Guide to EJB Set-up](https://www.baeldung.com/ejb-intro) +- [Java EE Session Beans](https://www.baeldung.com/ejb-session-beans) +- [Introduction to EJB JNDI Lookup on WildFly Application Server](httpss://www.baeldung.com/wildfly-ejb-jndi) +- [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) diff --git a/spring-exceptions/README.md b/spring-exceptions/README.md index b9472c4cca..f8c7553f05 100644 --- a/spring-exceptions/README.md +++ b/spring-exceptions/README.md @@ -1,14 +1,11 @@ -========= +## Spring `Exception`s -## Spring Exceptions Example Project +This module contains articles about Spring `Exception`s -This project is used to replicate Spring Exceptions only. - - ### Relevant articles: -- [Spring BeanCreationException](http://www.baeldung.com/spring-beancreationexception) -- [Spring DataIntegrityViolationException](http://www.baeldung.com/spring-dataIntegrityviolationexception) -- [Spring BeanDefinitionStoreException](http://www.baeldung.com/spring-beandefinitionstoreexception) -- [Spring NoSuchBeanDefinitionException](http://www.baeldung.com/spring-nosuchbeandefinitionexception) -- [Guide to Spring NonTransientDataAccessException](http://www.baeldung.com/nontransientdataaccessexception) -- [Hibernate Mapping Exception – Unknown Entity](http://www.baeldung.com/hibernate-mappingexception-unknown-entity) +- [Spring BeanCreationException](https://www.baeldung.com/spring-beancreationexception) +- [Spring DataIntegrityViolationException](https://www.baeldung.com/spring-dataIntegrityviolationexception) +- [Spring BeanDefinitionStoreException](https://www.baeldung.com/spring-beandefinitionstoreexception) +- [Spring NoSuchBeanDefinitionException](https://www.baeldung.com/spring-nosuchbeandefinitionexception) +- [Guide to Spring NonTransientDataAccessException](https://www.baeldung.com/nontransientdataaccessexception) +- [Hibernate Mapping Exception – Unknown Entity](https://www.baeldung.com/hibernate-mappingexception-unknown-entity) diff --git a/spring-freemarker/README.md b/spring-freemarker/README.md index bd939d11e9..410781f2ca 100644 --- a/spring-freemarker/README.md +++ b/spring-freemarker/README.md @@ -1,7 +1,6 @@ -========= - -## Using FreeMarker in Spring MVC +## Spring FreeMarker +This module contains articles about Spring with FreeMarker ### Relevant Articles: -- [Introduction to Using FreeMarker in Spring MVC](http://www.baeldung.com/freemarker-in-spring-mvc-tutorial) +- [Introduction to Using FreeMarker in Spring MVC](https://www.baeldung.com/freemarker-in-spring-mvc-tutorial) diff --git a/spring-groovy/README.md b/spring-groovy/README.md index 36404230a9..c3bb5636ba 100644 --- a/spring-groovy/README.md +++ b/spring-groovy/README.md @@ -1,3 +1,7 @@ +## Spring Groovy + +This module contains articles about Spring with Groovy + ## Relevant Articles: - [Groovy Bean Definitions](https://www.baeldung.com/spring-groovy-beans) diff --git a/spring-integration/README.md b/spring-integration/README.md index 244cf1fb14..2e719a8674 100644 --- a/spring-integration/README.md +++ b/spring-integration/README.md @@ -1,6 +1,10 @@ +## Spring Integration + +This module contains articles about Spring Integration + ### Relevant Articles: -- [Introduction to Spring Integration](http://www.baeldung.com/spring-integration) -- [Security In Spring Integration](http://www.baeldung.com/spring-integration-security) +- [Introduction to Spring Integration](https://www.baeldung.com/spring-integration) +- [Security In Spring Integration](https://www.baeldung.com/spring-integration-security) - [Spring Integration Java DSL](https://www.baeldung.com/spring-integration-java-dsl) - [Using Subflows in Spring Integration](https://www.baeldung.com/spring-integration-subflows) diff --git a/spring-jenkins-pipeline/README.md b/spring-jenkins-pipeline/README.md index 8c10e85da2..9182823f52 100644 --- a/spring-jenkins-pipeline/README.md +++ b/spring-jenkins-pipeline/README.md @@ -1,5 +1,12 @@ -BASIC CRUD API with Spring Boot -================================ +## Spring Jenkins + +This module contains articles about Spring with Jenkins + +### Relevant articles + +- [Intro to Jenkins 2 and the Power of Pipelines](https://www.baeldung.com/jenkins-pipelines) + +## Basic CRUD API with Spring Boot This is the code of a simple API for some CRUD operations build using Spring Boot. @@ -20,7 +27,3 @@ $ mvn spring-boot:run -Dserver.port=8989 Now with default configurations it will be available at: [http://localhost:8080](http://localhost:8080) Enjoy it :) - -### Relevant articles - -- [Intro to Jenkins 2 and the Power of Pipelines](http://www.baeldung.com/jenkins-pipelines) diff --git a/spring-jersey/README.md b/spring-jersey/README.md index 37928620d3..3c6b0577c0 100644 --- a/spring-jersey/README.md +++ b/spring-jersey/README.md @@ -1,6 +1,8 @@ -========= +## Spring Jersey + +This module contains articles about Spring with Jersey ## REST API with Jersey & Spring Example Project -- [REST API with Jersey and Spring](http://www.baeldung.com/jersey-rest-api-with-spring) -- [JAX-RS Client with Jersey](http://www.baeldung.com/jersey-jax-rs-client) +- [REST API with Jersey and Spring](https://www.baeldung.com/jersey-rest-api-with-spring) +- [JAX-RS Client with Jersey](https://www.baeldung.com/jersey-jax-rs-client) - [Reactive JAX-RS Client API](https://www.baeldung.com/jax-rs-reactive-client) diff --git a/spring-jinq/README.md b/spring-jinq/README.md index 10d7903f49..e049dc2ba8 100644 --- a/spring-jinq/README.md +++ b/spring-jinq/README.md @@ -1,4 +1,8 @@ +## Spring Jinq + +This module contains articles about Spring with Jinq + ## Relevant articles: -- [Introduction to Jinq with Spring](http://www.baeldung.com/spring-jinq) +- [Introduction to Jinq with Spring](https://www.baeldung.com/spring-jinq) diff --git a/spring-jms/README.md b/spring-jms/README.md index 55e74f18ff..fdeb64953a 100644 --- a/spring-jms/README.md +++ b/spring-jms/README.md @@ -1,2 +1,6 @@ +## Spring JMS + +This module contains articles about Spring with JMS + ### Relevant Articles: -- [Getting Started with Spring JMS](http://www.baeldung.com/spring-jms) +- [Getting Started with Spring JMS](https://www.baeldung.com/spring-jms) diff --git a/spring-jooq/README.md b/spring-jooq/README.md index 2777aa450c..515ab8be3c 100644 --- a/spring-jooq/README.md +++ b/spring-jooq/README.md @@ -1,6 +1,10 @@ +## Spring jOOQ + +This module contains articles about Spring with jOOQ + ### Relevant Articles: -- [Spring Boot Support for jOOQ](http://www.baeldung.com/spring-boot-support-for-jooq) -- [Introduction to jOOQ with Spring](http://www.baeldung.com/jooq-with-spring) +- [Spring Boot Support for jOOQ](https://www.baeldung.com/spring-boot-support-for-jooq) +- [Introduction to jOOQ with Spring](https://www.baeldung.com/jooq-with-spring) In order to fix the error "Plugin execution not covered by lifecycle configuration: org.jooq:jooq-codegen-maven:3.7.3:generate (execution: default, phase: generate-sources)", right-click on the error message and choose "Mark goal generated as ignore in pom.xml". Until version 1.4.x, the maven-plugin-plugin was covered by the default lifecycle mapping that ships with m2e. diff --git a/spring-jooq/src/test/resources/application.properties b/spring-jooq/src/test/resources/application.properties index dc5d81acfb..ef37552bf0 100644 --- a/spring-jooq/src/test/resources/application.properties +++ b/spring-jooq/src/test/resources/application.properties @@ -1,2 +1,4 @@ -spring.datasource.url=jdbc:h2:tcp:~/jooq;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE +spring.datasource.url=jdbc:h2:~/jooq;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE +spring.datasource.username=sa +spring.datasource.password= spring.jpa.hibernate.ddl-auto=update diff --git a/spring-kafka/README.md b/spring-kafka/README.md index 291bbca6f6..f2fecde894 100644 --- a/spring-kafka/README.md +++ b/spring-kafka/README.md @@ -1,10 +1,12 @@ +## Spring Kafka + +This module contains articles about Spring with Kafka + ### Relevant articles -- [Intro to Apache Kafka with Spring](http://www.baeldung.com/spring-kafka) +- [Intro to Apache Kafka with Spring](https://www.baeldung.com/spring-kafka) - - -# Spring Kafka +### Intro This is a simple Spring Boot app to demonstrate sending and receiving of messages in Kafka using spring-kafka. diff --git a/spring-katharsis/README.md b/spring-katharsis/README.md index 2082de2dda..d7454e6841 100644 --- a/spring-katharsis/README.md +++ b/spring-katharsis/README.md @@ -1,9 +1,11 @@ -========= +## Spring Katharsis -## Java Web Application - -###The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring +This module contains articles about Spring with Katharsis ### Relevant Articles: -- [JSON API in a Spring Application](http://www.baeldung.com/json-api-java-spring-web-app) + +- [JSON API in a Spring Application](https://www.baeldung.com/json-api-java-spring-web-app) + +### The Course + +The "REST With Spring" Classes: http://bit.ly/restwithspring diff --git a/spring-ldap/README.md b/spring-ldap/README.md index b8163ab44d..4872f897e1 100644 --- a/spring-ldap/README.md +++ b/spring-ldap/README.md @@ -1,6 +1,8 @@ -## Spring LDAP Example Project +## Spring LDAP + +This module contains articles about Spring LDAP ### Relevant articles -- [Spring LDAP Overview](http://www.baeldung.com/spring-ldap) -- [Guide to Spring Data LDAP](http://www.baeldung.com/spring-data-ldap) +- [Spring LDAP Overview](https://www.baeldung.com/spring-ldap) +- [Guide to Spring Data LDAP](https://www.baeldung.com/spring-data-ldap) diff --git a/spring-mobile/README.md b/spring-mobile/README.md index e3d23bcda6..badd79d162 100644 --- a/spring-mobile/README.md +++ b/spring-mobile/README.md @@ -1,4 +1,8 @@ +## Spring Mobile + +This module contains articles about Spring Mobile + ## Relevant articles: -- [A Guide to Spring Mobile](http://www.baeldung.com/spring-mobile) +- [A Guide to Spring Mobile](https://www.baeldung.com/spring-mobile) diff --git a/spring-mockito/README.md b/spring-mockito/README.md index 969954c15e..0ad8e05ce3 100644 --- a/spring-mockito/README.md +++ b/spring-mockito/README.md @@ -1,8 +1,7 @@ -========= - -## Mockito Mocks into Spring Beans +## Spring Mockito +This module contains articles about Spring with Mockito ### Relevant Articles: -- [Injecting Mockito Mocks into Spring Beans](http://www.baeldung.com/injecting-mocks-in-spring) -- [Mockito ArgumentMatchers](http://www.baeldung.com/mockito-argument-matchers) +- [Injecting Mockito Mocks into Spring Beans](https://www.baeldung.com/injecting-mocks-in-spring) +- [Mockito ArgumentMatchers](https://www.baeldung.com/mockito-argument-matchers) diff --git a/spring-mvc-basics/README.md b/spring-mvc-basics/README.md index b257b3587b..a04c6e7ae7 100644 --- a/spring-mvc-basics/README.md +++ b/spring-mvc-basics/README.md @@ -7,12 +7,12 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Spring MVC Tutorial](https://www.baeldung.com/spring-mvc-tutorial) -- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller) -- [A Guide to the ViewResolver in Spring MVC](http://www.baeldung.com/spring-mvc-view-resolver-tutorial) -- [Guide to Spring Handler Mappings](http://www.baeldung.com/spring-handler-mappings) -- [Spring MVC Content Negotiation](http://www.baeldung.com/spring-mvc-content-negotiation-json-xml) -- [Spring @RequestMapping New Shortcut Annotations](http://www.baeldung.com/spring-new-requestmapping-shortcuts) -- [Spring MVC Custom Validation](http://www.baeldung.com/spring-mvc-custom-validator) -- [Using Spring @ResponseStatus to Set HTTP Status Code](http://www.baeldung.com/spring-response-status) -- [Spring MVC and the @ModelAttribute Annotation](http://www.baeldung.com/spring-mvc-and-the-modelattribute-annotation) -- [The HttpMediaTypeNotAcceptableException in Spring MVC](http://www.baeldung.com/spring-httpmediatypenotacceptable) \ No newline at end of file +- [The Spring @Controller and @RestController Annotations](https://www.baeldung.com/spring-controller-vs-restcontroller) +- [A Guide to the ViewResolver in Spring MVC](https://www.baeldung.com/spring-mvc-view-resolver-tutorial) +- [Guide to Spring Handler Mappings](https://www.baeldung.com/spring-handler-mappings) +- [Spring MVC Content Negotiation](https://www.baeldung.com/spring-mvc-content-negotiation-json-xml) +- [Spring @RequestMapping New Shortcut Annotations](https://www.baeldung.com/spring-new-requestmapping-shortcuts) +- [Spring MVC Custom Validation](https://www.baeldung.com/spring-mvc-custom-validator) +- [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) diff --git a/spring-mvc-forms-jsp/README.md b/spring-mvc-forms-jsp/README.md index 588828c9cf..2c077f5171 100644 --- a/spring-mvc-forms-jsp/README.md +++ b/spring-mvc-forms-jsp/README.md @@ -1,7 +1,9 @@ -## Spring MVC Forms Tutorials +## Spring MVC Forms JSP + +This module contains articles about Spring MVC Forms using JSP ### Relevant Articles -- [MaxUploadSizeExceededException in Spring](http://www.baeldung.com/spring-maxuploadsizeexceeded) -- [Getting Started with Forms in Spring MVC](http://www.baeldung.com/spring-mvc-form-tutorial) -- [Form Validation with AngularJS and Spring MVC](http://www.baeldung.com/validation-angularjs-spring-mvc) -- [A Guide to the JSTL Library](http://www.baeldung.com/jstl) +- [MaxUploadSizeExceededException in Spring](https://www.baeldung.com/spring-maxuploadsizeexceeded) +- [Getting Started with Forms in Spring MVC](https://www.baeldung.com/spring-mvc-form-tutorial) +- [Form Validation with AngularJS and Spring MVC](https://www.baeldung.com/validation-angularjs-spring-mvc) +- [A Guide to the JSTL Library](https://www.baeldung.com/jstl) diff --git a/spring-mvc-forms-thymeleaf/README.md b/spring-mvc-forms-thymeleaf/README.md index 22f12afbca..57fa32901c 100644 --- a/spring-mvc-forms-thymeleaf/README.md +++ b/spring-mvc-forms-thymeleaf/README.md @@ -1,5 +1,9 @@ +## Spring MVC Forms Thymeleaf + +This module contains articles about Spring MVC Forms using Thymeleaf + ### Relevant articles -- [Session Attributes in Spring MVC](http://www.baeldung.com/spring-mvc-session-attributes) -- [Binding a List in Thymeleaf](http://www.baeldung.com/thymeleaf-list) +- [Session Attributes in Spring MVC](https://www.baeldung.com/spring-mvc-session-attributes) +- [Binding a List in Thymeleaf](https://www.baeldung.com/thymeleaf-list) diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index e67d4f30a1..7088162496 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -1,21 +1,23 @@ -========= +## Spring MVC with Java Configuration -## Spring MVC with Java Configuration Example Project +This module contains articles about Spring MVC with Java configuration ### The Course + The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Introduction to Pointcut Expressions in Spring](http://www.baeldung.com/spring-aop-pointcut-tutorial) -- [Introduction to Advice Types in Spring](http://www.baeldung.com/spring-aop-advice-tutorial) -- [Integration Testing in Spring](http://www.baeldung.com/integration-testing-in-spring) -- [A Quick Guide to Spring MVC Matrix Variables](http://www.baeldung.com/spring-mvc-matrix-variables) -- [Intro to WebSockets with Spring](http://www.baeldung.com/websockets-spring) -- [File Upload with Spring MVC](http://www.baeldung.com/spring-file-upload) -- [Introduction to HtmlUnit](http://www.baeldung.com/htmlunit) -- [Upload and Display Excel Files with Spring MVC](http://www.baeldung.com/spring-mvc-excel-files) -- [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config) -- [Spring MVC @PathVariable with a dot (.) gets truncated](http://www.baeldung.com/spring-mvc-pathvariable-dot) -- [A Quick Example of Spring Websockets’ @SendToUser Annotation](http://www.baeldung.com/spring-websockets-sendtouser) +- [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-kotlin/README.md b/spring-mvc-kotlin/README.md index cc6827eb1b..590c627cb6 100644 --- a/spring-mvc-kotlin/README.md +++ b/spring-mvc-kotlin/README.md @@ -1,5 +1,9 @@ +## Spring MVC with Kotlin + +This module contains articles about Spring MVC with Kotlin + ### Relevant articles -- [Spring MVC Setup with Kotlin](http://www.baeldung.com/spring-mvc-kotlin) -- [Working with Kotlin and JPA](http://www.baeldung.com/kotlin-jpa) -- [Kotlin-allopen and Spring](http://www.baeldung.com/kotlin-allopen-spring) +- [Spring MVC Setup with Kotlin](https://www.baeldung.com/spring-mvc-kotlin) +- [Working with Kotlin and JPA](https://www.baeldung.com/kotlin-jpa) +- [Kotlin-allopen and Spring](https://www.baeldung.com/kotlin-allopen-spring) - [MockMvc Kotlin DSL](https://www.baeldung.com/mockmvc-kotlin-dsl) diff --git a/spring-mvc-simple-2/README.md b/spring-mvc-simple-2/README.md index 6dfe789be4..80456c5732 100644 --- a/spring-mvc-simple-2/README.md +++ b/spring-mvc-simple-2/README.md @@ -1,2 +1,7 @@ +## Spring MVC Simple 2 + +This module contains articles about Spring MVC + ## Relevant articles: - [How to Read HTTP Headers in Spring REST Controllers](https://www.baeldung.com/spring-rest-http-headers) +- More articles: [[<-- prev]](/spring-mvc-simple) diff --git a/spring-mvc-simple-2/pom.xml b/spring-mvc-simple-2/pom.xml index 74302cff78..ca911b2719 100644 --- a/spring-mvc-simple-2/pom.xml +++ b/spring-mvc-simple-2/pom.xml @@ -18,6 +18,11 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java b/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java new file mode 100644 index 0000000000..efa3d62b88 --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java @@ -0,0 +1,29 @@ +package com.baeldung.interpolation; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.validation.MessageInterpolator; +import java.util.Locale; + +public class MyMessageInterpolator implements MessageInterpolator { + + private static Logger logger = LoggerFactory.getLogger(MyMessageInterpolator.class); + + private final MessageInterpolator defaultInterpolator; + + public MyMessageInterpolator(MessageInterpolator interpolator) { + this.defaultInterpolator = interpolator; + } + + @Override + public String interpolate(String messageTemplate, Context context) { + messageTemplate = messageTemplate.toUpperCase(); + return defaultInterpolator.interpolate(messageTemplate, context, Locale.getDefault()); + } + + @Override + public String interpolate(String messageTemplate, Context context, Locale locale) { + messageTemplate = messageTemplate.toUpperCase(); + return defaultInterpolator.interpolate(messageTemplate, context, locale); + } +} diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/NotNullRequest.java b/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/NotNullRequest.java new file mode 100644 index 0000000000..9a2b00be8f --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/NotNullRequest.java @@ -0,0 +1,17 @@ +package com.baeldung.interpolation; + +import javax.validation.constraints.NotNull; + +public class NotNullRequest { + + @NotNull(message = "stringValue has to be present") + private String stringValue; + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(String stringValue) { + this.stringValue = stringValue; + } +} diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationController.java b/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationController.java new file mode 100644 index 0000000000..3fed170fdf --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationController.java @@ -0,0 +1,15 @@ +package com.baeldung.interpolation; + +import javax.validation.Valid; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ValidationController { + + @PostMapping("/test-not-null") + public void testNotNull(@Valid @RequestBody NotNullRequest request) { + + } +} diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationExamples.java b/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationExamples.java new file mode 100644 index 0000000000..6c9b924200 --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/interpolation/ValidationExamples.java @@ -0,0 +1,31 @@ +package com.baeldung.interpolation; + +import java.util.Formatter; +import javax.validation.constraints.Size; +import javax.validation.constraints.Min; +import javax.validation.constraints.DecimalMin; + +public class ValidationExamples { + + private static final Formatter formatter = new Formatter(); + + @Size( + min = 5, + max = 14, + message = "The author email '${validatedValue}' must be between {min} and {max} characters long" + ) + private String authorEmail; + + @Min( + value = 1, + message = "There must be at least {value} test{value > 1 ? 's' : ''} in the test case" + ) + private int testCount; + + @DecimalMin( + value = "50", + message = "The code coverage ${formatter.format('%1$.2f', validatedValue)} must be higher than {value}%" + ) + private double codeCoverage; + +} diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/Application.java b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/Application.java new file mode 100644 index 0000000000..7db6ac3755 --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/Application.java @@ -0,0 +1,14 @@ +package com.baeldung.spring.slash; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@SpringBootApplication +public class Application implements WebMvcConfigurer { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/SlashParsingController.java b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/SlashParsingController.java new file mode 100644 index 0000000000..635587ee5b --- /dev/null +++ b/spring-mvc-simple-2/src/main/java/com/baeldung/spring/slash/SlashParsingController.java @@ -0,0 +1,31 @@ +package com.baeldung.spring.slash; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("slash") +public class SlashParsingController { + + @GetMapping("mypaths/{anything}") + public String pathVariable(@PathVariable("anything") String anything) { + return anything; + } + + @GetMapping("all/**") + public String allDirectories(HttpServletRequest request) { + return request.getRequestURI() + .split(request.getContextPath() + "/all/")[1]; + } + + @GetMapping("all") + public String queryParameter(@RequestParam("param") String param) { + return param; + } + +} diff --git a/spring-mvc-simple-2/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java b/spring-mvc-simple-2/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java new file mode 100644 index 0000000000..d81b34f7bf --- /dev/null +++ b/spring-mvc-simple-2/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java @@ -0,0 +1,87 @@ +package com.baeldung.spring.slash; + +import static org.junit.Assert.assertEquals; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.net.URI; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; + +@AutoConfigureMockMvc +@ExtendWith(SpringExtension.class) +@SpringBootTest +public class SlashParsingControllerIntTest { + + @Autowired + private MockMvc mockMvc; + + @Test + public void whenUsingPathVariablemWithoutSlashes_thenStatusOk() throws Exception { + final String stringWithoutSlashes = "noslash"; + + MvcResult mvcResult = mockMvc.perform(get("/slash/mypaths/" + stringWithoutSlashes)) + .andExpect(status().isOk()) + .andReturn(); + + assertEquals(stringWithoutSlashes, mvcResult.getResponse() + .getContentAsString()); + } + + @Test + public void whenUsingPathVariableWithSlashes_thenStatusNotFound() throws Exception { + final String stringWithSlashes = "url/with/slashes"; + + mockMvc.perform(get("/slash/mypaths/" + stringWithSlashes)) + .andExpect(status().isNotFound()); + } + + @Test + public void givenAllFallbackEndpoint_whenUsingPathWithSlashes_thenStatusOk() throws Exception { + final String stringWithSlashes = "url/for/testing/purposes"; + + MvcResult mvcResult = mockMvc.perform(get("/slash/all/" + stringWithSlashes)) + .andExpect(status().isOk()) + .andReturn(); + + assertEquals(stringWithSlashes, mvcResult.getResponse() + .getContentAsString()); + } + + @Test + public void givenAllFallbackEndpoint_whenUsingConsecutiveSlashes_thenPathNormalized() throws Exception { + final String stringWithSlashes = "http://myurl.com"; + + MvcResult mvcResult = mockMvc.perform(get("/slash/all/" + stringWithSlashes)) + .andExpect(status().isOk()) + .andReturn(); + + String stringWithSlashesNormalized = URI.create("/slash/all/" + stringWithSlashes) + .normalize() + .toString() + .split("/slash/all/")[1]; + + assertEquals(stringWithSlashesNormalized, mvcResult.getResponse() + .getContentAsString()); + } + + @Test + public void whenUsingSlashesInQueryParam_thenParameterAccepted() throws Exception { + final String stringWithSlashes = "url/for////testing/purposes"; + + MvcResult mvcResult = mockMvc.perform(get("/slash/all").param("param", stringWithSlashes)) + .andExpect(status().isOk()) + .andReturn(); + + assertEquals(stringWithSlashes, mvcResult.getResponse() + .getContentAsString()); + } + +} diff --git a/spring-mvc-simple/README.md b/spring-mvc-simple/README.md index 755e0932fc..ae03fedf3c 100644 --- a/spring-mvc-simple/README.md +++ b/spring-mvc-simple/README.md @@ -1,10 +1,15 @@ +## Spring MVC Simple + +This module contains articles about Spring MVC + ## Relevant articles: -- [HandlerAdapters in Spring MVC](http://www.baeldung.com/spring-mvc-handler-adapters) -- [Template Engines for Spring](http://www.baeldung.com/spring-template-engines) -- [Spring 5 and Servlet 4 – The PushBuilder](http://www.baeldung.com/spring-5-push) -- [Servlet Redirect vs Forward](http://www.baeldung.com/servlet-redirect-forward) -- [Apache Tiles Integration with Spring MVC](http://www.baeldung.com/spring-mvc-apache-tiles) -- [Guide to Spring Email](http://www.baeldung.com/spring-email) +- [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-velocity/README.md b/spring-mvc-velocity/README.md index 401e135f75..99c4c032de 100644 --- a/spring-mvc-velocity/README.md +++ b/spring-mvc-velocity/README.md @@ -1,2 +1,6 @@ +## Spring MVC Velocity + +This module contains articles about Spring MVC with Velocity + ### Relevant Articles: -- [Quick Guide to Spring MVC with Velocity](http://www.baeldung.com/spring-mvc-with-velocity) +- [Quick Guide to Spring MVC with Velocity](https://www.baeldung.com/spring-mvc-with-velocity) diff --git a/spring-mvc-webflow/README.md b/spring-mvc-webflow/README.md index 2df4716e31..f89b97963e 100644 --- a/spring-mvc-webflow/README.md +++ b/spring-mvc-webflow/README.md @@ -1,9 +1,7 @@ -========= +## Spring MVC WebFlow -## Spring MVC with Spring Web Flow - -###The Course +This module contains articles about Spring MVC Web Flow ### Relevant Articles: -- -- [Guide to Spring Web Flow](http://www.baeldung.com/spring-web-flow) + +- [Guide to Spring Web Flow](https://www.baeldung.com/spring-web-flow) diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index c8ec074d17..b6a34475ea 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -1,18 +1,19 @@ -========= +## Spring MVC XML + +This module contains articles about Spring MVC with XML configuration ###The Course The "REST With Spring" Classes: http://bit.ly/restwithspring +### Relevant Articles: +- [Java Session Timeout](https://www.baeldung.com/servlet-session-timeout) +- [Returning Image/Media Data with Spring MVC](https://www.baeldung.com/spring-mvc-image-media-data) +- [Geolocation by IP in Java](https://www.baeldung.com/geolocation-by-ip-with-maxmind) +- [Guide to JavaServer Pages (JSP)](https://www.baeldung.com/jsp) +- [Exploring SpringMVC’s Form Tag Library](https://www.baeldung.com/spring-mvc-form-tags) +- [web.xml vs Initializer with Spring](https://www.baeldung.com/spring-xml-vs-java-config) +- [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) +- [Validating RequestParams and PathVariables in Spring](https://www.baeldung.com/spring-validate-requestparam-pathvariable) + ## Spring MVC with XML Configuration Example Project - access a sample jsp page at: `http://localhost:8080/spring-mvc-xml/sample.html` - - -### Relevant Articles: -- [Java Session Timeout](http://www.baeldung.com/servlet-session-timeout) -- [Returning Image/Media Data with Spring MVC](http://www.baeldung.com/spring-mvc-image-media-data) -- [Geolocation by IP in Java](http://www.baeldung.com/geolocation-by-ip-with-maxmind) -- [Guide to JavaServer Pages (JSP)](http://www.baeldung.com/jsp) -- [Exploring SpringMVC’s Form Tag Library](http://www.baeldung.com/spring-mvc-form-tags) -- [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config) -- [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) -- [Validating RequestParams and PathVariables in Spring](https://www.baeldung.com/spring-validate-requestparam-pathvariable) \ No newline at end of file diff --git a/spring-protobuf/README.md b/spring-protobuf/README.md index dad0e3f54a..37f35808e1 100644 --- a/spring-protobuf/README.md +++ b/spring-protobuf/README.md @@ -1,2 +1,6 @@ +## Spring Protocol Buffers + +This module contains articles about Spring with Protocol Buffers + ### Relevant Articles: -- [Spring REST API with Protocol Buffers](http://www.baeldung.com/spring-rest-api-with-protocol-buffers) +- [Spring REST API with Protocol Buffers](https://www.baeldung.com/spring-rest-api-with-protocol-buffers) diff --git a/spring-quartz/README.md b/spring-quartz/README.md index 5d32e65053..d9257066d4 100644 --- a/spring-quartz/README.md +++ b/spring-quartz/README.md @@ -1,26 +1,25 @@ -========================================================================= +## Spring Quartz -## Scheduling in Spring with Quartz Example Project -This is the first example where we configure a basic scheduler. -##### Spring boot application, Main class -### -``` -org.baeldung.springquartz.SpringQuartzApp -``` -###### - -##### Configuration in *application.properties* -#### - - - Default: configures scheduler using Spring convenience classes: - ``` - using.spring.schedulerFactory=true - ``` - - To configure scheduler using Quartz API: - ``` - using.spring.schedulerFactory=false - ``` +This module contains articles about Spring with Quartz ### Relevant Articles: -- [Scheduling in Spring with Quartz](http://www.baeldung.com/spring-quartz-schedule) +- [Scheduling in Spring with Quartz](https://www.baeldung.com/spring-quartz-schedule) + +## #Scheduling in Spring with Quartz Example Project +This is the first example where we configure a basic scheduler. + +##### Spring boot application, Main class + + +`org.baeldung.springquartz.SpringQuartzApp` + +##### Configuration in *application.properties* + + - Default: configures scheduler using Spring convenience classes: + + `using.spring.schedulerFactory=true` + + - To configure scheduler using Quartz API: + + `using.spring.schedulerFactory=false` diff --git a/spring-reactive-kotlin/README.md b/spring-reactive-kotlin/README.md index 46f4b580fd..629f7e7f58 100644 --- a/spring-reactive-kotlin/README.md +++ b/spring-reactive-kotlin/README.md @@ -3,4 +3,4 @@ This module contains articles about reactive Kotlin ### Relevant Articles: -- [Spring Webflux with Kotlin](http://www.baeldung.com/spring-webflux-kotlin) +- [Spring Webflux with Kotlin](https://www.baeldung.com/spring-webflux-kotlin) diff --git a/spring-reactor/README.md b/spring-reactor/README.md index e7d7eb927d..b92478f6fb 100644 --- a/spring-reactor/README.md +++ b/spring-reactor/README.md @@ -4,4 +4,4 @@ This module contains articles about Spring Reactor ## Relevant articles: -- [Introduction to Spring Reactor](http://www.baeldung.com/spring-reactor) +- [Introduction to Spring Reactor](https://www.baeldung.com/spring-reactor) diff --git a/spring-remoting/README.md b/spring-remoting/README.md index 247aa52db2..a98893ebcb 100644 --- a/spring-remoting/README.md +++ b/spring-remoting/README.md @@ -3,11 +3,11 @@ This module contains articles about Spring Remoting ### Relevant Articles -- [Intro to Spring Remoting with HTTP Invokers](http://www.baeldung.com/spring-remoting-http-invoker) -- [Spring Remoting with Hessian and Burlap](http://www.baeldung.com/spring-remoting-hessian-burlap) -- [Spring Remoting with AMQP](http://www.baeldung.com/spring-remoting-amqp) -- [Spring Remoting with JMS and ActiveMQ](http://www.baeldung.com/spring-remoting-jms) -- [Spring Remoting with RMI](http://www.baeldung.com/spring-remoting-rmi) +- [Intro to Spring Remoting with HTTP Invokers](https://www.baeldung.com/spring-remoting-http-invoker) +- [Spring Remoting with Hessian and Burlap](https://www.baeldung.com/spring-remoting-hessian-burlap) +- [Spring Remoting with AMQP](https://www.baeldung.com/spring-remoting-amqp) +- [Spring Remoting with JMS and ActiveMQ](https://www.baeldung.com/spring-remoting-jms) +- [Spring Remoting with RMI](https://www.baeldung.com/spring-remoting-rmi) ### Overview This Maven project contains the Java source code for various modules used in the Spring Remoting series of articles. diff --git a/spring-rest-angular/README.md b/spring-rest-angular/README.md index 5cd2570152..038160db9d 100644 --- a/spring-rest-angular/README.md +++ b/spring-rest-angular/README.md @@ -4,4 +4,4 @@ This module contains articles about REST APIs with Spring and Angular ### Relevant Articles: -- [Pagination with Spring REST and AngularJS table](http://www.baeldung.com/pagination-with-a-spring-rest-api-and-an-angularjs-table) +- [Pagination with Spring REST and AngularJS table](https://www.baeldung.com/pagination-with-a-spring-rest-api-and-an-angularjs-table) diff --git a/spring-rest-full/README.md b/spring-rest-full/README.md index a0e6e74179..a0ba8df27d 100644 --- a/spring-rest-full/README.md +++ b/spring-rest-full/README.md @@ -9,9 +9,9 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [Integration Testing with the Maven Cargo plugin](http://www.baeldung.com/integration-testing-with-the-maven-cargo-plugin) -- [Project Configuration with Spring](http://www.baeldung.com/project-configuration-with-spring) -- [Metrics for your Spring REST API](http://www.baeldung.com/spring-rest-api-metrics) +- [Integration Testing with the Maven Cargo plugin](https://www.baeldung.com/integration-testing-with-the-maven-cargo-plugin) +- [Project Configuration with Spring](https://www.baeldung.com/project-configuration-with-spring) +- [Metrics for your Spring REST API](https://www.baeldung.com/spring-rest-api-metrics) - [Spring Security Expressions - hasRole Example](https://www.baeldung.com/spring-security-expressions-basic) diff --git a/spring-rest-hal-browser/README.md b/spring-rest-hal-browser/README.md index 027937f116..90337aad1a 100644 --- a/spring-rest-hal-browser/README.md +++ b/spring-rest-hal-browser/README.md @@ -3,4 +3,4 @@ This module contains articles about Spring REST with the HAL browser ### Relevant Articles: -- [Spring REST and HAL Browser](http://www.baeldung.com/spring-rest-hal) +- [Spring REST and HAL Browser](https://www.baeldung.com/spring-rest-hal) diff --git a/spring-rest-query-language/README.md b/spring-rest-query-language/README.md index 383cecec36..4458fc93fb 100644 --- a/spring-rest-query-language/README.md +++ b/spring-rest-query-language/README.md @@ -10,12 +10,12 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [REST Query Language with Spring and JPA Criteria](http://www.baeldung.com/rest-search-language-spring-jpa-criteria) -- [REST Query Language with Spring Data JPA Specifications](http://www.baeldung.com/rest-api-search-language-spring-data-specifications) -- [REST Query Language with Spring Data JPA and QueryDSL](http://www.baeldung.com/rest-api-search-language-spring-data-querydsl) -- [REST Query Language – Advanced Search Operations](http://www.baeldung.com/rest-api-query-search-language-more-operations) -- [REST Query Language with RSQL](http://www.baeldung.com/rest-api-search-language-rsql-fiql) -- [REST Query Language – Implementing OR Operation](http://www.baeldung.com/rest-api-query-search-or-operation) +- [REST Query Language with Spring and JPA Criteria](https://www.baeldung.com/rest-search-language-spring-jpa-criteria) +- [REST Query Language with Spring Data JPA Specifications](https://www.baeldung.com/rest-api-search-language-spring-data-specifications) +- [REST Query Language with Spring Data JPA and QueryDSL](https://www.baeldung.com/rest-api-search-language-spring-data-querydsl) +- [REST Query Language – Advanced Search Operations](https://www.baeldung.com/rest-api-query-search-language-more-operations) +- [REST Query Language with RSQL](https://www.baeldung.com/rest-api-search-language-rsql-fiql) +- [REST Query Language – Implementing OR Operation](https://www.baeldung.com/rest-api-query-search-or-operation) ### Build the Project ``` diff --git a/spring-rest-shell/README.md b/spring-rest-shell/README.md index 0b126e6b1c..3c04bb457e 100644 --- a/spring-rest-shell/README.md +++ b/spring-rest-shell/README.md @@ -4,4 +4,4 @@ This module contains articles about Spring REST Shell ### Relevant Articles -- [Introduction to Spring REST Shell](http://www.baeldung.com/spring-rest-shell) +- [Introduction to Spring REST Shell](https://www.baeldung.com/spring-rest-shell) diff --git a/spring-rest-simple/README.md b/spring-rest-simple/README.md index d60f57b227..1ad32bf120 100644 --- a/spring-rest-simple/README.md +++ b/spring-rest-simple/README.md @@ -4,9 +4,9 @@ This module contains articles about REST APIs in Spring ## Relevant articles: -- [Guide to UriComponentsBuilder in Spring](http://www.baeldung.com/spring-uricomponentsbuilder) -- [Returning Custom Status Codes from Spring Controllers](http://www.baeldung.com/spring-mvc-controller-custom-http-status-code) -- [Spring RequestMapping](http://www.baeldung.com/spring-requestmapping) -- [Spring and Apache FileUpload](http://www.baeldung.com/spring-apache-file-upload) -- [Test a REST API with curl](http://www.baeldung.com/curl-rest) +- [Guide to UriComponentsBuilder in Spring](https://www.baeldung.com/spring-uricomponentsbuilder) +- [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) +- [Spring and Apache FileUpload](https://www.baeldung.com/spring-apache-file-upload) +- [Test a REST API with curl](https://www.baeldung.com/curl-rest) - [CORS with Spring](https://www.baeldung.com/spring-cors) diff --git a/spring-rest-simple/src/main/java/com/baeldung/cors/EnumController.java b/spring-rest-simple/src/main/java/com/baeldung/cors/EnumController.java index 6bd5a16439..34ce4d3927 100644 --- a/spring-rest-simple/src/main/java/com/baeldung/cors/EnumController.java +++ b/spring-rest-simple/src/main/java/com/baeldung/cors/EnumController.java @@ -1,6 +1,7 @@ package com.baeldung.cors; import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -13,12 +14,12 @@ import com.baeldung.model.Modes; @RequestMapping("/enums") public class EnumController { - @RequestMapping("/mode2str") + @GetMapping("/mode2str") public String getStringToMode(@RequestParam("mode") Modes mode) { return "good"; } - @RequestMapping("/findbymode/{mode}") + @GetMapping("/findbymode/{mode}") public String findByEnum(@PathVariable Modes mode) { return "good"; } diff --git a/spring-rest-simple/src/main/java/com/baeldung/model/Modes.java b/spring-rest-simple/src/main/java/com/baeldung/model/Modes.java index a82df17d7d..d3a1ab4a61 100644 --- a/spring-rest-simple/src/main/java/com/baeldung/model/Modes.java +++ b/spring-rest-simple/src/main/java/com/baeldung/model/Modes.java @@ -1,5 +1,5 @@ package com.baeldung.model; public enum Modes { - ALPHA, DELTA + ALPHA, BETA; } diff --git a/spring-rest-simple/src/main/java/com/baeldung/repository/BookRepository.java b/spring-rest-simple/src/main/java/com/baeldung/repository/BookRepository.java new file mode 100644 index 0000000000..239d74b19c --- /dev/null +++ b/spring-rest-simple/src/main/java/com/baeldung/repository/BookRepository.java @@ -0,0 +1,25 @@ +package com.baeldung.repository; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.springframework.stereotype.Repository; + +import com.baeldung.web.dto.Book; + +@Repository +public class BookRepository { + + private List books = new ArrayList<>(); + + public Optional findById(long id) { + return books.stream() + .filter(book -> book.getId() == id) + .findFirst(); + } + + public void add(Book book) { + books.add(book); + } +} diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/controller/ApiExceptionHandler.java b/spring-rest-simple/src/main/java/com/baeldung/web/controller/ApiExceptionHandler.java new file mode 100644 index 0000000000..e7f0ac3510 --- /dev/null +++ b/spring-rest-simple/src/main/java/com/baeldung/web/controller/ApiExceptionHandler.java @@ -0,0 +1,22 @@ +package com.baeldung.web.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import com.baeldung.web.error.ApiErrorResponse; +import com.baeldung.web.error.BookNotFoundException; + +@RestControllerAdvice +public class ApiExceptionHandler { + + @ExceptionHandler(BookNotFoundException.class) + public ResponseEntity handleApiException( + BookNotFoundException ex) { + ApiErrorResponse response = + new ApiErrorResponse("error-0001", + "No book found with ID " + ex.getId()); + return new ResponseEntity<>(response, HttpStatus.NOT_FOUND); + } +} \ No newline at end of file diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/controller/BookController.java b/spring-rest-simple/src/main/java/com/baeldung/web/controller/BookController.java new file mode 100644 index 0000000000..126b40517d --- /dev/null +++ b/spring-rest-simple/src/main/java/com/baeldung/web/controller/BookController.java @@ -0,0 +1,25 @@ +package com.baeldung.web.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.repository.BookRepository; +import com.baeldung.web.dto.Book; +import com.baeldung.web.error.BookNotFoundException; + +@RestController +@RequestMapping("/api/book") +public class BookController { + + @Autowired + private BookRepository repository; + + @GetMapping("/{id}") + public Book findById(@PathVariable long id) { + return repository.findById(id) + .orElseThrow(() -> new BookNotFoundException(id)); + } +} \ No newline at end of file diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/dto/Book.java b/spring-rest-simple/src/main/java/com/baeldung/web/dto/Book.java new file mode 100644 index 0000000000..9ccd640319 --- /dev/null +++ b/spring-rest-simple/src/main/java/com/baeldung/web/dto/Book.java @@ -0,0 +1,32 @@ +package com.baeldung.web.dto; + +public class Book { + + private long id; + private String title; + private String author; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + 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; + } +} \ No newline at end of file diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/error/ApiErrorResponse.java b/spring-rest-simple/src/main/java/com/baeldung/web/error/ApiErrorResponse.java new file mode 100644 index 0000000000..a67a7a3f2f --- /dev/null +++ b/spring-rest-simple/src/main/java/com/baeldung/web/error/ApiErrorResponse.java @@ -0,0 +1,29 @@ +package com.baeldung.web.error; + +public class ApiErrorResponse { + + private String error; + private String message; + + public ApiErrorResponse(String error, String message) { + super(); + this.error = error; + this.message = message; + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} \ No newline at end of file diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/error/BookNotFoundException.java b/spring-rest-simple/src/main/java/com/baeldung/web/error/BookNotFoundException.java new file mode 100644 index 0000000000..ad93ef7f20 --- /dev/null +++ b/spring-rest-simple/src/main/java/com/baeldung/web/error/BookNotFoundException.java @@ -0,0 +1,19 @@ +package com.baeldung.web.error; + +@SuppressWarnings("serial") +public class BookNotFoundException extends RuntimeException { + + private long id; + + public BookNotFoundException(long id) { + this.id = id; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } +} \ No newline at end of file diff --git a/spring-rest-simple/src/test/java/com/baeldung/repository/BookRepositoryUnitTest.java b/spring-rest-simple/src/test/java/com/baeldung/repository/BookRepositoryUnitTest.java new file mode 100644 index 0000000000..dd64f302fe --- /dev/null +++ b/spring-rest-simple/src/test/java/com/baeldung/repository/BookRepositoryUnitTest.java @@ -0,0 +1,60 @@ +package com.baeldung.repository; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Optional; + +import org.junit.Before; +import org.junit.Test; + +import com.baeldung.web.dto.Book; + +public class BookRepositoryUnitTest { + + private BookRepository repository; + + @Before + public void setUp() { + repository = new BookRepository(); + } + + @Test + public void givenNoBooks_WhenFindById_ThenReturnEmptyOptional() { + assertFalse(repository.findById(1).isPresent()); + } + + @Test + public void givenOneMatchingBook_WhenFindById_ThenReturnEmptyOptional() { + + long id = 1; + Book expected = bookWithId(id); + + repository.add(expected); + + Optional found = repository.findById(id); + + assertTrue(found.isPresent()); + assertEquals(expected, found.get()); + } + + private static Book bookWithId(long id) { + Book book = new Book(); + book.setId(id); + return book; + } + + @Test + public void givenOneNonMatchingBook_WhenFindById_ThenReturnEmptyOptional() { + + long id = 1; + Book expected = bookWithId(id); + + repository.add(expected); + + Optional found = repository.findById(id + 1); + + assertFalse(found.isPresent()); + } +} \ No newline at end of file diff --git a/spring-rest-simple/src/test/java/com/baeldung/web/controller/BookControllerIntegrationTest.java b/spring-rest-simple/src/test/java/com/baeldung/web/controller/BookControllerIntegrationTest.java new file mode 100644 index 0000000000..3bf5ce3c3d --- /dev/null +++ b/spring-rest-simple/src/test/java/com/baeldung/web/controller/BookControllerIntegrationTest.java @@ -0,0 +1,74 @@ +package com.baeldung.web.controller; + +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +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 java.util.Optional; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import com.baeldung.Application; +import com.baeldung.repository.BookRepository; +import com.baeldung.web.dto.Book; +import com.baeldung.web.error.ApiErrorResponse; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(SpringRunner.class) +@WebMvcTest(BookController.class) +@ComponentScan(basePackageClasses = Application.class) +public class BookControllerIntegrationTest { + + private static final ObjectMapper MAPPER = new ObjectMapper(); + + @Autowired + private MockMvc mvc; + + @MockBean + private BookRepository repository; + + @Test + public void givenNoExistingBooks_WhenGetBookWithId1_ThenErrorReturned() throws Exception { + + long id = 1; + + doReturn(Optional.empty()).when(repository).findById(eq(id)); + + mvc.perform(get("/api/book/{id}", id)) + .andExpect(status().isNotFound()) + .andExpect(content().json(MAPPER.writeValueAsString(new ApiErrorResponse("error-0001", "No book found with ID " + id)))); + } + + @Test + public void givenMatchingBookExists_WhenGetBookWithId1_ThenBookReturned() throws Exception { + + long id = 1; + Book book = book(id, "foo", "bar"); + + doReturn(Optional.of(book)).when(repository).findById(eq(id)); + + mvc.perform(get("/api/book/{id}", id)) + .andExpect(status().isOk()) + .andExpect(content().json(MAPPER.writeValueAsString(book))); + } + + private static Book book(long id, String title, String author) { + + Book book = new Book(); + + book.setId(id); + book.setTitle(title); + book.setAuthor(author); + + return book; + } +} \ No newline at end of file diff --git a/spring-rest-simple/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java b/spring-rest-simple/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java index 4bbfa2818e..bc644af428 100644 --- a/spring-rest-simple/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java +++ b/spring-rest-simple/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java @@ -5,7 +5,7 @@ import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan({ "com.baeldung.web" }) +@ComponentScan({ "com.baeldung.web", "com.baeldung.repository" }) public class TestConfig { } diff --git a/spring-rest/README.md b/spring-rest/README.md index 1d713c05c0..ac12066e8f 100644 --- a/spring-rest/README.md +++ b/spring-rest/README.md @@ -6,20 +6,20 @@ This module contains articles about REST APIs with Spring The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [Spring @RequestMapping](http://www.baeldung.com/spring-requestmapping) -- [Returning Custom Status Codes from Spring Controllers](http://www.baeldung.com/spring-mvc-controller-custom-http-status-code) -- [Binary Data Formats in a Spring REST API](http://www.baeldung.com/spring-rest-api-with-binary-data-formats) -- [Guide to UriComponentsBuilder in Spring](http://www.baeldung.com/spring-uricomponentsbuilder) -- [Introduction to FindBugs](http://www.baeldung.com/intro-to-findbugs) -- [A Custom Media Type for a Spring REST API](http://www.baeldung.com/spring-rest-custom-media-type) -- [HTTP PUT vs HTTP PATCH in a REST API](http://www.baeldung.com/http-put-patch-difference-spring) -- [Spring – Log Incoming Requests](http://www.baeldung.com/spring-http-logging) -- [Introduction to CheckStyle](http://www.baeldung.com/checkstyle-java) -- [How to Change the Default Port in Spring Boot](http://www.baeldung.com/spring-boot-change-port) -- [Guide to DeferredResult in Spring](http://www.baeldung.com/spring-deferred-result) -- [Spring Custom Property Editor](http://www.baeldung.com/spring-mvc-custom-property-editor) -- [Using the Spring RestTemplate Interceptor](http://www.baeldung.com/spring-rest-template-interceptor) -- [Get and Post Lists of Objects with RestTemplate](http://www.baeldung.com/spring-rest-template-list) -- [How to Set a Header on a Response with Spring 5](http://www.baeldung.com/spring-response-header) -- [Uploading MultipartFile with Spring RestTemplate](http://www.baeldung.com/spring-rest-template-multipart-upload) -- [Download an Image or a File with Spring MVC](http://www.baeldung.com/spring-controller-return-image-file) +- [Spring @RequestMapping](https://www.baeldung.com/spring-requestmapping) +- [Returning Custom Status Codes from Spring Controllers](https://www.baeldung.com/spring-mvc-controller-custom-http-status-code) +- [Binary Data Formats in a Spring REST API](https://www.baeldung.com/spring-rest-api-with-binary-data-formats) +- [Guide to UriComponentsBuilder in Spring](https://www.baeldung.com/spring-uricomponentsbuilder) +- [Introduction to FindBugs](https://www.baeldung.com/intro-to-findbugs) +- [A Custom Media Type for a Spring REST API](https://www.baeldung.com/spring-rest-custom-media-type) +- [HTTP PUT vs HTTP PATCH in a REST API](https://www.baeldung.com/http-put-patch-difference-spring) +- [Spring – Log Incoming Requests](https://www.baeldung.com/spring-http-logging) +- [Introduction to CheckStyle](https://www.baeldung.com/checkstyle-java) +- [How to Change the Default Port in Spring Boot](https://www.baeldung.com/spring-boot-change-port) +- [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result) +- [Spring Custom Property Editor](https://www.baeldung.com/spring-mvc-custom-property-editor) +- [Using the Spring RestTemplate Interceptor](https://www.baeldung.com/spring-rest-template-interceptor) +- [Get and Post Lists of Objects with RestTemplate](https://www.baeldung.com/spring-rest-template-list) +- [How to Set a Header on a Response with Spring 5](https://www.baeldung.com/spring-response-header) +- [Uploading MultipartFile with Spring RestTemplate](https://www.baeldung.com/spring-rest-template-multipart-upload) +- [Download an Image or a File with Spring MVC](https://www.baeldung.com/spring-controller-return-image-file) diff --git a/spring-resttemplate/README.md b/spring-resttemplate/README.md index 9b75e1aa81..e98af0e787 100644 --- a/spring-resttemplate/README.md +++ b/spring-resttemplate/README.md @@ -6,10 +6,10 @@ This module contains articles about Spring RestTemplate The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: -- [The Guide to RestTemplate](http://www.baeldung.com/rest-template) -- [Exploring the Spring Boot TestRestTemplate](http://www.baeldung.com/spring-boot-testresttemplate) -- [Spring RestTemplate Error Handling](http://www.baeldung.com/spring-rest-template-error-handling) -- [Configure a RestTemplate with RestTemplateBuilder](http://www.baeldung.com/spring-rest-template-builder) +- [The Guide to RestTemplate](https://www.baeldung.com/rest-template) +- [Exploring the Spring Boot TestRestTemplate](https://www.baeldung.com/spring-boot-testresttemplate) +- [Spring RestTemplate Error Handling](https://www.baeldung.com/spring-rest-template-error-handling) +- [Configure a RestTemplate with RestTemplateBuilder](https://www.baeldung.com/spring-rest-template-builder) - [Mocking a RestTemplate in Spring](https://www.baeldung.com/spring-mock-rest-template) - [RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json) - [Download a Large File Through a Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-download-large-file) diff --git a/spring-roo/README.md b/spring-roo/README.md index 5a8ce6e30f..abbc4249d4 100644 --- a/spring-roo/README.md +++ b/spring-roo/README.md @@ -3,4 +3,4 @@ This module contains articles about Spring Roo ### Relevant Articles: -[Quick Guide to Spring Roo](http://www.baeldung.com/spring-roo) +[Quick Guide to Spring Roo](https://www.baeldung.com/spring-roo) diff --git a/spring-security-acl/README.md b/spring-security-acl/README.md index 2f95793f8d..b2f42d5c29 100644 --- a/spring-security-acl/README.md +++ b/spring-security-acl/README.md @@ -3,4 +3,4 @@ This module contains articles about Spring Security ACL ### Relevant Articles -- [Introduction to Spring Security ACL](http://www.baeldung.com/spring-security-acl) +- [Introduction to Spring Security ACL](https://www.baeldung.com/spring-security-acl) diff --git a/spring-security-cache-control/README.md b/spring-security-cache-control/README.md index fc5bdda1f6..1c7cbfd096 100644 --- a/spring-security-cache-control/README.md +++ b/spring-security-cache-control/README.md @@ -3,4 +3,4 @@ This module contains articles about cache control with Spring Security ### Relevant Articles: -- [Spring Security – Cache Control Headers](http://www.baeldung.com/spring-security-cache-control-headers) +- [Spring Security – Cache Control Headers](https://www.baeldung.com/spring-security-cache-control-headers) diff --git a/spring-security-core/README.md b/spring-security-core/README.md index 3dfcb276d7..3579e5e759 100644 --- a/spring-security-core/README.md +++ b/spring-security-core/README.md @@ -3,9 +3,9 @@ This module contains articles about core Spring Security ### Relevant Articles: -- [Spring Security – @PreFilter and @PostFilter](http://www.baeldung.com/spring-security-prefilter-postfilter) -- [Spring Boot Authentication Auditing Support](http://www.baeldung.com/spring-boot-authentication-audit) -- [Introduction to Spring Method Security](http://www.baeldung.com/spring-security-method-security) +- [Spring Security – @PreFilter and @PostFilter](https://www.baeldung.com/spring-security-prefilter-postfilter) +- [Spring Boot Authentication Auditing Support](https://www.baeldung.com/spring-boot-authentication-audit) +- [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 @@ -13,5 +13,3 @@ This module contains articles about core Spring Security #### Build the Project `mvn clean install` - - diff --git a/spring-security-cors/README.md b/spring-security-cors/README.md index 2ab5e33ee3..c9e00e04d7 100644 --- a/spring-security-cors/README.md +++ b/spring-security-cors/README.md @@ -1,3 +1,7 @@ +## Spring Security CORS + +This module contains articles about Spring Security with CORS (Cross Origin Requests) + ## Relevant Articles - [Fixing 401s with CORS Preflights and Spring Security](https://www.baeldung.com/spring-security-cors-preflight) diff --git a/spring-security-kerberos/README.md b/spring-security-kerberos/README.md index 1b77c380db..a868fb86b7 100644 --- a/spring-security-kerberos/README.md +++ b/spring-security-kerberos/README.md @@ -1,10 +1,13 @@ -## @PreFilter and @PostFilter annotations +## Spring Security Kerberos + +This module contains articles about Spring Security Kerberos + +### Relevant Articles: + +- [Introduction to SPNEGO/Kerberos Authentication in Spring](https://www.baeldung.com/spring-security-kerberos) + +### @PreFilter and @PostFilter annotations ### Build the Project ### -``` -mvn clean install -``` - -### Relevant Articles: -- [Introduction to SPNEGO/Kerberos Authentication in Spring](https://www.baeldung.com/spring-security-kerberos) +`mvn clean install` \ No newline at end of file diff --git a/spring-security-mvc-boot/README.md b/spring-security-mvc-boot/README.md index 150ea3eee9..7dcfe4d70f 100644 --- a/spring-security-mvc-boot/README.md +++ b/spring-security-mvc-boot/README.md @@ -6,13 +6,13 @@ This module contains articles about Spring Security with Spring MVC in Boot appl The "REST With Spring" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [A Custom Security Expression with Spring Security](http://www.baeldung.com/spring-security-create-new-custom-security-expression) -- [Custom AccessDecisionVoters in Spring Security](http://www.baeldung.com/spring-security-custom-voter) -- [Spring Security: Authentication with a Database-backed UserDetailsService](http://www.baeldung.com/spring-security-authentication-with-a-database) -- [Two Login Pages with Spring Security](http://www.baeldung.com/spring-security-two-login-pages) -- [Multiple Entry Points in Spring Security](http://www.baeldung.com/spring-security-multiple-entry-points) -- [Multiple Authentication Providers in Spring Security](http://www.baeldung.com/spring-security-multiple-auth-providers) -- [Granted Authority Versus Role in Spring Security](http://www.baeldung.com/spring-security-granted-authority-vs-role) +- [A Custom Security Expression with Spring Security](https://www.baeldung.com/spring-security-create-new-custom-security-expression) +- [Custom AccessDecisionVoters in Spring Security](https://www.baeldung.com/spring-security-custom-voter) +- [Spring Security: Authentication with a Database-backed UserDetailsService](https://www.baeldung.com/spring-security-authentication-with-a-database) +- [Two Login Pages with Spring Security](https://www.baeldung.com/spring-security-two-login-pages) +- [Multiple Entry Points in Spring Security](https://www.baeldung.com/spring-security-multiple-entry-points) +- [Multiple Authentication Providers in Spring Security](https://www.baeldung.com/spring-security-multiple-auth-providers) +- [Granted Authority Versus Role in Spring Security](https://www.baeldung.com/spring-security-granted-authority-vs-role) - [Spring Data with Spring Security](https://www.baeldung.com/spring-data-security) - [Spring Security – Whitelist IP Range](https://www.baeldung.com/spring-security-whitelist-ip-range) - [Find the Registered Spring Security Filters](https://www.baeldung.com/spring-security-registered-filters) diff --git a/spring-security-mvc-boot/src/main/java/org/baeldung/jdbcauthentication/README.md b/spring-security-mvc-boot/src/main/java/org/baeldung/jdbcauthentication/README.md new file mode 100644 index 0000000000..a7cdfec7d8 --- /dev/null +++ b/spring-security-mvc-boot/src/main/java/org/baeldung/jdbcauthentication/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Spring Security: Exploring JDBC Authentication](https://www.baeldung.com/spring-security-jdbc-authentication) diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md index 84bdec3c10..1a131f4c23 100644 --- a/spring-security-mvc-custom/README.md +++ b/spring-security-mvc-custom/README.md @@ -6,13 +6,13 @@ This module contains articles about Spring Security with custom MVC applications The "REST With Spring" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) -- [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) -- [Changing Spring Model Parameters with Handler Interceptor](http://www.baeldung.com/spring-model-parameters-with-handler-interceptor) -- [Introduction to Spring MVC HandlerInterceptor](http://www.baeldung.com/spring-mvc-handlerinterceptor) -- [Using a Custom Spring MVC’s Handler Interceptor to Manage Sessions](http://www.baeldung.com/spring-mvc-custom-handler-interceptor) -- [A Guide to CSRF Protection in Spring Security](http://www.baeldung.com/spring-security-csrf) -- [How to Manually Authenticate User with Spring Security](http://www.baeldung.com/manually-set-user-authentication-spring-security) +- [Spring Security Remember Me](https://www.baeldung.com/spring-security-remember-me) +- [Redirect to different pages after Login with Spring Security](https://www.baeldung.com/spring_redirect_after_login) +- [Changing Spring Model Parameters with Handler Interceptor](https://www.baeldung.com/spring-model-parameters-with-handler-interceptor) +- [Introduction to Spring MVC HandlerInterceptor](https://www.baeldung.com/spring-mvc-handlerinterceptor) +- [Using a Custom Spring MVC’s Handler Interceptor to Manage Sessions](https://www.baeldung.com/spring-mvc-custom-handler-interceptor) +- [A Guide to CSRF Protection in Spring Security](https://www.baeldung.com/spring-security-csrf) +- [How to Manually Authenticate User with Spring Security](https://www.baeldung.com/manually-set-user-authentication-spring-security) ### Build the Project ``` diff --git a/spring-security-mvc-digest-auth/README.md b/spring-security-mvc-digest-auth/README.md index da612e273b..0d36dbfd63 100644 --- a/spring-security-mvc-digest-auth/README.md +++ b/spring-security-mvc-digest-auth/README.md @@ -6,6 +6,6 @@ This module contains articles about digest authentication with Spring Security The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Article: -- [Spring Security Digest Authentication](http://www.baeldung.com/spring-security-digest-authentication) -- [RestTemplate with Digest Authentication](http://www.baeldung.com/resttemplate-digest-authentication) +- [Spring Security Digest Authentication](https://www.baeldung.com/spring-security-digest-authentication) +- [RestTemplate with Digest Authentication](https://www.baeldung.com/resttemplate-digest-authentication) diff --git a/spring-security-mvc-ldap/README.md b/spring-security-mvc-ldap/README.md index fe04cd23fa..3230c0398a 100644 --- a/spring-security-mvc-ldap/README.md +++ b/spring-security-mvc-ldap/README.md @@ -6,8 +6,8 @@ This module contains articles about Spring Security LDAP The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Article: -- [Spring Security – security none, filters none, access permitAll](http://www.baeldung.com/security-none-filters-none-access-permitAll) -- [Intro to Spring Security LDAP](http://www.baeldung.com/spring-security-ldap) +- [Spring Security – security none, filters none, access permitAll](https://www.baeldung.com/security-none-filters-none-access-permitAll) +- [Intro to Spring Security LDAP](https://www.baeldung.com/spring-security-ldap) ### Notes - the project uses Spring Boot - simply run 'SampleLDAPApplication.java' to start up Spring Boot with a Tomcat container and embedded LDAP server. diff --git a/spring-security-mvc-login/README.md b/spring-security-mvc-login/README.md index a20a04edec..5d92a8e1b4 100644 --- a/spring-security-mvc-login/README.md +++ b/spring-security-mvc-login/README.md @@ -6,13 +6,13 @@ This module contains articles about login mechanisms with Spring Security The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [Spring Security Form Login](http://www.baeldung.com/spring-security-login) -- [Spring Security Logout](http://www.baeldung.com/spring-security-logout) -- [Spring Security Expressions – hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) -- [Spring HTTP/HTTPS Channel Security](http://www.baeldung.com/spring-channel-security-https) -- [Spring Security – Customize the 403 Forbidden/Access Denied Page](http://www.baeldung.com/spring-security-custom-access-denied-page) -- [Spring Security – Redirect to the Previous URL After Login](http://www.baeldung.com/spring-security-redirect-login) -- [Spring Security Custom AuthenticationFailureHandler](http://www.baeldung.com/spring-security-custom-authentication-failure-handler) +- [Spring Security Form Login](https://www.baeldung.com/spring-security-login) +- [Spring Security Logout](https://www.baeldung.com/spring-security-logout) +- [Spring Security Expressions – hasRole Example](https://www.baeldung.com/spring-security-expressions-basic) +- [Spring HTTP/HTTPS Channel Security](https://www.baeldung.com/spring-channel-security-https) +- [Spring Security – Customize the 403 Forbidden/Access Denied Page](https://www.baeldung.com/spring-security-custom-access-denied-page) +- [Spring Security – Redirect to the Previous URL After Login](https://www.baeldung.com/spring-security-redirect-login) +- [Spring Security Custom AuthenticationFailureHandler](https://www.baeldung.com/spring-security-custom-authentication-failure-handler) ### Build the Project ``` diff --git a/spring-security-mvc-persisted-remember-me/README.md b/spring-security-mvc-persisted-remember-me/README.md index 260e55198a..e3003e89e2 100644 --- a/spring-security-mvc-persisted-remember-me/README.md +++ b/spring-security-mvc-persisted-remember-me/README.md @@ -6,7 +6,7 @@ This module contains articles about 'remember me' with Spring Security The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [Spring Security – Persistent Remember Me](http://www.baeldung.com/spring-security-persistent-remember-me) +- [Spring Security – Persistent Remember Me](https://www.baeldung.com/spring-security-persistent-remember-me) ### Build the Project ``` diff --git a/spring-security-mvc-socket/README.md b/spring-security-mvc-socket/README.md index 187bbe82b0..d134d19c84 100644 --- a/spring-security-mvc-socket/README.md +++ b/spring-security-mvc-socket/README.md @@ -4,7 +4,7 @@ This module contains articles about WebSockets with Spring Security ### Relevant Articles: -- [Intro to Security and WebSockets](http://www.baeldung.com/spring-security-websockets) +- [Intro to Security and WebSockets](https://www.baeldung.com/spring-security-websockets) - [Spring WebSockets: Build an User Chat](https://www.baeldung.com/spring-websockets-send-message-to-user) - [REST vs WebSockets](https://www.baeldung.com/rest-vs-websockets) @@ -15,5 +15,3 @@ To build the project, run the command: mvn clean install. This will build a war Alternatively, run the project from an IDE. To login, use credentials from the data.sql file in src/main/resource, eg: user/password. - - diff --git a/spring-security-mvc/README.md b/spring-security-mvc/README.md index ad55e903c5..a458127c61 100644 --- a/spring-security-mvc/README.md +++ b/spring-security-mvc/README.md @@ -6,8 +6,8 @@ This module contains articles about Spring Security in MVC applications The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [HttpSessionListener Example – Monitoring](http://www.baeldung.com/httpsessionlistener_with_metrics) -- [Control the Session with Spring Security](http://www.baeldung.com/spring-security-session) +- [HttpSessionListener Example – Monitoring](https://www.baeldung.com/httpsessionlistener_with_metrics) +- [Control the Session with Spring Security](https://www.baeldung.com/spring-security-session) ### Build the Project diff --git a/spring-security-openid/README.md b/spring-security-openid/README.md index 1512ffbde5..1f856fe191 100644 --- a/spring-security-openid/README.md +++ b/spring-security-openid/README.md @@ -4,7 +4,7 @@ This module contains articles about OpenID with Spring Security ### Relevant articles -- [Spring Security and OpenID Connect](http://www.baeldung.com/spring-security-openid-connect) +- [Spring Security and OpenID Connect](https://www.baeldung.com/spring-security-openid-connect) ### OpenID Connect with Spring Security diff --git a/spring-security-react/README.md b/spring-security-react/README.md index 4eb402c699..6c9e1dad7a 100644 --- a/spring-security-react/README.md +++ b/spring-security-react/README.md @@ -8,7 +8,7 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -* [Spring Security Login Page with React](http://www.baeldung.com/spring-security-login-react) +* [Spring Security Login Page with React](https://www.baeldung.com/spring-security-login-react) ### Build the Project diff --git a/spring-security-rest-basic-auth/README.md b/spring-security-rest-basic-auth/README.md index 41d463f1e2..d12427a106 100644 --- a/spring-security-rest-basic-auth/README.md +++ b/spring-security-rest-basic-auth/README.md @@ -7,6 +7,6 @@ This module contains articles about basic authentication in RESTful APIs with Sp The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [Basic Authentication with the RestTemplate](http://www.baeldung.com/how-to-use-resttemplate-with-basic-authentication-in-spring) -- [A Custom Filter in the Spring Security Filter Chain](http://www.baeldung.com/spring-security-custom-filter) -- [Spring Security Basic Authentication](http://www.baeldung.com/spring-security-basic-authentication) +- [Basic Authentication with the RestTemplate](https://www.baeldung.com/how-to-use-resttemplate-with-basic-authentication-in-spring) +- [A Custom Filter in the Spring Security Filter Chain](https://www.baeldung.com/spring-security-custom-filter) +- [Spring Security Basic Authentication](https://www.baeldung.com/spring-security-basic-authentication) diff --git a/spring-security-rest-custom/README.md b/spring-security-rest-custom/README.md index 846093b554..15cbc22b5f 100644 --- a/spring-security-rest-custom/README.md +++ b/spring-security-rest-custom/README.md @@ -6,6 +6,6 @@ This module contains articles about REST APIs with Spring Security The "REST With Spring" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [Spring Security Authentication Provider](http://www.baeldung.com/spring-security-authentication-provider) -- [Retrieve User Information in Spring Security](http://www.baeldung.com/get-user-in-spring-security) +- [Spring Security Authentication Provider](https://www.baeldung.com/spring-security-authentication-provider) +- [Retrieve User Information in Spring Security](https://www.baeldung.com/get-user-in-spring-security) - [Spring Security – Run-As Authentication](https://www.baeldung.com/spring-security-run-as-auth) diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md index c7ac45e38f..d61a52070c 100644 --- a/spring-security-rest/README.md +++ b/spring-security-rest/README.md @@ -8,10 +8,10 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [Spring REST Service Security](http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) -- [Setting Up Swagger 2 with a Spring REST API](http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) -- [Custom Error Message Handling for REST API](http://www.baeldung.com/global-error-handler-in-a-spring-rest-api) -- [Spring Security Context Propagation with @Async](http://www.baeldung.com/spring-security-async-principal-propagation) -- [Servlet 3 Async Support with Spring MVC and Spring Security](http://www.baeldung.com/spring-mvc-async-security) -- [Intro to Spring Security Expressions](http://www.baeldung.com/spring-security-expressions) -- [Spring Security for a REST API](http://www.baeldung.com/securing-a-restful-web-service-with-spring-security) +- [Spring REST Service Security](https://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/) +- [Setting Up Swagger 2 with a Spring REST API](https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) +- [Custom Error Message Handling for REST API](https://www.baeldung.com/global-error-handler-in-a-spring-rest-api) +- [Spring Security Context Propagation with @Async](https://www.baeldung.com/spring-security-async-principal-propagation) +- [Servlet 3 Async Support with Spring MVC and Spring Security](https://www.baeldung.com/spring-mvc-async-security) +- [Intro to Spring Security Expressions](https://www.baeldung.com/spring-security-expressions) +- [Spring Security for a REST API](https://www.baeldung.com/securing-a-restful-web-service-with-spring-security) diff --git a/spring-security-sso/README.md b/spring-security-sso/README.md index 31694bee45..23b53521be 100644 --- a/spring-security-sso/README.md +++ b/spring-security-sso/README.md @@ -3,5 +3,5 @@ This module contains modules about single-sign-on with Spring Security ### Relevant Articles: -- [Simple Single Sign-On with Spring Security OAuth2](http://www.baeldung.com/sso-spring-security-oauth2) +- [Simple Single Sign-On with Spring Security OAuth2](https://www.baeldung.com/sso-spring-security-oauth2) - [Spring Security Kerberos Integration](https://www.baeldung.com/spring-security-kerberos-integration) diff --git a/spring-security-stormpath/README.md b/spring-security-stormpath/README.md index abd65294a3..971d4cc858 100644 --- a/spring-security-stormpath/README.md +++ b/spring-security-stormpath/README.md @@ -4,4 +4,4 @@ This module contains articles about Spring Security with Stormpath ### Relevant articles -- [Spring Security with Stormpath](http://www.baeldung.com/spring-security-stormpath) +- [Spring Security with Stormpath](https://www.baeldung.com/spring-security-stormpath) diff --git a/spring-security-thymeleaf/README.MD b/spring-security-thymeleaf/README.MD index 67b811fac8..2ad7b9d2bd 100644 --- a/spring-security-thymeleaf/README.MD +++ b/spring-security-thymeleaf/README.MD @@ -4,4 +4,4 @@ This module contains articles about Spring Security with Thymeleaf ### Relevant Articles: -- [Spring Security with Thymeleaf](http://www.baeldung.com/spring-security-thymeleaf) +- [Spring Security with Thymeleaf](https://www.baeldung.com/spring-security-thymeleaf) diff --git a/spring-security-x509/README.md b/spring-security-x509/README.md index 2c0e25a229..b1eb0debf5 100644 --- a/spring-security-x509/README.md +++ b/spring-security-x509/README.md @@ -3,4 +3,4 @@ This module contains articles about X.509 authentication with Spring Security ### Relevant Articles: -- [X.509 Authentication in Spring Security](http://www.baeldung.com/x-509-authentication-in-spring-security) +- [X.509 Authentication in Spring Security](https://www.baeldung.com/x-509-authentication-in-spring-security) diff --git a/spring-sleuth/README.md b/spring-sleuth/README.md index 692fbaa8b7..ebaebde6c9 100644 --- a/spring-sleuth/README.md +++ b/spring-sleuth/README.md @@ -4,4 +4,4 @@ This module contains articles about Spring Cloud Sleuth ### Relevant articles: -- [Spring Cloud Sleuth in a Monolith Application](http://www.baeldung.com/spring-cloud-sleuth-single-application) +- [Spring Cloud Sleuth in a Monolith Application](https://www.baeldung.com/spring-cloud-sleuth-single-application) diff --git a/spring-social-login/README.md b/spring-social-login/README.md index c3ca867a95..2d97584e62 100644 --- a/spring-social-login/README.md +++ b/spring-social-login/README.md @@ -3,4 +3,4 @@ This module contains articles about Spring Social ### Relevant Articles: -- [A Secondary Facebook Login with Spring Social](http://www.baeldung.com/facebook-authentication-with-spring-security-and-social) +- [A Secondary Facebook Login with Spring Social](https://www.baeldung.com/facebook-authentication-with-spring-security-and-social) diff --git a/spring-spel/README.md b/spring-spel/README.md index f81d304e1a..2a1d900e38 100644 --- a/spring-spel/README.md +++ b/spring-spel/README.md @@ -3,4 +3,4 @@ This module contains articles about the Spring Expression Language (SpEL) ### Relevant Articles: -- [Spring Expression Language Guide](http://www.baeldung.com/spring-expression-language) +- [Spring Expression Language Guide](https://www.baeldung.com/spring-expression-language) diff --git a/spring-state-machine/README.md b/spring-state-machine/README.md index f80ef34ef8..dadb628572 100644 --- a/spring-state-machine/README.md +++ b/spring-state-machine/README.md @@ -4,4 +4,4 @@ This module contains articles about Spring State Machine ### Relevant articles -- [A Guide to the Spring State Machine Project](http://www.baeldung.com/spring-state-machine) +- [A Guide to the Spring State Machine Project](https://www.baeldung.com/spring-state-machine) diff --git a/spring-static-resources/README.md b/spring-static-resources/README.md index 8d77e6fe94..206421ed0e 100644 --- a/spring-static-resources/README.md +++ b/spring-static-resources/README.md @@ -3,7 +3,7 @@ This module contains articles about static resources with Spring ### Relevant Articles: -- [Cachable Static Assets with Spring MVC](http://www.baeldung.com/cachable-static-assets-with-spring-mvc) -- [Minification of JS and CSS Assets with Maven](http://www.baeldung.com/maven-minification-of-js-and-css-assets) -- [Serve Static Resources with Spring](http://www.baeldung.com/spring-mvc-static-resources) +- [Cachable Static Assets with Spring MVC](https://www.baeldung.com/cachable-static-assets-with-spring-mvc) +- [Minification of JS and CSS Assets with Maven](https://www.baeldung.com/maven-minification-of-js-and-css-assets) +- [Serve Static Resources with Spring](https://www.baeldung.com/spring-mvc-static-resources) - [Load a Resource as a String in Spring](https://www.baeldung.com/spring-load-resource-as-string) diff --git a/spring-swagger-codegen/README.md b/spring-swagger-codegen/README.md index dbcf2b3e8d..e375ae7594 100644 --- a/spring-swagger-codegen/README.md +++ b/spring-swagger-codegen/README.md @@ -4,4 +4,4 @@ This module contains articles about Spring with Swagger CodeGen ### Relevant articles -- [Generate Spring Boot REST Client with Swagger](http://www.baeldung.com/spring-boot-rest-client-swagger-codegen) +- [Generate Spring Boot REST Client with Swagger](https://www.baeldung.com/spring-boot-rest-client-swagger-codegen) diff --git a/spring-thymeleaf/README.md b/spring-thymeleaf/README.md index 88f3e35f8c..329ef8580c 100644 --- a/spring-thymeleaf/README.md +++ b/spring-thymeleaf/README.md @@ -3,20 +3,20 @@ This module contains articles about Spring with Thymeleaf ### Relevant Articles: -- [Introduction to Using Thymeleaf in Spring](http://www.baeldung.com/thymeleaf-in-spring-mvc) -- [CSRF Protection with Spring MVC and Thymeleaf](http://www.baeldung.com/csrf-thymeleaf-with-spring-security) -- [Thymeleaf: Custom Layout Dialect](http://www.baeldung.com/thymeleaf-spring-layouts) -- [Spring and Thymeleaf 3: Expressions](http://www.baeldung.com/spring-thymeleaf-3-expressions) -- [Spring MVC + Thymeleaf 3.0: New Features](http://www.baeldung.com/spring-thymeleaf-3) -- [How to Work with Dates in Thymeleaf](http://www.baeldung.com/dates-in-thymeleaf) -- [How to Create an Executable JAR with Maven](http://www.baeldung.com/executable-jar-with-maven) -- [Working with Boolean in Thymeleaf](http://www.baeldung.com/thymeleaf-boolean) -- [Working with Fragments in Thymeleaf](http://www.baeldung.com/spring-thymeleaf-fragments) -- [Conditionals in Thymeleaf](http://www.baeldung.com/spring-thymeleaf-conditionals) -- [Iteration in Thymeleaf](http://www.baeldung.com/thymeleaf-iteration) -- [Working With Arrays in Thymeleaf](http://www.baeldung.com/thymeleaf-arrays) -- [Spring with Thymeleaf Pagination for a List](http://www.baeldung.com/spring-thymeleaf-pagination) -- [Working with Select and Option in Thymeleaf](http://www.baeldung.com/thymeleaf-select-option) +- [Introduction to Using Thymeleaf in Spring](https://www.baeldung.com/thymeleaf-in-spring-mvc) +- [CSRF Protection with Spring MVC and Thymeleaf](https://www.baeldung.com/csrf-thymeleaf-with-spring-security) +- [Thymeleaf: Custom Layout Dialect](https://www.baeldung.com/thymeleaf-spring-layouts) +- [Spring and Thymeleaf 3: Expressions](https://www.baeldung.com/spring-thymeleaf-3-expressions) +- [Spring MVC + Thymeleaf 3.0: New Features](https://www.baeldung.com/spring-thymeleaf-3) +- [How to Work with Dates in Thymeleaf](https://www.baeldung.com/dates-in-thymeleaf) +- [How to Create an Executable JAR with Maven](https://www.baeldung.com/executable-jar-with-maven) +- [Working with Boolean in Thymeleaf](https://www.baeldung.com/thymeleaf-boolean) +- [Working with Fragments in Thymeleaf](https://www.baeldung.com/spring-thymeleaf-fragments) +- [Conditionals in Thymeleaf](https://www.baeldung.com/spring-thymeleaf-conditionals) +- [Iteration in Thymeleaf](https://www.baeldung.com/thymeleaf-iteration) +- [Working With Arrays in Thymeleaf](https://www.baeldung.com/thymeleaf-arrays) +- [Spring with Thymeleaf Pagination for a List](https://www.baeldung.com/spring-thymeleaf-pagination) +- [Working with Select and Option in Thymeleaf](https://www.baeldung.com/thymeleaf-select-option) - [Working With Custom HTML Attributes in Thymeleaf](https://www.baeldung.com/thymeleaf-custom-html-attributes) - [Spring Request Parameters with Thymeleaf](https://www.baeldung.com/spring-thymeleaf-request-parameters) - [[next -->]](/spring-thymeleaf-2) diff --git a/spring-vertx/README.md b/spring-vertx/README.md index e9557f330b..e310079ff4 100644 --- a/spring-vertx/README.md +++ b/spring-vertx/README.md @@ -3,4 +3,4 @@ This module contains articles about Spring with Vert.x ### Relevant Articles: -- [Vert.x Spring Integration](http://www.baeldung.com/spring-vertx) +- [Vert.x Spring Integration](https://www.baeldung.com/spring-vertx) diff --git a/spring-webflux-amqp/README.md b/spring-webflux-amqp/README.md index b7ac73b53d..20ddbe469a 100644 --- a/spring-webflux-amqp/README.md +++ b/spring-webflux-amqp/README.md @@ -4,4 +4,4 @@ This module contains articles about Spring WebFlux with AMQP ### Relevant Articles: -- [Spring AMQP in Reactive Applications](http://www.baeldung.com/spring-amqp-reactive) +- [Spring AMQP in Reactive Applications](https://www.baeldung.com/spring-amqp-reactive) diff --git a/spring-zuul/README.md b/spring-zuul/README.md index a2ea211195..e1067ebb9f 100644 --- a/spring-zuul/README.md +++ b/spring-zuul/README.md @@ -3,4 +3,4 @@ This module contains articles about Spring with Netflix Zuul ### Relevant Articles: -- [Spring REST with a Zuul Proxy](http://www.baeldung.com/spring-rest-with-zuul-proxy) +- [Spring REST with a Zuul Proxy](https://www.baeldung.com/spring-rest-with-zuul-proxy) diff --git a/static-analysis/README.md b/static-analysis/README.md index e3710831cf..235b79853b 100644 --- a/static-analysis/README.md +++ b/static-analysis/README.md @@ -4,5 +4,5 @@ This module contains articles about static program analysis ## Relevant articles: -- [Introduction to PMD](http://www.baeldung.com/pmd) -- [Java Static Analysis Tools in Eclipse and IntelliJ IDEA](http://www.baeldung.com/java-static-analysis-tools) +- [Introduction to PMD](https://www.baeldung.com/pmd) +- [Java Static Analysis Tools in Eclipse and IntelliJ IDEA](https://www.baeldung.com/java-static-analysis-tools) diff --git a/stripe/README.md b/stripe/README.md index a7134b9633..9e41dcf945 100644 --- a/stripe/README.md +++ b/stripe/README.md @@ -4,5 +4,5 @@ This module contains articles about Stripe ### Relevant articles -- [Introduction to the Stripe API for Java](http://www.baeldung.com/java-stripe-api) +- [Introduction to the Stripe API for Java](https://www.baeldung.com/java-stripe-api) diff --git a/structurizr/README.md b/structurizr/README.md index e596dfa458..15331228bd 100644 --- a/structurizr/README.md +++ b/structurizr/README.md @@ -1,2 +1,6 @@ +## Structurizr + +This module contains articles about Structurizr + ### Relevant Articles: -- [Intro to Structurizr](http://www.baeldung.com/structurizr) +- [Intro to Structurizr](https://www.baeldung.com/structurizr) diff --git a/struts-2/README.md b/struts-2/README.md index 8a1425ccb5..d15b94f662 100644 --- a/struts-2/README.md +++ b/struts-2/README.md @@ -1,3 +1,7 @@ +## Struts 2 + +This module contains articles about Struts 2 + ### Relevant articles -- [A Quick Struts 2 Intro](http://www.baeldung.com/struts-2-intro) +- [A Quick Struts 2 Intro](https://www.baeldung.com/struts-2-intro) diff --git a/tensorflow-java/README.md b/tensorflow-java/README.md index f826375ac1..b96e4a83db 100644 --- a/tensorflow-java/README.md +++ b/tensorflow-java/README.md @@ -1,3 +1,7 @@ +## Tensorflow + +This module contains articles about Tensorflow + ## Relevant articles: - [Introduction to Tensorflow for Java](https://www.baeldung.com/tensorflow-java) diff --git a/testing-modules/README.md b/testing-modules/README.md index 21fc87a67f..c6098d1210 100644 --- a/testing-modules/README.md +++ b/testing-modules/README.md @@ -1,4 +1,3 @@ - ## Testing Modules -This is a aggregator module containing several modules focused on testing libraries. +This is an aggregator module containing multiple modules focused on testing libraries. diff --git a/testing-modules/easymock/README.md b/testing-modules/easymock/README.md new file mode 100644 index 0000000000..c24ffa9099 --- /dev/null +++ b/testing-modules/easymock/README.md @@ -0,0 +1,3 @@ +## Relevant Articles + +- [Mocking a Void Method with EasyMock](https://www.baeldung.com/easymock-mocking-void-method) diff --git a/testing-modules/hamcrest/README.md b/testing-modules/hamcrest/README.md new file mode 100644 index 0000000000..f2ff6b996d --- /dev/null +++ b/testing-modules/hamcrest/README.md @@ -0,0 +1,12 @@ +## Hamcrest + +This module contains articles about Hamcrest + +### Relevant articles +- [Hamcrest Text Matchers](https://www.baeldung.com/hamcrest-text-matchers) +- [Hamcrest File Matchers](https://www.baeldung.com/hamcrest-file-matchers) +- [Hamcrest Object Matchers](https://www.baeldung.com/hamcrest-object-matchers) +- [Hamcrest Bean Matchers](https://www.baeldung.com/hamcrest-bean-matchers) +- [Hamcrest Number Matchers](https://www.baeldung.com/hamcrest-number-matchers) +- [Hamcrest Common Core Matchers](https://www.baeldung.com/hamcrest-core-matchers) +- [Hamcrest Custom Matchers](https://www.baeldung.com/hamcrest-custom-matchers) diff --git a/testing-modules/hamcrest/pom.xml b/testing-modules/hamcrest/pom.xml new file mode 100644 index 0000000000..2136702b3a --- /dev/null +++ b/testing-modules/hamcrest/pom.xml @@ -0,0 +1,29 @@ + + 4.0.0 + com.baeldung + hamcrest + 0.0.1-SNAPSHOT + hamcrest + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.hamcrest + java-hamcrest + ${hamcrest.version} + test + + + + + 2.0.0.0 + + diff --git a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/City.java b/testing-modules/hamcrest/src/main/java/com/baeldung/hamcrest/objectmatchers/City.java similarity index 94% rename from testing-modules/mockito/src/main/java/org/baeldung/hamcrest/City.java rename to testing-modules/hamcrest/src/main/java/com/baeldung/hamcrest/objectmatchers/City.java index d6369189c1..cc4fba8154 100644 --- a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/City.java +++ b/testing-modules/hamcrest/src/main/java/com/baeldung/hamcrest/objectmatchers/City.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest.objectmatchers; public class City extends Location { String name; diff --git a/testing-modules/hamcrest/src/main/java/com/baeldung/hamcrest/objectmatchers/Location.java b/testing-modules/hamcrest/src/main/java/com/baeldung/hamcrest/objectmatchers/Location.java new file mode 100644 index 0000000000..bb9c369c60 --- /dev/null +++ b/testing-modules/hamcrest/src/main/java/com/baeldung/hamcrest/objectmatchers/Location.java @@ -0,0 +1,4 @@ +package com.baeldung.hamcrest.objectmatchers; + +public class Location { +} diff --git a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestBeansUnitTest.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestBeansUnitTest.java similarity index 86% rename from testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestBeansUnitTest.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestBeansUnitTest.java index e7eb9bda1b..7f0c5290ba 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestBeansUnitTest.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestBeansUnitTest.java @@ -1,5 +1,6 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; +import com.baeldung.hamcrest.objectmatchers.City; import org.junit.Test; import java.beans.PropertyDescriptor; @@ -8,13 +9,7 @@ import java.util.List; import static java.util.stream.Collectors.toList; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.equalToIgnoringCase; -import static org.hamcrest.Matchers.samePropertyValuesAs; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.*; import static org.hamcrest.beans.PropertyUtil.getPropertyDescriptor; import static org.hamcrest.beans.PropertyUtil.propertyDescriptorsFor; diff --git a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestCoreMatchersUnitTest.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestCoreMatchersUnitTest.java similarity index 99% rename from testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestCoreMatchersUnitTest.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestCoreMatchersUnitTest.java index d66ed98e8d..5da6a77144 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestCoreMatchersUnitTest.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestCoreMatchersUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; import com.google.common.collect.Lists; @@ -145,7 +145,6 @@ public class HamcrestCoreMatchersUnitTest { @Test public void givenString_WhenContainsStringIgnoringCase_ThenCorrect() { - // GIVEN String testString = "hamcrest core"; @@ -164,7 +163,6 @@ public class HamcrestCoreMatchersUnitTest { assertThat(list, hasItem(isA(String.class))); } - @Test public void givenTestInput_WhenUsingHasItemsInCollection() { @@ -223,7 +221,6 @@ public class HamcrestCoreMatchersUnitTest { assertThat(testString, either(startsWith("Bael")).or(containsString("Core"))); } - @Test public void givenTestInput_WhenUsingEveryItemForMatchInCollection() { diff --git a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestFileUnitTest.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestFileUnitTest.java similarity index 72% rename from testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestFileUnitTest.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestFileUnitTest.java index 9973e325d6..73e2da52b5 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestFileUnitTest.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestFileUnitTest.java @@ -1,22 +1,13 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; -import static org.hamcrest.core.StringContains.containsString; -import static org.hamcrest.io.FileMatchers.aFileNamed; -import static org.hamcrest.io.FileMatchers.aFileWithAbsolutePath; -import static org.hamcrest.io.FileMatchers.aFileWithCanonicalPath; -import static org.hamcrest.io.FileMatchers.aFileWithSize; -import static org.hamcrest.io.FileMatchers.aReadableFile; -import static org.hamcrest.io.FileMatchers.aWritableFile; -import static org.hamcrest.io.FileMatchers.anExistingDirectory; -import static org.hamcrest.io.FileMatchers.anExistingFile; -import static org.hamcrest.io.FileMatchers.anExistingFileOrDirectory; -import static org.hamcrest.number.OrderingComparison.greaterThan; -import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase; -import static org.junit.Assert.assertThat; +import org.junit.Test; import java.io.File; -import org.junit.Test; +import static org.hamcrest.io.FileMatchers.*; +import static org.hamcrest.number.OrderingComparison.greaterThan; +import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase; +import static org.junit.Assert.assertThat; public class HamcrestFileUnitTest { diff --git a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestNumberUnitTest.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestNumberUnitTest.java similarity index 90% rename from testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestNumberUnitTest.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestNumberUnitTest.java index fbba6b94d2..d2b3392537 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestNumberUnitTest.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestNumberUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; import org.junit.Test; @@ -6,15 +6,7 @@ import java.math.BigDecimal; import java.time.LocalDate; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.closeTo; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.lessThan; -import static org.hamcrest.Matchers.lessThanOrEqualTo; -import static org.hamcrest.Matchers.comparesEqualTo; -import static org.hamcrest.Matchers.notANumber; +import static org.hamcrest.Matchers.*; public class HamcrestNumberUnitTest { diff --git a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestObjectUnitTest.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestObjectUnitTest.java similarity index 81% rename from testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestObjectUnitTest.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestObjectUnitTest.java index 8d30ff297b..c07fc422f6 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestObjectUnitTest.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestObjectUnitTest.java @@ -1,14 +1,11 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; +import com.baeldung.hamcrest.objectmatchers.City; +import com.baeldung.hamcrest.objectmatchers.Location; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasToString; -import static org.hamcrest.Matchers.equalToIgnoringCase; -import static org.hamcrest.Matchers.emptyOrNullString; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.typeCompatibleWith; -import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.*; public class HamcrestObjectUnitTest { diff --git a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestTextUnitTest.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestTextUnitTest.java similarity index 99% rename from testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestTextUnitTest.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestTextUnitTest.java index e336b1bba3..593fdf82b6 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestTextUnitTest.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/HamcrestTextUnitTest.java @@ -1,4 +1,6 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest; + +import org.junit.Test; import static org.hamcrest.core.StringContains.containsString; import static org.hamcrest.core.StringContains.containsStringIgnoringCase; @@ -16,8 +18,6 @@ import static org.hamcrest.text.MatchesPattern.matchesPattern; import static org.hamcrest.text.StringContainsInOrder.stringContainsInOrder; import static org.junit.Assert.assertThat; -import org.junit.Test; - public class HamcrestTextUnitTest { @Test diff --git a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestCustomUnitTest.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/HamcrestCustomUnitTest.java similarity index 82% rename from testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestCustomUnitTest.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/HamcrestCustomUnitTest.java index 6cc8692bc7..62c68d4561 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/hamcrest/HamcrestCustomUnitTest.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/HamcrestCustomUnitTest.java @@ -1,10 +1,10 @@ -package org.baeldung.hamcrest; +package com.baeldung.hamcrest.custommatchers; import org.junit.Test; -import static org.baeldung.hamcrest.custommatchers.IsDivisibleBy.divisibleBy; -import static org.baeldung.hamcrest.custommatchers.IsOnlyDigits.onlyDigits; -import static org.baeldung.hamcrest.custommatchers.IsUppercase.uppercase; +import static com.baeldung.hamcrest.custommatchers.IsDivisibleBy.divisibleBy; +import static com.baeldung.hamcrest.custommatchers.IsOnlyDigits.onlyDigits; +import static com.baeldung.hamcrest.custommatchers.IsUppercase.uppercase; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; diff --git a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/custommatchers/IsDivisibleBy.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/IsDivisibleBy.java similarity index 93% rename from testing-modules/mockito/src/main/java/org/baeldung/hamcrest/custommatchers/IsDivisibleBy.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/IsDivisibleBy.java index ea12ce0006..f865523be4 100644 --- a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/custommatchers/IsDivisibleBy.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/IsDivisibleBy.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest.custommatchers; +package com.baeldung.hamcrest.custommatchers; import org.hamcrest.Description; import org.hamcrest.Matcher; diff --git a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/custommatchers/IsOnlyDigits.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/IsOnlyDigits.java similarity index 92% rename from testing-modules/mockito/src/main/java/org/baeldung/hamcrest/custommatchers/IsOnlyDigits.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/IsOnlyDigits.java index 7515dfbf6d..f113c92983 100644 --- a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/custommatchers/IsOnlyDigits.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/IsOnlyDigits.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest.custommatchers; +package com.baeldung.hamcrest.custommatchers; import org.hamcrest.Description; import org.hamcrest.Matcher; diff --git a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/custommatchers/IsUppercase.java b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/IsUppercase.java similarity index 91% rename from testing-modules/mockito/src/main/java/org/baeldung/hamcrest/custommatchers/IsUppercase.java rename to testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/IsUppercase.java index 859e7006b7..4ffacd939c 100644 --- a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/custommatchers/IsUppercase.java +++ b/testing-modules/hamcrest/src/test/java/com/baeldung/hamcrest/custommatchers/IsUppercase.java @@ -1,4 +1,4 @@ -package org.baeldung.hamcrest.custommatchers; +package com.baeldung.hamcrest.custommatchers; import org.hamcrest.Description; import org.hamcrest.Matcher; diff --git a/testing-modules/mockito/src/test/resources/test1.in b/testing-modules/hamcrest/src/test/resources/test1.in similarity index 100% rename from testing-modules/mockito/src/test/resources/test1.in rename to testing-modules/hamcrest/src/test/resources/test1.in diff --git a/testing-modules/junit-4/README.md b/testing-modules/junit-4/README.md index dd975daf58..d19a0a1e47 100644 --- a/testing-modules/junit-4/README.md +++ b/testing-modules/junit-4/README.md @@ -3,3 +3,4 @@ - [Guide to JUnit 4 Rules](https://www.baeldung.com/junit-4-rules) - [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) diff --git a/testing-modules/junit-5/README.md b/testing-modules/junit-5/README.md index 14e018a5f9..676d2f2f03 100644 --- a/testing-modules/junit-5/README.md +++ b/testing-modules/junit-5/README.md @@ -1,14 +1,8 @@ ### Relevant Articles: -- [A Guide to @RepeatedTest in Junit 5](http://www.baeldung.com/junit-5-repeated-test) -- [Guide to Dynamic Tests in Junit 5](http://www.baeldung.com/junit5-dynamic-tests) -- [A Guide to JUnit 5 Extensions](http://www.baeldung.com/junit-5-extensions) -- [Inject Parameters into JUnit Jupiter Unit Tests](http://www.baeldung.com/junit-5-parameters) -- [Mockito and JUnit 5 – Using ExtendWith](http://www.baeldung.com/mockito-junit-5-extension) -- [JUnit5 Programmatic Extension Registration with @RegisterExtension](http://www.baeldung.com/junit-5-registerextension-annotation) -- [The Order of Tests in JUnit](http://www.baeldung.com/junit-5-test-order) +- [A Guide to JUnit 5 Extensions](https://www.baeldung.com/junit-5-extensions) +- [Inject Parameters into JUnit Jupiter Unit Tests](https://www.baeldung.com/junit-5-parameters) +- [Mockito and JUnit 5 – Using ExtendWith](https://www.baeldung.com/mockito-junit-5-extension) +- [The Order of Tests in JUnit](https://www.baeldung.com/junit-5-test-order) - [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java) - [Testing an Abstract Class With JUnit](https://www.baeldung.com/junit-test-abstract-class) -- [A Quick JUnit vs TestNG Comparison](http://www.baeldung.com/junit-vs-testng) -- [Guide to JUnit 5 Parameterized Tests](https://www.baeldung.com/parameterized-tests-junit-5) -- [JUnit 5 Conditional Test Execution with Annotations](https://www.baeldung.com/junit-5-conditional-test-execution) -- [Assertions in JUnit 4 and JUnit 5](http://www.baeldung.com/junit-assertions) +- [Guide to Dynamic Tests in Junit 5](https://www.baeldung.com/junit5-dynamic-tests) diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index b3074635a7..96944b4dc6 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -26,11 +26,6 @@ junit-jupiter-engine ${junit.jupiter.version} - - org.junit.jupiter - junit-jupiter-params - ${junit.jupiter.version} - org.junit.jupiter junit-jupiter-api diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/DynamicTestsExample.java b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/DynamicTestsUnitTest.java similarity index 97% rename from testing-modules/junit-5/src/test/java/com/baeldung/DynamicTestsExample.java rename to testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/DynamicTestsUnitTest.java index b684f3603f..8b3087497b 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/DynamicTestsExample.java +++ b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/DynamicTestsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.dynamictests; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -17,10 +17,8 @@ import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; import org.junit.jupiter.api.function.ThrowingConsumer; -import com.baeldung.helpers.Employee; -import com.baeldung.helpers.EmployeeDao; -public class DynamicTestsExample { +public class DynamicTestsUnitTest { @TestFactory Collection dynamicTestsWithCollection() { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/Employee.java b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/Employee.java new file mode 100644 index 0000000000..4b58a71135 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/Employee.java @@ -0,0 +1,38 @@ +package com.baeldung.dynamictests; + +public class Employee { + + private long id; + private String firstName; + + public Employee(long id) { + this.id = id; + this.firstName = ""; + } + + public Employee(long id, String firstName) { + this.id = id; + this.firstName = firstName; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @Override + public String toString() { + return "Employee [id=" + id + ", firstName=" + firstName + "]"; + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/EmployeeDao.java b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/EmployeeDao.java new file mode 100644 index 0000000000..4e2d9a5140 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/dynamictests/EmployeeDao.java @@ -0,0 +1,16 @@ +package com.baeldung.dynamictests; + +public class EmployeeDao { + + public Employee save(long id) { + return new Employee(id); + } + + public Employee save(long id, String firstName) { + return new Employee(id, firstName); + } + + public Employee update(Employee employee) { + return employee; + } +} diff --git a/testing-modules/junit5-annotations/README.md b/testing-modules/junit5-annotations/README.md new file mode 100644 index 0000000000..53819dbec5 --- /dev/null +++ b/testing-modules/junit5-annotations/README.md @@ -0,0 +1,9 @@ +## Junit 5 Annotations + +This module contains articles about Junit 5 Annotations + +### Relevant Articles: +- [A Guide to @RepeatedTest in Junit 5](https://www.baeldung.com/junit-5-repeated-test) +- [JUnit 5 Conditional Test Execution with Annotations](https://www.baeldung.com/junit-5-conditional-test-execution) +- [JUnit5 Programmatic Extension Registration with @RegisterExtension](https://www.baeldung.com/junit-5-registerextension-annotation) +- [Guide to JUnit 5 Parameterized Tests](https://www.baeldung.com/parameterized-tests-junit-5) diff --git a/testing-modules/junit5-annotations/pom.xml b/testing-modules/junit5-annotations/pom.xml new file mode 100644 index 0000000000..c8abfe909d --- /dev/null +++ b/testing-modules/junit5-annotations/pom.xml @@ -0,0 +1,57 @@ + + + 4.0.0 + junit5-annotations + 1.0-SNAPSHOT + junit5-annotations + Intro to JUnit 5 + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../../ + + + + + org.junit.platform + junit-platform-engine + ${junit.platform.version} + + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + + + org.junit.jupiter + junit-jupiter-params + ${junit.jupiter.version} + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + + + org.apache.logging.log4j + log4j-core + ${log4j2.version} + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + + + 5.4.2 + 1.4.2 + 2.8.2 + + + diff --git a/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/LoggingExtension.java b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/LoggingExtension.java new file mode 100644 index 0000000000..5de49e028b --- /dev/null +++ b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/LoggingExtension.java @@ -0,0 +1,18 @@ +package com.baeldung.junit5.registerextension; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestInstancePostProcessor; + +public class LoggingExtension implements TestInstancePostProcessor { + + @Override + public void postProcessTestInstance(Object testInstance, ExtensionContext context) throws Exception { + Logger logger = LogManager.getLogger(testInstance.getClass()); + testInstance.getClass() + .getMethod("setLogger", Logger.class) + .invoke(testInstance, logger); + } + +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/extensions/RegisterExtensionSampleExtension.java b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java similarity index 95% rename from testing-modules/junit-5/src/test/java/com/baeldung/extensions/RegisterExtensionSampleExtension.java rename to testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java index 64f4d8fd3e..5339f98875 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/extensions/RegisterExtensionSampleExtension.java +++ b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/registerextension/RegisterExtensionSampleExtension.java @@ -1,4 +1,4 @@ -package com.baeldung.extensions; +package com.baeldung.junit5.registerextension; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/RepeatedTestExample.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java similarity index 95% rename from testing-modules/junit-5/src/test/java/com/baeldung/RepeatedTestExample.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java index 749d7064bc..f9121d8790 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/RepeatedTestExample.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/RepeatedTestAnnotationUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.junit5; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -8,7 +8,7 @@ import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.RepetitionInfo; import org.junit.jupiter.api.TestInfo; -public class RepeatedTestExample { +public class RepeatedTestAnnotationUnitTest { @BeforeEach void beforeEachTest() { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/conditional/ConditionalAnnotationsUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java similarity index 98% rename from testing-modules/junit-5/src/test/java/com/baeldung/conditional/ConditionalAnnotationsUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java index ec76bd1488..ddceb78cac 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/conditional/ConditionalAnnotationsUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.conditional; +package com.baeldung.junit5.conditional; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/BlankStringsArgumentsProvider.java similarity index 92% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/BlankStringsArgumentsProvider.java index 1d2c76d37b..6c626efa40 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/BlankStringsArgumentsProvider.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.params.provider.Arguments; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/EnumsUnitTest.java similarity index 97% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/EnumsUnitTest.java index 0b2068dbf1..1e3bbcc772 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/EnumsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/LocalDateUnitTest.java similarity index 92% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/LocalDateUnitTest.java index 95487705f5..d411fcb7e2 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/LocalDateUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.converter.ConvertWith; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Numbers.java similarity index 72% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Numbers.java index 8a9b229aac..094da6de05 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Numbers.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; public class Numbers { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/NumbersUnitTest.java similarity index 89% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/NumbersUnitTest.java index b3a3371bb2..76ebf93f93 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/NumbersUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Person.java similarity index 92% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Person.java index 225f11ba29..c635b2e4da 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Person.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; class Person { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonAggregator.java similarity index 93% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonAggregator.java index df2ddc9e66..c899115df8 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonAggregator.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.params.aggregator.ArgumentsAccessor; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonUnitTest.java similarity index 96% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonUnitTest.java index b30ecc748e..62a2f32a63 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/PersonUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.aggregator.AggregateWith; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/SlashyDateConverter.java similarity index 95% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/SlashyDateConverter.java index 40773d29a9..d96fbce121 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/SlashyDateConverter.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.params.converter.ArgumentConversionException; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringParams.java similarity index 78% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringParams.java index bc9f881bd4..022fb797a4 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringParams.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import java.util.stream.Stream; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Strings.java similarity index 74% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Strings.java index f8e29f6b7f..5ee29339d7 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/Strings.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; class Strings { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringsUnitTest.java similarity index 97% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringsUnitTest.java index 6aea7668f1..064f305295 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/StringsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.*; @@ -44,7 +44,7 @@ class StringsUnitTest { } @ParameterizedTest - @MethodSource("com.baeldung.parameterized.StringParams#blankStrings") + @MethodSource("com.baeldung.junit5.parameterized.StringParams#blankStrings") void isBlank_ShouldReturnTrueForNullOrBlankStringsExternalSource(String input) { assertTrue(Strings.isBlank(input)); } diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableArgumentsProvider.java similarity index 96% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableArgumentsProvider.java index a96d01e854..af10860f6a 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableArgumentsProvider.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.params.provider.Arguments; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableSource.java similarity index 90% rename from testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableSource.java index 9c1d07c1be..11187a4865 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/parameterized/VariableSource.java @@ -1,4 +1,4 @@ -package com.baeldung.parameterized; +package com.baeldung.junit5.parameterized; import org.junit.jupiter.params.provider.ArgumentsSource; diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/RegisterExtensionUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/registerextension/RegisterExtensionUnitTest.java similarity index 86% rename from testing-modules/junit-5/src/test/java/com/baeldung/RegisterExtensionUnitTest.java rename to testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/registerextension/RegisterExtensionUnitTest.java index 721cfdb013..7b787f96d0 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/RegisterExtensionUnitTest.java +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/registerextension/RegisterExtensionUnitTest.java @@ -1,6 +1,6 @@ -package com.baeldung; +package com.baeldung.junit5.registerextension; -import com.baeldung.extensions.RegisterExtensionSampleExtension; +import com.baeldung.junit5.registerextension.RegisterExtensionSampleExtension; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/testing-modules/junit-5/src/test/resources/data.csv b/testing-modules/junit5-annotations/src/test/resources/data.csv similarity index 100% rename from testing-modules/junit-5/src/test/resources/data.csv rename to testing-modules/junit5-annotations/src/test/resources/data.csv diff --git a/testing-modules/junit5-migration/README.md b/testing-modules/junit5-migration/README.md index b97ff8255c..e6ad4f376c 100644 --- a/testing-modules/junit5-migration/README.md +++ b/testing-modules/junit5-migration/README.md @@ -1,2 +1,6 @@ - This is the code for the Junit 4 - Junit 5 Migration E-book. + +### Relevant Articles: +- [Junit 5 Migration](https://www.baeldung.com/junit-5-migration) +- [A Quick JUnit vs TestNG Comparison](https://www.baeldung.com/junit-vs-testng) +- [Assertions in JUnit 4 and JUnit 5](https://www.baeldung.com/junit-assertions) diff --git a/testing-modules/junit-5/src/main/java/com/baeldung/junit5vstestng/Calculator.java b/testing-modules/junit5-migration/src/main/java/com/baeldung/junit5vstestng/Calculator.java similarity index 100% rename from testing-modules/junit-5/src/main/java/com/baeldung/junit5vstestng/Calculator.java rename to testing-modules/junit5-migration/src/main/java/com/baeldung/junit5vstestng/Calculator.java diff --git a/testing-modules/junit-5/src/main/java/com/baeldung/junit5vstestng/DivideByZeroException.java b/testing-modules/junit5-migration/src/main/java/com/baeldung/junit5vstestng/DivideByZeroException.java similarity index 100% rename from testing-modules/junit-5/src/main/java/com/baeldung/junit5vstestng/DivideByZeroException.java rename to testing-modules/junit5-migration/src/main/java/com/baeldung/junit5vstestng/DivideByZeroException.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit4vstestng/SortedUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit4vstestng/SummationServiceIntegrationTest.java diff --git a/testing-modules/junit-4/src/test/java/com/baeldung/junit/AssertionsUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit4AssertionsUnitTest.java similarity index 96% rename from testing-modules/junit-4/src/test/java/com/baeldung/junit/AssertionsUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit4AssertionsUnitTest.java index b0209b01aa..7e74c2dace 100644 --- a/testing-modules/junit-4/src/test/java/com/baeldung/junit/AssertionsUnitTest.java +++ b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit4AssertionsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.junit; +package com.baeldung.junit5vsjunit4assertions; import org.junit.Test; @@ -10,7 +10,7 @@ import static org.junit.Assert.*; /** * Unit test that demonstrate the different assertions available within JUnit 4 */ -public class AssertionsUnitTest { +public class Junit4AssertionsUnitTest { @Test public void whenAssertingEquality_thenEqual() { diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/AssertionUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit5AssertionsUnitTest.java similarity index 98% rename from testing-modules/junit-5/src/test/java/com/baeldung/AssertionUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit5AssertionsUnitTest.java index f1f7c531f2..40b9143a71 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/AssertionUnitTest.java +++ b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vsjunit4assertions/Junit5AssertionsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.junit5vsjunit4assertions; import static java.time.Duration.ofSeconds; import static java.util.Arrays.asList; @@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test; * Unit test that demonstrate the different assertions available within JUnit 4 */ @DisplayName("Test case for assertions") -public class AssertionUnitTest { +public class Junit5AssertionsUnitTest { @Test @DisplayName("Arrays should be equals") diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/CalculatorUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/CalculatorUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/CalculatorUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/CalculatorUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/Class1UnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/Class1UnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/Class1UnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/Class1UnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/Class2UnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/Class2UnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/Class2UnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/Class2UnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/CustomNameUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/CustomNameUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/CustomNameUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/CustomNameUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/ParameterizedUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/ParameterizedUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/ParameterizedUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/ParameterizedUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/PizzaDeliveryStrategy.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/PizzaDeliveryStrategy.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/PizzaDeliveryStrategy.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/PizzaDeliveryStrategy.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SelectClassesSuiteUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectClassesSuiteUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SelectClassesSuiteUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectClassesSuiteUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SelectPackagesSuiteUnitTest.java diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SummationServiceUnitTest.java b/testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SummationServiceUnitTest.java similarity index 100% rename from testing-modules/junit-5/src/test/java/com/baeldung/junit5vstestng/SummationServiceUnitTest.java rename to testing-modules/junit5-migration/src/test/java/com/baeldung/junit5vstestng/SummationServiceUnitTest.java diff --git a/testing-modules/mockito-2/README.md b/testing-modules/mockito-2/README.md index 5c9e8fc81a..1d1bd6af7c 100644 --- a/testing-modules/mockito-2/README.md +++ b/testing-modules/mockito-2/README.md @@ -1,5 +1,7 @@ ### Relevant articles -- [Mockito’s Java 8 Features](http://www.baeldung.com/mockito-2-java-8) -- [Lazy Verification with Mockito 2](http://www.baeldung.com/mockito-2-lazy-verification) +- [Mockito’s Java 8 Features](https://www.baeldung.com/mockito-2-java-8) +- [Lazy Verification with Mockito 2](https://www.baeldung.com/mockito-2-lazy-verification) - [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) diff --git a/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/BDDMockitoUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/bddmockito/BDDMockitoUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/bddmockito/BDDMockitoUnitTest.java rename to testing-modules/mockito-2/src/test/java/com/baeldung/mockito/bddmockito/BDDMockitoUnitTest.java index 977a60933f..fd7f04870b 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/BDDMockitoUnitTest.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/bddmockito/BDDMockitoUnitTest.java @@ -1,7 +1,4 @@ -package org.baeldung.bddmockito; - -import static org.junit.Assert.fail; -import static org.mockito.BDDMockito.*; +package com.baeldung.mockito.bddmockito; import org.junit.Assert; import org.junit.Before; @@ -9,6 +6,9 @@ import org.junit.Test; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; +import static org.junit.Assert.fail; +import static org.mockito.BDDMockito.*; + public class BDDMockitoUnitTest { diff --git a/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/PhoneBookRepository.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/bddmockito/PhoneBookRepository.java similarity index 93% rename from testing-modules/mockito/src/test/java/org/baeldung/bddmockito/PhoneBookRepository.java rename to testing-modules/mockito-2/src/test/java/com/baeldung/mockito/bddmockito/PhoneBookRepository.java index 94d4a90d4b..dd44e5e3cc 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/PhoneBookRepository.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/bddmockito/PhoneBookRepository.java @@ -1,4 +1,4 @@ -package org.baeldung.bddmockito; +package com.baeldung.mockito.bddmockito; public interface PhoneBookRepository { diff --git a/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/PhoneBookService.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/bddmockito/PhoneBookService.java similarity index 95% rename from testing-modules/mockito/src/test/java/org/baeldung/bddmockito/PhoneBookService.java rename to testing-modules/mockito-2/src/test/java/com/baeldung/mockito/bddmockito/PhoneBookService.java index 8fc49b026d..b96cf4efb7 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/bddmockito/PhoneBookService.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/bddmockito/PhoneBookService.java @@ -1,4 +1,4 @@ -package org.baeldung.bddmockito; +package com.baeldung.mockito.bddmockito; public class PhoneBookService { diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/java8/LazyVerificationUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/lazyverification/LazyVerificationUnitTest.java similarity index 95% rename from testing-modules/mockito-2/src/test/java/com/baeldung/mockito/java8/LazyVerificationUnitTest.java rename to testing-modules/mockito-2/src/test/java/com/baeldung/mockito/lazyverification/LazyVerificationUnitTest.java index 0e6921c7a1..c7a9d84191 100644 --- a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/java8/LazyVerificationUnitTest.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/lazyverification/LazyVerificationUnitTest.java @@ -1,16 +1,16 @@ -package com.baeldung.mockito.java8; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import java.util.List; +package com.baeldung.mockito.lazyverification; import org.junit.Test; import org.mockito.exceptions.base.MockitoAssertionError; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.VerificationCollector; +import java.util.List; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + public class LazyVerificationUnitTest { @Test diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/misusing/MockitoMisusingUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/spy/MockitoMisusingUnitTest.java similarity index 96% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/misusing/MockitoMisusingUnitTest.java rename to testing-modules/mockito-2/src/test/java/com/baeldung/mockito/spy/MockitoMisusingUnitTest.java index 306f53297a..ea12061fc6 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/misusing/MockitoMisusingUnitTest.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/spy/MockitoMisusingUnitTest.java @@ -1,11 +1,4 @@ -package org.baeldung.mockito.misusing; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; -import static org.junit.jupiter.api.Assertions.fail; - -import java.util.ArrayList; -import java.util.List; +package com.baeldung.mockito.spy; import org.junit.After; import org.junit.Test; @@ -13,6 +6,13 @@ import org.mockito.Mockito; import org.mockito.exceptions.misusing.NotAMockException; import org.mockito.internal.progress.ThreadSafeMockingProgress; +import java.util.ArrayList; +import java.util.List; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; + public class MockitoMisusingUnitTest { @After diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/MockitoSpyUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/spy/MockitoSpyUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/MockitoSpyUnitTest.java rename to testing-modules/mockito-2/src/test/java/com/baeldung/mockito/spy/MockitoSpyUnitTest.java index 068a4c6de9..d4696e482b 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/spy/MockitoSpyUnitTest.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/spy/MockitoSpyUnitTest.java @@ -1,9 +1,4 @@ -package org.baeldung.mockito.spy; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; +package com.baeldung.mockito.spy; import org.junit.Test; import org.junit.runner.RunWith; @@ -11,6 +6,11 @@ import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + @RunWith(MockitoJUnitRunner.class) public class MockitoSpyUnitTest { diff --git a/testing-modules/mockito/README.md b/testing-modules/mockito/README.md index 9c6407f9da..6b8f53ffee 100644 --- a/testing-modules/mockito/README.md +++ b/testing-modules/mockito/README.md @@ -4,23 +4,13 @@ ### Relevant Articles: -- [Mockito Verify Cookbook](http://www.baeldung.com/mockito-verify) -- [Mockito When/Then Cookbook](http://www.baeldung.com/mockito-behavior) -- [Mockito – Using Spies](http://www.baeldung.com/mockito-spy) -- [Getting Started with Mockito @Mock, @Spy, @Captor and @InjectMocks](http://www.baeldung.com/mockito-annotations) -- [Mockito’s Mock Methods](http://www.baeldung.com/mockito-mock-methods) -- [Introduction to PowerMock](http://www.baeldung.com/intro-to-powermock) -- [Mocking Exception Throwing using Mockito](http://www.baeldung.com/mockito-exceptions) -- [Mocking Void Methods with Mockito](http://www.baeldung.com/mockito-void-methods) -- [Mocking of Private Methods Using PowerMock](http://www.baeldung.com/powermock-private-method) -- [Mock Final Classes and Methods with Mockito](http://www.baeldung.com/mockito-final) -- [Hamcrest Custom Matchers](http://www.baeldung.com/hamcrest-custom-matchers) -- [Hamcrest Common Core Matchers](http://www.baeldung.com/hamcrest-core-matchers) -- [Testing Callbacks with Mockito](http://www.baeldung.com/mockito-callbacks) -- [Using Hamcrest Number Matchers](https://www.baeldung.com/hamcrest-number-matchers) -- [Quick Guide to BDDMockito](http://www.baeldung.com/bdd-mockito) -- [Hamcrest Bean Matchers](http://www.baeldung.com/hamcrest-bean-matchers) -- [Hamcrest Object Matchers](http://www.baeldung.com/hamcrest-object-matchers) -- [Hamcrest File Matchers](https://www.baeldung.com/hamcrest-file-matchers) -- [Hamcrest Text Matchers](http://www.baeldung.com/hamcrest-text-matchers) -- [Testing Callbacks with Mockito](http://www.baeldung.com/mockito-callbacks) +- [Mockito Verify Cookbook](https://www.baeldung.com/mockito-verify) +- [Mockito When/Then Cookbook](https://www.baeldung.com/mockito-behavior) +- [Getting Started with Mockito @Mock, @Spy, @Captor and @InjectMocks](https://www.baeldung.com/mockito-annotations) +- [Mockito’s Mock Methods](https://www.baeldung.com/mockito-mock-methods) +- [Introduction to PowerMock](https://www.baeldung.com/intro-to-powermock) +- [Mocking of Private Methods Using PowerMock](https://www.baeldung.com/powermock-private-method) +- [Mocking Exception Throwing using Mockito](https://www.baeldung.com/mockito-exceptions) +- [Mocking Void Methods with Mockito](https://www.baeldung.com/mockito-void-methods) +- [Mock Final Classes and Methods with Mockito](https://www.baeldung.com/mockito-final) +- [Testing Callbacks with Mockito](https://www.baeldung.com/mockito-callbacks) diff --git a/testing-modules/mockito/pom.xml b/testing-modules/mockito/pom.xml index f307b80370..e0f32d88bf 100644 --- a/testing-modules/mockito/pom.xml +++ b/testing-modules/mockito/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - org.baeldung + com.baeldung mockito 0.1-SNAPSHOT mockito @@ -58,12 +58,6 @@ ${powermock.version} test - - org.hamcrest - java-hamcrest - ${hamcrest.version} - - org.springframework.boot spring-boot-starter diff --git a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/ActionHandler.java b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/ActionHandler.java similarity index 93% rename from testing-modules/mockito/src/main/java/org/baeldung/mockito/service/ActionHandler.java rename to testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/ActionHandler.java index 289dcff399..d70fc2b690 100644 --- a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/ActionHandler.java +++ b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/ActionHandler.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito.service; +package com.baeldung.mockito.callbacks; public class ActionHandler { diff --git a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Callback.java b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Callback.java similarity index 61% rename from testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Callback.java rename to testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Callback.java index fb8d01ce2e..cc6180c249 100644 --- a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Callback.java +++ b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Callback.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito.service; +package com.baeldung.mockito.callbacks; public interface Callback { diff --git a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Data.java b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Data.java similarity index 82% rename from testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Data.java rename to testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Data.java index 665c05382c..9549995469 100644 --- a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Data.java +++ b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Data.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito.service; +package com.baeldung.mockito.callbacks; public class Data { diff --git a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Response.java b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Response.java similarity index 90% rename from testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Response.java rename to testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Response.java index 22474a5ba7..03aded3895 100644 --- a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Response.java +++ b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Response.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito.service; +package com.baeldung.mockito.callbacks; public class Response { diff --git a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Service.java b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Service.java similarity index 70% rename from testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Service.java rename to testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Service.java index 63434e53fb..d9f1a44422 100644 --- a/testing-modules/mockito/src/main/java/org/baeldung/mockito/service/Service.java +++ b/testing-modules/mockito/src/main/java/com/baeldung/mockito/callbacks/Service.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito.service; +package com.baeldung.mockito.callbacks; public interface Service { diff --git a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/Location.java b/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/Location.java deleted file mode 100644 index 52561d07dc..0000000000 --- a/testing-modules/mockito/src/main/java/org/baeldung/hamcrest/Location.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.baeldung.hamcrest; - -public class Location { -} diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/FinalList.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/FinalList.java similarity index 56% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/FinalList.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/FinalList.java index e01f189f0b..27b7534978 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/FinalList.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/FinalList.java @@ -1,6 +1,4 @@ -package org.baeldung.mockito; - -import org.baeldung.mockito.voidmethods.MyList; +package com.baeldung.mockito; public final class FinalList extends MyList { diff --git a/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockFinals.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockFinals.java new file mode 100644 index 0000000000..6ff791ae06 --- /dev/null +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockFinals.java @@ -0,0 +1,35 @@ +package com.baeldung.mockito; + +import org.junit.Test; + +import static org.junit.Assert.assertNotEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class MockFinals { + + @Test + public void whenMockFinalClassMockWorks() { + + FinalList finalList = new FinalList(); + + FinalList mock = mock(FinalList.class); + when(mock.size()).thenReturn(2); + + assertNotEquals(mock.size(), finalList.size()); + + } + + @Test + public void whenMockFinalMethodMockWorks() { + + MyList myList = new MyList(); + + MyList mock = mock(MyList.class); + when(mock.finalMethod()).thenReturn(1); + + assertNotEquals(mock.finalMethod(), myList.finalMethod()); + } + + + } diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockFinalsUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockFinalsUnitTest.java similarity index 90% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockFinalsUnitTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/MockFinalsUnitTest.java index 000774592c..bb03fca06f 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockFinalsUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockFinalsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; import org.junit.Test; @@ -6,7 +6,7 @@ import static org.junit.Assert.assertNotEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.baeldung.mockito.voidmethods.MyList; +import com.baeldung.mockito.MyList; public class MockFinalsUnitTest { diff --git a/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationIntegrationTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationIntegrationTest.java new file mode 100644 index 0000000000..94054d1cbb --- /dev/null +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationIntegrationTest.java @@ -0,0 +1,114 @@ +package com.baeldung.mockito; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +//@RunWith(MockitoJUnitRunner.class) +public class MockitoAnnotationIntegrationTest { + + @Mock + private List mockedList; + + @Spy + private List spiedList = new ArrayList<>(); + + @Before + public void init() { + MockitoAnnotations.initMocks(this); + } + + // tests + + @Test + public void whenNotUseMockAnnotation_thenCorrect() { + final List mockList = Mockito.mock(List.class); + mockList.add("one"); + Mockito.verify(mockList).add("one"); + assertEquals(0, mockList.size()); + + Mockito.when(mockList.size()).thenReturn(100); + assertEquals(100, mockList.size()); + } + + @Test + public void whenUseMockAnnotation_thenMockIsInjected() { + mockedList.add("one"); + Mockito.verify(mockedList).add("one"); + assertEquals(0, mockedList.size()); + + Mockito.when(mockedList.size()).thenReturn(100); + assertEquals(100, mockedList.size()); + } + + @Test + public void whenNotUseSpyAnnotation_thenCorrect() { + final List spyList = Mockito.spy(new ArrayList()); + spyList.add("one"); + spyList.add("two"); + + Mockito.verify(spyList).add("one"); + Mockito.verify(spyList).add("two"); + + assertEquals(2, spyList.size()); + + Mockito.doReturn(100).when(spyList).size(); + assertEquals(100, spyList.size()); + } + + @Test + public void whenUseSpyAnnotation_thenSpyIsInjectedCorrectly() { + spiedList.add("one"); + spiedList.add("two"); + + Mockito.verify(spiedList).add("one"); + Mockito.verify(spiedList).add("two"); + + assertEquals(2, spiedList.size()); + + Mockito.doReturn(100).when(spiedList).size(); + assertEquals(100, spiedList.size()); + } + + @Test + public void whenNotUseCaptorAnnotation_thenCorrect() { + final List mockList = Mockito.mock(List.class); + final ArgumentCaptor arg = ArgumentCaptor.forClass(String.class); + mockList.add("one"); + Mockito.verify(mockList).add(arg.capture()); + + assertEquals("one", arg.getValue()); + } + + @Captor + private + ArgumentCaptor argCaptor; + + @Test + public void whenUseCaptorAnnotation_thenTheSam() { + mockedList.add("one"); + Mockito.verify(mockedList).add(argCaptor.capture()); + + assertEquals("one", argCaptor.getValue()); + } + + @Mock + private Map wordMap; + + @InjectMocks + private MyDictionary dic = new MyDictionary(); + + @Test + public void whenUseInjectMocksAnnotation_thenCorrect() { + Mockito.when(wordMap.get("aWord")).thenReturn("aMeaning"); + + assertEquals("aMeaning", dic.getMeaning("aWord")); + } + +} diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationUnitTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationUnitTest.java index 6bc0e69e65..731183bae2 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; import org.junit.Before; import org.junit.Test; diff --git a/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoConfigExamplesIntegrationTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoConfigExamplesIntegrationTest.java new file mode 100644 index 0000000000..5d3c009edc --- /dev/null +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoConfigExamplesIntegrationTest.java @@ -0,0 +1,95 @@ +package com.baeldung.mockito; + +import org.junit.Test; +import org.mockito.Mockito; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyInt; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.*; + +public class MockitoConfigExamplesIntegrationTest { + + // tests + + @Test + public final void whenMockReturnBehaviorIsConfigured_thenBehaviorIsVerified() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false); + + final boolean added = listMock.add(randomAlphabetic(6)); + assertThat(added, is(false)); + } + + @Test + public final void whenMockReturnBehaviorIsConfigured2_thenBehaviorIsVerified() { + final MyList listMock = Mockito.mock(MyList.class); + doReturn(false).when(listMock).add(anyString()); + + final boolean added = listMock.add(randomAlphabetic(6)); + assertThat(added, is(false)); + } + + @Test(expected = IllegalStateException.class) + public final void givenMethodIsConfiguredToThrowException_whenCallingMethod_thenExceptionIsThrown() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenThrow(IllegalStateException.class); + + listMock.add(randomAlphabetic(6)); + } + + @Test(expected = NullPointerException.class) + public final void whenMethodHasNoReturnType_whenConfiguringBehaviorOfMethod_thenPossible() { + final MyList listMock = Mockito.mock(MyList.class); + doThrow(NullPointerException.class).when(listMock).clear(); + + listMock.clear(); + } + + @Test + public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingOnlyOnce_thenNoExceptionIsThrown() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class); + + listMock.add(randomAlphabetic(6)); + } + + @Test(expected = IllegalStateException.class) + public final void givenBehaviorIsConfiguredToThrowExceptionOnSecondCall_whenCallingTwice_thenExceptionIsThrown() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false).thenThrow(IllegalStateException.class); + + listMock.add(randomAlphabetic(6)); + listMock.add(randomAlphabetic(6)); + } + + @Test + public final void whenMockMethodCallIsConfiguredToCallTheRealMethod_thenRealMethodIsCalled() { + final MyList listMock = Mockito.mock(MyList.class); + when(listMock.size()).thenCallRealMethod(); + + assertThat(listMock.size(), equalTo(1)); + } + + @Test + public final void whenMockMethodCallIsConfiguredWithCustomAnswer_thenRealMethodIsCalled() { + final MyList listMock = Mockito.mock(MyList.class); + doAnswer(invocation -> "Always the same").when(listMock).get(anyInt()); + + final String element = listMock.get(1); + assertThat(element, is(equalTo("Always the same"))); + } + + @Test(expected = NullPointerException.class) + public final void givenSpy_whenConfiguringBehaviorOfSpy_thenCorrectlyConfigured() { + final MyList instance = new MyList(); + final MyList spy = Mockito.spy(instance); + + doThrow(NullPointerException.class).when(spy).size(); + spy.size(); + } + +} diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoConfigExamplesUnitTest.java similarity index 97% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesUnitTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoConfigExamplesUnitTest.java index c065e164c5..389dc231c1 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoConfigExamplesUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoConfigExamplesUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; import org.junit.Test; import org.mockito.Mockito; @@ -11,7 +11,7 @@ import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*; -import org.baeldung.mockito.voidmethods.MyList; +import com.baeldung.mockito.MyList; public class MockitoConfigExamplesUnitTest { diff --git a/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoExceptionIntegrationTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoExceptionIntegrationTest.java new file mode 100644 index 0000000000..23fcba60b8 --- /dev/null +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoExceptionIntegrationTest.java @@ -0,0 +1,55 @@ +package com.baeldung.mockito; + +import org.junit.Test; +import org.mockito.Mockito; + +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.*; + +public class MockitoExceptionIntegrationTest { + + @Test(expected = NullPointerException.class) + public void whenConfigNonVoidRetunMethodToThrowEx_thenExIsThrown() { + MyDictionary dictMock = mock(MyDictionary.class); + when(dictMock.getMeaning(anyString())).thenThrow(NullPointerException.class); + + dictMock.getMeaning("word"); + } + + @Test(expected = IllegalStateException.class) + public void whenConfigVoidRetunMethodToThrowEx_thenExIsThrown() { + MyDictionary dictMock = mock(MyDictionary.class); + doThrow(IllegalStateException.class).when(dictMock) + .add(anyString(), anyString()); + + dictMock.add("word", "meaning"); + } + + @Test(expected = NullPointerException.class) + public void whenConfigNonVoidRetunMethodToThrowExWithNewExObj_thenExIsThrown() { + MyDictionary dictMock = mock(MyDictionary.class); + when(dictMock.getMeaning(anyString())).thenThrow(new NullPointerException("Error occurred")); + + dictMock.getMeaning("word"); + } + + @Test(expected = IllegalStateException.class) + public void whenConfigVoidRetunMethodToThrowExWithNewExObj_thenExIsThrown() { + MyDictionary dictMock = mock(MyDictionary.class); + doThrow(new IllegalStateException("Error occurred")).when(dictMock) + .add(anyString(), anyString()); + + dictMock.add("word", "meaning"); + } + + // ===== + + @Test(expected = NullPointerException.class) + public void givenSpy_whenConfigNonVoidRetunMethodToThrowEx_thenExIsThrown() { + MyDictionary dict = new MyDictionary(); + MyDictionary spy = Mockito.spy(dict); + + when(spy.getMeaning(anyString())).thenThrow(NullPointerException.class); + spy.getMeaning("word"); + } +} diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoExceptionUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoExceptionUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoExceptionUnitTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoExceptionUnitTest.java index 88da16ae2b..7ed4fbdf37 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoExceptionUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoExceptionUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doThrow; diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoInjectIntoSpyUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoInjectIntoSpyUnitTest.java similarity index 90% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoInjectIntoSpyUnitTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoInjectIntoSpyUnitTest.java index 568492ca10..d6a11bbc7d 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoInjectIntoSpyUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoInjectIntoSpyUnitTest.java @@ -1,13 +1,12 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; import org.mockito.*; import org.mockito.junit.MockitoJUnitRunner; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import static org.junit.Assert.assertEquals; diff --git a/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoMockIntegrationTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoMockIntegrationTest.java new file mode 100644 index 0000000000..e8cbcc4e8c --- /dev/null +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoMockIntegrationTest.java @@ -0,0 +1,69 @@ +package com.baeldung.mockito; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.MockSettings; +import org.mockito.exceptions.verification.TooLittleActualInvocations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.*; + +public class MockitoMockIntegrationTest { + + private static class CustomAnswer implements Answer { + @Override + public Boolean answer(InvocationOnMock invocation) throws Throwable { + return false; + } + } + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void whenUsingSimpleMock_thenCorrect() { + MyList listMock = mock(MyList.class); + when(listMock.add(anyString())).thenReturn(false); + boolean added = listMock.add(randomAlphabetic(6)); + + verify(listMock).add(anyString()); + assertThat(added, is(false)); + } + + @Test + public void whenUsingMockWithName_thenCorrect() { + MyList listMock = mock(MyList.class, "myMock"); + when(listMock.add(anyString())).thenReturn(false); + listMock.add(randomAlphabetic(6)); + + thrown.expect(TooLittleActualInvocations.class); + thrown.expectMessage(containsString("myMock.add")); + + verify(listMock, times(2)).add(anyString()); + } + + @Test + public void whenUsingMockWithAnswer_thenCorrect() { + MyList listMock = mock(MyList.class, new CustomAnswer()); + boolean added = listMock.add(randomAlphabetic(6)); + + verify(listMock).add(anyString()); + assertThat(added, is(false)); + } + + @Test + public void whenUsingMockWithSettings_thenCorrect() { + MockSettings customSettings = withSettings().defaultAnswer(new CustomAnswer()); + MyList listMock = mock(MyList.class, customSettings); + boolean added = listMock.add(randomAlphabetic(6)); + + verify(listMock).add(anyString()); + assertThat(added, is(false)); + } +} \ No newline at end of file diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoMockUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoMockUnitTest.java similarity index 96% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoMockUnitTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoMockUnitTest.java index 30c843ff13..e1d99f80a2 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoMockUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoMockUnitTest.java @@ -1,8 +1,8 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; import static org.mockito.Mockito.*; -import org.baeldung.mockito.voidmethods.MyList; +import com.baeldung.mockito.MyList; import static org.junit.Assert.assertThat; import static org.hamcrest.Matchers.is; diff --git a/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesIntegrationTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesIntegrationTest.java new file mode 100644 index 0000000000..b5075d7db2 --- /dev/null +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesIntegrationTest.java @@ -0,0 +1,117 @@ +package com.baeldung.mockito; + +import com.google.common.collect.Lists; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.InOrder; +import org.mockito.Mockito; +import org.mockito.exceptions.verification.NoInteractionsWanted; + +import java.util.List; + +import static org.hamcrest.Matchers.hasItem; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.*; + +public class MockitoVerifyExamplesIntegrationTest { + + // tests + + @Test + public final void givenInteractionWithMockOccurred_whenVerifyingInteraction_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + verify(mockedList).size(); + } + + @Test + public final void givenOneInteractionWithMockOccurred_whenVerifyingNumberOfInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + verify(mockedList, times(1)).size(); + } + + @Test + public final void givenNoInteractionWithMockOccurred_whenVerifyingInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + verifyZeroInteractions(mockedList); + } + + @Test + public final void givenNoInteractionWithMethodOfMockOccurred_whenVerifyingInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + verify(mockedList, times(0)).size(); + } + + @Test(expected = NoInteractionsWanted.class) + public final void givenUnverifiedInteraction_whenVerifyingNoUnexpectedInteractions_thenFail() { + final List mockedList = mock(MyList.class); + mockedList.size(); + mockedList.clear(); + + verify(mockedList).size(); + verifyNoMoreInteractions(mockedList); + } + + @Test + public final void whenVerifyingOrderOfInteractions_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + mockedList.add("a parameter"); + mockedList.clear(); + + final InOrder inOrder = Mockito.inOrder(mockedList); + inOrder.verify(mockedList).size(); + inOrder.verify(mockedList).add("a parameter"); + inOrder.verify(mockedList).clear(); + } + + @Test + public final void whenVerifyingAnInteractionHasNotOccurred_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.size(); + + verify(mockedList, never()).clear(); + } + + @Test + public final void whenVerifyingAnInteractionHasOccurredAtLeastOnce_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.clear(); + mockedList.clear(); + mockedList.clear(); + + verify(mockedList, atLeast(1)).clear(); + verify(mockedList, atMost(10)).clear(); + } + + // with arguments + + @Test + public final void whenVerifyingAnInteractionWithExactArgument_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.add("test"); + + verify(mockedList).add("test"); + } + + @Test + public final void whenVerifyingAnInteractionWithAnyArgument_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.add("test"); + + verify(mockedList).add(anyString()); + } + + @Test + public final void whenVerifyingAnInteractionWithArgumentCapture_thenCorrect() { + final List mockedList = mock(MyList.class); + mockedList.addAll(Lists.newArrayList("someElement")); + final ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(List.class); + verify(mockedList).addAll(argumentCaptor.capture()); + final List capturedArgument = argumentCaptor.>getValue(); + assertThat(capturedArgument, hasItem("someElement")); + } + +} diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesUnitTest.java similarity index 97% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesUnitTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesUnitTest.java index a6e40b84e1..ca09f77d2d 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MockitoVerifyExamplesUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesUnitTest.java @@ -1,8 +1,8 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; import com.google.common.collect.Lists; -import org.baeldung.mockito.voidmethods.MyList; +import com.baeldung.mockito.MyList; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MyDictionary.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MyDictionary.java similarity index 93% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/MyDictionary.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/MyDictionary.java index 9492c90d11..92a4498696 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/MyDictionary.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MyDictionary.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito; +package com.baeldung.mockito; import java.util.HashMap; import java.util.Map; diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/voidmethods/MyList.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MyList.java similarity index 90% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/voidmethods/MyList.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/MyList.java index f28c9b732f..ac3a76e04a 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/voidmethods/MyList.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MyList.java @@ -1,4 +1,4 @@ -package org.baeldung.mockito.voidmethods; +package com.baeldung.mockito; import java.util.AbstractList; diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/service/ActionHandlerUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/callbacks/ActionHandlerUnitTest.java similarity index 98% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/service/ActionHandlerUnitTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/callbacks/ActionHandlerUnitTest.java index c34a9a4a09..5ffe4ab28d 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/service/ActionHandlerUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/callbacks/ActionHandlerUnitTest.java @@ -1,11 +1,4 @@ -package org.baeldung.mockito.service; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.verify; +package com.baeldung.mockito.callbacks; import org.junit.Before; import org.junit.Test; @@ -15,6 +8,13 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.stubbing.Answer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.verify; + public class ActionHandlerUnitTest { @Mock diff --git a/testing-modules/mockito/src/test/java/org/baeldung/mockito/voidmethods/MockitoVoidMethodsUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/voidmethods/MockitoVoidMethodsUnitTest.java similarity index 79% rename from testing-modules/mockito/src/test/java/org/baeldung/mockito/voidmethods/MockitoVoidMethodsUnitTest.java rename to testing-modules/mockito/src/test/java/com/baeldung/mockito/voidmethods/MockitoVoidMethodsUnitTest.java index 0393490f9a..dd41d98b57 100644 --- a/testing-modules/mockito/src/test/java/org/baeldung/mockito/voidmethods/MockitoVoidMethodsUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/voidmethods/MockitoVoidMethodsUnitTest.java @@ -1,23 +1,16 @@ -package org.baeldung.mockito.voidmethods; - -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.isA; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doCallRealMethod; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; +package com.baeldung.mockito.voidmethods; +import com.baeldung.mockito.MyList; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.junit.MockitoJUnitRunner; import org.mockito.stubbing.Answer; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; + @RunWith(MockitoJUnitRunner.class) public class MockitoVoidMethodsUnitTest { diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index c0eb59f15e..aad709cfe9 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -19,16 +19,17 @@ gatling groovy-spock junit-5 + junit5-annotations junit5-migration load-testing-comparison mockito mockito-2 + hamcrest mocks mockserver parallel-tests-junit rest-assured rest-testing - selenium-junit-testng spring-testing test-containers diff --git a/testing-modules/runjunitfromjava/src/main/resources/logback.xml b/testing-modules/runjunitfromjava/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/testing-modules/runjunitfromjava/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/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit4/runfromjava/FirstUnitTest.java b/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit4/runfromjava/FirstUnitTest.java deleted file mode 100644 index 588a1e5d66..0000000000 --- a/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit4/runfromjava/FirstUnitTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.junit4.runfromjava; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - - -public class FirstUnitTest { - - @Test - public void whenThis_thenThat() { - assertTrue(true); - } - - @Test - public void whenSomething_thenSomething() { - assertTrue(true); - } - - @Test - public void whenSomethingElse_thenSomethingElse() { - assertTrue(true); - } - -} diff --git a/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit4/runfromjava/SecondUnitTest.java b/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit4/runfromjava/SecondUnitTest.java deleted file mode 100644 index e2d75021cf..0000000000 --- a/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit4/runfromjava/SecondUnitTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.junit4.runfromjava; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -public class SecondUnitTest { - - @Test - public void whenSomething_thenSomething() { - assertTrue(true); - } - - @Test - public void whensomethingElse_thenSomethingElse() { - assertTrue(true); - } -} diff --git a/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit5/runfromjava/FirstUnitTest.java b/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit5/runfromjava/FirstUnitTest.java deleted file mode 100644 index 57c505781d..0000000000 --- a/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit5/runfromjava/FirstUnitTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.junit5.runfromjava; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -class FirstUnitTest { - - @Test - void whenThis_thenThat() { - assertTrue(true); - } - - @Test - void whenSomething_thenSomething() { - assertTrue(true); - } - - @Test - void whenSomethingElse_thenSomethingElse() { - assertTrue(true); - } - -} diff --git a/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit5/runfromjava/SecondUnitTest.java b/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit5/runfromjava/SecondUnitTest.java deleted file mode 100644 index fbfb68898b..0000000000 --- a/testing-modules/runjunitfromjava/src/test/java/com/baeldung/junit5/runfromjava/SecondUnitTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.junit5.runfromjava; - -import org.junit.jupiter.api.RepeatedTest; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -class SecondUnitTest { - - @RepeatedTest(10) - void whenSomething_thenSomething() { - assertTrue(true); - } - - @RepeatedTest(5) - void whenSomethingElse_thenSomethingElse() { - assertTrue(true); - } -} diff --git a/testing-modules/testing-libraries/README.md b/testing-modules/testing-libraries/README.md index 0cd9ca7f2e..7191989224 100644 --- a/testing-modules/testing-libraries/README.md +++ b/testing-modules/testing-libraries/README.md @@ -6,5 +6,5 @@ - [Cucumber and Scenario Outline](http://www.baeldung.com/cucumber-scenario-outline) - [Cucumber Java 8 Support](http://www.baeldung.com/cucumber-java-8-support) - [Introduction to Lambda Behave](http://www.baeldung.com/lambda-behave) -- [Running JUnit Tests Programmatically, from a Java Application](https://www.baeldung.com/junit-tests-run-programmatically-from-java) + diff --git a/twilio/README.md b/twilio/README.md index 9d230610c7..f298a8b75d 100644 --- a/twilio/README.md +++ b/twilio/README.md @@ -1,5 +1,7 @@ +## Twilio +This module contains articles about Twilio ### Relevant Articles: -- [Sending SMS in Java with Twilio](http://www.baeldung.com/java-sms-twilio) +- [Sending SMS in Java with Twilio](https://www.baeldung.com/java-sms-twilio) diff --git a/twitter4j/README.md b/twitter4j/README.md index 3057c1c4b2..8c9ee92348 100644 --- a/twitter4j/README.md +++ b/twitter4j/README.md @@ -1,3 +1,7 @@ +## Twitter4J + +This module contains articles about Twitter4J + ### Relevant articles -- [Introduction to Twitter4J](http://www.baeldung.com/twitter4j) +- [Introduction to Twitter4J](https://www.baeldung.com/twitter4j) diff --git a/undertow/README.md b/undertow/README.md index 8bfb4832e2..f08c6cdb4d 100644 --- a/undertow/README.md +++ b/undertow/README.md @@ -1,2 +1,6 @@ +## Undertow + +This module contains articles about JBoss Undertow + ### Relevant Articles: -- [Introduction to JBoss Undertow](http://www.baeldung.com/jboss-undertow) +- [Introduction to JBoss Undertow](https://www.baeldung.com/jboss-undertow) diff --git a/vaadin/README.md b/vaadin/README.md index 43d2cc8961..1d570d1f58 100644 --- a/vaadin/README.md +++ b/vaadin/README.md @@ -1,4 +1,4 @@ ## Relevant articles: -- [Introduction to Vaadin](http://www.baeldung.com/vaadin) +- [Introduction to Vaadin](https://www.baeldung.com/vaadin) - [Sample Application with Spring Boot and Vaadin](https://www.baeldung.com/spring-boot-vaadin) diff --git a/vavr/README.md b/vavr/README.md index 266cae91bb..6832f78a62 100644 --- a/vavr/README.md +++ b/vavr/README.md @@ -1,13 +1,13 @@ ### Relevant Articles: -- [Introduction to Vavr](http://www.baeldung.com/vavr) -- [Guide to Try in Vavr](http://www.baeldung.com/vavr-try) -- [Guide to Pattern Matching in Vavr](http://www.baeldung.com/vavr-pattern-matching) -- [Property Testing Example With Vavr](http://www.baeldung.com/vavr-property-testing) -- [Exceptions in Lambda Expression Using Vavr](http://www.baeldung.com/exceptions-using-vavr) -- [Vavr Support in Spring Data](http://www.baeldung.com/spring-vavr) -- [Introduction to Vavr’s Validation API](http://www.baeldung.com/vavr-validation-api) -- [Guide to Collections API in Vavr](http://www.baeldung.com/vavr-collections) -- [Collection Factory Methods for Vavr](http://www.baeldung.com/vavr-collection-factory-methods) -- [Introduction to Future in Vavr](http://www.baeldung.com/vavr-future) -- [Introduction to Vavr’s Either](http://www.baeldung.com/vavr-either) -- [Interoperability Between Java and Vavr](http://www.baeldung.com/java-vavr) +- [Introduction to Vavr](https://www.baeldung.com/vavr) +- [Guide to Try in Vavr](https://www.baeldung.com/vavr-try) +- [Guide to Pattern Matching in Vavr](https://www.baeldung.com/vavr-pattern-matching) +- [Property Testing Example With Vavr](https://www.baeldung.com/vavr-property-testing) +- [Exceptions in Lambda Expression Using Vavr](https://www.baeldung.com/exceptions-using-vavr) +- [Vavr Support in Spring Data](https://www.baeldung.com/spring-vavr) +- [Introduction to Vavr’s Validation API](https://www.baeldung.com/vavr-validation-api) +- [Guide to Collections API in Vavr](https://www.baeldung.com/vavr-collections) +- [Collection Factory Methods for Vavr](https://www.baeldung.com/vavr-collection-factory-methods) +- [Introduction to Future in Vavr](https://www.baeldung.com/vavr-future) +- [Introduction to Vavr’s Either](https://www.baeldung.com/vavr-either) +- [Interoperability Between Java and Vavr](https://www.baeldung.com/java-vavr) diff --git a/vertx-and-rxjava/README.md b/vertx-and-rxjava/README.md index ccd4ce3457..622b80feca 100644 --- a/vertx-and-rxjava/README.md +++ b/vertx-and-rxjava/README.md @@ -1,2 +1,6 @@ +## Vert.x and RxJava + +This module contains articles about RxJava with Vert.x + ### Relevant articles -- [Example of Vertx and RxJava Integration](http://www.baeldung.com/vertx-rx-java) +- [Example of Vertx and RxJava Integration](https://www.baeldung.com/vertx-rx-java) diff --git a/vertx/README.md b/vertx/README.md index e710df362d..9a62c7b5dc 100644 --- a/vertx/README.md +++ b/vertx/README.md @@ -1,3 +1,7 @@ +## Vert.x + +This module contains articles about Vert.x + ### Relevant articles -- [Introduction to Vert.x](http://www.baeldung.com/vertx) +- [Introduction to Vert.x](https://www.baeldung.com/vertx) diff --git a/vraptor/README.md b/vraptor/README.md index 0dc531ba8d..037865d934 100644 --- a/vraptor/README.md +++ b/vraptor/README.md @@ -1,18 +1,29 @@ +## VRaptor + +This module contains articles about VRaptor + +### Relevant Article: + +- [Introduction to VRaptor in Java](https://www.baeldung.com/vraptor) + # VRaptor blank project This is a blank project to help you to use VRaptor. You can easily import in you IDE as Maven project. +### Instructions + +After creating your project, you can run it using Tomcat 7 or higher: + +`mvn tomcat7:run` + +Take care to never run `mvn tomcat:run` since that will use Tomcat 6, which isn't compatible with VRaptor. + +### Em Português + Este é um projeto em branco para ajudar você a usar o VRaptor. Você pode facilmente importá-lo na sua IDE favorita como um projeto Maven. Após criar seu projeto você pode rodá-lo com um tomcat7 ou +: -``` -mvn tomcat7:run -``` +`mvn tomcat7:run` Cuidado para *jamais* executar `mvn tomcat:run` pois ele usará um tomcat6 (incompatível). - - -### Relevant Article: - -- [Introduction to VRaptor in Java](http://www.baeldung.com/vraptor) diff --git a/wicket/README.md b/wicket/README.md index e873ee1ba1..65f0db2661 100644 --- a/wicket/README.md +++ b/wicket/README.md @@ -1,8 +1,13 @@ +## Wicket + +This module contains articles about Wicket + +### Relevant Articles + +- [Introduction to the Wicket Framework](https://www.baeldung.com/intro-to-the-wicket-framework) + +### Execution From the same directory where pom.xml is, execute the following command to run the project: -mvn jetty:run - - -###Relevant Articles: -- [Introduction to the Wicket Framework](http://www.baeldung.com/intro-to-the-wicket-framework) +`mvn jetty:run` diff --git a/wildfly/pom.xml b/wildfly/pom.xml new file mode 100644 index 0000000000..bd2c93a633 --- /dev/null +++ b/wildfly/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + org.springframework + gs-spring-boot-wildfly + 0.1.0 + + war + + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + org.springframework.boot + spring-boot-starter-test + test + + + javax.servlet + javax.servlet-api + provided + + + + + + 1.8 + + + + + + maven-failsafe-plugin + + + + integration-test + verify + + + + + + + org.apache.maven.plugins + maven-war-plugin + + + + jdk.unsupported + + + + + + + diff --git a/wildfly/src/main/java/hello/Application.java b/wildfly/src/main/java/hello/Application.java new file mode 100644 index 0000000000..07b259e3a9 --- /dev/null +++ b/wildfly/src/main/java/hello/Application.java @@ -0,0 +1,40 @@ +package hello; + +import java.util.Arrays; + +import org.springframework.boot.CommandLineRunner; +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; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(Application.class); + } + + @Bean + public CommandLineRunner commandLineRunner(ApplicationContext ctx) { + return args -> { + + System.out.println("Let's inspect the beans provided by Spring Boot:"); + + String[] beanNames = ctx.getBeanDefinitionNames(); + Arrays.sort(beanNames); + for (String beanName : beanNames) { + System.out.println(beanName); + } + + }; + } + +} diff --git a/wildfly/src/main/java/hello/HelloController.java b/wildfly/src/main/java/hello/HelloController.java new file mode 100644 index 0000000000..d9c1069cc5 --- /dev/null +++ b/wildfly/src/main/java/hello/HelloController.java @@ -0,0 +1,14 @@ +package hello; + +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RequestMapping; + +@RestController +public class HelloController { + + @RequestMapping("/") + public String index() { + return "Greetings from Spring Boot!"; + } + +} diff --git a/xml/README.md b/xml/README.md index c24fe3e785..d1aa3a798b 100644 --- a/xml/README.md +++ b/xml/README.md @@ -1,7 +1,12 @@ +## XML + +This module contains articles about eXtensible Markup Language (XML) + ### Relevant Articles: -- [Intro to XPath with Java](http://www.baeldung.com/java-xpath) -- [Introduction to JiBX](http://www.baeldung.com/jibx) -- [XML Libraries Support in Java](http://www.baeldung.com/java-xml-libraries) -- [DOM parsing with Xerces](http://www.baeldung.com/java-xerces-dom-parsing) +- [Intro to XPath with Java](https://www.baeldung.com/java-xpath) +- [Introduction to JiBX](https://www.baeldung.com/jibx) +- [XML Libraries Support in Java](https://www.baeldung.com/java-xml-libraries) +- [DOM parsing with Xerces](https://www.baeldung.com/java-xerces-dom-parsing) - [Write an org.w3.dom.Document to a File](https://www.baeldung.com/java-write-xml-document-file) +- [Modifying an XML Attribute in Java](https://www.baeldung.com/java-modify-xml-attribute) - [Convert XML to HTML in Java](https://www.baeldung.com/java-convert-xml-to-html) diff --git a/xml/pom.xml b/xml/pom.xml index d500d72454..bbd607f9b5 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -137,25 +137,68 @@ - - xml - - - src/main/resources - true - - - - - maven-compiler-plugin - ${maven-compiler-plugin.version} - - - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - + + xml + + + src/main/resources + true + + + + + + org.jibx + maven-jibx-plugin + + + + + + org.jibx + maven-jibx-plugin + ${maven-jibx-plugin.version} + + src/main/resources + + *-binding.xml + + + template-binding.xml + + src/main/resources + + *-binding.xml + + true + + + + process-classes + process-classes + + bind + + + + process-test-classes + process-test-classes + + test-bind + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + diff --git a/xml/src/main/java/com/baeldung/sax/SaxParserMain.java b/xml/src/main/java/com/baeldung/sax/SaxParserMain.java new file mode 100644 index 0000000000..4908c10386 --- /dev/null +++ b/xml/src/main/java/com/baeldung/sax/SaxParserMain.java @@ -0,0 +1,109 @@ +package com.baeldung.sax; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class SaxParserMain { + public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException { + SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParser saxParser = factory.newSAXParser(); + + BaeldungHandler baeldungHandler = new BaeldungHandler(); + saxParser.parse("xml/src/main/resources/sax/baeldung.xml", baeldungHandler); + System.out.println(baeldungHandler.getWebsite()); + } + + public static class BaeldungHandler extends DefaultHandler { + private static final String ARTICLES = "articles"; + private static final String ARTICLE = "article"; + private static final String TITLE = "title"; + private static final String CONTENT = "content"; + + private Baeldung website; + private String elementValue; + + @Override + public void characters(char[] ch, int start, int length) throws SAXException { + elementValue = new String(ch, start, length); + } + + @Override + public void startDocument() throws SAXException { + website = new Baeldung(); + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + switch (qName) { + case ARTICLES: + website.setArticleList(new ArrayList<>()); + break; + case ARTICLE: + website.getArticleList().add(new BaeldungArticle()); + } + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + switch (qName) { + case TITLE: + latestArticle().setTitle(elementValue); + break; + case CONTENT: + latestArticle().setContent(elementValue); + break; + } + } + + private BaeldungArticle latestArticle() { + List articleList = website.getArticleList(); + int latestArticleIndex = articleList.size() - 1; + return articleList.get(latestArticleIndex); + } + + public Baeldung getWebsite() { + return website; + } + } + + public static class Baeldung { + private List articleList; + + public void setArticleList(List articleList) { + this.articleList = articleList; + } + + public List getArticleList() { + return this.articleList; + } + } + + public static class BaeldungArticle { + private String title; + private String content; + + public void setTitle(String title) { + this.title = title; + } + + public String getTitle() { + return this.title; + } + + public void setContent(String content) { + this.content = content; + } + + public String getContent() { + return this.content; + } + } +} diff --git a/xml/src/main/resources/sax/baeldung.xml b/xml/src/main/resources/sax/baeldung.xml new file mode 100644 index 0000000000..6736d5bdca --- /dev/null +++ b/xml/src/main/resources/sax/baeldung.xml @@ -0,0 +1,16 @@ + + +
+ Parsing an XML File Using SAX Parser + SAX Parser's Lorem ipsum... +
+
+ Parsing an XML File Using DOM Parser + DOM Parser's Lorem ipsum... +
+
+ Parsing an XML File Using StAX Parser + StAX Parser's Lorem ipsum... +
+
+
\ No newline at end of file diff --git a/xml/src/test/java/com/baeldung/sax/SaxParserMainUnitTest.java b/xml/src/test/java/com/baeldung/sax/SaxParserMainUnitTest.java new file mode 100644 index 0000000000..333c5619c8 --- /dev/null +++ b/xml/src/test/java/com/baeldung/sax/SaxParserMainUnitTest.java @@ -0,0 +1,44 @@ +package com.baeldung.sax; + +import org.junit.Test; +import org.xml.sax.SAXException; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.IOException; +import java.util.List; + +import static org.junit.Assert.*; + +public class SaxParserMainUnitTest { + + @Test + public void givenAProperXMLFile_whenItIsParsed_ThenAnObjectContainsAllItsElements() throws IOException, SAXException, ParserConfigurationException { + SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParser saxParser = factory.newSAXParser(); + + SaxParserMain.BaeldungHandler baeldungHandler = new SaxParserMain.BaeldungHandler(); + saxParser.parse("src/test/resources/sax/baeldung.xml", baeldungHandler); + + SaxParserMain.Baeldung result = baeldungHandler.getWebsite(); + + assertNotNull(result); + List articles = result.getArticleList(); + + assertNotNull(articles); + assertEquals(3, articles.size()); + + SaxParserMain.BaeldungArticle articleOne = articles.get(0); + assertEquals("Parsing an XML File Using SAX Parser", articleOne.getTitle()); + assertEquals("SAX Parser's Lorem ipsum...", articleOne.getContent()); + + SaxParserMain.BaeldungArticle articleTwo = articles.get(1); + assertEquals("Parsing an XML File Using DOM Parser", articleTwo.getTitle()); + assertEquals("DOM Parser's Lorem ipsum...", articleTwo.getContent()); + + SaxParserMain.BaeldungArticle articleThree = articles.get(2); + assertEquals("Parsing an XML File Using StAX Parser", articleThree.getTitle()); + assertEquals("StAX Parser's Lorem ipsum...", articleThree.getContent()); + } +} diff --git a/xml/src/test/java/com/baeldung/xml/jibx/CustomerIntegrationTest.java b/xml/src/test/java/com/baeldung/xml/jibx/CustomerUnitTest.java similarity index 94% rename from xml/src/test/java/com/baeldung/xml/jibx/CustomerIntegrationTest.java rename to xml/src/test/java/com/baeldung/xml/jibx/CustomerUnitTest.java index be28dfe00a..9a4b5bc14b 100644 --- a/xml/src/test/java/com/baeldung/xml/jibx/CustomerIntegrationTest.java +++ b/xml/src/test/java/com/baeldung/xml/jibx/CustomerUnitTest.java @@ -11,7 +11,7 @@ import java.io.InputStream; import static junit.framework.Assert.assertEquals; -public class CustomerIntegrationTest { +public class CustomerUnitTest { @Test public void whenUnmarshalXML_ThenFieldsAreMapped() throws JiBXException, FileNotFoundException { @@ -21,7 +21,7 @@ public class CustomerIntegrationTest { InputStream inputStream = classLoader.getResourceAsStream("Customer1.xml"); Customer customer = (Customer) uctx.unmarshalDocument(inputStream, null); - assertEquals("Stefan Jaegar", customer.getPerson().getName()); + assertEquals("Stefan Jaeger", customer.getPerson().getName()); assertEquals("Davos Dorf", customer.getCity()); } diff --git a/xml/src/test/resources/sax/baeldung.xml b/xml/src/test/resources/sax/baeldung.xml new file mode 100644 index 0000000000..6736d5bdca --- /dev/null +++ b/xml/src/test/resources/sax/baeldung.xml @@ -0,0 +1,16 @@ + + +
+ Parsing an XML File Using SAX Parser + SAX Parser's Lorem ipsum... +
+
+ Parsing an XML File Using DOM Parser + DOM Parser's Lorem ipsum... +
+
+ Parsing an XML File Using StAX Parser + StAX Parser's Lorem ipsum... +
+
+
\ No newline at end of file diff --git a/xstream/README.md b/xstream/README.md index bf917e81fb..505ce1e2d9 100644 --- a/xstream/README.md +++ b/xstream/README.md @@ -1,6 +1,10 @@ +## XStream + +This module contains articles about XStream + ## Relevant Articles: -- [XStream User Guide: JSON](http://www.baeldung.com/xstream-json-processing) -- [XStream User Guide: Converting XML to Objects](http://www.baeldung.com/xstream-deserialize-xml-to-object) -- [XStream User Guide: Converting Objects to XML](http://www.baeldung.com/xstream-serialize-object-to-xml) +- [XStream User Guide: JSON](https://www.baeldung.com/xstream-json-processing) +- [XStream User Guide: Converting XML to Objects](https://www.baeldung.com/xstream-deserialize-xml-to-object) +- [XStream User Guide: Converting Objects to XML](https://www.baeldung.com/xstream-serialize-object-to-xml) - [Remote Code Execution with XStream](https://www.baeldung.com/java-xstream-remote-code-execution)