From e02050387ced5beee52b48753ba236b1d7bc538f Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:42:58 +0300 Subject: [PATCH 01/27] Update README.md (#1925) --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 1d1e63f36a..c21c8f35ec 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -104,3 +104,4 @@ - [Guide to DelayQueue](http://www.baeldung.com/java-delay-queue) - [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](http://www.baeldung.com/java-path) - [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend) +- [Using Java MappedByteBuffer](http://www.baeldung.com/java-mapped-byte-buffer) From 3177e3b3af087f81b1cbad7f02bd36d1d1db5e83 Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:44:14 +0300 Subject: [PATCH 02/27] Update README.md (#1924) --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index c21c8f35ec..0369e88439 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -104,4 +104,5 @@ - [Guide to DelayQueue](http://www.baeldung.com/java-delay-queue) - [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](http://www.baeldung.com/java-path) - [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend) +- [LongAdder and LongAccumulator in Java](http://www.baeldung.com/java-longadder-and-longaccumulator) - [Using Java MappedByteBuffer](http://www.baeldung.com/java-mapped-byte-buffer) From ff870c986813764df9f72a67961d1dd725c1630a Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:44:49 +0300 Subject: [PATCH 03/27] Update README.md (#1923) --- core-java/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-java/README.md b/core-java/README.md index 0369e88439..04b5d92407 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -104,5 +104,7 @@ - [Guide to DelayQueue](http://www.baeldung.com/java-delay-queue) - [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](http://www.baeldung.com/java-path) - [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend) +- [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep) - [LongAdder and LongAccumulator in Java](http://www.baeldung.com/java-longadder-and-longaccumulator) - [Using Java MappedByteBuffer](http://www.baeldung.com/java-mapped-byte-buffer) + From e8037caa9dfa12d612ceb5e51561f27099ef9cd6 Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:45:22 +0300 Subject: [PATCH 04/27] Update README.md (#1922) --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 04b5d92407..1ef4f86e59 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -104,6 +104,7 @@ - [Guide to DelayQueue](http://www.baeldung.com/java-delay-queue) - [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](http://www.baeldung.com/java-path) - [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend) +- [Guide to the ConcurrentSkipListMap](http://www.baeldung.com/java-concurrent-skip-list-map) - [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep) - [LongAdder and LongAccumulator in Java](http://www.baeldung.com/java-longadder-and-longaccumulator) - [Using Java MappedByteBuffer](http://www.baeldung.com/java-mapped-byte-buffer) From 41af122b7f0e8ba064b52aad26ff77000a68c64f Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:46:01 +0300 Subject: [PATCH 05/27] Update README.md (#1921) --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 1ef4f86e59..3ed43f6fd2 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -104,6 +104,7 @@ - [Guide to DelayQueue](http://www.baeldung.com/java-delay-queue) - [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](http://www.baeldung.com/java-path) - [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend) +- [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability) - [Guide to the ConcurrentSkipListMap](http://www.baeldung.com/java-concurrent-skip-list-map) - [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep) - [LongAdder and LongAccumulator in Java](http://www.baeldung.com/java-longadder-and-longaccumulator) From 633f5b067d30ad347e85e2dfb03d718ab3f8a71f Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:46:30 +0300 Subject: [PATCH 06/27] Update README.md (#1920) --- libraries/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/README.md b/libraries/README.md index 1cfa7be86c..ca47332441 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -9,7 +9,7 @@ - [Introduction to Apache Flink with Java](http://www.baeldung.com/apache-flink) - [Introduction to JSONassert](http://www.baeldung.com/jsonassert) - [Intro to JaVer](http://www.baeldung.com/javers) - +- [Intro to JaVer](http://www.baeldung.com/serenity-bdd) The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. From 3cd52788b4934fc6a9faec19cbf7c769191b23ef Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:46:43 +0300 Subject: [PATCH 07/27] Update README.MD (#1916) --- spring-boot/README.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot/README.MD b/spring-boot/README.MD index a1168106cb..c28851ab7b 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -21,3 +21,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [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) - [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration) +- [Guide to @ConfigurationProperties in Spring Boot](http://www.baeldung.com/configuration-properties-in-spring-boot) From eaa7d78222e2569a8cd26c5cdb3177daf3d8914a Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:46:54 +0300 Subject: [PATCH 08/27] Update README.md (#1913) --- jee7/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jee7/README.md b/jee7/README.md index fdd260468c..71163d6640 100644 --- a/jee7/README.md +++ b/jee7/README.md @@ -3,3 +3,4 @@ - [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) From 1083fd41ede5bee38f1a51884557bc3ee3a35eb8 Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:47:03 +0300 Subject: [PATCH 09/27] Update README.md (#1912) --- kotlin/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/kotlin/README.md b/kotlin/README.md index 950f6460d5..57d16e0415 100644 --- a/kotlin/README.md +++ b/kotlin/README.md @@ -5,3 +5,4 @@ - [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 “===” in Kotlin]() +- [Generics in Kotlin](http://www.baeldung.com/kotlin-generics) From d0d4344c2fca357ac862f0913df2f01fca8a8956 Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:47:39 +0300 Subject: [PATCH 10/27] Update README.md (#1919) --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 3ed43f6fd2..550ad96295 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -104,6 +104,7 @@ - [Guide to DelayQueue](http://www.baeldung.com/java-delay-queue) - [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](http://www.baeldung.com/java-path) - [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend) +- [Guide to the Java TransferQueue](http://www.baeldung.com/java-transfer-queue) - [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability) - [Guide to the ConcurrentSkipListMap](http://www.baeldung.com/java-concurrent-skip-list-map) - [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep) From 48e5fabb0507e417a3db8d77e1c292f806904ae3 Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:48:16 +0300 Subject: [PATCH 11/27] Update README.MD (#1918) --- spring-boot/README.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot/README.MD b/spring-boot/README.MD index c28851ab7b..4199b43e9a 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -21,4 +21,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [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) - [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration) +- [Testing in Spring Boot](http://www.baeldung.com/spring-boot-testing) - [Guide to @ConfigurationProperties in Spring Boot](http://www.baeldung.com/configuration-properties-in-spring-boot) From 3b8e516447094ba2b4a881ed4e1dbbc2207b91d6 Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:48:29 +0300 Subject: [PATCH 12/27] Update README.md (#1917) --- spring-cloud/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/README.md b/spring-cloud/README.md index 2ffb3a86d0..1b793144b1 100644 --- a/spring-cloud/README.md +++ b/spring-cloud/README.md @@ -18,3 +18,4 @@ ### Relevant Articles: - [Introduction to Spring Cloud Rest Client with Netflix Ribbon](http://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon) + [An Introduction to Spring Cloud Zookeeper](http://www.baeldung.com/spring-cloud-zookeeper) From d98ba10f486aff0cc161990fad083f88f12a6bab Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:49:01 +0300 Subject: [PATCH 13/27] Update README.md (#1915) --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 550ad96295..1de57c9311 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -104,6 +104,7 @@ - [Guide to DelayQueue](http://www.baeldung.com/java-delay-queue) - [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](http://www.baeldung.com/java-path) - [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend) +- [A Guide to Java SynchronousQueue](http://www.baeldung.com/java-synchronous-queue) - [Guide to the Java TransferQueue](http://www.baeldung.com/java-transfer-queue) - [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability) - [Guide to the ConcurrentSkipListMap](http://www.baeldung.com/java-concurrent-skip-list-map) From 86ccb23a1a2b181df57f3425da3d7207954854b3 Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:49:28 +0300 Subject: [PATCH 14/27] Update README.md (#1914) --- libraries/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/README.md b/libraries/README.md index ca47332441..c405cc90d8 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -9,6 +9,7 @@ - [Introduction to Apache Flink with Java](http://www.baeldung.com/apache-flink) - [Introduction to JSONassert](http://www.baeldung.com/jsonassert) - [Intro to JaVer](http://www.baeldung.com/javers) +- [Introduction to Apache Commons Math](http://www.baeldung.com/apache-commons-math) - [Intro to JaVer](http://www.baeldung.com/serenity-bdd) The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. From 4807b6f080b4ee7473f1e6fb2f795650c16e581d Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 19:49:38 +0300 Subject: [PATCH 15/27] Update README.md (#1911) --- guava21/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guava21/README.md b/guava21/README.md index 8725352d69..2a54416e41 100644 --- a/guava21/README.md +++ b/guava21/README.md @@ -1,2 +1,3 @@ ### Relevant articles: - [New Stream, Comparator and Collector Functionality in Guava 21](http://www.baeldung.com/guava-21-new) +- [New in Guava 21 common.util.concurrent](http://www.baeldung.com/guava-21-util-concurrent) From 550ad9c57e42f2eec34116ec56a309e7419cf2b9 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 24 May 2017 18:49:57 +0200 Subject: [PATCH 16/27] Update pom.xml (#1910) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3663d1308a..6ae5440a3e 100644 --- a/pom.xml +++ b/pom.xml @@ -121,7 +121,7 @@ selenium-junit-testng solr spark-java - spring-5 + spring-akka spring-amqp spring-all From d31b661415b784a4b98d6975c1ac5226fb094bec Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 21:19:39 +0300 Subject: [PATCH 17/27] Create README.md --- spring-amqp-simple/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 spring-amqp-simple/README.md diff --git a/spring-amqp-simple/README.md b/spring-amqp-simple/README.md new file mode 100644 index 0000000000..a176247d4c --- /dev/null +++ b/spring-amqp-simple/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [RabbitMQ Message Dispatching with Spring AMQP](http://www.baeldung.com/rabbitmq-spring-amqp) From bddc05ae79a21676bf4e15e83ea553c6ced985d0 Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 21:20:57 +0300 Subject: [PATCH 18/27] Create README.md --- spring-boot-custom-starter/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 spring-boot-custom-starter/README.md diff --git a/spring-boot-custom-starter/README.md b/spring-boot-custom-starter/README.md new file mode 100644 index 0000000000..5b05394d6e --- /dev/null +++ b/spring-boot-custom-starter/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Creating a Custom Starter with Spring Boot](http://www.baeldung.com/spring-boot-custom-starter) From dd3b537d91a55a2dea6c135ccf723afc009e1bf2 Mon Sep 17 00:00:00 2001 From: MMonik Date: Wed, 24 May 2017 21:21:59 +0300 Subject: [PATCH 19/27] Create README.md --- mybatis/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 mybatis/README.md diff --git a/mybatis/README.md b/mybatis/README.md new file mode 100644 index 0000000000..7c366aeab6 --- /dev/null +++ b/mybatis/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Quick Guide to MyBatis](http://www.baeldung.com/mybatis) From 513c1c5e6975d68fb88df390dda95cf3dc2429d5 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 24 May 2017 22:13:42 +0200 Subject: [PATCH 20/27] Update pom.xml (#1929) * Update pom.xml * Update pom.xml --- pom.xml | 2 +- spring-5/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6ae5440a3e..5216eb306b 100644 --- a/pom.xml +++ b/pom.xml @@ -121,7 +121,7 @@ selenium-junit-testng solr spark-java - + spring-5 spring-akka spring-amqp spring-all diff --git a/spring-5/pom.xml b/spring-5/pom.xml index 63014d6e51..605dbe39e1 100644 --- a/spring-5/pom.xml +++ b/spring-5/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.0.BUILD-SNAPSHOT + 2.0.0.M1 From a2e2192494535b7c34f97a56bc28af4ee9b17bee Mon Sep 17 00:00:00 2001 From: Alex Vargas Date: Wed, 24 May 2017 14:23:49 -0700 Subject: [PATCH 21/27] Code example for article BAEL-818 (#1909) * Quartz example for article: Introduction to Quartz * Adding new module for Java Quartz * Removing Quartz code from jee7 module * Fixing folder structure --- java-quartz/pom.xml | 31 + .../baeldung/java_quartz/QuartzExample.java | 42 + .../com/baeldung/java_quartz/SimpleJob.java | 13 + .../com/baeldung/java_quartz/AppTest.java | 38 + jee7/pom.xml | 720 +++++++++--------- 5 files changed, 484 insertions(+), 360 deletions(-) create mode 100644 java-quartz/pom.xml create mode 100644 java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java create mode 100644 java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java create mode 100644 java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java diff --git a/java-quartz/pom.xml b/java-quartz/pom.xml new file mode 100644 index 0000000000..51b9d56a7b --- /dev/null +++ b/java-quartz/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + + com.baeldung + java-quartz + 0.0.1-SNAPSHOT + jar + + java-quartz + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + org.quartz-scheduler + quartz + 2.3.0 + + + + diff --git a/java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java b/java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java new file mode 100644 index 0000000000..89cd2680e2 --- /dev/null +++ b/java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java @@ -0,0 +1,42 @@ +package com.baeldung.java_quartz; + +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.SchedulerFactory; +import org.quartz.SimpleScheduleBuilder; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.impl.StdSchedulerFactory; + +public class QuartzExample { + + public static void main(String args[]) { + + SchedulerFactory schedFact = new StdSchedulerFactory(); + try { + + Scheduler sched = schedFact.getScheduler(); + + JobDetail job = JobBuilder.newJob(SimpleJob.class) + .withIdentity("myJob", "group1") + .build(); + + Trigger trigger = TriggerBuilder.newTrigger() + .withIdentity("myTrigger", "group1") + .startNow() + .withSchedule(SimpleScheduleBuilder.simpleSchedule() + .withIntervalInSeconds(40) + .repeatForever()) + .build(); + + sched.scheduleJob(job, trigger); + sched.start(); + + } catch (SchedulerException e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java b/java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java new file mode 100644 index 0000000000..a9e677c24f --- /dev/null +++ b/java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java @@ -0,0 +1,13 @@ +package com.baeldung.java_quartz; + +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +public class SimpleJob implements Job { + + public void execute(JobExecutionContext arg0) throws JobExecutionException { + System.out.println("This is a quartz job!"); + } + +} \ No newline at end of file diff --git a/java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java b/java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java new file mode 100644 index 0000000000..68754c2c15 --- /dev/null +++ b/java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java @@ -0,0 +1,38 @@ +package com.baeldung.java_quartz; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/jee7/pom.xml b/jee7/pom.xml index fe7c5e4c11..e633d2df3d 100644 --- a/jee7/pom.xml +++ b/jee7/pom.xml @@ -1,381 +1,381 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - com.baeldung - jee7 - 1.0-SNAPSHOT - JavaEE 7 Arquillian Archetype Sample + com.baeldung + jee7 + 1.0-SNAPSHOT + JavaEE 7 Arquillian Archetype Sample - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + - - 1.8 - 3.0.0 + + 1.8 + 3.0.0 - 7.0 - 1.1.11.Final - 8.2.1.Final - 1.7.0 - 1.4.6.Final - 3.0.19.Final - 4.1.1 - 1.0.4 - 1.13 - 2.25 - 1.0.0.Final + 7.0 + 1.1.11.Final + 8.2.1.Final + 1.7.0 + 1.4.6.Final + 3.0.19.Final + 4.1.1 + 1.0.4 + 1.13 + 2.25 + 1.0.0.Final - 2.6 - + 2.6 + - - ${maven.min.version} - + + ${maven.min.version} + - - - - org.jboss.arquillian - arquillian-bom - ${arquillian_core.version} - import - pom - - - org.jboss.arquillian.extension - arquillian-drone-bom - 2.0.1.Final - pom - import - - - + + + + org.jboss.arquillian + arquillian-bom + ${arquillian_core.version} + import + pom + + + org.jboss.arquillian.extension + arquillian-drone-bom + 2.0.1.Final + pom + import + + + - - - javax - javaee-api - ${javaee_api.version} - provided - - - - org.jboss.arquillian.junit - arquillian-junit-container - test - + - org.jboss.arquillian.graphene - graphene-webdriver - 2.1.0.Final - pom - test - - - com.jayway.awaitility - awaitility - ${awaitility.version} - test - + javax + javaee-api + ${javaee_api.version} + provided + - - org.jboss.shrinkwrap.resolver - shrinkwrap-resolver-impl-maven - test - jar - - - - org.jboss.shrinkwrap.resolver - shrinkwrap-resolver-impl-maven-archive - test - - - org.apache.httpcomponents - httpclient - 4.5 - - - commons-io - commons-io - 2.4 - - - com.sun.faces - jsf-api - 2.2.14 - - - com.sun.faces - jsf-impl - 2.2.14 - - - javax.servlet - jstl - 1.2 - - - javax.servlet - javax.servlet-api - 3.1.0 - - javax.servlet.jsp - jsp-api - 2.2 - provided + org.jboss.arquillian.junit + arquillian-junit-container + test - taglibs - standard - 1.1.2 - - + org.jboss.arquillian.graphene + graphene-webdriver + 2.1.0.Final + pom + test + + + com.jayway.awaitility + awaitility + ${awaitility.version} + test + - - - - org.apache.maven.plugins - maven-war-plugin - ${maven-war-plugin.version} - - false - - - - + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + test + jar + - + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven-archive + test + + + org.apache.httpcomponents + httpclient + 4.5 + + + commons-io + commons-io + 2.4 + + + com.sun.faces + jsf-api + 2.2.14 + + + com.sun.faces + jsf-impl + 2.2.14 + + + javax.servlet + jstl + 1.2 + + + javax.servlet + javax.servlet-api + 3.1.0 + + + javax.servlet.jsp + jsp-api + 2.2 + provided + + + taglibs + standard + 1.1.2 + + - - wildfly-managed-arquillian - - true - - - standalone-full.xml - ${project.build.directory}/wildfly-${version.wildfly} - - - - io.undertow - undertow-websockets-jsr - ${undertow-websockets-jsr.version} - test - - - org.jboss.resteasy - resteasy-client - ${resteasy.version} - test - - - org.jboss.resteasy - resteasy-jaxb-provider - ${resteasy.version} - test - - - org.jboss.resteasy - resteasy-json-p-provider - ${resteasy.version} - test - - - org.wildfly - wildfly-arquillian-container-managed - ${wildfly.version} - test - - - - - - - maven-dependency-plugin - 2.8 - - ${maven.test.skip} - - - - unpack - process-test-classes - - unpack - - - - - org.wildfly - wildfly-dist - ${wildfly.version} - zip - false - ${project.build.directory} - - - - - - - - maven-surefire-plugin - 2.17 - - - ${project.build.directory}/wildfly-${wildfly.version} - - - - - - - - - wildfly-remote-arquillian - - - io.undertow - undertow-websockets-jsr - ${undertow-websockets-jsr.version} - test - - - org.jboss.resteasy - resteasy-client - ${resteasy.version} - test - - - org.jboss.resteasy - resteasy-jaxb-provider - ${resteasy.version} - test - - - org.jboss.resteasy - resteasy-json-p-provider - ${resteasy.version} - test - - - org.wildfly - wildfly-arquillian-container-remote - ${wildfly.version} - test - - - - - glassfish-embedded-arquillian - - - org.glassfish.main.extras - glassfish-embedded-all - ${glassfish-embedded-all.version} - test - - - org.glassfish - javax.json - ${javax.json.version} - test - - - org.glassfish.tyrus - tyrus-client - ${tyrus.version} - test - - - org.glassfish.tyrus - tyrus-container-grizzly-client - ${tyrus.version} - test - - - org.glassfish.jersey.core - jersey-client - ${jersey.version} - test - - - org.jboss.arquillian.container - arquillian-glassfish-embedded-3.1 - ${arquillian-glassfish.version} - test - - - - - glassfish-remote-arquillian - - - org.glassfish - javax.json - ${javax.json.version} - test - - - org.glassfish.tyrus - tyrus-client - ${tyrus.version} - test - - - org.glassfish.tyrus - tyrus-container-grizzly-client - ${tyrus.version} - test - - - org.glassfish.jersey.core - jersey-client - ${jersey.version} - test - - - org.glassfish.jersey.media - jersey-media-json-jackson - ${jersey.version} - test - - - org.glassfish.jersey.media - jersey-media-json-processing - ${jersey.version} - test - - - org.jboss.arquillian.container - arquillian-glassfish-remote-3.1 - ${arquillian-glassfish.version} - test - - - - - webdriver-chrome - - true - - - chrome - - + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + false + + + + - - webdriver-firefox - - firefox - + + + + wildfly-managed-arquillian + + true + + + standalone-full.xml + ${project.build.directory}/wildfly-${version.wildfly} + + + + io.undertow + undertow-websockets-jsr + ${undertow-websockets-jsr.version} + test + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + test + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + test + + + org.jboss.resteasy + resteasy-json-p-provider + ${resteasy.version} + test + + + org.wildfly + wildfly-arquillian-container-managed + ${wildfly.version} + test + + + + + + + maven-dependency-plugin + 2.8 + + ${maven.test.skip} + + + + unpack + process-test-classes + + unpack + + + + + org.wildfly + wildfly-dist + ${wildfly.version} + zip + false + ${project.build.directory} + + + + + + + + maven-surefire-plugin + 2.17 + + + ${project.build.directory}/wildfly-${wildfly.version} + + + + + + - + + wildfly-remote-arquillian + + + io.undertow + undertow-websockets-jsr + ${undertow-websockets-jsr.version} + test + + + org.jboss.resteasy + resteasy-client + ${resteasy.version} + test + + + org.jboss.resteasy + resteasy-jaxb-provider + ${resteasy.version} + test + + + org.jboss.resteasy + resteasy-json-p-provider + ${resteasy.version} + test + + + org.wildfly + wildfly-arquillian-container-remote + ${wildfly.version} + test + + + + + glassfish-embedded-arquillian + + + org.glassfish.main.extras + glassfish-embedded-all + ${glassfish-embedded-all.version} + test + + + org.glassfish + javax.json + ${javax.json.version} + test + + + org.glassfish.tyrus + tyrus-client + ${tyrus.version} + test + + + org.glassfish.tyrus + tyrus-container-grizzly-client + ${tyrus.version} + test + + + org.glassfish.jersey.core + jersey-client + ${jersey.version} + test + + + org.jboss.arquillian.container + arquillian-glassfish-embedded-3.1 + ${arquillian-glassfish.version} + test + + + + + glassfish-remote-arquillian + + + org.glassfish + javax.json + ${javax.json.version} + test + + + org.glassfish.tyrus + tyrus-client + ${tyrus.version} + test + + + org.glassfish.tyrus + tyrus-container-grizzly-client + ${tyrus.version} + test + + + org.glassfish.jersey.core + jersey-client + ${jersey.version} + test + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${jersey.version} + test + + + org.glassfish.jersey.media + jersey-media-json-processing + ${jersey.version} + test + + + org.jboss.arquillian.container + arquillian-glassfish-remote-3.1 + ${arquillian-glassfish.version} + test + + + + + webdriver-chrome + + true + + + chrome + + + + + webdriver-firefox + + firefox + + + From 772038390f5833c9acd367bf80211aeccb6b4eaa Mon Sep 17 00:00:00 2001 From: Alex Vargas Date: Thu, 25 May 2017 14:45:53 -0700 Subject: [PATCH 22/27] Code snippets for article BAEL-818 (#1934) * Quartz example for article: Introduction to Quartz * Adding new module for Java Quartz * Removing Quartz code from jee7 module * Fixing folder structure * Removing java-quartz module and adding code snippets in libraries module --- java-quartz/pom.xml | 31 --------------- .../com/baeldung/java_quartz/AppTest.java | 38 ------------------- libraries/pom.xml | 5 +++ .../com/baeldung/quartz}/QuartzExample.java | 2 +- .../java/com/baeldung/quartz}/SimpleJob.java | 2 +- 5 files changed, 7 insertions(+), 71 deletions(-) delete mode 100644 java-quartz/pom.xml delete mode 100644 java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java rename {java-quartz/src/main/java/com/baeldung/java_quartz => libraries/src/main/java/com/baeldung/quartz}/QuartzExample.java (97%) rename {java-quartz/src/main/java/com/baeldung/java_quartz => libraries/src/main/java/com/baeldung/quartz}/SimpleJob.java (89%) diff --git a/java-quartz/pom.xml b/java-quartz/pom.xml deleted file mode 100644 index 51b9d56a7b..0000000000 --- a/java-quartz/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - 4.0.0 - - com.baeldung - java-quartz - 0.0.1-SNAPSHOT - jar - - java-quartz - http://maven.apache.org - - - UTF-8 - - - - - junit - junit - 3.8.1 - test - - - org.quartz-scheduler - quartz - 2.3.0 - - - - diff --git a/java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java b/java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java deleted file mode 100644 index 68754c2c15..0000000000 --- a/java-quartz/src/test/java/com/baeldung/java_quartz/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baeldung.java_quartz; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff --git a/libraries/pom.xml b/libraries/pom.xml index 6d41902db7..95948a83dd 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -269,6 +269,11 @@ h2 1.4.195 + + org.quartz-scheduler + quartz + 2.3.0 + 0.7.0 diff --git a/java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java b/libraries/src/main/java/com/baeldung/quartz/QuartzExample.java similarity index 97% rename from java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java rename to libraries/src/main/java/com/baeldung/quartz/QuartzExample.java index 89cd2680e2..1e37fc028b 100644 --- a/java-quartz/src/main/java/com/baeldung/java_quartz/QuartzExample.java +++ b/libraries/src/main/java/com/baeldung/quartz/QuartzExample.java @@ -1,4 +1,4 @@ -package com.baeldung.java_quartz; +package com.baeldung.quartz; import org.quartz.JobBuilder; import org.quartz.JobDetail; diff --git a/java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java b/libraries/src/main/java/com/baeldung/quartz/SimpleJob.java similarity index 89% rename from java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java rename to libraries/src/main/java/com/baeldung/quartz/SimpleJob.java index a9e677c24f..370d698d13 100644 --- a/java-quartz/src/main/java/com/baeldung/java_quartz/SimpleJob.java +++ b/libraries/src/main/java/com/baeldung/quartz/SimpleJob.java @@ -1,4 +1,4 @@ -package com.baeldung.java_quartz; +package com.baeldung.quartz; import org.quartz.Job; import org.quartz.JobExecutionContext; From c9cd50d58133377c743a8657bb5fceacf70c7df9 Mon Sep 17 00:00:00 2001 From: amilabanuka Date: Fri, 26 May 2017 08:39:08 +0800 Subject: [PATCH 23/27] BAEL-919 (#1931) Added the JUnitParams intorduction classes --- libraries/pom.xml | 7 +++ .../junitparams/SafeAdditionUtil.java | 15 +++++ .../junitparams/SafeAdditionUtilTest.java | 55 +++++++++++++++++++ .../junitparams/TestDataProvider.java | 13 +++++ .../resources/JunitParamsTestParameters.csv | 4 ++ 5 files changed, 94 insertions(+) create mode 100644 libraries/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java create mode 100644 libraries/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java create mode 100644 libraries/src/test/java/com/baeldung/junitparams/TestDataProvider.java create mode 100644 libraries/src/test/resources/JunitParamsTestParameters.csv diff --git a/libraries/pom.xml b/libraries/pom.xml index 95948a83dd..3d99c53779 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -269,6 +269,12 @@ h2 1.4.195 + + pl.pragmatists + JUnitParams + ${jUnitParams.version} + test + org.quartz-scheduler quartz @@ -297,6 +303,7 @@ 1.24.0 1.1.3-rc.5 1.4.0 + 1.1.0 diff --git a/libraries/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java b/libraries/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java new file mode 100644 index 0000000000..a2c1573dca --- /dev/null +++ b/libraries/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java @@ -0,0 +1,15 @@ +package com.baeldung.junitparams; + +public class SafeAdditionUtil { + + public int safeAdd(int a, int b) { + long result = ((long) a) + b; + if (result > Integer.MAX_VALUE) { + return Integer.MAX_VALUE; + } else if (result < Integer.MIN_VALUE) { + return Integer.MIN_VALUE; + } + return (int) result; + } + +} diff --git a/libraries/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java b/libraries/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java new file mode 100644 index 0000000000..c9141a6e57 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java @@ -0,0 +1,55 @@ +package com.baeldung.junitparams; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import junitparams.FileParameters; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +@RunWith(JUnitParamsRunner.class) +public class SafeAdditionUtilTest { + + private SafeAdditionUtil serviceUnderTest = new SafeAdditionUtil(); + + @Test + @Parameters({ "1, 2, 3", "-10, 30, 20", "15, -5, 10", "-5, -10, -15" }) + public void whenCalledWithAnnotationProvidedParams_thenSafeAddAndReturn(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + + @Test + @Parameters(method = "parametersToTestAdd") + public void whenCalledWithNamedMethod_thendSafeAddAndReturn(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + + private Object[] parametersToTestAdd() { + return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -8, Integer.MIN_VALUE } }; + } + + @Test + @Parameters + public void whenCalledWithnoParam_thenLoadByNameSafeAddAndReturn(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + + private Object[] parametersForWhenCalledWithnoParam_thenLoadByNameSafeAddAndReturn() { + return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -8, Integer.MIN_VALUE } }; + } + + @Test + @Parameters(source = TestDataProvider.class) + public void whenCalledWithNamedClass_thenSafeAddAndReturn(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + + @Test + @FileParameters("src/test/resources/JunitParamsTestParameters.csv") + public void whenCalledWithCsvFile_thenSafeAddAndReturn(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + +} diff --git a/libraries/src/test/java/com/baeldung/junitparams/TestDataProvider.java b/libraries/src/test/java/com/baeldung/junitparams/TestDataProvider.java new file mode 100644 index 0000000000..d318345a56 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/junitparams/TestDataProvider.java @@ -0,0 +1,13 @@ +package com.baeldung.junitparams; + +public class TestDataProvider { + + public static Object[] provideBasicData() { + return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { 15, -5, 10 }, new Object[] { -5, -10, -15 } }; + } + + public static Object[] provideEdgeCaseData() { + return new Object[] { new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -2, Integer.MIN_VALUE }, }; + } + +} diff --git a/libraries/src/test/resources/JunitParamsTestParameters.csv b/libraries/src/test/resources/JunitParamsTestParameters.csv new file mode 100644 index 0000000000..84eb5a0b23 --- /dev/null +++ b/libraries/src/test/resources/JunitParamsTestParameters.csv @@ -0,0 +1,4 @@ +1,2,3 +-10, 30, 20 +15, -5, 10 +-5, -10, -15 \ No newline at end of file From e52d858914a0cf387c4ab34867c4fe72c7007ace Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Fri, 26 May 2017 09:10:52 +0200 Subject: [PATCH 24/27] Update pom.xml (#1935) --- libraries/pom.xml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries/pom.xml b/libraries/pom.xml index 3d99c53779..9c10a13b7b 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -225,12 +225,7 @@ org.datanucleus datanucleus-maven-plugin 5.0.2 - - - com.h2database - h2 - 1.4.194 - + org.datanucleus datanucleus-xml From 8e709d587dbc38ce56cbb83c010162ead5476a6c Mon Sep 17 00:00:00 2001 From: Sunil Mogadati Date: Fri, 26 May 2017 07:26:55 -0600 Subject: [PATCH 25/27] Update README.MD to include Multiple Authentication Providers (#1936) --- spring-security-mvc-boot/README.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-mvc-boot/README.MD b/spring-security-mvc-boot/README.MD index 70b0f23cbb..feda6efcd7 100644 --- a/spring-security-mvc-boot/README.MD +++ b/spring-security-mvc-boot/README.MD @@ -7,3 +7,4 @@ The "REST With Spring" Classes: http://github.learnspringsecurity.com - [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) From 49724d1691e3e7d07fcecd625f91a23be0518947 Mon Sep 17 00:00:00 2001 From: amilabanuka Date: Fri, 26 May 2017 23:47:50 +0800 Subject: [PATCH 26/27] BAEL-919: Introduction to JUnitParams (#1938) * BAEL-919 Added the JUnitParams intorduction classes * BAEL-919 Added the JUnitParams intorduction classes * Reverting the adding to libraries folder --- libraries/pom.xml | 1 + testing/pom.xml | 7 +++ .../junitparams/SafeAdditionUtil.java | 15 ++++++ .../junitparams/SafeAdditionUtilTest.java | 54 +++++++++++++++++++ .../junitparams/TestDataProvider.java | 13 +++++ .../resources/JunitParamsTestParameters.csv | 4 ++ 6 files changed, 94 insertions(+) create mode 100644 testing/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java create mode 100644 testing/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java create mode 100644 testing/src/test/java/com/baeldung/junitparams/TestDataProvider.java create mode 100644 testing/src/test/resources/JunitParamsTestParameters.csv diff --git a/libraries/pom.xml b/libraries/pom.xml index 9c10a13b7b..a4b554365d 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -275,6 +275,7 @@ quartz 2.3.0 + 0.7.0 diff --git a/testing/pom.xml b/testing/pom.xml index a0bc5b99cf..8c6898ac67 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -64,6 +64,12 @@ ${truth.version} test + + pl.pragmatists + JUnitParams + ${jUnitParams.version} + test + @@ -130,5 +136,6 @@ 3.1.0 3.6.1 0.32 + 1.1.0 diff --git a/testing/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java b/testing/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java new file mode 100644 index 0000000000..a2c1573dca --- /dev/null +++ b/testing/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java @@ -0,0 +1,15 @@ +package com.baeldung.junitparams; + +public class SafeAdditionUtil { + + public int safeAdd(int a, int b) { + long result = ((long) a) + b; + if (result > Integer.MAX_VALUE) { + return Integer.MAX_VALUE; + } else if (result < Integer.MIN_VALUE) { + return Integer.MIN_VALUE; + } + return (int) result; + } + +} diff --git a/testing/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java b/testing/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java new file mode 100644 index 0000000000..8ab49309cd --- /dev/null +++ b/testing/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java @@ -0,0 +1,54 @@ +package com.baeldung.junitparams; + +import static org.junit.Assert.assertEquals; + +import junitparams.FileParameters; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(JUnitParamsRunner.class) +public class SafeAdditionUtilTest { + + private SafeAdditionUtil serviceUnderTest = new SafeAdditionUtil(); + + @Test + @Parameters({ "1, 2, 3", "-10, 30, 20", "15, -5, 10", "-5, -10, -15" }) + public void whenWithAnnotationProvidedParams_thenSafeAdd(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + + @Test + @Parameters(method = "parametersToTestAdd") + public void whenWithNamedMethod_thendSafeAdd(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + + private Object[] parametersToTestAdd() { + return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -8, Integer.MIN_VALUE } }; + } + + @Test + @Parameters + public void whenWithnoParam_thenLoadByNameSafeAdd(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + + private Object[] parametersForWhenWithnoParam_thenLoadByNameSafeAdd() { + return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -8, Integer.MIN_VALUE } }; + } + + @Test + @Parameters(source = TestDataProvider.class) + public void whenWithNamedClass_thenSafeAdd(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + + @Test + @FileParameters("src/test/resources/JunitParamsTestParameters.csv") + public void whenWithCsvFile_thenSafeAdd(int a, int b, int expectedValue) { + assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); + } + +} diff --git a/testing/src/test/java/com/baeldung/junitparams/TestDataProvider.java b/testing/src/test/java/com/baeldung/junitparams/TestDataProvider.java new file mode 100644 index 0000000000..d318345a56 --- /dev/null +++ b/testing/src/test/java/com/baeldung/junitparams/TestDataProvider.java @@ -0,0 +1,13 @@ +package com.baeldung.junitparams; + +public class TestDataProvider { + + public static Object[] provideBasicData() { + return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { 15, -5, 10 }, new Object[] { -5, -10, -15 } }; + } + + public static Object[] provideEdgeCaseData() { + return new Object[] { new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -2, Integer.MIN_VALUE }, }; + } + +} diff --git a/testing/src/test/resources/JunitParamsTestParameters.csv b/testing/src/test/resources/JunitParamsTestParameters.csv new file mode 100644 index 0000000000..84eb5a0b23 --- /dev/null +++ b/testing/src/test/resources/JunitParamsTestParameters.csv @@ -0,0 +1,4 @@ +1,2,3 +-10, 30, 20 +15, -5, 10 +-5, -10, -15 \ No newline at end of file From b9b642c6a9b2c05ac8f663b8c0b882a9ac14e2e3 Mon Sep 17 00:00:00 2001 From: Yasin Date: Sat, 27 May 2017 01:47:42 +0530 Subject: [PATCH 27/27] BAEL-900 Guide to dynamic tests in Junit 5 (#1932) * BAEL-900 Guide to dynamic tests in Junit 5 * BAEL-900 Guide to Dynamic Tests in Junit 5 * Revert "BAEL-900 Guide to Dynamic Tests in Junit 5" This reverts commit d0d45c9067223347da20d0f2c80de391fcade38e. * BAEL-900 Guide to Dynamic Tests in Junit 5 * BAEL-900 Guide to dynamic tests in Junit 5 * removed unnecessary annotation * BAEL-900 unused imports removed --- .../com/baeldung/DynamicTestsExample.java | 26 +++++++++++++ .../java/com/baeldung/helpers/Employee.java | 38 +++++++++++++++++++ .../com/baeldung/helpers/EmployeeDao.java | 16 ++++++++ 3 files changed, 80 insertions(+) create mode 100644 junit5/src/test/java/com/baeldung/helpers/Employee.java create mode 100644 junit5/src/test/java/com/baeldung/helpers/EmployeeDao.java diff --git a/junit5/src/test/java/com/baeldung/DynamicTestsExample.java b/junit5/src/test/java/com/baeldung/DynamicTestsExample.java index ce1f8b16a7..6a97f2347b 100644 --- a/junit5/src/test/java/com/baeldung/DynamicTestsExample.java +++ b/junit5/src/test/java/com/baeldung/DynamicTestsExample.java @@ -18,6 +18,9 @@ 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 { @TestFactory @@ -111,6 +114,29 @@ public class DynamicTestsExample { } + @TestFactory + Stream dynamicTestsForEmployeeWorkflows() { + List inputList = + Arrays.asList(new Employee(1, "Fred"), new Employee(2), new Employee(3, "John")); + + EmployeeDao dao = new EmployeeDao(); + Stream saveEmployeeStream = inputList.stream().map(emp -> + DynamicTest.dynamicTest("saveEmployee: " + emp.toString(), () -> { + Employee returned = dao.save(emp.getId()); + assertEquals(returned.getId(), emp.getId()); + })); + + Stream saveEmployeeWithFirstNameStream + = inputList.stream().filter(emp -> !emp.getFirstName().isEmpty()) + .map(emp -> DynamicTest.dynamicTest("saveEmployeeWithName" + emp.toString(), () -> { + Employee returned = dao.save(emp.getId(), emp.getFirstName()); + assertEquals(returned.getId(), emp.getId()); + assertEquals(returned.getFirstName(), emp.getFirstName()); + })); + + return Stream.concat(saveEmployeeStream, saveEmployeeWithFirstNameStream); + } + class DomainNameResolver { private Map ipByDomainName = new HashMap<>(); diff --git a/junit5/src/test/java/com/baeldung/helpers/Employee.java b/junit5/src/test/java/com/baeldung/helpers/Employee.java new file mode 100644 index 0000000000..7fa724e4a8 --- /dev/null +++ b/junit5/src/test/java/com/baeldung/helpers/Employee.java @@ -0,0 +1,38 @@ +package com.baeldung.helpers; + +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/junit5/src/test/java/com/baeldung/helpers/EmployeeDao.java b/junit5/src/test/java/com/baeldung/helpers/EmployeeDao.java new file mode 100644 index 0000000000..b23e5bf5e3 --- /dev/null +++ b/junit5/src/test/java/com/baeldung/helpers/EmployeeDao.java @@ -0,0 +1,16 @@ +package com.baeldung.helpers; + +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; + } +}