From ae47827879d0e9396ad5de5f979f495629a35838 Mon Sep 17 00:00:00 2001 From: alv21 Date: Thu, 8 Feb 2018 19:15:56 +0100 Subject: [PATCH 001/441] Different Types of Bean Injection in Spring --- .../beansinjectiontypes/Cabriolet.java | 8 +++ .../com/baeldung/beansinjectiontypes/Car.java | 6 ++ .../DealershipTraditionalStyle.java | 9 +++ .../DealershipWithDependenciesInjection.java | 13 +++++ .../baeldung/beansinjectiontypes/Sedan.java | 10 ++++ .../constructor/Config.java | 20 +++++++ .../constructor/Dealership.java | 20 +++++++ .../constructor/HornCheckerFile.java | 15 +++++ .../constructor/HornCheckerXML.java | 15 +++++ .../beansinjectiontypes/setter/Config.java | 22 ++++++++ .../setter/Dealership.java | 19 +++++++ .../setter/HornCheckerFile.java | 15 +++++ .../setter/HornCheckerXML.java | 15 +++++ .../resources/beansinjectiontypes-ctx.xml | 10 ++++ .../BeansInjectionTypesIntegrationTest.java | 56 +++++++++++++++++++ 15 files changed, 253 insertions(+) create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/Cabriolet.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/Car.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipTraditionalStyle.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipWithDependenciesInjection.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/Sedan.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Config.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Dealership.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerFile.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerXML.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Config.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Dealership.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerFile.java create mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerXML.java create mode 100644 spring-core/src/main/resources/beansinjectiontypes-ctx.xml create mode 100644 spring-core/src/test/java/com/baeldung/beansinjectiontypes/BeansInjectionTypesIntegrationTest.java diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Cabriolet.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Cabriolet.java new file mode 100644 index 0000000000..2bf9b8b954 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Cabriolet.java @@ -0,0 +1,8 @@ +package com.baeldung.beansinjectiontypes; + +public class Cabriolet implements Car{ + + public void honk(){ + System.out.println("I'm a cabriolet!"); + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Car.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Car.java new file mode 100644 index 0000000000..e88e218f95 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Car.java @@ -0,0 +1,6 @@ +package com.baeldung.beansinjectiontypes; + +public interface Car { + + public void honk(); +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipTraditionalStyle.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipTraditionalStyle.java new file mode 100644 index 0000000000..b917049e41 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipTraditionalStyle.java @@ -0,0 +1,9 @@ +package com.baeldung.beansinjectiontypes; + +public class DealershipTraditionalStyle { + private Car car = new Sedan(); + + public Car getCar() { + return car; + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipWithDependenciesInjection.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipWithDependenciesInjection.java new file mode 100644 index 0000000000..9b25e21dc7 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipWithDependenciesInjection.java @@ -0,0 +1,13 @@ +package com.baeldung.beansinjectiontypes; + +public class DealershipWithDependenciesInjection { + private Car car; + + public DealershipWithDependenciesInjection(Car car) { + this.car = car; + } + + public Car getCar() { + return car; + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Sedan.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Sedan.java new file mode 100644 index 0000000000..0ae4cf5a40 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Sedan.java @@ -0,0 +1,10 @@ +package com.baeldung.beansinjectiontypes; + +import org.springframework.stereotype.Component; + +@Component +public class Sedan implements Car { + public void honk(){ + System.out.println("I'm a sedan!"); + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Config.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Config.java new file mode 100644 index 0000000000..3e2534f892 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Config.java @@ -0,0 +1,20 @@ +package com.baeldung.beansinjectiontypes.constructor; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.baeldung.beansinjectiontypes.Car; +import com.baeldung.beansinjectiontypes.Sedan; + +@Configuration(value="constructorConfig") +public class Config { + @Bean + public Car car() { + return new Sedan(); + } + + @Bean + public Dealership dealership() { + return new Dealership(car()); + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Dealership.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Dealership.java new file mode 100644 index 0000000000..6151ec8e70 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Dealership.java @@ -0,0 +1,20 @@ +package com.baeldung.beansinjectiontypes.constructor; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.baeldung.beansinjectiontypes.Car; + +@Component(value="constructorDealership") +public class Dealership { + private Car car; + + @Autowired + public Dealership(Car car) { + this.car = car; + } + + public Car getCar() { + return car; + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerFile.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerFile.java new file mode 100644 index 0000000000..924372e3df --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerFile.java @@ -0,0 +1,15 @@ +package com.baeldung.beansinjectiontypes.constructor; + +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +public class HornCheckerFile { + + public static void main(String[] args) { + try (AnnotationConfigApplicationContext context = + new AnnotationConfigApplicationContext(Config.class)) { + Dealership dealership = (Dealership) context.getBean("dealership"); + + dealership.getCar().honk(); + } + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerXML.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerXML.java new file mode 100644 index 0000000000..3c035986e6 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerXML.java @@ -0,0 +1,15 @@ +package com.baeldung.beansinjectiontypes.constructor; + +import org.springframework.context.support.FileSystemXmlApplicationContext; + +public class HornCheckerXML { + + public static void main(String[] args) { + try (FileSystemXmlApplicationContext context = + new FileSystemXmlApplicationContext("src/main/resources/beansinjectiontypes-ctx.xml")) { + Dealership dealership = (Dealership) context.getBean("constructorDealership"); + + dealership.getCar().honk(); + } + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Config.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Config.java new file mode 100644 index 0000000000..212d303ce7 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Config.java @@ -0,0 +1,22 @@ +package com.baeldung.beansinjectiontypes.setter; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.baeldung.beansinjectiontypes.Car; +import com.baeldung.beansinjectiontypes.Sedan; + +@Configuration(value="setterConfig") +public class Config { + @Bean + public Car car() { + return new Sedan(); + } + + @Bean + public Dealership dealership() { + Dealership dealership = new Dealership(); + dealership.setCar(car()); + return dealership; + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Dealership.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Dealership.java new file mode 100644 index 0000000000..db9c7cbceb --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Dealership.java @@ -0,0 +1,19 @@ +package com.baeldung.beansinjectiontypes.setter; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.baeldung.beansinjectiontypes.Car; + +@Component(value="setterDealership") +public class Dealership { + private Car car; + + @Autowired + public void setCar(Car car) { + this.car = car; + } + public Car getCar() { + return car; + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerFile.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerFile.java new file mode 100644 index 0000000000..3372635bd3 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerFile.java @@ -0,0 +1,15 @@ +package com.baeldung.beansinjectiontypes.setter; + +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +public class HornCheckerFile { + + public static void main(String[] args) { + try (AnnotationConfigApplicationContext context = + new AnnotationConfigApplicationContext(Config.class)) { + Dealership dealership = (Dealership) context.getBean("dealership"); + + dealership.getCar().honk(); + } + } +} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerXML.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerXML.java new file mode 100644 index 0000000000..0863d16d86 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerXML.java @@ -0,0 +1,15 @@ +package com.baeldung.beansinjectiontypes.setter; + +import org.springframework.context.support.FileSystemXmlApplicationContext; + +public class HornCheckerXML { + + public static void main(String[] args) { + try (FileSystemXmlApplicationContext context = + new FileSystemXmlApplicationContext("src/main/resources/beansinjectiontypes-ctx.xml")) { + Dealership dealership = (Dealership) context.getBean("setterDealership"); + + dealership.getCar().honk(); + } + } +} diff --git a/spring-core/src/main/resources/beansinjectiontypes-ctx.xml b/spring-core/src/main/resources/beansinjectiontypes-ctx.xml new file mode 100644 index 0000000000..86131a83b1 --- /dev/null +++ b/spring-core/src/main/resources/beansinjectiontypes-ctx.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/spring-core/src/test/java/com/baeldung/beansinjectiontypes/BeansInjectionTypesIntegrationTest.java b/spring-core/src/test/java/com/baeldung/beansinjectiontypes/BeansInjectionTypesIntegrationTest.java new file mode 100644 index 0000000000..9ffa44ced7 --- /dev/null +++ b/spring-core/src/test/java/com/baeldung/beansinjectiontypes/BeansInjectionTypesIntegrationTest.java @@ -0,0 +1,56 @@ +package com.baeldung.beansinjectiontypes; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.support.FileSystemXmlApplicationContext; + +import com.baeldung.beansinjectiontypes.constructor.Config; +import com.baeldung.beansinjectiontypes.constructor.Dealership; + +public class BeansInjectionTypesIntegrationTest { + + @Test + public void configBean_WhenSetOnConstructor_ThenDependencyValid() { + try (AnnotationConfigApplicationContext context = + new AnnotationConfigApplicationContext(Config.class)) { + Dealership dealership = (Dealership) context.getBean("dealership"); + + assertTrue(dealership.getCar() instanceof Sedan); + } + } + + @Test + public void configBean_WhenSetOnSetter_ThenDependencyValid() { + try (AnnotationConfigApplicationContext context = + new AnnotationConfigApplicationContext(com.baeldung.beansinjectiontypes.setter.Config.class)) { + com.baeldung.beansinjectiontypes.setter.Dealership dealership = + (com.baeldung.beansinjectiontypes.setter.Dealership) context.getBean("dealership"); + + assertTrue(dealership.getCar() instanceof Sedan); + } + } + + @Test + public void annotationAndXML_WhenSetOnSetter_ThenDependencyValid() { + try (FileSystemXmlApplicationContext context = + new FileSystemXmlApplicationContext("src/main/resources/beansinjectiontypes-ctx.xml")) { + Dealership dealership = (Dealership) context.getBean("constructorDealership"); + + assertTrue(dealership.getCar() instanceof Sedan); + } + } + + @Test + public void annotationAndXML_WhenSetOnConstructor_ThenDependencyValid() { + try (FileSystemXmlApplicationContext context = + new FileSystemXmlApplicationContext("src/main/resources/beansinjectiontypes-ctx.xml")) { + com.baeldung.beansinjectiontypes.setter.Dealership dealership = + (com.baeldung.beansinjectiontypes.setter.Dealership) context.getBean("setterDealership"); + + assertTrue(dealership.getCar() instanceof Sedan); + } + } + +} From e792f17f82f863850d07884f4638c53beca7f52f Mon Sep 17 00:00:00 2001 From: alv21 Date: Fri, 2 Mar 2018 18:08:04 +0100 Subject: [PATCH 002/441] BAEL-1585 --- .../com/baeldung/java_8_features/Car.java | 31 +++++++++++++++++++ .../baeldung/java8/Java8MaxMinUnitTest.java | 26 ++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 core-java-8/src/main/java/com/baeldung/java_8_features/Car.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/Car.java b/core-java-8/src/main/java/com/baeldung/java_8_features/Car.java new file mode 100644 index 0000000000..139475bc25 --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/java_8_features/Car.java @@ -0,0 +1,31 @@ +package com.baeldung.java_8_features; + +public class Car { + + private String model; + private int topSpeed; + + public Car(String model, int topSpeed) { + super(); + this.model = model; + this.topSpeed = topSpeed; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public int getTopSpeed() { + return topSpeed; + } + + public void setTopSpeed(int topSpeed) { + this.topSpeed = topSpeed; + } + + +} diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java index 4979338452..55caeeba5e 100644 --- a/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.java8; import com.baeldung.java_8_features.Person; +import com.baeldung.java_8_features.Car; import org.junit.Test; import java.util.Arrays; @@ -44,4 +45,29 @@ public class Java8MaxMinUnitTest { assertEquals("Should be Alex", alex, minByAge); } + @Test + public void whenArrayIsOfIntegerThenMinCanBeDoneUsingIntegerComparator() { + int[] integers = new int[] { 20, 98, 12, 7, 35 }; + + int min = Arrays.stream(integers) + .min() + .getAsInt(); + + assertEquals(7, min); + } + + @Test + public void whenArrayIsOfPersonObjectThenMaxCanBeDoneUsingCustomComparatorThroughLambda() { + final Car porsche = new Car("Porsche 959", 319); + final Car ferrari = new Car("Ferrari 288 GTO", 303); + final Car bugatti = new Car("Bugatti Veyron 16.4 Super Sport", 415); + final Car mcLaren = new Car("McLaren F1", 355); + final Car[] fastCars = { porsche, ferrari, bugatti, mcLaren }; + + final Car maxBySpeed = Arrays.stream(fastCars) + .max(Comparator.comparing(Car::getTopSpeed)) + .orElseThrow(NoSuchElementException::new); + + assertEquals(bugatti, maxBySpeed); + } } From af542fce4092246ca65e9799260be3bd726f286f Mon Sep 17 00:00:00 2001 From: alv21 Date: Fri, 2 Mar 2018 22:32:37 +0100 Subject: [PATCH 003/441] Revert "Different Types of Bean Injection in Spring" This reverts commit ae47827879d0e9396ad5de5f979f495629a35838. --- .../beansinjectiontypes/Cabriolet.java | 8 --- .../com/baeldung/beansinjectiontypes/Car.java | 6 -- .../DealershipTraditionalStyle.java | 9 --- .../DealershipWithDependenciesInjection.java | 13 ----- .../baeldung/beansinjectiontypes/Sedan.java | 10 ---- .../constructor/Config.java | 20 ------- .../constructor/Dealership.java | 20 ------- .../constructor/HornCheckerFile.java | 15 ----- .../constructor/HornCheckerXML.java | 15 ----- .../beansinjectiontypes/setter/Config.java | 22 -------- .../setter/Dealership.java | 19 ------- .../setter/HornCheckerFile.java | 15 ----- .../setter/HornCheckerXML.java | 15 ----- .../resources/beansinjectiontypes-ctx.xml | 10 ---- .../BeansInjectionTypesIntegrationTest.java | 56 ------------------- 15 files changed, 253 deletions(-) delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/Cabriolet.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/Car.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipTraditionalStyle.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipWithDependenciesInjection.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/Sedan.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Config.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Dealership.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerFile.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerXML.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Config.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Dealership.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerFile.java delete mode 100644 spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerXML.java delete mode 100644 spring-core/src/main/resources/beansinjectiontypes-ctx.xml delete mode 100644 spring-core/src/test/java/com/baeldung/beansinjectiontypes/BeansInjectionTypesIntegrationTest.java diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Cabriolet.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Cabriolet.java deleted file mode 100644 index 2bf9b8b954..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Cabriolet.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.beansinjectiontypes; - -public class Cabriolet implements Car{ - - public void honk(){ - System.out.println("I'm a cabriolet!"); - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Car.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Car.java deleted file mode 100644 index e88e218f95..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Car.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.baeldung.beansinjectiontypes; - -public interface Car { - - public void honk(); -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipTraditionalStyle.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipTraditionalStyle.java deleted file mode 100644 index b917049e41..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipTraditionalStyle.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.beansinjectiontypes; - -public class DealershipTraditionalStyle { - private Car car = new Sedan(); - - public Car getCar() { - return car; - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipWithDependenciesInjection.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipWithDependenciesInjection.java deleted file mode 100644 index 9b25e21dc7..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/DealershipWithDependenciesInjection.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.beansinjectiontypes; - -public class DealershipWithDependenciesInjection { - private Car car; - - public DealershipWithDependenciesInjection(Car car) { - this.car = car; - } - - public Car getCar() { - return car; - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Sedan.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Sedan.java deleted file mode 100644 index 0ae4cf5a40..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/Sedan.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.beansinjectiontypes; - -import org.springframework.stereotype.Component; - -@Component -public class Sedan implements Car { - public void honk(){ - System.out.println("I'm a sedan!"); - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Config.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Config.java deleted file mode 100644 index 3e2534f892..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Config.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.beansinjectiontypes.constructor; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.baeldung.beansinjectiontypes.Car; -import com.baeldung.beansinjectiontypes.Sedan; - -@Configuration(value="constructorConfig") -public class Config { - @Bean - public Car car() { - return new Sedan(); - } - - @Bean - public Dealership dealership() { - return new Dealership(car()); - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Dealership.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Dealership.java deleted file mode 100644 index 6151ec8e70..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/Dealership.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.beansinjectiontypes.constructor; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.baeldung.beansinjectiontypes.Car; - -@Component(value="constructorDealership") -public class Dealership { - private Car car; - - @Autowired - public Dealership(Car car) { - this.car = car; - } - - public Car getCar() { - return car; - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerFile.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerFile.java deleted file mode 100644 index 924372e3df..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerFile.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.beansinjectiontypes.constructor; - -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -public class HornCheckerFile { - - public static void main(String[] args) { - try (AnnotationConfigApplicationContext context = - new AnnotationConfigApplicationContext(Config.class)) { - Dealership dealership = (Dealership) context.getBean("dealership"); - - dealership.getCar().honk(); - } - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerXML.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerXML.java deleted file mode 100644 index 3c035986e6..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/constructor/HornCheckerXML.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.beansinjectiontypes.constructor; - -import org.springframework.context.support.FileSystemXmlApplicationContext; - -public class HornCheckerXML { - - public static void main(String[] args) { - try (FileSystemXmlApplicationContext context = - new FileSystemXmlApplicationContext("src/main/resources/beansinjectiontypes-ctx.xml")) { - Dealership dealership = (Dealership) context.getBean("constructorDealership"); - - dealership.getCar().honk(); - } - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Config.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Config.java deleted file mode 100644 index 212d303ce7..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Config.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.beansinjectiontypes.setter; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.baeldung.beansinjectiontypes.Car; -import com.baeldung.beansinjectiontypes.Sedan; - -@Configuration(value="setterConfig") -public class Config { - @Bean - public Car car() { - return new Sedan(); - } - - @Bean - public Dealership dealership() { - Dealership dealership = new Dealership(); - dealership.setCar(car()); - return dealership; - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Dealership.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Dealership.java deleted file mode 100644 index db9c7cbceb..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/Dealership.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.beansinjectiontypes.setter; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.baeldung.beansinjectiontypes.Car; - -@Component(value="setterDealership") -public class Dealership { - private Car car; - - @Autowired - public void setCar(Car car) { - this.car = car; - } - public Car getCar() { - return car; - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerFile.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerFile.java deleted file mode 100644 index 3372635bd3..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerFile.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.beansinjectiontypes.setter; - -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -public class HornCheckerFile { - - public static void main(String[] args) { - try (AnnotationConfigApplicationContext context = - new AnnotationConfigApplicationContext(Config.class)) { - Dealership dealership = (Dealership) context.getBean("dealership"); - - dealership.getCar().honk(); - } - } -} diff --git a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerXML.java b/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerXML.java deleted file mode 100644 index 0863d16d86..0000000000 --- a/spring-core/src/main/java/com/baeldung/beansinjectiontypes/setter/HornCheckerXML.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.beansinjectiontypes.setter; - -import org.springframework.context.support.FileSystemXmlApplicationContext; - -public class HornCheckerXML { - - public static void main(String[] args) { - try (FileSystemXmlApplicationContext context = - new FileSystemXmlApplicationContext("src/main/resources/beansinjectiontypes-ctx.xml")) { - Dealership dealership = (Dealership) context.getBean("setterDealership"); - - dealership.getCar().honk(); - } - } -} diff --git a/spring-core/src/main/resources/beansinjectiontypes-ctx.xml b/spring-core/src/main/resources/beansinjectiontypes-ctx.xml deleted file mode 100644 index 86131a83b1..0000000000 --- a/spring-core/src/main/resources/beansinjectiontypes-ctx.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/spring-core/src/test/java/com/baeldung/beansinjectiontypes/BeansInjectionTypesIntegrationTest.java b/spring-core/src/test/java/com/baeldung/beansinjectiontypes/BeansInjectionTypesIntegrationTest.java deleted file mode 100644 index 9ffa44ced7..0000000000 --- a/spring-core/src/test/java/com/baeldung/beansinjectiontypes/BeansInjectionTypesIntegrationTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.baeldung.beansinjectiontypes; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.support.FileSystemXmlApplicationContext; - -import com.baeldung.beansinjectiontypes.constructor.Config; -import com.baeldung.beansinjectiontypes.constructor.Dealership; - -public class BeansInjectionTypesIntegrationTest { - - @Test - public void configBean_WhenSetOnConstructor_ThenDependencyValid() { - try (AnnotationConfigApplicationContext context = - new AnnotationConfigApplicationContext(Config.class)) { - Dealership dealership = (Dealership) context.getBean("dealership"); - - assertTrue(dealership.getCar() instanceof Sedan); - } - } - - @Test - public void configBean_WhenSetOnSetter_ThenDependencyValid() { - try (AnnotationConfigApplicationContext context = - new AnnotationConfigApplicationContext(com.baeldung.beansinjectiontypes.setter.Config.class)) { - com.baeldung.beansinjectiontypes.setter.Dealership dealership = - (com.baeldung.beansinjectiontypes.setter.Dealership) context.getBean("dealership"); - - assertTrue(dealership.getCar() instanceof Sedan); - } - } - - @Test - public void annotationAndXML_WhenSetOnSetter_ThenDependencyValid() { - try (FileSystemXmlApplicationContext context = - new FileSystemXmlApplicationContext("src/main/resources/beansinjectiontypes-ctx.xml")) { - Dealership dealership = (Dealership) context.getBean("constructorDealership"); - - assertTrue(dealership.getCar() instanceof Sedan); - } - } - - @Test - public void annotationAndXML_WhenSetOnConstructor_ThenDependencyValid() { - try (FileSystemXmlApplicationContext context = - new FileSystemXmlApplicationContext("src/main/resources/beansinjectiontypes-ctx.xml")) { - com.baeldung.beansinjectiontypes.setter.Dealership dealership = - (com.baeldung.beansinjectiontypes.setter.Dealership) context.getBean("setterDealership"); - - assertTrue(dealership.getCar() instanceof Sedan); - } - } - -} From c7fbcd217ce6abe93d5dabafad98cc5007adf5ed Mon Sep 17 00:00:00 2001 From: alv21 Date: Fri, 2 Mar 2018 22:38:52 +0100 Subject: [PATCH 004/441] Revert "BAEL-1585" This reverts commit e792f17f82f863850d07884f4638c53beca7f52f. --- .../com/baeldung/java_8_features/Car.java | 31 ------------------- .../baeldung/java8/Java8MaxMinUnitTest.java | 26 ---------------- 2 files changed, 57 deletions(-) delete mode 100644 core-java-8/src/main/java/com/baeldung/java_8_features/Car.java diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/Car.java b/core-java-8/src/main/java/com/baeldung/java_8_features/Car.java deleted file mode 100644 index 139475bc25..0000000000 --- a/core-java-8/src/main/java/com/baeldung/java_8_features/Car.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baeldung.java_8_features; - -public class Car { - - private String model; - private int topSpeed; - - public Car(String model, int topSpeed) { - super(); - this.model = model; - this.topSpeed = topSpeed; - } - - public String getModel() { - return model; - } - - public void setModel(String model) { - this.model = model; - } - - public int getTopSpeed() { - return topSpeed; - } - - public void setTopSpeed(int topSpeed) { - this.topSpeed = topSpeed; - } - - -} diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java index 55caeeba5e..4979338452 100644 --- a/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java @@ -1,7 +1,6 @@ package com.baeldung.java8; import com.baeldung.java_8_features.Person; -import com.baeldung.java_8_features.Car; import org.junit.Test; import java.util.Arrays; @@ -45,29 +44,4 @@ public class Java8MaxMinUnitTest { assertEquals("Should be Alex", alex, minByAge); } - @Test - public void whenArrayIsOfIntegerThenMinCanBeDoneUsingIntegerComparator() { - int[] integers = new int[] { 20, 98, 12, 7, 35 }; - - int min = Arrays.stream(integers) - .min() - .getAsInt(); - - assertEquals(7, min); - } - - @Test - public void whenArrayIsOfPersonObjectThenMaxCanBeDoneUsingCustomComparatorThroughLambda() { - final Car porsche = new Car("Porsche 959", 319); - final Car ferrari = new Car("Ferrari 288 GTO", 303); - final Car bugatti = new Car("Bugatti Veyron 16.4 Super Sport", 415); - final Car mcLaren = new Car("McLaren F1", 355); - final Car[] fastCars = { porsche, ferrari, bugatti, mcLaren }; - - final Car maxBySpeed = Arrays.stream(fastCars) - .max(Comparator.comparing(Car::getTopSpeed)) - .orElseThrow(NoSuchElementException::new); - - assertEquals(bugatti, maxBySpeed); - } } From c1d7b27f244b355da11a4aa562002d2b94bfd953 Mon Sep 17 00:00:00 2001 From: Rafael Zucareli Date: Wed, 1 Aug 2018 20:14:08 -0300 Subject: [PATCH 005/441] Add Subject alternative name I add a Subject alternative name (SAN) parameter in all commands. This make the generated certificate work in Google Chrome. Before that change Chrome presents a ERR_CERT_COMMON_NAME_INVALID even when you had add the certificate as a know Authority. --- spring-security-x509/keystore/Makefile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spring-security-x509/keystore/Makefile b/spring-security-x509/keystore/Makefile index 63498fea76..2b5b5e8abe 100644 --- a/spring-security-x509/keystore/Makefile +++ b/spring-security-x509/keystore/Makefile @@ -20,65 +20,65 @@ all: clean create-keystore add-host create-truststore add-client create-keystore: # Generate a certificate authority (CA) - keytool -genkey -alias ca -ext BC=ca:true \ + keytool -genkey -alias ca -ext san=dns:localhost,ip:127.0.0.1 -ext BC=ca:true \ -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -keypass $(PASSWORD) \ -validity 3650 -dname $(DNAME_CA) \ -keystore $(KEYSTORE) -storepass $(PASSWORD) add-host: # Generate a host certificate - keytool -genkey -alias $(HOSTNAME) \ + keytool -genkey -alias $(HOSTNAME) -ext san=dns:localhost,ip:127.0.0.1 \ -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -keypass $(PASSWORD) \ -validity 3650 -dname $(DNAME_HOST) \ -keystore $(KEYSTORE) -storepass $(PASSWORD) # Generate a host certificate signing request - keytool -certreq -alias $(HOSTNAME) -ext BC=ca:true \ + keytool -certreq -alias $(HOSTNAME) -ext san=dns:localhost,ip:127.0.0.1 -ext BC=ca:true \ -keyalg RSA -keysize 4096 -sigalg SHA512withRSA \ -validity 3650 -file "$(HOSTNAME).csr" \ -keystore $(KEYSTORE) -storepass $(PASSWORD) # Generate signed certificate with the certificate authority - keytool -gencert -alias ca \ + keytool -gencert -alias ca -ext san=dns:localhost,ip:127.0.0.1 \ -validity 3650 -sigalg SHA512withRSA \ -infile "$(HOSTNAME).csr" -outfile "$(HOSTNAME).crt" -rfc \ -keystore $(KEYSTORE) -storepass $(PASSWORD) # Import signed certificate into the keystore - keytool -import -trustcacerts -alias $(HOSTNAME) \ + keytool -import -trustcacerts -alias $(HOSTNAME) -ext san=dns:localhost,ip:127.0.0.1 \ -file "$(HOSTNAME).crt" \ -keystore $(KEYSTORE) -storepass $(PASSWORD) export-authority: # Export certificate authority - keytool -export -alias ca -file ca.crt -rfc \ + keytool -export -alias ca -ext san=dns:localhost,ip:127.0.0.1 -file ca.crt -rfc \ -keystore $(KEYSTORE) -storepass $(PASSWORD) create-truststore: export-authority # Import certificate authority into a new truststore - keytool -import -trustcacerts -noprompt -alias ca -file ca.crt \ + keytool -import -trustcacerts -noprompt -alias ca -ext san=dns:localhost,ip:127.0.0.1 -file ca.crt \ -keystore $(TRUSTSTORE) -storepass $(PASSWORD) add-client: # Generate client certificate - keytool -genkey -alias $(CLIENTNAME) \ + keytool -genkey -alias $(CLIENTNAME) -ext san=dns:localhost,ip:127.0.0.1 \ -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -keypass $(PASSWORD) \ -validity 3650 -dname $(DNAME_CLIENT) \ -keystore $(TRUSTSTORE) -storepass $(PASSWORD) # Generate a host certificate signing request - keytool -certreq -alias $(CLIENTNAME) -ext BC=ca:true \ + keytool -certreq -alias $(CLIENTNAME) -ext san=dns:localhost,ip:127.0.0.1 -ext BC=ca:true \ -keyalg RSA -keysize 4096 -sigalg SHA512withRSA \ -validity 3650 -file "$(CLIENTNAME).csr" \ -keystore $(TRUSTSTORE) -storepass $(PASSWORD) # Generate signed certificate with the certificate authority - keytool -gencert -alias ca \ + keytool -gencert -alias ca -ext san=dns:localhost,ip:127.0.0.1 \ -validity 3650 -sigalg SHA512withRSA \ -infile "$(CLIENTNAME).csr" -outfile "$(CLIENTNAME).crt" -rfc \ -keystore $(KEYSTORE) -storepass $(PASSWORD) # Import signed certificate into the truststore - keytool -import -trustcacerts -alias $(CLIENTNAME) \ + keytool -import -trustcacerts -alias $(CLIENTNAME) -ext san=dns:localhost,ip:127.0.0.1 \ -file "$(CLIENTNAME).crt" \ -keystore $(TRUSTSTORE) -storepass $(PASSWORD) # Export private certificate for importing into a browser - keytool -importkeystore -srcalias $(CLIENTNAME) \ + keytool -importkeystore -srcalias $(CLIENTNAME) -ext san=dns:localhost,ip:127.0.0.1 \ -srckeystore $(TRUSTSTORE) -srcstorepass $(PASSWORD) \ -destkeystore "$(CLIENTNAME).p12" -deststorepass $(PASSWORD) \ -deststoretype PKCS12 From 69c160aab9963e0fdd649719a16003c7e16e865a Mon Sep 17 00:00:00 2001 From: Yatendra Goel Date: Sun, 21 Oct 2018 07:27:01 +0530 Subject: [PATCH 006/441] BAEL-2203 - Convert java.time.Instant to java.sql.Timestamp and vice-versa --- .../datetime/ConvertInstantToTimestamp.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java diff --git a/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java b/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java new file mode 100644 index 0000000000..b2f18fd3bf --- /dev/null +++ b/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java @@ -0,0 +1,36 @@ +package com.baeldung.datetime; + +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.ZoneId; +import java.util.TimeZone; + +public class ConvertInstantToTimestamp { + + public static void main(String[] args) { + run(); + } + + public static void run() { + Instant instant = Instant.now(); + Timestamp timestamp = Timestamp.from(instant); // same point on the time-line as Instant + + System.out.println("Instant (milliseconds from epoch)" + instant.toEpochMilli()); + System.out.println("Timestamp (milliseconds from epoch): " + timestamp.getTime()); + System.out.print("\n"); + + // Local TimeZone of the machine at the time of running this code is GMT +5:30 a.k.a IST + ZoneId zoneId = ZoneId.of(ZoneId.SHORT_IDS.get("IST")); + + DateFormat df = DateFormat.getDateTimeInstance(); + df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SS'Z'"); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + + System.out.println("Instant (in UTC): " + instant); + System.out.println("Timestamp (in UTC): " + df.format(timestamp)); + System.out.println("Instant (in GMT +05:30): " + instant.atZone(zoneId)); + System.out.println("Timestamp (in GMT +05:30): " + timestamp); + } +} \ No newline at end of file From 3b17051337aee90d0f85885263af4840666ab37f Mon Sep 17 00:00:00 2001 From: Yatendra Goel Date: Wed, 24 Oct 2018 17:55:34 +0530 Subject: [PATCH 007/441] BAEL-2203: Review edits --- .../java/com/baeldung/datetime/ConvertInstantToTimestamp.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java b/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java index b2f18fd3bf..e8ce4adaa1 100644 --- a/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java +++ b/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java @@ -16,8 +16,9 @@ public class ConvertInstantToTimestamp { public static void run() { Instant instant = Instant.now(); Timestamp timestamp = Timestamp.from(instant); // same point on the time-line as Instant + instant = timestamp.toInstant(); - System.out.println("Instant (milliseconds from epoch)" + instant.toEpochMilli()); + System.out.println("Instant (milliseconds from epoch): " + instant.toEpochMilli()); System.out.println("Timestamp (milliseconds from epoch): " + timestamp.getTime()); System.out.print("\n"); From 7064a7e30960c51b7ed2b8aebee6465d6d4c3cb2 Mon Sep 17 00:00:00 2001 From: Yatendra Goel Date: Sat, 3 Nov 2018 01:01:07 +0530 Subject: [PATCH 008/441] Removed ZoneId code --- .../datetime/ConvertInstantToTimestamp.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java b/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java index e8ce4adaa1..53618b3c31 100644 --- a/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java +++ b/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java @@ -1,5 +1,7 @@ package com.baeldung.datetime; +import static org.junit.Assert.assertEquals; + import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -16,22 +18,15 @@ public class ConvertInstantToTimestamp { public static void run() { Instant instant = Instant.now(); Timestamp timestamp = Timestamp.from(instant); // same point on the time-line as Instant + assertEquals(instant.toEpochMilli(), timestamp.getTime()); + instant = timestamp.toInstant(); - - System.out.println("Instant (milliseconds from epoch): " + instant.toEpochMilli()); - System.out.println("Timestamp (milliseconds from epoch): " + timestamp.getTime()); - System.out.print("\n"); - - // Local TimeZone of the machine at the time of running this code is GMT +5:30 a.k.a IST - ZoneId zoneId = ZoneId.of(ZoneId.SHORT_IDS.get("IST")); + assertEquals(instant.toEpochMilli(), timestamp.getTime()); DateFormat df = DateFormat.getDateTimeInstance(); - df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SS'Z'"); + df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); - System.out.println("Instant (in UTC): " + instant); - System.out.println("Timestamp (in UTC): " + df.format(timestamp)); - System.out.println("Instant (in GMT +05:30): " + instant.atZone(zoneId)); - System.out.println("Timestamp (in GMT +05:30): " + timestamp); + assertEquals(instant.toString(), df.format(timestamp).toString()); } -} \ No newline at end of file +} From 5e1fc54ec2cfc589988af9f2b8cd4a3bf1ac7290 Mon Sep 17 00:00:00 2001 From: Yatendra Goel Date: Sat, 3 Nov 2018 15:59:05 +0530 Subject: [PATCH 009/441] Converted class to JUnit Test --- .../ConvertInstantToTimestampTest.java} | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) rename java-dates/src/{main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java => test/java/com/baeldung/datetime/ConvertInstantToTimestampTest.java} (55%) diff --git a/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java b/java-dates/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampTest.java similarity index 55% rename from java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java rename to java-dates/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampTest.java index 53618b3c31..bfbd911e95 100644 --- a/java-dates/src/main/java/com/baeldung/datetime/ConvertInstantToTimestamp.java +++ b/java-dates/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampTest.java @@ -1,6 +1,6 @@ package com.baeldung.datetime; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.sql.Timestamp; import java.text.DateFormat; @@ -9,24 +9,22 @@ import java.time.Instant; import java.time.ZoneId; import java.util.TimeZone; -public class ConvertInstantToTimestamp { +import org.junit.Test; - public static void main(String[] args) { - run(); - } +public class ConvertInstantToTimestampTest { - public static void run() { + @Test + public void givenInstant_whenConvertedToTimestamp_thenGetTimestampWithSamePointOnTimeline() { Instant instant = Instant.now(); Timestamp timestamp = Timestamp.from(instant); // same point on the time-line as Instant - assertEquals(instant.toEpochMilli(), timestamp.getTime()); + assertThat(instant.toEpochMilli()).isEqualTo(timestamp.getTime()); instant = timestamp.toInstant(); - assertEquals(instant.toEpochMilli(), timestamp.getTime()); + assertThat(instant.toEpochMilli()).isEqualTo(timestamp.getTime()); DateFormat df = DateFormat.getDateTimeInstance(); df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); - - assertEquals(instant.toString(), df.format(timestamp).toString()); + assertThat(instant.toString()).isEqualTo(df.format(timestamp).toString()); } } From ce76dcde0d3594abb32b8b369d57baefaad786d1 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 3 Nov 2018 20:41:53 +0200 Subject: [PATCH 010/441] Update and rename ConvertInstantToTimestampTest.java to ConvertInstantToTimestampUnitTest.java --- ...imestampTest.java => ConvertInstantToTimestampUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename java-dates/src/test/java/com/baeldung/datetime/{ConvertInstantToTimestampTest.java => ConvertInstantToTimestampUnitTest.java} (95%) diff --git a/java-dates/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampTest.java b/java-dates/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampUnitTest.java similarity index 95% rename from java-dates/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampTest.java rename to java-dates/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampUnitTest.java index bfbd911e95..3ba01a591a 100644 --- a/java-dates/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampTest.java +++ b/java-dates/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampUnitTest.java @@ -11,7 +11,7 @@ import java.util.TimeZone; import org.junit.Test; -public class ConvertInstantToTimestampTest { +public class ConvertInstantToTimestampUnitTest { @Test public void givenInstant_whenConvertedToTimestamp_thenGetTimestampWithSamePointOnTimeline() { From 530395a44a35abab70d4ca599cc5088ba01a855a Mon Sep 17 00:00:00 2001 From: Yatendra Goel Date: Sun, 2 Dec 2018 23:45:35 +0530 Subject: [PATCH 011/441] BAEL-2403: Immutable Map implementations in Java --- .../baeldung/java/map/ImmutableMapTest.java | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapTest.java diff --git a/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapTest.java b/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapTest.java new file mode 100644 index 0000000000..d2637d8368 --- /dev/null +++ b/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapTest.java @@ -0,0 +1,87 @@ +package com.baeldung.java.map; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import com.google.common.collect.ImmutableMap; + + +public class ImmutableMapTest { + + @Test + public void whenCollectionsUnModifiableMapMethod_thenOriginalCollectionChangesReflectInUnmodifiableMap() { + + Map mutableMap = new HashMap<>(); + mutableMap.put("USA", "North America"); + + Map unmodifiableMap = Collections.unmodifiableMap(mutableMap); + assertThrows(UnsupportedOperationException.class, () -> unmodifiableMap.put("Canada", "North America")); + + mutableMap.remove("USA"); + assertFalse(unmodifiableMap.containsKey("USA")); + + mutableMap.put("Mexico", "North America"); + assertTrue(unmodifiableMap.containsKey("Mexico")); + } + + @Test + @SuppressWarnings("deprecation") + public void whenGuavaImmutableMapFromCopyOfMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() { + + Map mutableMap = new HashMap<>(); + mutableMap.put("USA", "North America"); + + ImmutableMap immutableMap = ImmutableMap.copyOf(mutableMap); + assertTrue(immutableMap.containsKey("USA")); + + assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); + + mutableMap.remove("USA"); + assertTrue(immutableMap.containsKey("USA")); + + mutableMap.put("Mexico", "North America"); + assertFalse(immutableMap.containsKey("Mexico")); + } + + @Test + @SuppressWarnings("deprecation") + public void whenGuavaImmutableMapFromBuilderMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() { + + Map mutableMap = new HashMap<>(); + mutableMap.put("USA", "North America"); + + ImmutableMap immutableMap = ImmutableMap.builder() + .putAll(mutableMap) + .put("Costa Rica", "North America") + .build(); + assertTrue(immutableMap.containsKey("USA")); + assertTrue(immutableMap.containsKey("Costa Rica")); + + assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); + + mutableMap.remove("USA"); + assertTrue(immutableMap.containsKey("USA")); + + mutableMap.put("Mexico", "North America"); + assertFalse(immutableMap.containsKey("Mexico")); + } + + @Test + @SuppressWarnings("deprecation") + public void whenGuavaImmutableMapFromOfMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() { + + ImmutableMap immutableMap = ImmutableMap.of("USA", "North America", "Costa Rica", "North America"); + assertTrue(immutableMap.containsKey("USA")); + assertTrue(immutableMap.containsKey("Costa Rica")); + + assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); + } + +} From 3b30ae74ceb47604688fac7922e5a850e51d5423 Mon Sep 17 00:00:00 2001 From: Yatendra Goel Date: Mon, 3 Dec 2018 22:53:00 +0530 Subject: [PATCH 012/441] BAEL-2403: Immutable Map implementations in Java - Changed file name --- .../map/{ImmutableMapTest.java => ImmutableMapUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename java-collections-maps/src/test/java/com/baeldung/java/map/{ImmutableMapTest.java => ImmutableMapUnitTest.java} (98%) diff --git a/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapTest.java b/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapUnitTest.java similarity index 98% rename from java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapTest.java rename to java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapUnitTest.java index d2637d8368..b239ae07d8 100644 --- a/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapTest.java +++ b/java-collections-maps/src/test/java/com/baeldung/java/map/ImmutableMapUnitTest.java @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test; import com.google.common.collect.ImmutableMap; -public class ImmutableMapTest { +public class ImmutableMapUnitTest { @Test public void whenCollectionsUnModifiableMapMethod_thenOriginalCollectionChangesReflectInUnmodifiableMap() { From a4d768763b9275d717c92bdf19ea93f4186dfd15 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Thu, 6 Dec 2018 15:23:13 +0400 Subject: [PATCH 013/441] Vector class example --- .../com/baeldung/java/list/VectorExample.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java diff --git a/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java b/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java new file mode 100644 index 0000000000..38736390ca --- /dev/null +++ b/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java @@ -0,0 +1,21 @@ +package com.baeldung.java.list; + +import java.util.Enumeration; +import java.util.Vector; + +public class VectorExample { + + public static void main(String[] args) { + + Vector vector = new Vector<>(); + vector.add("baeldung"); + vector.add("Vector"); + vector.add("example"); + + Enumeration e = vector.elements(); + while(e.hasMoreElements()){ + System.out.println(e.nextElement()); + } + } + +} From c52862fdd42d370f6a9ac923cb9a43ad2a29696d Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Thu, 13 Dec 2018 17:23:25 +0400 Subject: [PATCH 014/441] Vector class JMH --- .../baeldung/performance/ArrayListBenchmark.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java b/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java index dddd85007d..5c3f7531e3 100644 --- a/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java +++ b/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java @@ -17,6 +17,7 @@ public class ArrayListBenchmark { public static class MyState { List employeeList = new ArrayList<>(); + Vector employeeVector = new Vector<>(); //LinkedList employeeList = new LinkedList<>(); long iterations = 100000; @@ -29,9 +30,11 @@ public class ArrayListBenchmark { public void setUp() { for (long i = 0; i < iterations; i++) { employeeList.add(new Employee(i, "John")); + employeeVector.add(new Employee(i, "John")); } employeeList.add(employee); + employeeVector.add(employee); employeeIndex = employeeList.indexOf(employee); } } @@ -55,16 +58,20 @@ public class ArrayListBenchmark { public Employee testGet(ArrayListBenchmark.MyState state) { return state.employeeList.get(state.employeeIndex); } + @Benchmark + public Employee testVectorGet(ArrayListBenchmark.MyState state) { + return state.employeeVector.get(state.employeeIndex); + } @Benchmark public boolean testRemove(ArrayListBenchmark.MyState state) { return state.employeeList.remove(state.employee); } -// @Benchmark -// public void testAdd(ArrayListBenchmark.MyState state) { -// state.employeeList.add(new Employee(state.iterations + 1, "John")); -// } + @Benchmark + public void testAdd(ArrayListBenchmark.MyState state) { + state.employeeList.add(new Employee(state.iterations + 1, "John")); + } public static void main(String[] args) throws Exception { Options options = new OptionsBuilder() From 8e2c1ba4000cf4e25afbfb9fb826612989b88a88 Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Sat, 15 Dec 2018 16:05:16 +0530 Subject: [PATCH 015/441] BAEL-2100 Custom Lombok Annotation --- lombok-custom/pom.xml | 58 ++++++++ .../com/baeldung/singleton/Singleton.java | 10 ++ .../handlers/SingletonEclipseHandler.java | 124 ++++++++++++++++++ .../handlers/SingletonJavacHandler.java | 108 +++++++++++++++ pom.xml | 5 +- 5 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 lombok-custom/pom.xml create mode 100644 lombok-custom/src/main/java/com/baeldung/singleton/Singleton.java create mode 100644 lombok-custom/src/main/java/com/baeldung/singleton/handlers/SingletonEclipseHandler.java create mode 100644 lombok-custom/src/main/java/com/baeldung/singleton/handlers/SingletonJavacHandler.java diff --git a/lombok-custom/pom.xml b/lombok-custom/pom.xml new file mode 100644 index 0000000000..41bd042a5e --- /dev/null +++ b/lombok-custom/pom.xml @@ -0,0 +1,58 @@ + + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + 4.0.0 + lombok-custom + 0.1-SNAPSHOT + + + + org.projectlombok + lombok + 1.14.8 + provided + + + + org.kohsuke.metainf-services + metainf-services + 1.8 + + + + org.eclipse.jdt + core + 3.3.0-v_771 + + + + + + default-tools.jar + + + java.vendor + Oracle Corporation + + + + + com.sun + tools + ${java.version} + system + ${java.home}/../lib/tools.jar + + + + + + + \ No newline at end of file diff --git a/lombok-custom/src/main/java/com/baeldung/singleton/Singleton.java b/lombok-custom/src/main/java/com/baeldung/singleton/Singleton.java new file mode 100644 index 0000000000..2d2fd0ffb9 --- /dev/null +++ b/lombok-custom/src/main/java/com/baeldung/singleton/Singleton.java @@ -0,0 +1,10 @@ +package com.baeldung.singleton; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +public @interface Singleton { + + +} diff --git a/lombok-custom/src/main/java/com/baeldung/singleton/handlers/SingletonEclipseHandler.java b/lombok-custom/src/main/java/com/baeldung/singleton/handlers/SingletonEclipseHandler.java new file mode 100644 index 0000000000..03cdd707a4 --- /dev/null +++ b/lombok-custom/src/main/java/com/baeldung/singleton/handlers/SingletonEclipseHandler.java @@ -0,0 +1,124 @@ +package com.baeldung.singleton.handlers; + +import com.baeldung.singleton.Singleton; +import lombok.core.AnnotationValues; +import lombok.eclipse.EclipseAnnotationHandler; +import lombok.eclipse.EclipseNode; +import lombok.eclipse.handlers.EclipseHandlerUtil; +import org.eclipse.jdt.internal.compiler.ast.AllocationExpression; +import org.eclipse.jdt.internal.compiler.ast.Annotation; +import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; +import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; +import org.eclipse.jdt.internal.compiler.ast.FieldReference; +import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.ReturnStatement; +import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; +import org.eclipse.jdt.internal.compiler.ast.Statement; +import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; +import org.eclipse.jdt.internal.compiler.ast.TypeReference; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.kohsuke.MetaInfServices; + +import static lombok.eclipse.Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; +import static org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.AccFinal; +import static org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.AccPrivate; +import static org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.AccStatic; + +@MetaInfServices(EclipseAnnotationHandler.class) +public class SingletonEclipseHandler extends EclipseAnnotationHandler { + + + @Override + public void handle(AnnotationValues annotation, Annotation ast, EclipseNode annotationNode) { + + //remove annotation + EclipseHandlerUtil.unboxAndRemoveAnnotationParameter(ast, "onType", "@Singleton(onType=", annotationNode); + + //add private constructor + EclipseNode singletonClass = annotationNode.up(); + + TypeDeclaration singletonClassType = (TypeDeclaration) singletonClass.get(); + ConstructorDeclaration constructor = addConstructor(singletonClass, singletonClassType); + + TypeReference singletonTypeRef = EclipseHandlerUtil.cloneSelfType(singletonClass, singletonClassType); + + //add inner class + + //add instance field + StringBuilder sb = new StringBuilder(); + sb.append(singletonClass.getName()); + sb.append("Holder"); + String innerClassName = sb.toString(); + TypeDeclaration innerClass = new TypeDeclaration(singletonClassType.compilationResult); + innerClass.modifiers = AccPrivate | AccStatic; + innerClass.name = innerClassName.toCharArray(); + + FieldDeclaration instanceVar = addInstanceVar(constructor, singletonTypeRef, innerClass); + + FieldDeclaration[] declarations = new FieldDeclaration[]{instanceVar}; + innerClass.fields = declarations; + + EclipseHandlerUtil.injectType(singletonClass, innerClass); + + addFactoryMethod(singletonClass, singletonClassType, singletonTypeRef, innerClass, instanceVar); + + + } + + private void addFactoryMethod(EclipseNode singletonClass, TypeDeclaration astNode, TypeReference typeReference, TypeDeclaration innerClass, FieldDeclaration field) { + MethodDeclaration factoryMethod = new MethodDeclaration(astNode.compilationResult); + factoryMethod.modifiers = AccStatic | ClassFileConstants.AccPublic; + factoryMethod.returnType = typeReference; + factoryMethod.sourceStart = astNode.sourceStart; + factoryMethod.sourceEnd = astNode.sourceEnd; + factoryMethod.selector = "getInstance".toCharArray(); + factoryMethod.bits = ECLIPSE_DO_NOT_TOUCH_FLAG; + + long pS = factoryMethod.sourceStart; + long pE = factoryMethod.sourceEnd; + long p = (long) pS << 32 | pE; + + FieldReference ref = new FieldReference(field.name, p); + ref.receiver = new SingleNameReference(innerClass.name, p); + + ReturnStatement statement = new ReturnStatement(ref, astNode.sourceStart, astNode.sourceEnd); + + factoryMethod.statements = new Statement[]{statement}; + + EclipseHandlerUtil.injectMethod(singletonClass, factoryMethod); + } + + private FieldDeclaration addInstanceVar(ConstructorDeclaration constructor, TypeReference typeReference, TypeDeclaration innerClass) { + FieldDeclaration field = new FieldDeclaration(); + field.modifiers = AccPrivate | AccStatic | AccFinal; + field.name = "INSTANCE".toCharArray(); + + field.type = typeReference; + + AllocationExpression exp = new AllocationExpression(); + exp.type = typeReference; + exp.binding = constructor.binding; + exp.sourceStart = innerClass.sourceStart; + exp.sourceEnd = innerClass.sourceEnd; + + field.initialization = exp; + return field; + } + + private ConstructorDeclaration addConstructor(EclipseNode singletonClass, TypeDeclaration astNode) { + ConstructorDeclaration constructor = new ConstructorDeclaration(astNode.compilationResult); + constructor.modifiers = AccPrivate; + constructor.selector = astNode.name; + constructor.sourceStart = astNode.sourceStart; + constructor.sourceEnd = astNode.sourceEnd; + constructor.thrownExceptions = null; + constructor.typeParameters = null; + constructor.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; + constructor.bodyStart = constructor.declarationSourceStart = constructor.sourceStart = astNode.sourceStart; + constructor.bodyEnd = constructor.declarationSourceEnd = constructor.sourceEnd = astNode.sourceEnd; + constructor.arguments = null; + + EclipseHandlerUtil.injectMethod(singletonClass, constructor); + return constructor; + } +} diff --git a/lombok-custom/src/main/java/com/baeldung/singleton/handlers/SingletonJavacHandler.java b/lombok-custom/src/main/java/com/baeldung/singleton/handlers/SingletonJavacHandler.java new file mode 100644 index 0000000000..1f4cf0ea58 --- /dev/null +++ b/lombok-custom/src/main/java/com/baeldung/singleton/handlers/SingletonJavacHandler.java @@ -0,0 +1,108 @@ +package com.baeldung.singleton.handlers; + +import com.baeldung.singleton.Singleton; +import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; +import lombok.core.AnnotationValues; +import lombok.javac.Javac8BasedLombokOptions; +import lombok.javac.JavacAnnotationHandler; +import lombok.javac.JavacNode; +import lombok.javac.JavacTreeMaker; +import lombok.javac.handlers.JavacHandlerUtil; +import org.kohsuke.MetaInfServices; + +import static lombok.javac.handlers.JavacHandlerUtil.deleteAnnotationIfNeccessary; +import static lombok.javac.handlers.JavacHandlerUtil.deleteImportFromCompilationUnit; + +@MetaInfServices(JavacAnnotationHandler.class) +public class SingletonJavacHandler extends JavacAnnotationHandler { + + @Override + public void handle(AnnotationValues annotation, JCTree.JCAnnotation ast, JavacNode annotationNode) { + + Context context = annotationNode.getContext(); + + Javac8BasedLombokOptions options = Javac8BasedLombokOptions.replaceWithDelombokOptions(context); + options.deleteLombokAnnotations(); + + //remove annotation + deleteAnnotationIfNeccessary(annotationNode, Singleton.class); + //remove import + deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel"); + + //private constructor + JavacNode singletonClass = annotationNode.up(); + JavacTreeMaker singletonClassTreeMaker = singletonClass.getTreeMaker(); + + addPrivateConstructor(singletonClass, singletonClassTreeMaker); + + //singleton holder + JavacNode holderInnerClass = addInnerClass(singletonClass, singletonClassTreeMaker); + + //inject static field to this + addInstanceVar(singletonClass, singletonClassTreeMaker, holderInnerClass); + + //add factory method + addFactoryMethod(singletonClass, singletonClassTreeMaker, holderInnerClass); + } + + private void addFactoryMethod(JavacNode singletonClass, JavacTreeMaker singletonClassTreeMaker, JavacNode holderInnerClass) { + JCTree.JCModifiers modifiers = singletonClassTreeMaker.Modifiers(Flags.PUBLIC | Flags.STATIC); + + JCTree.JCClassDecl singletonClassDecl = (JCTree.JCClassDecl) singletonClass.get(); + JCTree.JCIdent singletonClassType = singletonClassTreeMaker.Ident(singletonClassDecl.name); + + JCTree.JCBlock block = addReturnBlock(singletonClassTreeMaker, holderInnerClass); + + JCTree.JCMethodDecl factoryMethod = singletonClassTreeMaker.MethodDef(modifiers, singletonClass.toName("getInstance"), singletonClassType, List.nil(), List.nil(), List.nil(), block, null); + JavacHandlerUtil.injectMethod(singletonClass, factoryMethod); + } + + private JCTree.JCBlock addReturnBlock(JavacTreeMaker singletonClassTreeMaker, JavacNode holderInnerClass) { + + JCTree.JCClassDecl holderInnerClassDecl = (JCTree.JCClassDecl) holderInnerClass.get(); + JavacTreeMaker holderInnerClassTreeMaker = holderInnerClass.getTreeMaker(); + JCTree.JCIdent holderInnerClassType = holderInnerClassTreeMaker.Ident(holderInnerClassDecl.name); + + JCTree.JCFieldAccess instanceVarAccess = holderInnerClassTreeMaker.Select(holderInnerClassType, holderInnerClass.toName("INSTANCE")); + JCTree.JCReturn returnValue = singletonClassTreeMaker.Return(instanceVarAccess); + + ListBuffer statements = new ListBuffer<>(); + statements.append(returnValue); + + return singletonClassTreeMaker.Block(0L, statements.toList()); + } + + + private void addInstanceVar(JavacNode singletonClass, JavacTreeMaker singletonClassTM, JavacNode holderClass) { + JCTree.JCModifiers fieldMod = singletonClassTM.Modifiers(Flags.PRIVATE | Flags.STATIC | Flags.FINAL); + + JCTree.JCClassDecl singletonClassDecl = (JCTree.JCClassDecl) singletonClass.get(); + JCTree.JCIdent singletonClassType = singletonClassTM.Ident(singletonClassDecl.name); + + JCTree.JCNewClass newKeyword = singletonClassTM.NewClass(null, List.nil(), singletonClassType, List.nil(), null); + + JCTree.JCVariableDecl instanceVar = singletonClassTM.VarDef(fieldMod, singletonClass.toName("INSTANCE"), singletonClassType, newKeyword); + JavacHandlerUtil.injectField(holderClass, instanceVar); + } + + private JavacNode addInnerClass(JavacNode singletonClass, JavacTreeMaker singletonTM) { + JCTree.JCModifiers modifiers = singletonTM.Modifiers(Flags.PRIVATE | Flags.STATIC); + String innerClassName = singletonClass.getName() + "Holder"; + JCTree.JCClassDecl innerClassDecl = singletonTM.ClassDef(modifiers, singletonClass.toName(innerClassName), List.nil(), null, List.nil(), List.nil()); + return JavacHandlerUtil.injectType(singletonClass, innerClassDecl); + } + + private void addPrivateConstructor(JavacNode singletonClass, JavacTreeMaker singletonTM) { + JCTree.JCModifiers modifiers = singletonTM.Modifiers(Flags.PRIVATE); + JCTree.JCBlock block = singletonTM.Block(0L, List.nil()); + JCTree.JCMethodDecl constructor = singletonTM.MethodDef(modifiers, singletonClass.toName(""), null, List.nil(), List.nil(), List.nil(), block, null); + + JavacHandlerUtil.injectMethod(singletonClass, constructor); + } + + +} diff --git a/pom.xml b/pom.xml index 99dae9decb..03a66080c2 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,10 @@ com.baeldung parent-modules 1.0.0-SNAPSHOT - parent-modules + + lombok-custom + + parent-modules pom From cf56b33b9bc2890f419e529ffd37dea4ec5c38ae Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 14:43:32 +0100 Subject: [PATCH 016/441] BAEL-2435 Update pom file -Add description -Change parent to parent-boot-2 to leverage a spring boot start up approach -Replace core dependency for axon-spring-boot-autoconfigure excluding axon-server as we cant start that up for this use case -Add spring-boot-autoconfigure dependency -Adjust the axon version to 4.0.3 --- axon/pom.xml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/axon/pom.xml b/axon/pom.xml index c643ea9e57..bb7839f150 100644 --- a/axon/pom.xml +++ b/axon/pom.xml @@ -4,29 +4,45 @@ 4.0.0 axon axon - + Basic Axon Framework with Spring Boot configuration tutorial + - parent-modules com.baeldung - 1.0.0-SNAPSHOT + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + + org.axonframework + axon-spring-boot-autoconfigure + ${axon.version} + + + org.axonframework + axon-server-connector + + + + org.axonframework axon-test ${axon.version} test + - org.axonframework - axon-core - ${axon.version} + org.springframework.boot + spring-boot-autoconfigure + 2.1.1.RELEASE + compile - 3.0.2 + 4.0.3 \ No newline at end of file From bd4881d4787cea8ee7f78309e956a7363d14c1b3 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 14:47:23 +0100 Subject: [PATCH 017/441] BAEL-2435 Update Aggregate in regards to latest axon version -Replace old import statements for the new locations -Mark the aggregate as @Aggregate to make it autowired through the spring boot starter -Move all command handlers/decision making functions to the top of the file -Rename the command handler to `handle` as a best practice for command handlers -Use @EventSourcingHandler i.o. @EventHandler as a best practice for event handlers in Aggregates, as those only are used to 'source' the aggregate -Update test case according to latest standards --- .../axon/aggregates/MessagesAggregate.java | 26 ++++++++++--------- .../MessagesAggregateIntegrationTest.java | 21 +++++++-------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/axon/src/main/java/com/baeldung/axon/aggregates/MessagesAggregate.java b/axon/src/main/java/com/baeldung/axon/aggregates/MessagesAggregate.java index e762604b74..d95dd81df9 100644 --- a/axon/src/main/java/com/baeldung/axon/aggregates/MessagesAggregate.java +++ b/axon/src/main/java/com/baeldung/axon/aggregates/MessagesAggregate.java @@ -1,16 +1,18 @@ package com.baeldung.axon.aggregates; +import static org.axonframework.modelling.command.AggregateLifecycle.apply; + +import org.axonframework.commandhandling.CommandHandler; +import org.axonframework.eventsourcing.EventSourcingHandler; +import org.axonframework.modelling.command.AggregateIdentifier; +import org.axonframework.spring.stereotype.Aggregate; + import com.baeldung.axon.commands.CreateMessageCommand; import com.baeldung.axon.commands.MarkReadMessageCommand; import com.baeldung.axon.events.MessageCreatedEvent; import com.baeldung.axon.events.MessageReadEvent; -import org.axonframework.commandhandling.CommandHandler; -import org.axonframework.commandhandling.model.AggregateIdentifier; -import org.axonframework.eventhandling.EventHandler; - -import static org.axonframework.commandhandling.model.AggregateLifecycle.apply; - +@Aggregate public class MessagesAggregate { @AggregateIdentifier @@ -24,13 +26,13 @@ public class MessagesAggregate { apply(new MessageCreatedEvent(command.getId(), command.getText())); } - @EventHandler + @CommandHandler + public void handle(MarkReadMessageCommand command) { + apply(new MessageReadEvent(id)); + } + + @EventSourcingHandler public void on(MessageCreatedEvent event) { this.id = event.getId(); } - - @CommandHandler - public void markRead(MarkReadMessageCommand command) { - apply(new MessageReadEvent(id)); - } } \ No newline at end of file diff --git a/axon/src/test/java/com/baeldung/axon/MessagesAggregateIntegrationTest.java b/axon/src/test/java/com/baeldung/axon/MessagesAggregateIntegrationTest.java index ad099d2c2b..dc008dcd78 100644 --- a/axon/src/test/java/com/baeldung/axon/MessagesAggregateIntegrationTest.java +++ b/axon/src/test/java/com/baeldung/axon/MessagesAggregateIntegrationTest.java @@ -1,29 +1,28 @@ package com.baeldung.axon; +import java.util.UUID; + +import org.axonframework.test.aggregate.AggregateTestFixture; +import org.axonframework.test.aggregate.FixtureConfiguration; +import org.junit.*; + import com.baeldung.axon.aggregates.MessagesAggregate; import com.baeldung.axon.commands.CreateMessageCommand; import com.baeldung.axon.commands.MarkReadMessageCommand; import com.baeldung.axon.events.MessageCreatedEvent; import com.baeldung.axon.events.MessageReadEvent; -import org.axonframework.test.aggregate.AggregateTestFixture; -import org.axonframework.test.aggregate.FixtureConfiguration; -import org.junit.Before; -import org.junit.Test; - -import java.util.UUID; public class MessagesAggregateIntegrationTest { private FixtureConfiguration fixture; @Before - public void setUp() throws Exception { - fixture = new AggregateTestFixture(MessagesAggregate.class); - + public void setUp() { + fixture = new AggregateTestFixture<>(MessagesAggregate.class); } @Test - public void giveAggregateRoot_whenCreateMessageCommand_thenShouldProduceMessageCreatedEvent() throws Exception { + public void giveAggregateRoot_whenCreateMessageCommand_thenShouldProduceMessageCreatedEvent() { String eventText = "Hello, how is your day?"; String id = UUID.randomUUID().toString(); fixture.given() @@ -32,7 +31,7 @@ public class MessagesAggregateIntegrationTest { } @Test - public void givenMessageCreatedEvent_whenReadMessageCommand_thenShouldProduceMessageReadEvent() throws Exception { + public void givenMessageCreatedEvent_whenReadMessageCommand_thenShouldProduceMessageReadEvent() { String id = UUID.randomUUID().toString(); fixture.given(new MessageCreatedEvent(id, "Hello :-)")) From 11b1112771d6327560debdf0c06306103c5bf7ac Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 14:48:10 +0100 Subject: [PATCH 018/441] BAEL-2435 Update the event handler Change the event handler to become a spring service, as this way Axon will automatically pick it up as an event handling component --- .../baeldung/axon/eventhandlers/MessagesEventHandler.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/axon/src/main/java/com/baeldung/axon/eventhandlers/MessagesEventHandler.java b/axon/src/main/java/com/baeldung/axon/eventhandlers/MessagesEventHandler.java index 3e51e19c4e..d7ac115a16 100644 --- a/axon/src/main/java/com/baeldung/axon/eventhandlers/MessagesEventHandler.java +++ b/axon/src/main/java/com/baeldung/axon/eventhandlers/MessagesEventHandler.java @@ -1,10 +1,12 @@ package com.baeldung.axon.eventhandlers; -import com.baeldung.axon.events.MessageReadEvent; -import com.baeldung.axon.events.MessageCreatedEvent; import org.axonframework.eventhandling.EventHandler; +import org.springframework.stereotype.Service; +import com.baeldung.axon.events.MessageCreatedEvent; +import com.baeldung.axon.events.MessageReadEvent; +@Service public class MessagesEventHandler { @EventHandler From 3553fb750685f94af4f8dbdeaffb0a140497556a Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 14:49:30 +0100 Subject: [PATCH 019/441] BAEL-2435 Update commands and events -Change TargetAggregateIdentifier import statement to the new location -Add equals/hashcode as best practice for commands and events -Add description -Change parent to parent-boot-2 to leverage a spring boot start up approach --- .../axon/commands/CreateMessageCommand.java | 28 +++++++++++++++---- .../axon/commands/MarkReadMessageCommand.java | 26 ++++++++++++++--- .../axon/events/MessageCreatedEvent.java | 27 +++++++++++++++--- .../axon/events/MessageReadEvent.java | 25 +++++++++++++++-- 4 files changed, 90 insertions(+), 16 deletions(-) diff --git a/axon/src/main/java/com/baeldung/axon/commands/CreateMessageCommand.java b/axon/src/main/java/com/baeldung/axon/commands/CreateMessageCommand.java index d0651bf12e..70d2e46480 100644 --- a/axon/src/main/java/com/baeldung/axon/commands/CreateMessageCommand.java +++ b/axon/src/main/java/com/baeldung/axon/commands/CreateMessageCommand.java @@ -1,24 +1,42 @@ package com.baeldung.axon.commands; +import java.util.Objects; -import org.axonframework.commandhandling.TargetAggregateIdentifier; +import org.axonframework.modelling.command.TargetAggregateIdentifier; public class CreateMessageCommand { - + @TargetAggregateIdentifier private final String id; private final String text; - + public CreateMessageCommand(String id, String text) { this.id = id; this.text = text; } - + public String getId() { return id; } - + public String getText() { return text; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateMessageCommand that = (CreateMessageCommand) o; + return Objects.equals(id, that.id) && Objects.equals(text, that.text); + } + + @Override + public int hashCode() { + return Objects.hash(id, text); + } } \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/commands/MarkReadMessageCommand.java b/axon/src/main/java/com/baeldung/axon/commands/MarkReadMessageCommand.java index e66582d9ec..f7d911d65b 100644 --- a/axon/src/main/java/com/baeldung/axon/commands/MarkReadMessageCommand.java +++ b/axon/src/main/java/com/baeldung/axon/commands/MarkReadMessageCommand.java @@ -1,18 +1,36 @@ package com.baeldung.axon.commands; +import java.util.Objects; -import org.axonframework.commandhandling.TargetAggregateIdentifier; +import org.axonframework.modelling.command.TargetAggregateIdentifier; public class MarkReadMessageCommand { - + @TargetAggregateIdentifier private final String id; - + public MarkReadMessageCommand(String id) { this.id = id; } - + public String getId() { return id; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MarkReadMessageCommand that = (MarkReadMessageCommand) o; + return Objects.equals(id, that.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } } \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/events/MessageCreatedEvent.java b/axon/src/main/java/com/baeldung/axon/events/MessageCreatedEvent.java index 3c9aac5ed8..e638a2a94d 100644 --- a/axon/src/main/java/com/baeldung/axon/events/MessageCreatedEvent.java +++ b/axon/src/main/java/com/baeldung/axon/events/MessageCreatedEvent.java @@ -1,20 +1,39 @@ package com.baeldung.axon.events; +import java.util.Objects; + public class MessageCreatedEvent { - + private final String id; private final String text; - + public MessageCreatedEvent(String id, String text) { this.id = id; this.text = text; } - + public String getId() { return id; } - + public String getText() { return text; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MessageCreatedEvent that = (MessageCreatedEvent) o; + return Objects.equals(id, that.id) && Objects.equals(text, that.text); + } + + @Override + public int hashCode() { + return Objects.hash(id, text); + } } \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/events/MessageReadEvent.java b/axon/src/main/java/com/baeldung/axon/events/MessageReadEvent.java index 57bfc8e19e..e362599bb3 100644 --- a/axon/src/main/java/com/baeldung/axon/events/MessageReadEvent.java +++ b/axon/src/main/java/com/baeldung/axon/events/MessageReadEvent.java @@ -1,14 +1,33 @@ package com.baeldung.axon.events; +import java.util.Objects; + public class MessageReadEvent { - + private final String id; - + public MessageReadEvent(String id) { this.id = id; } - + public String getId() { return id; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MessageReadEvent that = (MessageReadEvent) o; + return Objects.equals(id, that.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } } \ No newline at end of file From 3e3210a8038b4c9453d1958714119243d0c732d3 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 14:52:54 +0100 Subject: [PATCH 020/441] BAEL-2435 Change aggregate package -Change aggregate package to commandmodel package per best practice -Move the aggregate test to the same package for the test directory --- .../axon/{aggregates => commandmodel}/MessagesAggregate.java | 2 +- .../{ => commandmodel}/MessagesAggregateIntegrationTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) rename axon/src/main/java/com/baeldung/axon/{aggregates => commandmodel}/MessagesAggregate.java (96%) rename axon/src/test/java/com/baeldung/axon/{ => commandmodel}/MessagesAggregateIntegrationTest.java (94%) diff --git a/axon/src/main/java/com/baeldung/axon/aggregates/MessagesAggregate.java b/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java similarity index 96% rename from axon/src/main/java/com/baeldung/axon/aggregates/MessagesAggregate.java rename to axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java index d95dd81df9..b2c3a0a0b6 100644 --- a/axon/src/main/java/com/baeldung/axon/aggregates/MessagesAggregate.java +++ b/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java @@ -1,4 +1,4 @@ -package com.baeldung.axon.aggregates; +package com.baeldung.axon.commandmodel; import static org.axonframework.modelling.command.AggregateLifecycle.apply; diff --git a/axon/src/test/java/com/baeldung/axon/MessagesAggregateIntegrationTest.java b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateIntegrationTest.java similarity index 94% rename from axon/src/test/java/com/baeldung/axon/MessagesAggregateIntegrationTest.java rename to axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateIntegrationTest.java index dc008dcd78..96bb2cf3b7 100644 --- a/axon/src/test/java/com/baeldung/axon/MessagesAggregateIntegrationTest.java +++ b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.axon; +package com.baeldung.axon.commandmodel; import java.util.UUID; @@ -6,7 +6,6 @@ import org.axonframework.test.aggregate.AggregateTestFixture; import org.axonframework.test.aggregate.FixtureConfiguration; import org.junit.*; -import com.baeldung.axon.aggregates.MessagesAggregate; import com.baeldung.axon.commands.CreateMessageCommand; import com.baeldung.axon.commands.MarkReadMessageCommand; import com.baeldung.axon.events.MessageCreatedEvent; From 00b297a4d0a21282d13b7c7a41544aa56b782b59 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 14:53:43 +0100 Subject: [PATCH 021/441] BAEL-2435 Rename aggregate test Rename aggregate test from MessagesAggregateIntegrationTest to MessagesAggregateTest, as it's not an integration test but a regular unit test --- ...AggregateIntegrationTest.java => MessagesAggregateTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename axon/src/test/java/com/baeldung/axon/commandmodel/{MessagesAggregateIntegrationTest.java => MessagesAggregateTest.java} (96%) diff --git a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateIntegrationTest.java b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java similarity index 96% rename from axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateIntegrationTest.java rename to axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java index 96bb2cf3b7..30914e3fd3 100644 --- a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateIntegrationTest.java +++ b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java @@ -11,7 +11,7 @@ import com.baeldung.axon.commands.MarkReadMessageCommand; import com.baeldung.axon.events.MessageCreatedEvent; import com.baeldung.axon.events.MessageReadEvent; -public class MessagesAggregateIntegrationTest { +public class MessagesAggregateTest { private FixtureConfiguration fixture; From aaf2ef22276bc1b3f0bc64f3acbf0d3582afb9c9 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 14:54:07 +0100 Subject: [PATCH 022/441] BAEL-2435 Change eventhandlers package Change eventhandlers package to querymodel package per best practices --- .../{eventhandlers => querymodel}/MessagesEventHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename axon/src/main/java/com/baeldung/axon/{eventhandlers => querymodel}/MessagesEventHandler.java (93%) diff --git a/axon/src/main/java/com/baeldung/axon/eventhandlers/MessagesEventHandler.java b/axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java similarity index 93% rename from axon/src/main/java/com/baeldung/axon/eventhandlers/MessagesEventHandler.java rename to axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java index d7ac115a16..d93fe03941 100644 --- a/axon/src/main/java/com/baeldung/axon/eventhandlers/MessagesEventHandler.java +++ b/axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java @@ -1,4 +1,4 @@ -package com.baeldung.axon.eventhandlers; +package com.baeldung.axon.querymodel; import org.axonframework.eventhandling.EventHandler; import org.springframework.stereotype.Service; From 96945027a14e5bf1a9b72ddfac7e38e1c170af74 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 14:55:28 +0100 Subject: [PATCH 023/441] BAEL-2435 Change command message package Change the package of the command messages to coreapi.commands to signal that the commands are part of the API you'd share with the outside --- .../com/baeldung/axon/commandmodel/MessagesAggregate.java | 4 ++-- .../axon/{ => coreapi}/commands/CreateMessageCommand.java | 2 +- .../axon/{ => coreapi}/commands/MarkReadMessageCommand.java | 2 +- .../com/baeldung/axon/commandmodel/MessagesAggregateTest.java | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename axon/src/main/java/com/baeldung/axon/{ => coreapi}/commands/CreateMessageCommand.java (95%) rename axon/src/main/java/com/baeldung/axon/{ => coreapi}/commands/MarkReadMessageCommand.java (94%) diff --git a/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java b/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java index b2c3a0a0b6..60b5c7c94e 100644 --- a/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java +++ b/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java @@ -7,8 +7,8 @@ import org.axonframework.eventsourcing.EventSourcingHandler; import org.axonframework.modelling.command.AggregateIdentifier; import org.axonframework.spring.stereotype.Aggregate; -import com.baeldung.axon.commands.CreateMessageCommand; -import com.baeldung.axon.commands.MarkReadMessageCommand; +import com.baeldung.axon.coreapi.commands.CreateMessageCommand; +import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand; import com.baeldung.axon.events.MessageCreatedEvent; import com.baeldung.axon.events.MessageReadEvent; diff --git a/axon/src/main/java/com/baeldung/axon/commands/CreateMessageCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/CreateMessageCommand.java similarity index 95% rename from axon/src/main/java/com/baeldung/axon/commands/CreateMessageCommand.java rename to axon/src/main/java/com/baeldung/axon/coreapi/commands/CreateMessageCommand.java index 70d2e46480..fd03d6b269 100644 --- a/axon/src/main/java/com/baeldung/axon/commands/CreateMessageCommand.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/commands/CreateMessageCommand.java @@ -1,4 +1,4 @@ -package com.baeldung.axon.commands; +package com.baeldung.axon.coreapi.commands; import java.util.Objects; diff --git a/axon/src/main/java/com/baeldung/axon/commands/MarkReadMessageCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/MarkReadMessageCommand.java similarity index 94% rename from axon/src/main/java/com/baeldung/axon/commands/MarkReadMessageCommand.java rename to axon/src/main/java/com/baeldung/axon/coreapi/commands/MarkReadMessageCommand.java index f7d911d65b..ec68a380f8 100644 --- a/axon/src/main/java/com/baeldung/axon/commands/MarkReadMessageCommand.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/commands/MarkReadMessageCommand.java @@ -1,4 +1,4 @@ -package com.baeldung.axon.commands; +package com.baeldung.axon.coreapi.commands; import java.util.Objects; diff --git a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java index 30914e3fd3..3bb7fdc9a2 100644 --- a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java +++ b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java @@ -6,8 +6,8 @@ import org.axonframework.test.aggregate.AggregateTestFixture; import org.axonframework.test.aggregate.FixtureConfiguration; import org.junit.*; -import com.baeldung.axon.commands.CreateMessageCommand; -import com.baeldung.axon.commands.MarkReadMessageCommand; +import com.baeldung.axon.coreapi.commands.CreateMessageCommand; +import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand; import com.baeldung.axon.events.MessageCreatedEvent; import com.baeldung.axon.events.MessageReadEvent; From 2b07c0364d5f7cd1e4d8f178bd99c968e89324c2 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 14:56:23 +0100 Subject: [PATCH 024/441] BAEL-2435 Change event message package Change the package of the event messages to coreapi.events to signal that the events are part of the API you'd share with the outside --- .../com/baeldung/axon/commandmodel/MessagesAggregate.java | 4 ++-- .../axon/{ => coreapi}/events/MessageCreatedEvent.java | 2 +- .../baeldung/axon/{ => coreapi}/events/MessageReadEvent.java | 2 +- .../com/baeldung/axon/querymodel/MessagesEventHandler.java | 4 ++-- .../com/baeldung/axon/commandmodel/MessagesAggregateTest.java | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename axon/src/main/java/com/baeldung/axon/{ => coreapi}/events/MessageCreatedEvent.java (94%) rename axon/src/main/java/com/baeldung/axon/{ => coreapi}/events/MessageReadEvent.java (93%) diff --git a/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java b/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java index 60b5c7c94e..1ab9501617 100644 --- a/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java +++ b/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java @@ -9,8 +9,8 @@ import org.axonframework.spring.stereotype.Aggregate; import com.baeldung.axon.coreapi.commands.CreateMessageCommand; import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand; -import com.baeldung.axon.events.MessageCreatedEvent; -import com.baeldung.axon.events.MessageReadEvent; +import com.baeldung.axon.coreapi.events.MessageCreatedEvent; +import com.baeldung.axon.coreapi.events.MessageReadEvent; @Aggregate public class MessagesAggregate { diff --git a/axon/src/main/java/com/baeldung/axon/events/MessageCreatedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageCreatedEvent.java similarity index 94% rename from axon/src/main/java/com/baeldung/axon/events/MessageCreatedEvent.java rename to axon/src/main/java/com/baeldung/axon/coreapi/events/MessageCreatedEvent.java index e638a2a94d..debf383771 100644 --- a/axon/src/main/java/com/baeldung/axon/events/MessageCreatedEvent.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageCreatedEvent.java @@ -1,4 +1,4 @@ -package com.baeldung.axon.events; +package com.baeldung.axon.coreapi.events; import java.util.Objects; diff --git a/axon/src/main/java/com/baeldung/axon/events/MessageReadEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageReadEvent.java similarity index 93% rename from axon/src/main/java/com/baeldung/axon/events/MessageReadEvent.java rename to axon/src/main/java/com/baeldung/axon/coreapi/events/MessageReadEvent.java index e362599bb3..f90bfb054e 100644 --- a/axon/src/main/java/com/baeldung/axon/events/MessageReadEvent.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageReadEvent.java @@ -1,4 +1,4 @@ -package com.baeldung.axon.events; +package com.baeldung.axon.coreapi.events; import java.util.Objects; diff --git a/axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java b/axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java index d93fe03941..6988d40a53 100644 --- a/axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java +++ b/axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java @@ -3,8 +3,8 @@ package com.baeldung.axon.querymodel; import org.axonframework.eventhandling.EventHandler; import org.springframework.stereotype.Service; -import com.baeldung.axon.events.MessageCreatedEvent; -import com.baeldung.axon.events.MessageReadEvent; +import com.baeldung.axon.coreapi.events.MessageCreatedEvent; +import com.baeldung.axon.coreapi.events.MessageReadEvent; @Service public class MessagesEventHandler { diff --git a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java index 3bb7fdc9a2..1a95726c83 100644 --- a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java +++ b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java @@ -8,8 +8,8 @@ import org.junit.*; import com.baeldung.axon.coreapi.commands.CreateMessageCommand; import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand; -import com.baeldung.axon.events.MessageCreatedEvent; -import com.baeldung.axon.events.MessageReadEvent; +import com.baeldung.axon.coreapi.events.MessageCreatedEvent; +import com.baeldung.axon.coreapi.events.MessageReadEvent; public class MessagesAggregateTest { From e731b95ffbb596d3674bd3e6de724e35dcf4a7df Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 15:01:29 +0100 Subject: [PATCH 025/441] BAEL-2435 Rename unit test class Rename unit test class to actual contain 'UnitTest' per the defined standards --- ...essagesAggregateTest.java => MessagesAggregateUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename axon/src/test/java/com/baeldung/axon/commandmodel/{MessagesAggregateTest.java => MessagesAggregateUnitTest.java} (97%) diff --git a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateUnitTest.java similarity index 97% rename from axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java rename to axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateUnitTest.java index 1a95726c83..46357ddff8 100644 --- a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateTest.java +++ b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateUnitTest.java @@ -11,7 +11,7 @@ import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand; import com.baeldung.axon.coreapi.events.MessageCreatedEvent; import com.baeldung.axon.coreapi.events.MessageReadEvent; -public class MessagesAggregateTest { +public class MessagesAggregateUnitTest { private FixtureConfiguration fixture; From fe30c44889111ccaa94b4e69d49fc800b21c5d90 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 15:15:23 +0100 Subject: [PATCH 026/441] BAEL-2435 Add a GUI -Add spring-boot-starter-web to support rest endpoints -Add a rest endpoint to spoof some form of UI to publish a message, as the old main will no longer publish the commands upon start up --- axon/pom.xml | 5 ++++ .../axon/gui/MessagesRestEndpoint.java | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 axon/src/main/java/com/baeldung/axon/gui/MessagesRestEndpoint.java diff --git a/axon/pom.xml b/axon/pom.xml index bb7839f150..639c50d70b 100644 --- a/axon/pom.xml +++ b/axon/pom.xml @@ -39,6 +39,11 @@ 2.1.1.RELEASE compile + + + org.springframework.boot + spring-boot-starter-web + diff --git a/axon/src/main/java/com/baeldung/axon/gui/MessagesRestEndpoint.java b/axon/src/main/java/com/baeldung/axon/gui/MessagesRestEndpoint.java new file mode 100644 index 0000000000..ddbc3e2fc5 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/gui/MessagesRestEndpoint.java @@ -0,0 +1,28 @@ +package com.baeldung.axon.gui; + +import java.util.UUID; + +import org.axonframework.commandhandling.gateway.CommandGateway; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.axon.coreapi.commands.CreateMessageCommand; +import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand; + +@RestController +public class MessagesRestEndpoint { + + private final CommandGateway commandGateway; + + public MessagesRestEndpoint(CommandGateway commandGateway) { + this.commandGateway = commandGateway; + } + + @PostMapping("/hello") + public void publishMessages() { + final String itemId = UUID.randomUUID().toString(); + commandGateway.send(new CreateMessageCommand(itemId, "Hello, how is your day? :-)")); + commandGateway.send(new MarkReadMessageCommand(itemId)); + } + +} From d8ef050867fbf473260f51509ed775a719737879 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 15:16:31 +0100 Subject: [PATCH 027/441] BAEL-2435 Add JPA and H2 dependencies Add JPA and H2 dependencies to allow event sourcing, as for event sourcing and EventStore is mandatory, and to make an EventStore a database needs to be present for Axon's auto-configuration --- axon/pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/axon/pom.xml b/axon/pom.xml index 639c50d70b..03d2499a99 100644 --- a/axon/pom.xml +++ b/axon/pom.xml @@ -44,6 +44,17 @@ org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + com.h2database + h2 + runtime + From 557ce655522559c849e4a02cdd54955872d700c5 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Tue, 18 Dec 2018 15:17:16 +0100 Subject: [PATCH 028/441] BAEL-2435 Update main application Update the MessagesRunner to be a spring boot application --- .../com/baeldung/axon/MessagesRunner.java | 51 ++----------------- 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/axon/src/main/java/com/baeldung/axon/MessagesRunner.java b/axon/src/main/java/com/baeldung/axon/MessagesRunner.java index 77b50d09bd..4f83dd86f0 100644 --- a/axon/src/main/java/com/baeldung/axon/MessagesRunner.java +++ b/axon/src/main/java/com/baeldung/axon/MessagesRunner.java @@ -1,54 +1,13 @@ package com.baeldung.axon; -import com.baeldung.axon.aggregates.MessagesAggregate; -import com.baeldung.axon.commands.CreateMessageCommand; -import com.baeldung.axon.commands.MarkReadMessageCommand; -import com.baeldung.axon.eventhandlers.MessagesEventHandler; -import org.axonframework.commandhandling.AggregateAnnotationCommandHandler; -import org.axonframework.commandhandling.CommandBus; -import org.axonframework.commandhandling.SimpleCommandBus; -import org.axonframework.commandhandling.gateway.CommandGateway; -import org.axonframework.commandhandling.gateway.DefaultCommandGateway; -import org.axonframework.eventhandling.AnnotationEventListenerAdapter; -import org.axonframework.eventsourcing.EventSourcingRepository; -import org.axonframework.eventsourcing.eventstore.EmbeddedEventStore; -import org.axonframework.eventsourcing.eventstore.EventStore; -import org.axonframework.eventsourcing.eventstore.inmemory.InMemoryEventStorageEngine; - -import java.util.UUID; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +@SpringBootApplication public class MessagesRunner { public static void main(String[] args) { - CommandBus commandBus = new SimpleCommandBus(); - - CommandGateway commandGateway = new DefaultCommandGateway(commandBus); - - EventStore eventStore = new EmbeddedEventStore(new InMemoryEventStorageEngine()); - - EventSourcingRepository repository = - new EventSourcingRepository<>(MessagesAggregate.class, eventStore); - - - AggregateAnnotationCommandHandler messagesAggregateAggregateAnnotationCommandHandler = - new AggregateAnnotationCommandHandler(MessagesAggregate.class, repository); - messagesAggregateAggregateAnnotationCommandHandler.subscribe(commandBus); - - final AnnotationEventListenerAdapter annotationEventListenerAdapter = - new AnnotationEventListenerAdapter(new MessagesEventHandler()); - eventStore.subscribe(eventMessages -> eventMessages.forEach(e -> { - try { - annotationEventListenerAdapter.handle(e); - } catch (Exception e1) { - throw new RuntimeException(e1); - - } - } - - )); - - final String itemId = UUID.randomUUID().toString(); - commandGateway.send(new CreateMessageCommand(itemId, "Hello, how is your day? :-)")); - commandGateway.send(new MarkReadMessageCommand(itemId)); + SpringApplication.run(MessagesRunner.class, args); } + } \ No newline at end of file From 64b205a6ce2360de18c418fef3da2e53f1468e90 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Fri, 21 Dec 2018 12:19:09 +0400 Subject: [PATCH 029/441] Vector iterator --- .../src/main/java/com/baeldung/java/list/VectorExample.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java b/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java index 38736390ca..7debc07911 100644 --- a/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java +++ b/core-java-collections/src/main/java/com/baeldung/java/list/VectorExample.java @@ -1,6 +1,7 @@ package com.baeldung.java.list; import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; public class VectorExample { @@ -16,6 +17,11 @@ public class VectorExample { while(e.hasMoreElements()){ System.out.println(e.nextElement()); } + + Iterator iterator = vector.iterator(); + while (iterator.hasNext()) { + System.out.println(iterator.next()); + } } } From 29b4110b34701c1ac004d03bc8e8555158a40e31 Mon Sep 17 00:00:00 2001 From: geroza Date: Wed, 28 Nov 2018 12:17:30 -0200 Subject: [PATCH 030/441] just migrated poms, nothing checked --- mustache/pom.xml | 4 ++-- spring-amqp-simple/pom.xml | 4 ++-- spring-aop/pom.xml | 4 ++-- spring-cucumber/pom.xml | 4 ++-- spring-jooq/pom.xml | 4 ++-- spring-kafka/pom.xml | 4 ++-- spring-mockito/pom.xml | 4 ++-- spring-protobuf/pom.xml | 4 ++-- spring-quartz/pom.xml | 4 ++-- spring-reactor/pom.xml | 4 ++-- spring-remoting/pom.xml | 4 ++-- spring-sleuth/pom.xml | 4 ++-- spring-vertx/pom.xml | 4 ++-- spring-zuul/pom.xml | 4 ++-- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/mustache/pom.xml b/mustache/pom.xml index a276dfbf43..0c35345100 100644 --- a/mustache/pom.xml +++ b/mustache/pom.xml @@ -7,10 +7,10 @@ mustache - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-amqp-simple/pom.xml b/spring-amqp-simple/pom.xml index 57d84acee6..45cdc066a0 100644 --- a/spring-amqp-simple/pom.xml +++ b/spring-amqp-simple/pom.xml @@ -8,10 +8,10 @@ spring-amqp-simple - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-aop/pom.xml b/spring-aop/pom.xml index 368f3ada14..9e2f97916a 100644 --- a/spring-aop/pom.xml +++ b/spring-aop/pom.xml @@ -6,10 +6,10 @@ spring-aop - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-cucumber/pom.xml b/spring-cucumber/pom.xml index 64b543bb6c..2bc3201775 100644 --- a/spring-cucumber/pom.xml +++ b/spring-cucumber/pom.xml @@ -10,10 +10,10 @@ Demo project for Spring Boot - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-jooq/pom.xml b/spring-jooq/pom.xml index bbd6025418..c1f9dbff5b 100644 --- a/spring-jooq/pom.xml +++ b/spring-jooq/pom.xml @@ -5,10 +5,10 @@ spring-jooq - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-kafka/pom.xml b/spring-kafka/pom.xml index 3060dc00b3..e710f1ac03 100644 --- a/spring-kafka/pom.xml +++ b/spring-kafka/pom.xml @@ -8,10 +8,10 @@ Intro to Kafka with Spring - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-mockito/pom.xml b/spring-mockito/pom.xml index d1fa7f410e..481c818f39 100644 --- a/spring-mockito/pom.xml +++ b/spring-mockito/pom.xml @@ -11,10 +11,10 @@ Injecting Mockito Mocks into Spring Beans - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-protobuf/pom.xml b/spring-protobuf/pom.xml index 1ab5048d27..3d7b7efd7c 100644 --- a/spring-protobuf/pom.xml +++ b/spring-protobuf/pom.xml @@ -7,10 +7,10 @@ spring-protobuf - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-quartz/pom.xml b/spring-quartz/pom.xml index 47ffeccba9..77424c219e 100644 --- a/spring-quartz/pom.xml +++ b/spring-quartz/pom.xml @@ -11,10 +11,10 @@ Demo project for Scheduling in Spring with Quartz - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-reactor/pom.xml b/spring-reactor/pom.xml index e828c44f74..9ab512cddb 100644 --- a/spring-reactor/pom.xml +++ b/spring-reactor/pom.xml @@ -9,10 +9,10 @@ http://maven.apache.org - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-remoting/pom.xml b/spring-remoting/pom.xml index 9f05bc91d2..6fa2846130 100644 --- a/spring-remoting/pom.xml +++ b/spring-remoting/pom.xml @@ -10,10 +10,10 @@ Parent for all projects related to Spring Remoting. - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-sleuth/pom.xml b/spring-sleuth/pom.xml index dd4477c551..c693466ab0 100644 --- a/spring-sleuth/pom.xml +++ b/spring-sleuth/pom.xml @@ -9,10 +9,10 @@ spring-sleuth - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-vertx/pom.xml b/spring-vertx/pom.xml index 14ed77d359..7a0bdc81d0 100644 --- a/spring-vertx/pom.xml +++ b/spring-vertx/pom.xml @@ -8,10 +8,10 @@ A demo project with vertx spring integration - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-zuul/pom.xml b/spring-zuul/pom.xml index 266c20adee..b662b2ef6a 100644 --- a/spring-zuul/pom.xml +++ b/spring-zuul/pom.xml @@ -9,10 +9,10 @@ pom - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 From a1b5d77656e8582fd4f094ceef19098816c353e5 Mon Sep 17 00:00:00 2001 From: geroza Date: Wed, 19 Dec 2018 16:37:10 -0200 Subject: [PATCH 031/441] Migrated the following modules, nos using parent-boot-2: spring-protobuf spring-mockito spring-mustache spring-kafka spring-jooq spring-cucumber spring-aop spring-amqp-simple --- .../baeldung/springamqpsimple/SpringAmqpConfig.java | 2 +- .../springamqpsimple/broadcast/BroadcastConfig.java | 2 +- .../src/test/resources/application.yaml | 5 +++++ spring-jooq/pom.xml | 7 ++++--- spring-kafka/pom.xml | 2 -- .../com/baeldung/spring/kafka/KafkaApplication.java | 8 ++++---- .../com/baeldung/NameServiceTestConfiguration.java | 2 +- spring-protobuf/pom.xml | 13 +------------ .../java/com/baeldung/protobuf/Application.java | 6 ++++++ 9 files changed, 23 insertions(+), 24 deletions(-) create mode 100644 spring-amqp-simple/src/test/resources/application.yaml diff --git a/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/SpringAmqpConfig.java b/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/SpringAmqpConfig.java index f6c82b635e..3bb0dbf33c 100644 --- a/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/SpringAmqpConfig.java +++ b/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/SpringAmqpConfig.java @@ -35,7 +35,7 @@ public class SpringAmqpConfig { } @Bean - SimpleMessageListenerContainer container(ConnectionFactory connectionFactory, + SimpleMessageListenerContainer SpringAmqpContainer(ConnectionFactory connectionFactory, MessageListenerAdapter listenerAdapter) { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); diff --git a/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/broadcast/BroadcastConfig.java b/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/broadcast/BroadcastConfig.java index 1d02b4dad9..c1df053c02 100644 --- a/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/broadcast/BroadcastConfig.java +++ b/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/broadcast/BroadcastConfig.java @@ -61,7 +61,7 @@ public class BroadcastConfig { } @Bean - public SimpleRabbitListenerContainerFactory container(ConnectionFactory connectionFactory, SimpleRabbitListenerContainerFactoryConfigurer configurer) { + public SimpleRabbitListenerContainerFactory BroadcastContainer(ConnectionFactory connectionFactory, SimpleRabbitListenerContainerFactoryConfigurer configurer) { SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); configurer.configure(factory, connectionFactory); return factory; diff --git a/spring-amqp-simple/src/test/resources/application.yaml b/spring-amqp-simple/src/test/resources/application.yaml new file mode 100644 index 0000000000..aa7a91bac5 --- /dev/null +++ b/spring-amqp-simple/src/test/resources/application.yaml @@ -0,0 +1,5 @@ +spring: + rabbitmq: + username: guest + password: guest + host: localhost \ No newline at end of file diff --git a/spring-jooq/pom.xml b/spring-jooq/pom.xml index c1f9dbff5b..8bce500a86 100644 --- a/spring-jooq/pom.xml +++ b/spring-jooq/pom.xml @@ -129,6 +129,9 @@ com.baeldung.jooq.introduction.db src/main/java + + + @@ -185,14 +188,12 @@ - 3.8.6 + 3.11.7 1.4.193 - 4.3.17.RELEASE 1.0.0 1.5 1.0.0 - 1.5.13.RELEASE org.jooq.example.spring.Application diff --git a/spring-kafka/pom.xml b/spring-kafka/pom.xml index e710f1ac03..67e732d819 100644 --- a/spring-kafka/pom.xml +++ b/spring-kafka/pom.xml @@ -30,11 +30,9 @@ com.fasterxml.jackson.core jackson-databind - - 1.1.3.RELEASE 2.6.7 diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplication.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplication.java index 50978d5ea9..4ee7f40335 100644 --- a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplication.java +++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplication.java @@ -22,7 +22,7 @@ public class KafkaApplication { public static void main(String[] args) throws Exception { ConfigurableApplicationContext context = SpringApplication.run(KafkaApplication.class, args); - + MessageProducer producer = context.getBean(MessageProducer.class); MessageListener listener = context.getBean(MessageListener.class); /* @@ -102,7 +102,7 @@ public class KafkaApplication { } public void sendMessageToPartion(String message, int partition) { - kafkaTemplate.send(partionedTopicName, partition, message); + kafkaTemplate.send(partionedTopicName, partition, null, message); } public void sendMessageToFiltered(String message) { @@ -124,13 +124,13 @@ public class KafkaApplication { private CountDownLatch greetingLatch = new CountDownLatch(1); - @KafkaListener(topics = "${message.topic.name}", group = "foo", containerFactory = "fooKafkaListenerContainerFactory") + @KafkaListener(topics = "${message.topic.name}", groupId = "foo", containerFactory = "fooKafkaListenerContainerFactory") public void listenGroupFoo(String message) { System.out.println("Received Messasge in group 'foo': " + message); latch.countDown(); } - @KafkaListener(topics = "${message.topic.name}", group = "bar", containerFactory = "barKafkaListenerContainerFactory") + @KafkaListener(topics = "${message.topic.name}", groupId = "bar", containerFactory = "barKafkaListenerContainerFactory") public void listenGroupBar(String message) { System.out.println("Received Messasge in group 'bar': " + message); latch.countDown(); diff --git a/spring-mockito/src/test/java/com/baeldung/NameServiceTestConfiguration.java b/spring-mockito/src/test/java/com/baeldung/NameServiceTestConfiguration.java index 2c63ff6203..c50377a22a 100644 --- a/spring-mockito/src/test/java/com/baeldung/NameServiceTestConfiguration.java +++ b/spring-mockito/src/test/java/com/baeldung/NameServiceTestConfiguration.java @@ -11,7 +11,7 @@ import org.springframework.context.annotation.Profile; public class NameServiceTestConfiguration { @Bean @Primary - public NameService nameService() { + public NameService nameServiceTest() { return Mockito.mock(NameService.class); } } diff --git a/spring-protobuf/pom.xml b/spring-protobuf/pom.xml index 3d7b7efd7c..372f969bd7 100644 --- a/spring-protobuf/pom.xml +++ b/spring-protobuf/pom.xml @@ -36,21 +36,10 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - - 3.1.0 1.4 + com.baeldung.protobuf.Application diff --git a/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java b/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java index 76f0e45244..d8aa34eb7c 100644 --- a/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java +++ b/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java @@ -4,7 +4,9 @@ import com.baeldung.protobuf.BaeldungTraining.Course; import com.baeldung.protobuf.BaeldungTraining.Student; import com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber; import com.baeldung.protobuf.BaeldungTraining.Student.PhoneType; + import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.Bean; import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter; import org.springframework.web.client.RestTemplate; @@ -17,6 +19,10 @@ import java.util.Map; @SpringBootApplication public class Application { + + public static void main(String[] args) { + new SpringApplicationBuilder(Application.class).run(args); + } @Bean RestTemplate restTemplate(ProtobufHttpMessageConverter hmc) { From dcc054d6de77dce144d58129b6a437a113776907 Mon Sep 17 00:00:00 2001 From: geroza Date: Fri, 21 Dec 2018 13:39:11 -0200 Subject: [PATCH 032/441] Migrated the following modules to parent-boot-2: spring-reactor spring-quartz --- spring-reactor/pom.xml | 7 ++++++- .../com/baeldung/controller/NotificationController.java | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/spring-reactor/pom.xml b/spring-reactor/pom.xml index 9ab512cddb..c6ad99aea7 100644 --- a/spring-reactor/pom.xml +++ b/spring-reactor/pom.xml @@ -27,7 +27,12 @@ io.projectreactor reactor-bus + 2.0.8.RELEASE + + + io.projectreactor + reactor-core + 2.0.8.RELEASE - diff --git a/spring-reactor/src/main/java/com/baeldung/controller/NotificationController.java b/spring-reactor/src/main/java/com/baeldung/controller/NotificationController.java index b17691498e..8665f247b0 100644 --- a/spring-reactor/src/main/java/com/baeldung/controller/NotificationController.java +++ b/spring-reactor/src/main/java/com/baeldung/controller/NotificationController.java @@ -1,14 +1,16 @@ package com.baeldung.controller; -import com.baeldung.doman.NotificationData; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.doman.NotificationData; + import reactor.bus.Event; import reactor.bus.EventBus; -@Controller +@RestController public class NotificationController { @Autowired From cb4470edea53c68dd48688a6bc01901bbf133275 Mon Sep 17 00:00:00 2001 From: geroza Date: Sat, 22 Dec 2018 10:30:08 -0200 Subject: [PATCH 033/441] migration of modules: spring-zuul spring-vertx spring-sleuth --- spring-remoting/pom.xml | 5 +++-- .../remoting-hessian-burlap/pom.xml | 6 ++++-- spring-zuul/pom.xml | 18 +++++++++++++++--- .../config/ResourceServerApplication.java | 2 +- .../config/ResourceServerWebConfig.java | 4 ++-- .../src/main/resources/application.properties | 4 ++-- spring-zuul/spring-zuul-ui/pom.xml | 2 +- .../org/baeldung/config/UiApplication.java | 2 +- .../java/org/baeldung/config/UiWebConfig.java | 5 ++--- 9 files changed, 31 insertions(+), 17 deletions(-) diff --git a/spring-remoting/pom.xml b/spring-remoting/pom.xml index 6fa2846130..060f33837c 100644 --- a/spring-remoting/pom.xml +++ b/spring-remoting/pom.xml @@ -7,7 +7,8 @@ pom 1.0-SNAPSHOT spring-remoting - Parent for all projects related to Spring Remoting. + Parent for all projects related to Spring Remoting, except remoting-hessian-burlap + parent-boot-2 @@ -28,8 +29,8 @@ - remoting-http remoting-hessian-burlap + remoting-http remoting-amqp remoting-jms remoting-rmi diff --git a/spring-remoting/remoting-hessian-burlap/pom.xml b/spring-remoting/remoting-hessian-burlap/pom.xml index e63d0ee22e..8c30e76296 100644 --- a/spring-remoting/remoting-hessian-burlap/pom.xml +++ b/spring-remoting/remoting-hessian-burlap/pom.xml @@ -6,11 +6,13 @@ remoting-hessian-burlap pom remoting-hessian-burlap + 1.0-SNAPSHOT - spring-remoting + parent-boot-1 com.baeldung - 1.0-SNAPSHOT + 0.0.1-SNAPSHOT + ../../parent-boot-1 diff --git a/spring-zuul/pom.xml b/spring-zuul/pom.xml index b662b2ef6a..a8c891cd89 100644 --- a/spring-zuul/pom.xml +++ b/spring-zuul/pom.xml @@ -1,7 +1,8 @@ - 4.0.0 - + com.baeldung spring-zuul 1.0.0-SNAPSHOT @@ -38,11 +39,22 @@ - 1.2.7.RELEASE + 2.1.0.RC3 3.5 2.6 + + + spring-milestones + Spring Milestones + http://repo.spring.io/milestone + + false + + + + \ No newline at end of file diff --git a/spring-zuul/spring-zuul-foos-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java b/spring-zuul/spring-zuul-foos-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java index 9f1d2e162b..77eabe771b 100644 --- a/spring-zuul/spring-zuul-foos-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java +++ b/spring-zuul/spring-zuul-foos-resource/src/main/java/org/baeldung/config/ResourceServerApplication.java @@ -2,7 +2,7 @@ package org.baeldung.config; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication public class ResourceServerApplication extends SpringBootServletInitializer { diff --git a/spring-zuul/spring-zuul-foos-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java b/spring-zuul/spring-zuul-foos-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java index c040c8ac42..1a45d20edb 100644 --- a/spring-zuul/spring-zuul-foos-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java +++ b/spring-zuul/spring-zuul-foos-resource/src/main/java/org/baeldung/config/ResourceServerWebConfig.java @@ -3,11 +3,11 @@ package org.baeldung.config; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @EnableWebMvc @ComponentScan({ "org.baeldung.web.controller" }) -public class ResourceServerWebConfig extends WebMvcConfigurerAdapter { +public class ResourceServerWebConfig implements WebMvcConfigurer { } diff --git a/spring-zuul/spring-zuul-foos-resource/src/main/resources/application.properties b/spring-zuul/spring-zuul-foos-resource/src/main/resources/application.properties index 94c0984ac3..9298027030 100644 --- a/spring-zuul/spring-zuul-foos-resource/src/main/resources/application.properties +++ b/spring-zuul/spring-zuul-foos-resource/src/main/resources/application.properties @@ -1,2 +1,2 @@ -server.contextPath=/spring-zuul-foos-resource -server.port=8081 \ No newline at end of file +server.servlet.context-path=/spring-zuul-foos-resource +server.port=8081 diff --git a/spring-zuul/spring-zuul-ui/pom.xml b/spring-zuul/spring-zuul-ui/pom.xml index 6090f5f8b8..159decd331 100644 --- a/spring-zuul/spring-zuul-ui/pom.xml +++ b/spring-zuul/spring-zuul-ui/pom.xml @@ -15,7 +15,7 @@ org.springframework.cloud - spring-cloud-starter-zuul + spring-cloud-starter-netflix-zuul ${spring-cloud.version} diff --git a/spring-zuul/spring-zuul-ui/src/main/java/org/baeldung/config/UiApplication.java b/spring-zuul/spring-zuul-ui/src/main/java/org/baeldung/config/UiApplication.java index b8eda25960..d3e13639ef 100644 --- a/spring-zuul/spring-zuul-ui/src/main/java/org/baeldung/config/UiApplication.java +++ b/spring-zuul/spring-zuul-ui/src/main/java/org/baeldung/config/UiApplication.java @@ -2,7 +2,7 @@ package org.baeldung.config; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.cloud.netflix.zuul.EnableZuulProxy; @EnableZuulProxy diff --git a/spring-zuul/spring-zuul-ui/src/main/java/org/baeldung/config/UiWebConfig.java b/spring-zuul/spring-zuul-ui/src/main/java/org/baeldung/config/UiWebConfig.java index 0732182354..7cda1f0e95 100644 --- a/spring-zuul/spring-zuul-ui/src/main/java/org/baeldung/config/UiWebConfig.java +++ b/spring-zuul/spring-zuul-ui/src/main/java/org/baeldung/config/UiWebConfig.java @@ -7,11 +7,11 @@ import org.springframework.web.servlet.config.annotation.DefaultServletHandlerCo import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @EnableWebMvc -public class UiWebConfig extends WebMvcConfigurerAdapter { +public class UiWebConfig implements WebMvcConfigurer { @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { @@ -25,7 +25,6 @@ public class UiWebConfig extends WebMvcConfigurerAdapter { @Override public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); registry.addViewController("/").setViewName("forward:/index"); registry.addViewController("/index"); registry.addViewController("/login"); From 832a3dc1761fdfbb0c9fed276863a6f222389548 Mon Sep 17 00:00:00 2001 From: geroza Date: Sat, 22 Dec 2018 10:30:56 -0200 Subject: [PATCH 034/441] Fixed deprecation usage in spring-boot --- .../main/java/com/baeldung/properties/ConfigProperties.java | 2 +- .../main/java/org/baeldung/properties/ConfigProperties.java | 2 +- .../demo/boottest/EmployeeControllerIntegrationTest.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot/src/main/java/com/baeldung/properties/ConfigProperties.java b/spring-boot/src/main/java/com/baeldung/properties/ConfigProperties.java index 863510738b..35b0239287 100644 --- a/spring-boot/src/main/java/com/baeldung/properties/ConfigProperties.java +++ b/spring-boot/src/main/java/com/baeldung/properties/ConfigProperties.java @@ -5,10 +5,10 @@ import java.util.Map; import javax.validation.constraints.Max; import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.Pattern; import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.NotBlank; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; diff --git a/spring-boot/src/main/java/org/baeldung/properties/ConfigProperties.java b/spring-boot/src/main/java/org/baeldung/properties/ConfigProperties.java index 2c815fe998..2d3e56100c 100644 --- a/spring-boot/src/main/java/org/baeldung/properties/ConfigProperties.java +++ b/spring-boot/src/main/java/org/baeldung/properties/ConfigProperties.java @@ -5,10 +5,10 @@ import java.util.Map; import javax.validation.constraints.Max; import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.Pattern; import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.NotBlank; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; diff --git a/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java b/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java index 640a8b322a..2d70583a54 100644 --- a/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java +++ b/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java @@ -45,10 +45,10 @@ public class EmployeeControllerIntegrationTest { @Test public void whenPostEmployee_thenCreateEmployee() throws Exception { Employee alex = new Employee("alex"); - given(service.save(Mockito.anyObject())).willReturn(alex); + given(service.save(Mockito.any())).willReturn(alex); mvc.perform(post("/api/employees").contentType(MediaType.APPLICATION_JSON).content(JsonUtil.toJson(alex))).andExpect(status().isCreated()).andExpect(jsonPath("$.name", is("alex"))); - verify(service, VerificationModeFactory.times(1)).save(Mockito.anyObject()); + verify(service, VerificationModeFactory.times(1)).save(Mockito.any()); reset(service); } From cb259f6f6ca97806cfb391bb38edf77ad0f324d1 Mon Sep 17 00:00:00 2001 From: geroza Date: Sat, 22 Dec 2018 11:05:38 -0200 Subject: [PATCH 035/441] minor fixes: fixed method naming added dirtiesContext annotation to classes that shouldnt share the app context state using SpringApplication instead of unnecessary SpringApplicationBuilder --- .../springamqpsimple/SpringAmqpConfig.java | 2 +- .../broadcast/BroadcastConfig.java | 2 +- .../com/baeldung/protobuf/Application.java | 24 +++++++++---------- .../protobuf/ApplicationIntegrationTest.java | 2 ++ .../SpringContextIntegrationTest.java | 2 ++ 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/SpringAmqpConfig.java b/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/SpringAmqpConfig.java index 3bb0dbf33c..92fa28ed6f 100644 --- a/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/SpringAmqpConfig.java +++ b/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/SpringAmqpConfig.java @@ -35,7 +35,7 @@ public class SpringAmqpConfig { } @Bean - SimpleMessageListenerContainer SpringAmqpContainer(ConnectionFactory connectionFactory, + SimpleMessageListenerContainer springAmqpContainer(ConnectionFactory connectionFactory, MessageListenerAdapter listenerAdapter) { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); diff --git a/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/broadcast/BroadcastConfig.java b/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/broadcast/BroadcastConfig.java index c1df053c02..868cfff0ac 100644 --- a/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/broadcast/BroadcastConfig.java +++ b/spring-amqp-simple/src/main/java/com/baeldung/springamqpsimple/broadcast/BroadcastConfig.java @@ -61,7 +61,7 @@ public class BroadcastConfig { } @Bean - public SimpleRabbitListenerContainerFactory BroadcastContainer(ConnectionFactory connectionFactory, SimpleRabbitListenerContainerFactoryConfigurer configurer) { + public SimpleRabbitListenerContainerFactory broadcastContainer(ConnectionFactory connectionFactory, SimpleRabbitListenerContainerFactoryConfigurer configurer) { SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); configurer.configure(factory, connectionFactory); return factory; diff --git a/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java b/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java index d8aa34eb7c..fd36986549 100644 --- a/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java +++ b/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java @@ -1,27 +1,27 @@ package com.baeldung.protobuf; -import com.baeldung.protobuf.BaeldungTraining.Course; -import com.baeldung.protobuf.BaeldungTraining.Student; -import com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber; -import com.baeldung.protobuf.BaeldungTraining.Student.PhoneType; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter; -import org.springframework.web.client.RestTemplate; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter; +import org.springframework.web.client.RestTemplate; + +import com.baeldung.protobuf.BaeldungTraining.Course; +import com.baeldung.protobuf.BaeldungTraining.Student; +import com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber; +import com.baeldung.protobuf.BaeldungTraining.Student.PhoneType; + @SpringBootApplication public class Application { public static void main(String[] args) { - new SpringApplicationBuilder(Application.class).run(args); + SpringApplication.run(Application.class, args); } @Bean diff --git a/spring-protobuf/src/test/java/com/baeldung/protobuf/ApplicationIntegrationTest.java b/spring-protobuf/src/test/java/com/baeldung/protobuf/ApplicationIntegrationTest.java index 4b9f41ace3..f0e2473ec4 100644 --- a/spring-protobuf/src/test/java/com/baeldung/protobuf/ApplicationIntegrationTest.java +++ b/spring-protobuf/src/test/java/com/baeldung/protobuf/ApplicationIntegrationTest.java @@ -16,12 +16,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.http.ResponseEntity; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.client.RestTemplate; import com.baeldung.protobuf.BaeldungTraining.Course; import com.googlecode.protobuf.format.JsonFormat; +@DirtiesContext @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.DEFINED_PORT) public class ApplicationIntegrationTest { diff --git a/spring-protobuf/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-protobuf/src/test/java/org/baeldung/SpringContextIntegrationTest.java index 615ebd5f4a..6d021eb400 100644 --- a/spring-protobuf/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-protobuf/src/test/java/org/baeldung/SpringContextIntegrationTest.java @@ -3,10 +3,12 @@ package org.baeldung; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; import com.baeldung.protobuf.Application; +@DirtiesContext @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class SpringContextIntegrationTest { From c2fc5c0aa676e86696bf2ae9435e343803520077 Mon Sep 17 00:00:00 2001 From: Karanbir Singh Date: Sat, 22 Dec 2018 19:27:25 +0530 Subject: [PATCH 036/441] spelling mistake - minor one --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f3fe5e3bf0..378d77196a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Java and Spring Tutorials ================ This project is **a collection of small and focused tutorials** - each covering a single and well defined area of development in the Java ecosystem. -A strong focus of these is, of course, the Spring Framework - Spring, Spring Boot and Spring Securiyt. +A strong focus of these is, of course, the Spring Framework - Spring, Spring Boot and Spring Security. In additional to Spring, the following technologies are in focus: `core Java`, `Jackson`, `HttpClient`, `Guava`. From e8b07fea1dc1b44fcb904c3d0d33ae27ffd4ecd3 Mon Sep 17 00:00:00 2001 From: Ganesh Pagade Date: Sun, 23 Dec 2018 12:05:51 +0530 Subject: [PATCH 037/441] unit tests for nest based access control --- .../src/main/java/com/baeldung/Outer.java | 24 +++++++++ .../test/java/com/baeldung/OuterUnitTest.java | 50 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 core-java-11/src/main/java/com/baeldung/Outer.java create mode 100644 core-java-11/src/test/java/com/baeldung/OuterUnitTest.java diff --git a/core-java-11/src/main/java/com/baeldung/Outer.java b/core-java-11/src/main/java/com/baeldung/Outer.java new file mode 100644 index 0000000000..e2f1479ab1 --- /dev/null +++ b/core-java-11/src/main/java/com/baeldung/Outer.java @@ -0,0 +1,24 @@ +package com.baeldung; + +import java.lang.reflect.Method; + +public class Outer { + + public void outerPublic() { + } + + private void outerPrivate() { + } + + class Inner { + + public void innerPublic() { + outerPrivate(); + } + + public void innerPublicReflection(Outer ob) throws Exception { + Method method = ob.getClass().getDeclaredMethod("outerPrivate"); + method.invoke(ob); + } + } +} \ No newline at end of file diff --git a/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java new file mode 100644 index 0000000000..a954416f68 --- /dev/null +++ b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java @@ -0,0 +1,50 @@ +package com.baeldung; + +import static org.hamcrest.CoreMatchers.is; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.Test; + +public class OuterUnitTest { + + private static final String NEST_HOST_NAME = "com.baeldung.Outer"; + + @Test + public void whenGetNestHostFromOuter_thenGetNestHost() { + is(Outer.class.getNestHost().getName()).equals(NEST_HOST_NAME); + } + + @Test + public void whenGetNestHostFromInner_thenGetNestHost() { + is(Outer.Inner.class.getNestHost().getName()).equals(NEST_HOST_NAME); + } + + @Test + public void whenCheckNestmatesForNestedClasses_thenGetTrue() { + is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(true); + } + + @Test + public void whenCheckNestmatesForUnrelatedClasses_thenGetFalse() { + is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(false); + } + + @Test + public void whenGetNestMembersForNestedClasses_thenGetAllNestedClasses() { + List nestMembers = Arrays.stream(Outer.Inner.class.getNestMembers()) + .map(Class::getName) + .collect(Collectors.toList()); + + is(nestMembers.size()).equals(2); + + boolean containsOuter = nestMembers.stream() + .anyMatch("com.baeldung.Outer"::equals); + is(containsOuter).equals(true); + + boolean containsInner = nestMembers.stream() + .anyMatch("com.baeldung.Outer$Inner"::equals); + is(containsInner).equals(true); + } +} \ No newline at end of file From 338b0bc80cf15eb20e9f9201e8efafc3d2a65eab Mon Sep 17 00:00:00 2001 From: Ganesh Pagade Date: Sun, 23 Dec 2018 12:08:36 +0530 Subject: [PATCH 038/441] format --- .../src/main/java/com/baeldung/Outer.java | 30 +++++----- .../test/java/com/baeldung/OuterUnitTest.java | 60 +++++++++---------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/core-java-11/src/main/java/com/baeldung/Outer.java b/core-java-11/src/main/java/com/baeldung/Outer.java index e2f1479ab1..1d3cd72b44 100644 --- a/core-java-11/src/main/java/com/baeldung/Outer.java +++ b/core-java-11/src/main/java/com/baeldung/Outer.java @@ -4,21 +4,21 @@ import java.lang.reflect.Method; public class Outer { - public void outerPublic() { - } - - private void outerPrivate() { - } - - class Inner { - - public void innerPublic() { - outerPrivate(); + public void outerPublic() { } - public void innerPublicReflection(Outer ob) throws Exception { - Method method = ob.getClass().getDeclaredMethod("outerPrivate"); - method.invoke(ob); - } - } + private void outerPrivate() { + } + + class Inner { + + public void innerPublic() { + outerPrivate(); + } + + public void innerPublicReflection(Outer ob) throws Exception { + Method method = ob.getClass().getDeclaredMethod("outerPrivate"); + method.invoke(ob); + } + } } \ No newline at end of file diff --git a/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java index a954416f68..6680a8d518 100644 --- a/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java +++ b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java @@ -9,42 +9,42 @@ import org.junit.Test; public class OuterUnitTest { - private static final String NEST_HOST_NAME = "com.baeldung.Outer"; + private static final String NEST_HOST_NAME = "com.baeldung.Outer"; - @Test - public void whenGetNestHostFromOuter_thenGetNestHost() { - is(Outer.class.getNestHost().getName()).equals(NEST_HOST_NAME); - } + @Test + public void whenGetNestHostFromOuter_thenGetNestHost() { + is(Outer.class.getNestHost().getName()).equals(NEST_HOST_NAME); + } - @Test - public void whenGetNestHostFromInner_thenGetNestHost() { - is(Outer.Inner.class.getNestHost().getName()).equals(NEST_HOST_NAME); - } + @Test + public void whenGetNestHostFromInner_thenGetNestHost() { + is(Outer.Inner.class.getNestHost().getName()).equals(NEST_HOST_NAME); + } - @Test - public void whenCheckNestmatesForNestedClasses_thenGetTrue() { - is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(true); - } + @Test + public void whenCheckNestmatesForNestedClasses_thenGetTrue() { + is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(true); + } - @Test - public void whenCheckNestmatesForUnrelatedClasses_thenGetFalse() { - is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(false); - } + @Test + public void whenCheckNestmatesForUnrelatedClasses_thenGetFalse() { + is(Outer.Inner.class.isNestmateOf(Outer.class)).equals(false); + } - @Test - public void whenGetNestMembersForNestedClasses_thenGetAllNestedClasses() { - List nestMembers = Arrays.stream(Outer.Inner.class.getNestMembers()) - .map(Class::getName) - .collect(Collectors.toList()); + @Test + public void whenGetNestMembersForNestedClasses_thenGetAllNestedClasses() { + List nestMembers = Arrays.stream(Outer.Inner.class.getNestMembers()) + .map(Class::getName) + .collect(Collectors.toList()); - is(nestMembers.size()).equals(2); + is(nestMembers.size()).equals(2); - boolean containsOuter = nestMembers.stream() - .anyMatch("com.baeldung.Outer"::equals); - is(containsOuter).equals(true); + boolean containsOuter = nestMembers.stream() + .anyMatch("com.baeldung.Outer"::equals); + is(containsOuter).equals(true); - boolean containsInner = nestMembers.stream() - .anyMatch("com.baeldung.Outer$Inner"::equals); - is(containsInner).equals(true); - } + boolean containsInner = nestMembers.stream() + .anyMatch("com.baeldung.Outer$Inner"::equals); + is(containsInner).equals(true); + } } \ No newline at end of file From 8880d96d3a0c6c5dcdc0f188756d89543fec7481 Mon Sep 17 00:00:00 2001 From: codehunter34 Date: Sun, 23 Dec 2018 16:41:11 -0500 Subject: [PATCH 039/441] BAEL-2399: Guice vs Spring - Dependency Injection --- .../com/baeldung/examples/common/Account.java | 27 +++++++ .../examples/common/AccountService.java | 8 +++ .../examples/common/AccountServiceImpl.java | 15 ++++ .../com/baeldung/examples/common/Address.java | 35 +++++++++ .../baeldung/examples/common/BookService.java | 9 +++ .../examples/common/BookServiceImpl.java | 12 ++++ .../com/baeldung/examples/guice/Employee.java | 32 +++++++++ .../java/com/baeldung/examples/guice/Foo.java | 5 ++ .../baeldung/examples/guice/FooGenerator.java | 11 +++ .../baeldung/examples/guice/GuiceUser.java | 32 +++++++++ .../examples/guice/GuiceUserService.java | 19 +++++ .../com/baeldung/examples/guice/Person.java | 39 ++++++++++ .../examples/guice/modules/GuiceModule.java | 47 ++++++++++++ .../baeldung/examples/spring/AppConfig.java | 19 +++++ .../baeldung/examples/spring/SpringUser.java | 35 +++++++++ .../com/baeldung/examples/spring/Student.java | 34 +++++++++ .../baeldung/examples/spring/UserService.java | 22 ++++++ .../com/baeldung/examples/GuiceTests.java | 72 +++++++++++++++++++ .../com/baeldung/examples/SpringTests.java | 58 +++++++++++++++ 19 files changed, 531 insertions(+) create mode 100644 guice/src/main/java/com/baeldung/examples/common/Account.java create mode 100644 guice/src/main/java/com/baeldung/examples/common/AccountService.java create mode 100644 guice/src/main/java/com/baeldung/examples/common/AccountServiceImpl.java create mode 100644 guice/src/main/java/com/baeldung/examples/common/Address.java create mode 100644 guice/src/main/java/com/baeldung/examples/common/BookService.java create mode 100644 guice/src/main/java/com/baeldung/examples/common/BookServiceImpl.java create mode 100644 guice/src/main/java/com/baeldung/examples/guice/Employee.java create mode 100644 guice/src/main/java/com/baeldung/examples/guice/Foo.java create mode 100644 guice/src/main/java/com/baeldung/examples/guice/FooGenerator.java create mode 100644 guice/src/main/java/com/baeldung/examples/guice/GuiceUser.java create mode 100644 guice/src/main/java/com/baeldung/examples/guice/GuiceUserService.java create mode 100644 guice/src/main/java/com/baeldung/examples/guice/Person.java create mode 100644 guice/src/main/java/com/baeldung/examples/guice/modules/GuiceModule.java create mode 100644 guice/src/main/java/com/baeldung/examples/spring/AppConfig.java create mode 100644 guice/src/main/java/com/baeldung/examples/spring/SpringUser.java create mode 100644 guice/src/main/java/com/baeldung/examples/spring/Student.java create mode 100644 guice/src/main/java/com/baeldung/examples/spring/UserService.java create mode 100644 guice/src/test/java/com/baeldung/examples/GuiceTests.java create mode 100644 guice/src/test/java/com/baeldung/examples/SpringTests.java diff --git a/guice/src/main/java/com/baeldung/examples/common/Account.java b/guice/src/main/java/com/baeldung/examples/common/Account.java new file mode 100644 index 0000000000..09a9d80b6a --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/common/Account.java @@ -0,0 +1,27 @@ +package com.baeldung.examples.common; + +import org.springframework.stereotype.Component; + +@Component +public class Account { + + private String accountNumber; + private String type; + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/common/AccountService.java b/guice/src/main/java/com/baeldung/examples/common/AccountService.java new file mode 100644 index 0000000000..d6a7fe1d11 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/common/AccountService.java @@ -0,0 +1,8 @@ +package com.baeldung.examples.common; + +import java.util.List; + +public interface AccountService { + public List listAccountTypes(); + +} diff --git a/guice/src/main/java/com/baeldung/examples/common/AccountServiceImpl.java b/guice/src/main/java/com/baeldung/examples/common/AccountServiceImpl.java new file mode 100644 index 0000000000..9cecf021fe --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/common/AccountServiceImpl.java @@ -0,0 +1,15 @@ +package com.baeldung.examples.common; + +import java.util.Arrays; +import java.util.List; + +import org.springframework.stereotype.Component; + +@Component +public class AccountServiceImpl implements AccountService { + + public List listAccountTypes() { + return Arrays.asList("Checking", "Saving"); + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/common/Address.java b/guice/src/main/java/com/baeldung/examples/common/Address.java new file mode 100644 index 0000000000..3b07c47011 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/common/Address.java @@ -0,0 +1,35 @@ +package com.baeldung.examples.common; + +import org.springframework.stereotype.Component; + +@Component +public class Address { + private String city; + private String state; + private String county; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCounty() { + return county; + } + + public void setCounty(String county) { + this.county = county; + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/common/BookService.java b/guice/src/main/java/com/baeldung/examples/common/BookService.java new file mode 100644 index 0000000000..3aca9d90d7 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/common/BookService.java @@ -0,0 +1,9 @@ +package com.baeldung.examples.common; + +import java.util.List; + +public interface BookService { + + public List findBestSellerBooks(); + +} diff --git a/guice/src/main/java/com/baeldung/examples/common/BookServiceImpl.java b/guice/src/main/java/com/baeldung/examples/common/BookServiceImpl.java new file mode 100644 index 0000000000..b5499c678d --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/common/BookServiceImpl.java @@ -0,0 +1,12 @@ +package com.baeldung.examples.common; + +import java.util.Arrays; +import java.util.List; + +public class BookServiceImpl implements BookService { + + public List findBestSellerBooks() { + return Arrays.asList("Harry Potter", "Lord of The Rings"); + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/guice/Employee.java b/guice/src/main/java/com/baeldung/examples/guice/Employee.java new file mode 100644 index 0000000000..b85d251a05 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/guice/Employee.java @@ -0,0 +1,32 @@ +package com.baeldung.examples.guice; + +import com.google.inject.Inject; + +public class Employee { + + private String firstName; + private String lastName; + + @Inject + public Employee(String firstName) { + this.firstName = firstName; + this.lastName = "Default"; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/guice/Foo.java b/guice/src/main/java/com/baeldung/examples/guice/Foo.java new file mode 100644 index 0000000000..a4f22a6f69 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/guice/Foo.java @@ -0,0 +1,5 @@ +package com.baeldung.examples.guice; + + +public class Foo { +} diff --git a/guice/src/main/java/com/baeldung/examples/guice/FooGenerator.java b/guice/src/main/java/com/baeldung/examples/guice/FooGenerator.java new file mode 100644 index 0000000000..b2d3309d0e --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/guice/FooGenerator.java @@ -0,0 +1,11 @@ +package com.baeldung.examples.guice; + +import org.springframework.lang.Nullable; + +import com.google.inject.Inject; + +public class FooGenerator { + @Inject + public FooGenerator(@Nullable Foo foo) { + } +} \ No newline at end of file diff --git a/guice/src/main/java/com/baeldung/examples/guice/GuiceUser.java b/guice/src/main/java/com/baeldung/examples/guice/GuiceUser.java new file mode 100644 index 0000000000..df438add5b --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/guice/GuiceUser.java @@ -0,0 +1,32 @@ +package com.baeldung.examples.guice; + +import com.baeldung.examples.common.Account; +import com.baeldung.examples.common.Address; +import com.google.inject.Inject; + +public class GuiceUser { + + @Inject + private Account account; + + private Address address; + + public Account getAccount() { + return account; + } + + public void setAccount(Account account) { + this.account = account; + } + + public Address getAddress() { + return address; + } + + @Inject + public void setAddress(Address address) { + this.address = address; + address.setCity("Default"); + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/guice/GuiceUserService.java b/guice/src/main/java/com/baeldung/examples/guice/GuiceUserService.java new file mode 100644 index 0000000000..18cb076661 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/guice/GuiceUserService.java @@ -0,0 +1,19 @@ +package com.baeldung.examples.guice; + +import com.baeldung.examples.common.AccountService; +import com.google.inject.Inject; + +public class GuiceUserService { + + @Inject + private AccountService accountService; + + public AccountService getAccountService() { + return accountService; + } + + public void setAccountService(AccountService accountService) { + this.accountService = accountService; + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/guice/Person.java b/guice/src/main/java/com/baeldung/examples/guice/Person.java new file mode 100644 index 0000000000..45ee5f4b89 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/guice/Person.java @@ -0,0 +1,39 @@ +package com.baeldung.examples.guice; + +import com.baeldung.examples.common.Address; +import com.google.inject.Inject; + +public class Person { + private String firstName; + + private String lastName; + + private Address address; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public Address getAddress() { + return address; + } + + @Inject + public void setAddress(Address address) { + this.address = address; + address.setCity("Default"); + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/guice/modules/GuiceModule.java b/guice/src/main/java/com/baeldung/examples/guice/modules/GuiceModule.java new file mode 100644 index 0000000000..44b566240e --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/guice/modules/GuiceModule.java @@ -0,0 +1,47 @@ +package com.baeldung.examples.guice.modules; + +import com.baeldung.examples.common.AccountService; +import com.baeldung.examples.common.AccountServiceImpl; +import com.baeldung.examples.common.BookService; +import com.baeldung.examples.common.BookServiceImpl; +import com.baeldung.examples.guice.Foo; +import com.baeldung.examples.guice.Person; +import com.google.inject.AbstractModule; +import com.google.inject.Provider; +import com.google.inject.Provides; + +public class GuiceModule extends AbstractModule { + + @Override + protected void configure() { + try { + bind(AccountService.class).to(AccountServiceImpl.class); + bind(Foo.class).toProvider(new Provider() { + public Foo get() { + return null; + } + }); + + bind(Person.class).toConstructor(Person.class.getConstructor()); + // bind(Person.class).toProvider(new Provider() { + // public Person get() { + // Person p = new Person(); + // return p; + // } + // }); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + @Provides + public BookService bookServiceGenerator() { + return new BookServiceImpl(); + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/spring/AppConfig.java b/guice/src/main/java/com/baeldung/examples/spring/AppConfig.java new file mode 100644 index 0000000000..e5b6648e0d --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/spring/AppConfig.java @@ -0,0 +1,19 @@ +package com.baeldung.examples.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +import com.baeldung.examples.common.BookService; +import com.baeldung.examples.common.BookServiceImpl; + +@Configuration +@ComponentScan("com.baeldung.examples") +public class AppConfig { + + @Bean + public BookService bookServiceGenerator() { + return new BookServiceImpl(); + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/spring/SpringUser.java b/guice/src/main/java/com/baeldung/examples/spring/SpringUser.java new file mode 100644 index 0000000000..ba6aaab09b --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/spring/SpringUser.java @@ -0,0 +1,35 @@ +package com.baeldung.examples.spring; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.baeldung.examples.common.Account; +import com.baeldung.examples.common.Address; + +@Component +public class SpringUser { + + @Autowired + private Account account; + + private Address address; + + public Account getAccount() { + return account; + } + + public void setAccount(Account account) { + this.account = account; + } + + public Address getAddress() { + return address; + } + + @Autowired + public void setAddress(Address address) { + this.address = address; + address.setCity("Default"); + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/spring/Student.java b/guice/src/main/java/com/baeldung/examples/spring/Student.java new file mode 100644 index 0000000000..d8b61a91ef --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/spring/Student.java @@ -0,0 +1,34 @@ +package com.baeldung.examples.spring; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +public class Student { + private String firstName; + private String lastName; + + @Autowired + public Student(@Value("Default") String firstName, @Value("Default") String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + +} diff --git a/guice/src/main/java/com/baeldung/examples/spring/UserService.java b/guice/src/main/java/com/baeldung/examples/spring/UserService.java new file mode 100644 index 0000000000..91b95c100d --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/spring/UserService.java @@ -0,0 +1,22 @@ +package com.baeldung.examples.spring; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.baeldung.examples.common.AccountService; + +@Component +public class UserService { + + @Autowired + private AccountService accountService; + + public AccountService getAccountService() { + return accountService; + } + + public void setAccountService(AccountService accountService) { + this.accountService = accountService; + } + +} diff --git a/guice/src/test/java/com/baeldung/examples/GuiceTests.java b/guice/src/test/java/com/baeldung/examples/GuiceTests.java new file mode 100644 index 0000000000..b87289a1a4 --- /dev/null +++ b/guice/src/test/java/com/baeldung/examples/GuiceTests.java @@ -0,0 +1,72 @@ +package com.baeldung.examples; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +import com.baeldung.examples.common.BookService; +import com.baeldung.examples.guice.Employee; +import com.baeldung.examples.guice.FooGenerator; +import com.baeldung.examples.guice.GuiceUser; +import com.baeldung.examples.guice.GuiceUserService; +import com.baeldung.examples.guice.Person; +import com.baeldung.examples.guice.modules.GuiceModule; +import com.google.inject.Guice; +import com.google.inject.Injector; + +public class GuiceTests { + + @Test + public void givenAccountFieldInjectedInGuiceUser_WhenGetAccountInvoked_ThenReturnValueIsNotNull() { + Injector injector = Guice.createInjector(new GuiceModule()); + GuiceUser guiceUser = injector.getInstance(GuiceUser.class); + assertNotNull(guiceUser.getAccount()); + } + + @Test + public void givenAccountServiceInjectedInGuiceUserService_WhenGetAccountServiceInvoked_ThenReturnValueIsNotNull() { + Injector injector = Guice.createInjector(new GuiceModule()); + GuiceUserService guiceUserService = injector.getInstance(GuiceUserService.class); + assertNotNull(guiceUserService.getAccountService()); + } + + @Test + public void givenBookServiceIsRegisteredInModule_WhenBookServiceIsInjected_ThenReturnValueIsNotNull() { + Injector injector = Guice.createInjector(new GuiceModule()); + BookService bookService = injector.getInstance(BookService.class); + assertNotNull(bookService); + } + + @Test + public void givenFooGeneratorConstructorParameterIsNotNullable_WhenFooGeneratorIsInjected_ThenTestFailsByProvisionException() { + Injector injector = Guice.createInjector(new GuiceModule()); + FooGenerator fooGenerator = injector.getInstance(FooGenerator.class); + assertNotNull(fooGenerator); + } + + @Test + public void givenMultipleBindingsForPerson_WhenPersonIsInjected_ThenTestFailsByProvisionException() { + Injector injector = Guice.createInjector(new GuiceModule()); + Person person = injector.getInstance(Person.class); + assertNotNull(person); + } + + @Test + public void givenEmployeeConstructorAnnotatedByInject_WhenEmployeeIsInjected_ThenInstanceWillBeCreatedFromTheConstructor() { + Injector injector = Guice.createInjector(new GuiceModule()); + Employee employee = injector.getInstance(Employee.class); + assertNotNull(employee); + assertEquals("Default", employee.getLastName()); + } + + @Test + public void givenAddressAutowiredToGuiceUserBySetterInjection_WhenGuiceUserIsInjected_ThenAddressInitializedByTheSetter() { + Injector injector = Guice.createInjector(new GuiceModule()); + GuiceUser guiceUser = injector.getInstance(GuiceUser.class); + assertNotNull(guiceUser); + assertNotNull(guiceUser.getAddress()); + assertEquals("Default", guiceUser.getAddress().getCity()); + } + +} diff --git a/guice/src/test/java/com/baeldung/examples/SpringTests.java b/guice/src/test/java/com/baeldung/examples/SpringTests.java new file mode 100644 index 0000000000..327e409cc1 --- /dev/null +++ b/guice/src/test/java/com/baeldung/examples/SpringTests.java @@ -0,0 +1,58 @@ +package com.baeldung.examples; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.examples.common.BookService; +import com.baeldung.examples.spring.AppConfig; +import com.baeldung.examples.spring.SpringUser; +import com.baeldung.examples.spring.Student; +import com.baeldung.examples.spring.UserService; + +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = { AppConfig.class }) +public class SpringTests { + @Autowired + ApplicationContext context; + + @Test + public void givenAccountFieldAutowiredToSpringUser_WhenGetAccountInvoked_ThenReturnValueIsNotNull() { + SpringUser springUser = context.getBean(SpringUser.class); + assertNotNull(springUser.getAccount()); + } + + @Test + public void givenAccountServiceFieldAutowiredToUserService_WhenGetAccountServiceInvoked_ThenReturnValueIsNotNull() { + UserService userService = context.getBean(UserService.class); + assertNotNull(userService.getAccountService()); + } + + @Test + public void givenBookServiceIsRegisteredAsBeanInContext_WhenBookServiceIsRetrievedFromContext_ThenReturnValueIsNotNull() { + BookService bookService = context.getBean(BookService.class); + assertNotNull(bookService); + } + + @Test + public void givenStudentConstructorAnnotatedByAutowired_WhenStudentIsRetrievedFromContext_ThenInstanceWillBeCreatedFromTheConstructor() { + Student student = context.getBean(Student.class); + assertNotNull(student); + assertEquals("Default", student.getFirstName()); + assertEquals("Default", student.getLastName()); + } + + @Test + public void givenAddressAutowiredToSpringUserBySetterInjection_WhenSpringUserRetrievedFromContext_ThenAddressInitializedByTheSetter() { + SpringUser springUser = context.getBean(SpringUser.class); + assertNotNull(springUser.getAddress()); + assertEquals("Default", springUser.getAddress().getCity()); + } + +} From acf8034d9352feded9a4e442e654ae517c182e10 Mon Sep 17 00:00:00 2001 From: codehunter34 Date: Wed, 26 Dec 2018 23:58:04 -0500 Subject: [PATCH 040/441] BAEL-2399: Guice vs Spring - Dependency Injection --- guice/pom.xml | 62 ++++++++++++------- .../{GuiceTests.java => GuiceUnitTest.java} | 2 +- .../{SpringTests.java => SpringUnitTest.java} | 2 +- 3 files changed, 41 insertions(+), 25 deletions(-) rename guice/src/test/java/com/baeldung/examples/{GuiceTests.java => GuiceUnitTest.java} (96%) rename guice/src/test/java/com/baeldung/examples/{SpringTests.java => SpringUnitTest.java} (96%) diff --git a/guice/pom.xml b/guice/pom.xml index f3e7873245..54532bc992 100644 --- a/guice/pom.xml +++ b/guice/pom.xml @@ -1,29 +1,45 @@ - - 4.0.0 - com.baeldung.examples.guice - guice - 1.0-SNAPSHOT - jar - guice + + 4.0.0 + com.baeldung.examples.guice + guice + 1.0-SNAPSHOT + jar + guice - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + - - - com.google.inject - guice - ${guice.version} - - + + + com.google.inject + guice + ${guice.version} + - - 4.1.0 - + + org.springframework + spring-context + ${spring.version} + + + + org.springframework + spring-test + ${springtest.version} + test + + + + + 4.1.0 + 5.1.3.RELEASE + 5.1.3.RELEASE + diff --git a/guice/src/test/java/com/baeldung/examples/GuiceTests.java b/guice/src/test/java/com/baeldung/examples/GuiceUnitTest.java similarity index 96% rename from guice/src/test/java/com/baeldung/examples/GuiceTests.java rename to guice/src/test/java/com/baeldung/examples/GuiceUnitTest.java index b87289a1a4..ebc35de405 100644 --- a/guice/src/test/java/com/baeldung/examples/GuiceTests.java +++ b/guice/src/test/java/com/baeldung/examples/GuiceUnitTest.java @@ -15,7 +15,7 @@ import com.baeldung.examples.guice.modules.GuiceModule; import com.google.inject.Guice; import com.google.inject.Injector; -public class GuiceTests { +public class GuiceUnitTest { @Test public void givenAccountFieldInjectedInGuiceUser_WhenGetAccountInvoked_ThenReturnValueIsNotNull() { diff --git a/guice/src/test/java/com/baeldung/examples/SpringTests.java b/guice/src/test/java/com/baeldung/examples/SpringUnitTest.java similarity index 96% rename from guice/src/test/java/com/baeldung/examples/SpringTests.java rename to guice/src/test/java/com/baeldung/examples/SpringUnitTest.java index 327e409cc1..0bd6770909 100644 --- a/guice/src/test/java/com/baeldung/examples/SpringTests.java +++ b/guice/src/test/java/com/baeldung/examples/SpringUnitTest.java @@ -18,7 +18,7 @@ import com.baeldung.examples.spring.UserService; @RunWith(SpringRunner.class) @ContextConfiguration(classes = { AppConfig.class }) -public class SpringTests { +public class SpringUnitTest { @Autowired ApplicationContext context; From 2279246a426c9d35618ce2a1dc2f26b724922060 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Thu, 27 Dec 2018 09:39:40 +0100 Subject: [PATCH 041/441] BAEL-2435 Switch domain around Change the domain from 'Messages' to 'Order' as that domain is better suited for an example project like this. First, update the commands and events, adding an extra command/event to flesh out the domain some what --- .../coreapi/commands/ConfirmOrderCommand.java | 36 ++++++++++++++++ .../commands/CreateMessageCommand.java | 42 ------------------ .../commands/MarkReadMessageCommand.java | 36 ---------------- .../coreapi/commands/PlaceOrderCommand.java | 43 +++++++++++++++++++ .../coreapi/commands/ShipOrderCommand.java | 36 ++++++++++++++++ .../coreapi/events/MessageCreatedEvent.java | 39 ----------------- .../axon/coreapi/events/MessageReadEvent.java | 33 -------------- .../coreapi/events/OrderConfirmedEvent.java | 33 ++++++++++++++ .../axon/coreapi/events/OrderPlacedEvent.java | 40 +++++++++++++++++ .../coreapi/events/OrderShippedEvent.java | 33 ++++++++++++++ 10 files changed, 221 insertions(+), 150 deletions(-) create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/commands/ConfirmOrderCommand.java delete mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/commands/CreateMessageCommand.java delete mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/commands/MarkReadMessageCommand.java create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/commands/PlaceOrderCommand.java create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/commands/ShipOrderCommand.java delete mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/events/MessageCreatedEvent.java delete mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/events/MessageReadEvent.java create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/events/OrderConfirmedEvent.java create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/events/OrderShippedEvent.java diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/commands/ConfirmOrderCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/ConfirmOrderCommand.java new file mode 100644 index 0000000000..ba04343af1 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/commands/ConfirmOrderCommand.java @@ -0,0 +1,36 @@ +package com.baeldung.axon.coreapi.commands; + +import org.axonframework.modelling.command.TargetAggregateIdentifier; + +import java.util.Objects; + +public class ConfirmOrderCommand { + + @TargetAggregateIdentifier + private final String orderId; + + public ConfirmOrderCommand(String orderId) { + this.orderId = orderId; + } + + public String getOrderId() { + return orderId; + } + + @Override + public int hashCode() { + return Objects.hash(orderId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ConfirmOrderCommand other = (ConfirmOrderCommand) obj; + return Objects.equals(this.orderId, other.orderId); + } +} diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/commands/CreateMessageCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/CreateMessageCommand.java deleted file mode 100644 index fd03d6b269..0000000000 --- a/axon/src/main/java/com/baeldung/axon/coreapi/commands/CreateMessageCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.axon.coreapi.commands; - -import java.util.Objects; - -import org.axonframework.modelling.command.TargetAggregateIdentifier; - -public class CreateMessageCommand { - - @TargetAggregateIdentifier - private final String id; - private final String text; - - public CreateMessageCommand(String id, String text) { - this.id = id; - this.text = text; - } - - public String getId() { - return id; - } - - public String getText() { - return text; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CreateMessageCommand that = (CreateMessageCommand) o; - return Objects.equals(id, that.id) && Objects.equals(text, that.text); - } - - @Override - public int hashCode() { - return Objects.hash(id, text); - } -} \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/commands/MarkReadMessageCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/MarkReadMessageCommand.java deleted file mode 100644 index ec68a380f8..0000000000 --- a/axon/src/main/java/com/baeldung/axon/coreapi/commands/MarkReadMessageCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.axon.coreapi.commands; - -import java.util.Objects; - -import org.axonframework.modelling.command.TargetAggregateIdentifier; - -public class MarkReadMessageCommand { - - @TargetAggregateIdentifier - private final String id; - - public MarkReadMessageCommand(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MarkReadMessageCommand that = (MarkReadMessageCommand) o; - return Objects.equals(id, that.id); - } - - @Override - public int hashCode() { - return Objects.hash(id); - } -} \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/commands/PlaceOrderCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/PlaceOrderCommand.java new file mode 100644 index 0000000000..cde2d7f1ae --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/commands/PlaceOrderCommand.java @@ -0,0 +1,43 @@ +package com.baeldung.axon.coreapi.commands; + +import java.util.Objects; + +import org.axonframework.modelling.command.TargetAggregateIdentifier; + +public class PlaceOrderCommand { + + @TargetAggregateIdentifier + private final String orderId; + private final String product; + + public PlaceOrderCommand(String orderId, String product) { + this.orderId = orderId; + this.product = product; + } + + public String getOrderId() { + return orderId; + } + + public String getProduct() { + return product; + } + + @Override + public int hashCode() { + return Objects.hash(orderId, product); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final PlaceOrderCommand other = (PlaceOrderCommand) obj; + return Objects.equals(this.orderId, other.orderId) + && Objects.equals(this.product, other.product); + } +} \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/commands/ShipOrderCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/ShipOrderCommand.java new file mode 100644 index 0000000000..75469533b9 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/commands/ShipOrderCommand.java @@ -0,0 +1,36 @@ +package com.baeldung.axon.coreapi.commands; + +import java.util.Objects; + +import org.axonframework.modelling.command.TargetAggregateIdentifier; + +public class ShipOrderCommand { + + @TargetAggregateIdentifier + private final String orderId; + + public ShipOrderCommand(String orderId) { + this.orderId = orderId; + } + + public String getOrderId() { + return orderId; + } + + @Override + public int hashCode() { + return Objects.hash(orderId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final ShipOrderCommand other = (ShipOrderCommand) obj; + return Objects.equals(this.orderId, other.orderId); + } +} \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageCreatedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageCreatedEvent.java deleted file mode 100644 index debf383771..0000000000 --- a/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageCreatedEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.baeldung.axon.coreapi.events; - -import java.util.Objects; - -public class MessageCreatedEvent { - - private final String id; - private final String text; - - public MessageCreatedEvent(String id, String text) { - this.id = id; - this.text = text; - } - - public String getId() { - return id; - } - - public String getText() { - return text; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MessageCreatedEvent that = (MessageCreatedEvent) o; - return Objects.equals(id, that.id) && Objects.equals(text, that.text); - } - - @Override - public int hashCode() { - return Objects.hash(id, text); - } -} \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageReadEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageReadEvent.java deleted file mode 100644 index f90bfb054e..0000000000 --- a/axon/src/main/java/com/baeldung/axon/coreapi/events/MessageReadEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung.axon.coreapi.events; - -import java.util.Objects; - -public class MessageReadEvent { - - private final String id; - - public MessageReadEvent(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MessageReadEvent that = (MessageReadEvent) o; - return Objects.equals(id, that.id); - } - - @Override - public int hashCode() { - return Objects.hash(id); - } -} \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderConfirmedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderConfirmedEvent.java new file mode 100644 index 0000000000..1706b08023 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderConfirmedEvent.java @@ -0,0 +1,33 @@ +package com.baeldung.axon.coreapi.events; + +import java.util.Objects; + +public class OrderConfirmedEvent { + + private final String orderId; + + public OrderConfirmedEvent(String orderId) { + this.orderId = orderId; + } + + public String getOrderId() { + return orderId; + } + + @Override + public int hashCode() { + return Objects.hash(orderId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final OrderConfirmedEvent other = (OrderConfirmedEvent) obj; + return Objects.equals(this.orderId, other.orderId); + } +} diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java new file mode 100644 index 0000000000..8d5364f4c6 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java @@ -0,0 +1,40 @@ +package com.baeldung.axon.coreapi.events; + +import java.util.Objects; + +public class OrderPlacedEvent { + + private final String orderId; + private final String product; + + public OrderPlacedEvent(String orderId, String product) { + this.orderId = orderId; + this.product = product; + } + + public String getOrderId() { + return orderId; + } + + public String getProduct() { + return product; + } + + @Override + public int hashCode() { + return Objects.hash(orderId, product); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final OrderPlacedEvent other = (OrderPlacedEvent) obj; + return Objects.equals(this.orderId, other.orderId) + && Objects.equals(this.product, other.product); + } +} \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderShippedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderShippedEvent.java new file mode 100644 index 0000000000..5abcd09a3c --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderShippedEvent.java @@ -0,0 +1,33 @@ +package com.baeldung.axon.coreapi.events; + +import java.util.Objects; + +public class OrderShippedEvent { + + private final String orderId; + + public OrderShippedEvent(String orderId) { + this.orderId = orderId; + } + + public String getOrderId() { + return orderId; + } + + @Override + public int hashCode() { + return Objects.hash(orderId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final OrderShippedEvent other = (OrderShippedEvent) obj; + return Objects.equals(this.orderId, other.orderId); + } +} \ No newline at end of file From 5dd6d520254050e3378cbc06c46f1985467a8557 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Thu, 27 Dec 2018 12:48:51 +0400 Subject: [PATCH 042/441] Vector class more tests --- .../com/baeldung/performance/ArrayListBenchmark.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java b/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java index 5c3f7531e3..1eeb17df87 100644 --- a/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java +++ b/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java @@ -49,6 +49,11 @@ public class ArrayListBenchmark { return state.employeeList.contains(state.employee); } + @Benchmark + public boolean testContainsVector(ArrayListBenchmark.MyState state) { + return state.employeeVector.contains(state.employee); + } + @Benchmark public int testIndexOf(ArrayListBenchmark.MyState state) { return state.employeeList.indexOf(state.employee); @@ -73,6 +78,11 @@ public class ArrayListBenchmark { state.employeeList.add(new Employee(state.iterations + 1, "John")); } + @Benchmark + public void testAddVector(ArrayListBenchmark.MyState state) { + state.employeeVector.add(new Employee(state.iterations + 1, "John")); + } + public static void main(String[] args) throws Exception { Options options = new OptionsBuilder() .include(ArrayListBenchmark.class.getSimpleName()).threads(1) From bd0a1efe707ba65b04f21a21f621110b7769ab0a Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Thu, 27 Dec 2018 09:51:08 +0100 Subject: [PATCH 043/441] BAEL-2435 Switch domain around Change the domain from 'Messages' to 'Order' as that domain is better suited for an example project like this. To that end the MessagesAggregate should be replaced by an OrderAggregate. Additionally, add some decision making logic which denies the shipping of an order if it hasn't been confirmed yet. Adjust and update thee unit test accordingly --- .../axon/commandmodel/MessagesAggregate.java | 38 ------------ .../axon/commandmodel/OrderAggregate.java | 58 +++++++++++++++++++ .../MessagesAggregateUnitTest.java | 40 ------------- .../commandmodel/OrderAggregateUnitTest.java | 48 +++++++++++++++ 4 files changed, 106 insertions(+), 78 deletions(-) delete mode 100644 axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java create mode 100644 axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java delete mode 100644 axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateUnitTest.java create mode 100644 axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java diff --git a/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java b/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java deleted file mode 100644 index 1ab9501617..0000000000 --- a/axon/src/main/java/com/baeldung/axon/commandmodel/MessagesAggregate.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baeldung.axon.commandmodel; - -import static org.axonframework.modelling.command.AggregateLifecycle.apply; - -import org.axonframework.commandhandling.CommandHandler; -import org.axonframework.eventsourcing.EventSourcingHandler; -import org.axonframework.modelling.command.AggregateIdentifier; -import org.axonframework.spring.stereotype.Aggregate; - -import com.baeldung.axon.coreapi.commands.CreateMessageCommand; -import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand; -import com.baeldung.axon.coreapi.events.MessageCreatedEvent; -import com.baeldung.axon.coreapi.events.MessageReadEvent; - -@Aggregate -public class MessagesAggregate { - - @AggregateIdentifier - private String id; - - public MessagesAggregate() { - } - - @CommandHandler - public MessagesAggregate(CreateMessageCommand command) { - apply(new MessageCreatedEvent(command.getId(), command.getText())); - } - - @CommandHandler - public void handle(MarkReadMessageCommand command) { - apply(new MessageReadEvent(id)); - } - - @EventSourcingHandler - public void on(MessageCreatedEvent event) { - this.id = event.getId(); - } -} \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java b/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java new file mode 100644 index 0000000000..fd4f901032 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java @@ -0,0 +1,58 @@ +package com.baeldung.axon.commandmodel; + +import static org.axonframework.modelling.command.AggregateLifecycle.apply; + +import org.axonframework.commandhandling.CommandHandler; +import org.axonframework.eventsourcing.EventSourcingHandler; +import org.axonframework.modelling.command.AggregateIdentifier; +import org.axonframework.spring.stereotype.Aggregate; + +import com.baeldung.axon.coreapi.commands.ConfirmOrderCommand; +import com.baeldung.axon.coreapi.commands.PlaceOrderCommand; +import com.baeldung.axon.coreapi.commands.ShipOrderCommand; +import com.baeldung.axon.coreapi.events.OrderConfirmedEvent; +import com.baeldung.axon.coreapi.events.OrderPlacedEvent; +import com.baeldung.axon.coreapi.events.OrderShippedEvent; + +@Aggregate +public class OrderAggregate { + + @AggregateIdentifier + private String orderId; + private boolean orderConfirmed; + + @CommandHandler + public OrderAggregate(PlaceOrderCommand command) { + apply(new OrderPlacedEvent(command.getOrderId(), command.getProduct())); + } + + @CommandHandler + public void handle(ConfirmOrderCommand command) { + apply(new OrderConfirmedEvent(orderId)); + } + + @CommandHandler + public void handle(ShipOrderCommand command) { + if (!orderConfirmed) { + throw new IllegalStateException("Cannot ship an order which has not ben confirmed yet."); + } + + apply(new OrderShippedEvent(orderId)); + } + + @EventSourcingHandler + public void on(OrderPlacedEvent event) { + this.orderId = event.getOrderId(); + orderConfirmed = false; + } + + @EventSourcingHandler + public void on(OrderConfirmedEvent event) { + orderConfirmed = true; + } + + protected OrderAggregate() { + // Required by Axon to build a default Aggregate prior to Event Sourcing + } + +} \ No newline at end of file diff --git a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateUnitTest.java b/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateUnitTest.java deleted file mode 100644 index 46357ddff8..0000000000 --- a/axon/src/test/java/com/baeldung/axon/commandmodel/MessagesAggregateUnitTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.axon.commandmodel; - -import java.util.UUID; - -import org.axonframework.test.aggregate.AggregateTestFixture; -import org.axonframework.test.aggregate.FixtureConfiguration; -import org.junit.*; - -import com.baeldung.axon.coreapi.commands.CreateMessageCommand; -import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand; -import com.baeldung.axon.coreapi.events.MessageCreatedEvent; -import com.baeldung.axon.coreapi.events.MessageReadEvent; - -public class MessagesAggregateUnitTest { - - private FixtureConfiguration fixture; - - @Before - public void setUp() { - fixture = new AggregateTestFixture<>(MessagesAggregate.class); - } - - @Test - public void giveAggregateRoot_whenCreateMessageCommand_thenShouldProduceMessageCreatedEvent() { - String eventText = "Hello, how is your day?"; - String id = UUID.randomUUID().toString(); - fixture.given() - .when(new CreateMessageCommand(id, eventText)) - .expectEvents(new MessageCreatedEvent(id, eventText)); - } - - @Test - public void givenMessageCreatedEvent_whenReadMessageCommand_thenShouldProduceMessageReadEvent() { - String id = UUID.randomUUID().toString(); - - fixture.given(new MessageCreatedEvent(id, "Hello :-)")) - .when(new MarkReadMessageCommand(id)) - .expectEvents(new MessageReadEvent(id)); - } -} \ No newline at end of file diff --git a/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java b/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java new file mode 100644 index 0000000000..e7dfdeb794 --- /dev/null +++ b/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java @@ -0,0 +1,48 @@ +package com.baeldung.axon.commandmodel; + +import java.util.UUID; + +import org.axonframework.test.aggregate.AggregateTestFixture; +import org.axonframework.test.aggregate.FixtureConfiguration; +import org.junit.*; + +import com.baeldung.axon.coreapi.commands.PlaceOrderCommand; +import com.baeldung.axon.coreapi.commands.ShipOrderCommand; +import com.baeldung.axon.coreapi.events.OrderConfirmedEvent; +import com.baeldung.axon.coreapi.events.OrderPlacedEvent; +import com.baeldung.axon.coreapi.events.OrderShippedEvent; + +public class OrderAggregateUnitTest { + + private static final String ORDER_ID = UUID.randomUUID().toString(); + private static final String DEFAULT_PRODUCT = "Deluxe Chair"; + + private FixtureConfiguration fixture; + + @Before + public void setUp() { + fixture = new AggregateTestFixture<>(OrderAggregate.class); + } + + @Test + public void giveNoPriorActivity_whenPlaceOrderCommand_thenShouldPublishOrderPlacedEvent() { + fixture.givenNoPriorActivity() + .when(new PlaceOrderCommand(ORDER_ID, DEFAULT_PRODUCT)) + .expectEvents(new OrderPlacedEvent(ORDER_ID, DEFAULT_PRODUCT)); + } + + @Test + public void givenOrderPlacedEvent_whenShipOrderCommand_thenShouldThrowIllegalStateException() { + fixture.given(new OrderPlacedEvent(ORDER_ID, DEFAULT_PRODUCT)) + .when(new ShipOrderCommand(ORDER_ID)) + .expectException(IllegalStateException.class); + } + + @Test + public void givenOrderPlacedEventAndOrderConfirmedEvent_whenShipOrderCommand_thenShouldPublishOrderShippedEvent() { + fixture.given(new OrderPlacedEvent(ORDER_ID, DEFAULT_PRODUCT), new OrderConfirmedEvent(ORDER_ID)) + .when(new ShipOrderCommand(ORDER_ID)) + .expectEvents(new OrderShippedEvent(ORDER_ID)); + } + +} \ No newline at end of file From eab6dfe0dd5e29afd990f7b3770242c93d1f3d01 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Thu, 27 Dec 2018 09:55:49 +0100 Subject: [PATCH 044/441] BAEL-2435 Switch domain around Change the domain from 'Messages' to 'Order' as that domain is better suited for an example project like this. Update the endpoint to reflect the order focus i.o. the message focus. Additionally, add a POST endpoint which would return an exception due to the state check in the aggregate --- .../axon/gui/MessagesRestEndpoint.java | 28 ------------- .../baeldung/axon/gui/OrderRestEndpoint.java | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 28 deletions(-) delete mode 100644 axon/src/main/java/com/baeldung/axon/gui/MessagesRestEndpoint.java create mode 100644 axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java diff --git a/axon/src/main/java/com/baeldung/axon/gui/MessagesRestEndpoint.java b/axon/src/main/java/com/baeldung/axon/gui/MessagesRestEndpoint.java deleted file mode 100644 index ddbc3e2fc5..0000000000 --- a/axon/src/main/java/com/baeldung/axon/gui/MessagesRestEndpoint.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.axon.gui; - -import java.util.UUID; - -import org.axonframework.commandhandling.gateway.CommandGateway; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.baeldung.axon.coreapi.commands.CreateMessageCommand; -import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand; - -@RestController -public class MessagesRestEndpoint { - - private final CommandGateway commandGateway; - - public MessagesRestEndpoint(CommandGateway commandGateway) { - this.commandGateway = commandGateway; - } - - @PostMapping("/hello") - public void publishMessages() { - final String itemId = UUID.randomUUID().toString(); - commandGateway.send(new CreateMessageCommand(itemId, "Hello, how is your day? :-)")); - commandGateway.send(new MarkReadMessageCommand(itemId)); - } - -} diff --git a/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java b/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java new file mode 100644 index 0000000000..3c86f9c3b1 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java @@ -0,0 +1,40 @@ +package com.baeldung.axon.gui; + +import java.util.UUID; + +import org.axonframework.commandhandling.gateway.CommandGateway; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.axon.coreapi.commands.ConfirmOrderCommand; +import com.baeldung.axon.coreapi.commands.PlaceOrderCommand; +import com.baeldung.axon.coreapi.commands.ShipOrderCommand; + +@RestController +public class OrderRestEndpoint { + + private static final String DEFAULT_PRODUCT = "Deluxe Chair"; + + private final CommandGateway commandGateway; + + public OrderRestEndpoint(CommandGateway commandGateway) { + this.commandGateway = commandGateway; + } + + @PostMapping("/ship-order") + public void shipOrder() { + String orderId = UUID.randomUUID().toString(); + commandGateway.send(new PlaceOrderCommand(orderId, DEFAULT_PRODUCT)); + commandGateway.send(new ConfirmOrderCommand(orderId)); + commandGateway.send(new ShipOrderCommand(orderId)); + } + + @PostMapping("/ship-unconfirmed-order") + public void shipUnconfirmedOrder() { + String orderId = UUID.randomUUID().toString(); + commandGateway.send(new PlaceOrderCommand(orderId, DEFAULT_PRODUCT)); + // This throws an exception, as an Order cannot be shipped if it has not been confirmed yet. + commandGateway.send(new ShipOrderCommand(orderId)); + } + +} From 84b6dc1dbb7badacaed4bbcc5a889ba5a1d5171c Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Thu, 27 Dec 2018 10:36:10 +0100 Subject: [PATCH 045/441] BAEL-2435 Switch domain around Change the domain from 'Messages' to 'Order' as that domain is better suited for an example project like this. The Query Model would be better suited to revolve around the OrderedProducts rather than just printing out a line of text. To that end, add a OrderedProduct model with the OrderStatus, which is updated in the (renamed) OrderedProductsEventHandler upon all the events --- .../axon/coreapi/queries/OrderStatus.java | 7 +++ .../axon/coreapi/queries/OrderedProduct.java | 55 +++++++++++++++++++ .../axon/querymodel/MessagesEventHandler.java | 21 ------- .../OrderedProductsEventHandler.java | 42 ++++++++++++++ 4 files changed, 104 insertions(+), 21 deletions(-) create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderStatus.java create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderedProduct.java delete mode 100644 axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java create mode 100644 axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderStatus.java b/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderStatus.java new file mode 100644 index 0000000000..d215c5fc32 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderStatus.java @@ -0,0 +1,7 @@ +package com.baeldung.axon.coreapi.queries; + +public enum OrderStatus { + + PLACED, CONFIRMED, SHIPPED + +} diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderedProduct.java b/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderedProduct.java new file mode 100644 index 0000000000..25096eeb42 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderedProduct.java @@ -0,0 +1,55 @@ +package com.baeldung.axon.coreapi.queries; + +import java.util.Objects; + +public class OrderedProduct { + + private final String orderId; + private final String product; + private OrderStatus orderStatus; + + public OrderedProduct(String orderId, String product) { + this.orderId = orderId; + this.product = product; + orderStatus = OrderStatus.PLACED; + } + + public String getOrderId() { + return orderId; + } + + public String getProduct() { + return product; + } + + public OrderStatus getOrderStatus() { + return orderStatus; + } + + public void setOrderConfirmed() { + this.orderStatus = OrderStatus.CONFIRMED; + } + + public void setOrderShipped() { + this.orderStatus = OrderStatus.SHIPPED; + } + + @Override + public int hashCode() { + return Objects.hash(orderId, product, orderStatus); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + final OrderedProduct other = (OrderedProduct) obj; + return Objects.equals(this.orderId, other.orderId) + && Objects.equals(this.product, other.product) + && Objects.equals(this.orderStatus, other.orderStatus); + } +} diff --git a/axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java b/axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java deleted file mode 100644 index 6988d40a53..0000000000 --- a/axon/src/main/java/com/baeldung/axon/querymodel/MessagesEventHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.axon.querymodel; - -import org.axonframework.eventhandling.EventHandler; -import org.springframework.stereotype.Service; - -import com.baeldung.axon.coreapi.events.MessageCreatedEvent; -import com.baeldung.axon.coreapi.events.MessageReadEvent; - -@Service -public class MessagesEventHandler { - - @EventHandler - public void handle(MessageCreatedEvent event) { - System.out.println("Message received: " + event.getText() + " (" + event.getId() + ")"); - } - - @EventHandler - public void handle(MessageReadEvent event) { - System.out.println("Message read: " + event.getId()); - } -} \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java b/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java new file mode 100644 index 0000000000..7bcdb27af7 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java @@ -0,0 +1,42 @@ +package com.baeldung.axon.querymodel; + +import java.util.HashMap; +import java.util.Map; + +import org.axonframework.eventhandling.EventHandler; +import org.springframework.stereotype.Service; + +import com.baeldung.axon.coreapi.queries.OrderedProduct; +import com.baeldung.axon.coreapi.events.OrderConfirmedEvent; +import com.baeldung.axon.coreapi.events.OrderPlacedEvent; +import com.baeldung.axon.coreapi.events.OrderShippedEvent; + +@Service +public class OrderedProductsEventHandler { + + private final Map orderedProducts = new HashMap<>(); + + @EventHandler + public void on(OrderPlacedEvent event) { + String orderId = event.getOrderId(); + orderedProducts.put(orderId, new OrderedProduct(orderId, event.getProduct())); + + } + + @EventHandler + public void on(OrderShippedEvent event) { + orderedProducts.computeIfPresent(event.getOrderId(), (orderId, orderedProduct) -> { + orderedProduct.setOrderShipped(); + return orderedProduct; + }); + } + + @EventHandler + public void on(OrderConfirmedEvent event) { + orderedProducts.computeIfPresent(event.getOrderId(), (orderId, orderedProduct) -> { + orderedProduct.setOrderConfirmed(); + return orderedProduct; + }); + } + +} \ No newline at end of file From 769af6759ed6dca02d6c8732f2627e11e5f66a48 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Thu, 27 Dec 2018 10:39:42 +0100 Subject: [PATCH 046/441] BAEL-2435 Introduce Query message logic Introduce a FindAllOrderedProductsQuery query message, which is published on the QueryGateway through the OrderRestEndpoint and handled by the OrderedProductsEventHandler --- .../queries/FindAllOrderedProductsQuery.java | 5 +++++ .../com/baeldung/axon/gui/OrderRestEndpoint.java | 16 +++++++++++++++- .../querymodel/OrderedProductsEventHandler.java | 11 ++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/queries/FindAllOrderedProductsQuery.java diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/queries/FindAllOrderedProductsQuery.java b/axon/src/main/java/com/baeldung/axon/coreapi/queries/FindAllOrderedProductsQuery.java new file mode 100644 index 0000000000..9d6ca2cfb2 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/queries/FindAllOrderedProductsQuery.java @@ -0,0 +1,5 @@ +package com.baeldung.axon.coreapi.queries; + +public class FindAllOrderedProductsQuery { + +} diff --git a/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java b/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java index 3c86f9c3b1..3b8be0bc46 100644 --- a/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java +++ b/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java @@ -1,14 +1,20 @@ package com.baeldung.axon.gui; +import java.util.List; import java.util.UUID; import org.axonframework.commandhandling.gateway.CommandGateway; +import org.axonframework.messaging.responsetypes.ResponseTypes; +import org.axonframework.queryhandling.QueryGateway; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import com.baeldung.axon.coreapi.commands.ConfirmOrderCommand; import com.baeldung.axon.coreapi.commands.PlaceOrderCommand; import com.baeldung.axon.coreapi.commands.ShipOrderCommand; +import com.baeldung.axon.coreapi.queries.FindAllOrderedProductsQuery; +import com.baeldung.axon.coreapi.queries.OrderedProduct; @RestController public class OrderRestEndpoint { @@ -16,9 +22,11 @@ public class OrderRestEndpoint { private static final String DEFAULT_PRODUCT = "Deluxe Chair"; private final CommandGateway commandGateway; + private final QueryGateway queryGateway; - public OrderRestEndpoint(CommandGateway commandGateway) { + public OrderRestEndpoint(CommandGateway commandGateway, QueryGateway queryGateway) { this.commandGateway = commandGateway; + this.queryGateway = queryGateway; } @PostMapping("/ship-order") @@ -37,4 +45,10 @@ public class OrderRestEndpoint { commandGateway.send(new ShipOrderCommand(orderId)); } + @GetMapping("/all-orders") + public List findAllOrderedProducts() { + return queryGateway.query(new FindAllOrderedProductsQuery(), ResponseTypes.multipleInstancesOf(OrderedProduct.class)) + .join(); + } + } diff --git a/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java b/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java index 7bcdb27af7..c2bf48614b 100644 --- a/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java +++ b/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java @@ -1,15 +1,19 @@ package com.baeldung.axon.querymodel; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.axonframework.eventhandling.EventHandler; +import org.axonframework.queryhandling.QueryHandler; import org.springframework.stereotype.Service; -import com.baeldung.axon.coreapi.queries.OrderedProduct; import com.baeldung.axon.coreapi.events.OrderConfirmedEvent; import com.baeldung.axon.coreapi.events.OrderPlacedEvent; import com.baeldung.axon.coreapi.events.OrderShippedEvent; +import com.baeldung.axon.coreapi.queries.FindAllOrderedProductsQuery; +import com.baeldung.axon.coreapi.queries.OrderedProduct; @Service public class OrderedProductsEventHandler { @@ -39,4 +43,9 @@ public class OrderedProductsEventHandler { }); } + @QueryHandler + public List handle(FindAllOrderedProductsQuery query) { + return new ArrayList<>(orderedProducts.values()); + } + } \ No newline at end of file From 4c7303c2936706da2aa207eae4b41f0caf8f9d19 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Thu, 27 Dec 2018 10:46:45 +0100 Subject: [PATCH 047/441] BAEL-2435 Rename main file Rename main file from MessagesRunner to OrderApplication --- .../axon/{MessagesRunner.java => OrderApplication.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename axon/src/main/java/com/baeldung/axon/{MessagesRunner.java => OrderApplication.java} (70%) diff --git a/axon/src/main/java/com/baeldung/axon/MessagesRunner.java b/axon/src/main/java/com/baeldung/axon/OrderApplication.java similarity index 70% rename from axon/src/main/java/com/baeldung/axon/MessagesRunner.java rename to axon/src/main/java/com/baeldung/axon/OrderApplication.java index 4f83dd86f0..8f507e141c 100644 --- a/axon/src/main/java/com/baeldung/axon/MessagesRunner.java +++ b/axon/src/main/java/com/baeldung/axon/OrderApplication.java @@ -4,10 +4,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class MessagesRunner { +public class OrderApplication { public static void main(String[] args) { - SpringApplication.run(MessagesRunner.class, args); + SpringApplication.run(OrderApplication.class, args); } } \ No newline at end of file From d5ad67a801d96ba707729c0dcb87e331eef5ae28 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Thu, 27 Dec 2018 10:47:22 +0100 Subject: [PATCH 048/441] BAEL-2435 Add http resource Add http resource to try out all the end points when running the application in Intellij --- axon/src/main/resources/order-api.http | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 axon/src/main/resources/order-api.http diff --git a/axon/src/main/resources/order-api.http b/axon/src/main/resources/order-api.http new file mode 100644 index 0000000000..a3c69c72bc --- /dev/null +++ b/axon/src/main/resources/order-api.http @@ -0,0 +1,11 @@ +POST http://localhost:8080/ship-order + +### + +POST http://localhost:8080/ship-unconfirmed-order + +### + +GET http://localhost:8080/all-orders + +### From 9e23ea5abee98cd5dfd874bb31619045e35e62fd Mon Sep 17 00:00:00 2001 From: Ganesh Pagade Date: Thu, 27 Dec 2018 17:02:37 +0530 Subject: [PATCH 049/441] simplier asserts --- .../src/test/java/com/baeldung/OuterUnitTest.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java index 6680a8d518..798736149a 100644 --- a/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java +++ b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java @@ -1,9 +1,11 @@ package com.baeldung; +import static org.junit.Assert.assertTrue; import static org.hamcrest.CoreMatchers.is; import java.util.Arrays; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import org.junit.Test; @@ -33,18 +35,13 @@ public class OuterUnitTest { @Test public void whenGetNestMembersForNestedClasses_thenGetAllNestedClasses() { - List nestMembers = Arrays.stream(Outer.Inner.class.getNestMembers()) + Set nestMembers = Arrays.stream(Outer.Inner.class.getNestMembers()) .map(Class::getName) - .collect(Collectors.toList()); + .collect(Collectors.toSet()); is(nestMembers.size()).equals(2); - boolean containsOuter = nestMembers.stream() - .anyMatch("com.baeldung.Outer"::equals); - is(containsOuter).equals(true); - - boolean containsInner = nestMembers.stream() - .anyMatch("com.baeldung.Outer$Inner"::equals); - is(containsInner).equals(true); + assertTrue(nestMembers.contains("com.baeldung.Outer")); + assertTrue(nestMembers.contains("com.baeldung.Outer$Inner")); } } \ No newline at end of file From 6ae59f8f8d36a8a20612fe449a7a33ec683c869b Mon Sep 17 00:00:00 2001 From: Ganesh Pagade Date: Thu, 27 Dec 2018 17:08:34 +0530 Subject: [PATCH 050/441] clean up --- core-java-11/src/test/java/com/baeldung/OuterUnitTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java index 798736149a..9e6bd72680 100644 --- a/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java +++ b/core-java-11/src/test/java/com/baeldung/OuterUnitTest.java @@ -4,7 +4,6 @@ import static org.junit.Assert.assertTrue; import static org.hamcrest.CoreMatchers.is; import java.util.Arrays; -import java.util.List; import java.util.Set; import java.util.stream.Collectors; import org.junit.Test; From 15071b6d49ef751184dbf7fbd033553257a69400 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Fri, 28 Dec 2018 10:44:23 +0200 Subject: [PATCH 051/441] Update README.md --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index b6e112b5fc..c066ccb50b 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -21,3 +21,4 @@ - [Custom Types in Hibernate](https://www.baeldung.com/hibernate-custom-types) - [Criteria API – An Example of IN Expressions](https://www.baeldung.com/jpa-criteria-api-in-expressions) - [Difference Between @JoinColumn and mappedBy](https://www.baeldung.com/jpa-joincolumn-vs-mappedby) +- [Hibernate 5 Bootstrapping API](https://www.baeldung.com/hibernate-5-bootstrapping-api) From 8ce227cce7d92ca7ac1e5e7b0e63b8b41da604a2 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Fri, 28 Dec 2018 16:26:57 +0400 Subject: [PATCH 052/441] immutable sets --- .../com/baeldung/set/UnmodifiableSet.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java diff --git a/core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java b/core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java new file mode 100644 index 0000000000..d821c46a3c --- /dev/null +++ b/core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java @@ -0,0 +1,44 @@ +package com.baeldung.set; + +import com.google.common.collect.ImmutableSet; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +public class UnmodifiableSet { + + public static void main(String[] args) { + + Set set = new HashSet<>(); + set.add("Canada"); + set.add("USA"); + + coreJDK(set); + guavaOf(); + copyOf(set); + setOf(); + } + + private static void setOf() { + Set immutable = Set.of("Canada", "USA"); + System.out.println(immutable); + } + + private static void guavaOf() { + Set immutable = ImmutableSet.of("Canada", "USA"); + System.out.println(immutable); + } + + private static void copyOf(Set set) { + Set immutable = ImmutableSet.copyOf(set); + set.add("Costa Rica"); + System.out.println(immutable); + } + + private static void coreJDK(Set set) { + Set unmodifiableSet = Collections.unmodifiableSet(set); + set.add("Costa Rica"); + System.out.println(unmodifiableSet); + } +} From fb8183d69434b3f3a4b3d2ec311cdbe6a40d98da Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Fri, 28 Dec 2018 16:33:41 +0400 Subject: [PATCH 053/441] comment java 9 --- .../src/main/java/com/baeldung/set/UnmodifiableSet.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java b/core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java index d821c46a3c..06f477c50a 100644 --- a/core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java +++ b/core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java @@ -17,12 +17,12 @@ public class UnmodifiableSet { coreJDK(set); guavaOf(); copyOf(set); - setOf(); + java9Of(); } - private static void setOf() { - Set immutable = Set.of("Canada", "USA"); - System.out.println(immutable); + private static void java9Of() { + //Set immutable = Set.of("Canada", "USA"); + //System.out.println(immutable); } private static void guavaOf() { From 415ecc6421ff449dba0fc09458f2aa896c54af16 Mon Sep 17 00:00:00 2001 From: Loredana Date: Fri, 28 Dec 2018 16:22:03 +0200 Subject: [PATCH 054/441] remove completablefuture --- .../controllers/EthereumRestController.java | 16 +++++------ .../baeldung/web3j/services/Web3Service.java | 28 +++++++++---------- .../services/EthereumContractUnitTest.java | 10 +++---- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/ethereum/src/main/java/com/baeldung/web3j/controllers/EthereumRestController.java b/ethereum/src/main/java/com/baeldung/web3j/controllers/EthereumRestController.java index e05517bc79..3238a19ff9 100644 --- a/ethereum/src/main/java/com/baeldung/web3j/controllers/EthereumRestController.java +++ b/ethereum/src/main/java/com/baeldung/web3j/controllers/EthereumRestController.java @@ -32,8 +32,8 @@ public class EthereumRestController { return CompletableFuture.supplyAsync(() -> { try { - CompletableFuture result = web3Service.getBlockNumber(); - responseTransfer.setMessage(result.get().toString()); + EthBlockNumber result = web3Service.getBlockNumber(); + responseTransfer.setMessage(result.toString()); } catch (Exception e) { responseTransfer.setMessage(GENERIC_EXCEPTION); } @@ -51,8 +51,8 @@ public class EthereumRestController { return CompletableFuture.supplyAsync(() -> { try { - CompletableFuture result = web3Service.getEthAccounts(); - responseTransfer.setMessage(result.get().toString()); + EthAccounts result = web3Service.getEthAccounts(); + responseTransfer.setMessage(result.toString()); } catch (Exception e) { responseTransfer.setMessage(GENERIC_EXCEPTION); } @@ -70,8 +70,8 @@ public class EthereumRestController { Instant start = TimeHelper.start(); return CompletableFuture.supplyAsync(() -> { try { - CompletableFuture result = web3Service.getTransactionCount(); - responseTransfer.setMessage(result.get().toString()); + EthGetTransactionCount result = web3Service.getTransactionCount(); + responseTransfer.setMessage(result.toString()); } catch (Exception e) { responseTransfer.setMessage(GENERIC_EXCEPTION); } @@ -88,8 +88,8 @@ public class EthereumRestController { Instant start = TimeHelper.start(); return CompletableFuture.supplyAsync(() -> { try { - CompletableFuture result = web3Service.getEthBalance(); - responseTransfer.setMessage(result.get().toString()); + EthGetBalance result = web3Service.getEthBalance(); + responseTransfer.setMessage(result.toString()); } catch (Exception e) { responseTransfer.setMessage(GENERIC_EXCEPTION); } diff --git a/ethereum/src/main/java/com/baeldung/web3j/services/Web3Service.java b/ethereum/src/main/java/com/baeldung/web3j/services/Web3Service.java index c943ee4006..4b7d01e52b 100644 --- a/ethereum/src/main/java/com/baeldung/web3j/services/Web3Service.java +++ b/ethereum/src/main/java/com/baeldung/web3j/services/Web3Service.java @@ -47,47 +47,47 @@ public class Web3Service { return "0x" + binary; } - public CompletableFuture getBlockNumber() { + public EthBlockNumber getBlockNumber() { EthBlockNumber result = new EthBlockNumber(); try { result = this.web3j.ethBlockNumber().sendAsync().get(); } catch (Exception ex) { System.out.println(GENERIC_EXCEPTION); } - return CompletableFuture.completedFuture(result); + return result; } - public CompletableFuture getEthAccounts() { + public EthAccounts getEthAccounts() { EthAccounts result = new EthAccounts(); try { result = this.web3j.ethAccounts().sendAsync().get(); } catch (Exception ex) { System.out.println(GENERIC_EXCEPTION); } - return CompletableFuture.completedFuture(result); + return result; } - public CompletableFuture getTransactionCount() { + public EthGetTransactionCount getTransactionCount() { EthGetTransactionCount result = new EthGetTransactionCount(); try { result = this.web3j.ethGetTransactionCount(DEFAULT_ADDRESS, DefaultBlockParameter.valueOf("latest")).sendAsync().get(); } catch (Exception ex) { System.out.println(GENERIC_EXCEPTION); } - return CompletableFuture.completedFuture(result); + return result; } - public CompletableFuture getEthBalance() { + public EthGetBalance getEthBalance() { EthGetBalance result = new EthGetBalance(); try { result = this.web3j.ethGetBalance(DEFAULT_ADDRESS, DefaultBlockParameter.valueOf("latest")).sendAsync().get(); } catch (Exception ex) { System.out.println(GENERIC_EXCEPTION); } - return CompletableFuture.completedFuture(result); + return result; } - public CompletableFuture fromScratchContractExample() { + public String fromScratchContractExample() { String contractAddress = ""; @@ -108,13 +108,13 @@ public class Web3Service { } catch (Exception ex) { System.out.println(PLEASE_SUPPLY_REAL_DATA); - return CompletableFuture.completedFuture(PLEASE_SUPPLY_REAL_DATA); + return PLEASE_SUPPLY_REAL_DATA; } - return CompletableFuture.completedFuture(contractAddress); + return contractAddress; } @Async - public CompletableFuture sendTx() { + public String sendTx() { String transactionHash = ""; try { @@ -135,10 +135,10 @@ public class Web3Service { } catch (Exception ex) { System.out.println(PLEASE_SUPPLY_REAL_DATA); - return CompletableFuture.completedFuture(PLEASE_SUPPLY_REAL_DATA); + return PLEASE_SUPPLY_REAL_DATA; } - return CompletableFuture.completedFuture(transactionHash); + return transactionHash; } } diff --git a/ethereum/src/test/java/com/baeldung/web3j/services/EthereumContractUnitTest.java b/ethereum/src/test/java/com/baeldung/web3j/services/EthereumContractUnitTest.java index 382c96e985..ff02659bd5 100644 --- a/ethereum/src/test/java/com/baeldung/web3j/services/EthereumContractUnitTest.java +++ b/ethereum/src/test/java/com/baeldung/web3j/services/EthereumContractUnitTest.java @@ -4,8 +4,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.util.concurrent.CompletableFuture; - public class EthereumContractUnitTest { private Web3Service web3Service; @@ -17,14 +15,14 @@ public class EthereumContractUnitTest { @Test public void testContract() { - CompletableFuture result = web3Service.fromScratchContractExample(); - assert (result instanceof CompletableFuture); + String result = web3Service.fromScratchContractExample(); + assert (result instanceof String); } @Test public void sendTx() { - CompletableFuture result = web3Service.sendTx(); - assert (result instanceof CompletableFuture); + String result = web3Service.sendTx(); + assert (result instanceof String); } @After From 03306112bdc117277afa828912a81b5fe938d158 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Fri, 28 Dec 2018 15:58:41 +0100 Subject: [PATCH 055/441] BAEL-2435 Minor clean ups -Add toString() function to messages/query-model -Fix typo in exception -Reorder event handlers in OrderedProductsEventHandler -Replace usage of constants for local fields -Add missing Aggregate test case --- .../axon/commandmodel/OrderAggregate.java | 2 +- .../coreapi/commands/ConfirmOrderCommand.java | 7 ++++ .../coreapi/commands/PlaceOrderCommand.java | 8 +++++ .../coreapi/commands/ShipOrderCommand.java | 7 ++++ .../coreapi/events/OrderConfirmedEvent.java | 7 ++++ .../axon/coreapi/events/OrderPlacedEvent.java | 8 +++++ .../coreapi/events/OrderShippedEvent.java | 7 ++++ .../axon/coreapi/queries/OrderedProduct.java | 9 +++++ .../baeldung/axon/gui/OrderRestEndpoint.java | 8 ++--- .../OrderedProductsEventHandler.java | 17 +++++----- .../commandmodel/OrderAggregateUnitTest.java | 33 +++++++++++++------ 11 files changed, 88 insertions(+), 25 deletions(-) diff --git a/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java b/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java index fd4f901032..b37b2fdd66 100644 --- a/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java +++ b/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java @@ -34,7 +34,7 @@ public class OrderAggregate { @CommandHandler public void handle(ShipOrderCommand command) { if (!orderConfirmed) { - throw new IllegalStateException("Cannot ship an order which has not ben confirmed yet."); + throw new IllegalStateException("Cannot ship an order which has not been confirmed yet."); } apply(new OrderShippedEvent(orderId)); diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/commands/ConfirmOrderCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/ConfirmOrderCommand.java index ba04343af1..244b69f3b7 100644 --- a/axon/src/main/java/com/baeldung/axon/coreapi/commands/ConfirmOrderCommand.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/commands/ConfirmOrderCommand.java @@ -33,4 +33,11 @@ public class ConfirmOrderCommand { final ConfirmOrderCommand other = (ConfirmOrderCommand) obj; return Objects.equals(this.orderId, other.orderId); } + + @Override + public String toString() { + return "ConfirmOrderCommand{" + + "orderId='" + orderId + '\'' + + '}'; + } } diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/commands/PlaceOrderCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/PlaceOrderCommand.java index cde2d7f1ae..c70d503050 100644 --- a/axon/src/main/java/com/baeldung/axon/coreapi/commands/PlaceOrderCommand.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/commands/PlaceOrderCommand.java @@ -40,4 +40,12 @@ public class PlaceOrderCommand { return Objects.equals(this.orderId, other.orderId) && Objects.equals(this.product, other.product); } + + @Override + public String toString() { + return "PlaceOrderCommand{" + + "orderId='" + orderId + '\'' + + ", product='" + product + '\'' + + '}'; + } } \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/commands/ShipOrderCommand.java b/axon/src/main/java/com/baeldung/axon/coreapi/commands/ShipOrderCommand.java index 75469533b9..7312bc1fdb 100644 --- a/axon/src/main/java/com/baeldung/axon/coreapi/commands/ShipOrderCommand.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/commands/ShipOrderCommand.java @@ -33,4 +33,11 @@ public class ShipOrderCommand { final ShipOrderCommand other = (ShipOrderCommand) obj; return Objects.equals(this.orderId, other.orderId); } + + @Override + public String toString() { + return "ShipOrderCommand{" + + "orderId='" + orderId + '\'' + + '}'; + } } \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderConfirmedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderConfirmedEvent.java index 1706b08023..d2b7d58435 100644 --- a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderConfirmedEvent.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderConfirmedEvent.java @@ -30,4 +30,11 @@ public class OrderConfirmedEvent { final OrderConfirmedEvent other = (OrderConfirmedEvent) obj; return Objects.equals(this.orderId, other.orderId); } + + @Override + public String toString() { + return "OrderConfirmedEvent{" + + "orderId='" + orderId + '\'' + + '}'; + } } diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java index 8d5364f4c6..06de4c5f9f 100644 --- a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java @@ -37,4 +37,12 @@ public class OrderPlacedEvent { return Objects.equals(this.orderId, other.orderId) && Objects.equals(this.product, other.product); } + + @Override + public String toString() { + return "OrderPlacedEvent{" + + "orderId='" + orderId + '\'' + + ", product='" + product + '\'' + + '}'; + } } \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderShippedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderShippedEvent.java index 5abcd09a3c..76aa684629 100644 --- a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderShippedEvent.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderShippedEvent.java @@ -30,4 +30,11 @@ public class OrderShippedEvent { final OrderShippedEvent other = (OrderShippedEvent) obj; return Objects.equals(this.orderId, other.orderId); } + + @Override + public String toString() { + return "OrderShippedEvent{" + + "orderId='" + orderId + '\'' + + '}'; + } } \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderedProduct.java b/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderedProduct.java index 25096eeb42..d847bb2a98 100644 --- a/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderedProduct.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/queries/OrderedProduct.java @@ -52,4 +52,13 @@ public class OrderedProduct { && Objects.equals(this.product, other.product) && Objects.equals(this.orderStatus, other.orderStatus); } + + @Override + public String toString() { + return "OrderedProduct{" + + "orderId='" + orderId + '\'' + + ", product='" + product + '\'' + + ", orderStatus=" + orderStatus + + '}'; + } } diff --git a/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java b/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java index 3b8be0bc46..a9f34cc691 100644 --- a/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java +++ b/axon/src/main/java/com/baeldung/axon/gui/OrderRestEndpoint.java @@ -19,8 +19,6 @@ import com.baeldung.axon.coreapi.queries.OrderedProduct; @RestController public class OrderRestEndpoint { - private static final String DEFAULT_PRODUCT = "Deluxe Chair"; - private final CommandGateway commandGateway; private final QueryGateway queryGateway; @@ -32,7 +30,7 @@ public class OrderRestEndpoint { @PostMapping("/ship-order") public void shipOrder() { String orderId = UUID.randomUUID().toString(); - commandGateway.send(new PlaceOrderCommand(orderId, DEFAULT_PRODUCT)); + commandGateway.send(new PlaceOrderCommand(orderId, "Deluxe Chair")); commandGateway.send(new ConfirmOrderCommand(orderId)); commandGateway.send(new ShipOrderCommand(orderId)); } @@ -40,7 +38,7 @@ public class OrderRestEndpoint { @PostMapping("/ship-unconfirmed-order") public void shipUnconfirmedOrder() { String orderId = UUID.randomUUID().toString(); - commandGateway.send(new PlaceOrderCommand(orderId, DEFAULT_PRODUCT)); + commandGateway.send(new PlaceOrderCommand(orderId, "Deluxe Chair")); // This throws an exception, as an Order cannot be shipped if it has not been confirmed yet. commandGateway.send(new ShipOrderCommand(orderId)); } @@ -48,7 +46,7 @@ public class OrderRestEndpoint { @GetMapping("/all-orders") public List findAllOrderedProducts() { return queryGateway.query(new FindAllOrderedProductsQuery(), ResponseTypes.multipleInstancesOf(OrderedProduct.class)) - .join(); + .join(); } } diff --git a/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java b/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java index c2bf48614b..d4cf3d999b 100644 --- a/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java +++ b/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java @@ -24,15 +24,6 @@ public class OrderedProductsEventHandler { public void on(OrderPlacedEvent event) { String orderId = event.getOrderId(); orderedProducts.put(orderId, new OrderedProduct(orderId, event.getProduct())); - - } - - @EventHandler - public void on(OrderShippedEvent event) { - orderedProducts.computeIfPresent(event.getOrderId(), (orderId, orderedProduct) -> { - orderedProduct.setOrderShipped(); - return orderedProduct; - }); } @EventHandler @@ -43,6 +34,14 @@ public class OrderedProductsEventHandler { }); } + @EventHandler + public void on(OrderShippedEvent event) { + orderedProducts.computeIfPresent(event.getOrderId(), (orderId, orderedProduct) -> { + orderedProduct.setOrderShipped(); + return orderedProduct; + }); + } + @QueryHandler public List handle(FindAllOrderedProductsQuery query) { return new ArrayList<>(orderedProducts.values()); diff --git a/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java b/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java index e7dfdeb794..9beedbaa19 100644 --- a/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java +++ b/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java @@ -6,6 +6,7 @@ import org.axonframework.test.aggregate.AggregateTestFixture; import org.axonframework.test.aggregate.FixtureConfiguration; import org.junit.*; +import com.baeldung.axon.coreapi.commands.ConfirmOrderCommand; import com.baeldung.axon.coreapi.commands.PlaceOrderCommand; import com.baeldung.axon.coreapi.commands.ShipOrderCommand; import com.baeldung.axon.coreapi.events.OrderConfirmedEvent; @@ -14,9 +15,6 @@ import com.baeldung.axon.coreapi.events.OrderShippedEvent; public class OrderAggregateUnitTest { - private static final String ORDER_ID = UUID.randomUUID().toString(); - private static final String DEFAULT_PRODUCT = "Deluxe Chair"; - private FixtureConfiguration fixture; @Before @@ -26,23 +24,38 @@ public class OrderAggregateUnitTest { @Test public void giveNoPriorActivity_whenPlaceOrderCommand_thenShouldPublishOrderPlacedEvent() { + String orderId = UUID.randomUUID().toString(); + String product = "Deluxe Chair"; fixture.givenNoPriorActivity() - .when(new PlaceOrderCommand(ORDER_ID, DEFAULT_PRODUCT)) - .expectEvents(new OrderPlacedEvent(ORDER_ID, DEFAULT_PRODUCT)); + .when(new PlaceOrderCommand(orderId, product)) + .expectEvents(new OrderPlacedEvent(orderId, product)); + } + + @Test + public void givenOrderPlacedEvent_whenConfirmOrderCommand_thenShouldPublishOrderConfirmedEvent() { + String orderId = UUID.randomUUID().toString(); + String product = "Deluxe Chair"; + fixture.given(new OrderPlacedEvent(orderId, product)) + .when(new ConfirmOrderCommand(orderId)) + .expectEvents(new OrderConfirmedEvent(orderId)); } @Test public void givenOrderPlacedEvent_whenShipOrderCommand_thenShouldThrowIllegalStateException() { - fixture.given(new OrderPlacedEvent(ORDER_ID, DEFAULT_PRODUCT)) - .when(new ShipOrderCommand(ORDER_ID)) + String orderId = UUID.randomUUID().toString(); + String product = "Deluxe Chair"; + fixture.given(new OrderPlacedEvent(orderId, product)) + .when(new ShipOrderCommand(orderId)) .expectException(IllegalStateException.class); } @Test public void givenOrderPlacedEventAndOrderConfirmedEvent_whenShipOrderCommand_thenShouldPublishOrderShippedEvent() { - fixture.given(new OrderPlacedEvent(ORDER_ID, DEFAULT_PRODUCT), new OrderConfirmedEvent(ORDER_ID)) - .when(new ShipOrderCommand(ORDER_ID)) - .expectEvents(new OrderShippedEvent(ORDER_ID)); + String orderId = UUID.randomUUID().toString(); + String product = "Deluxe Chair"; + fixture.given(new OrderPlacedEvent(orderId, product), new OrderConfirmedEvent(orderId)) + .when(new ShipOrderCommand(orderId)) + .expectEvents(new OrderShippedEvent(orderId)); } } \ No newline at end of file From 4d6cb52be4642c22cfa57ed52162c695ebe6b2f5 Mon Sep 17 00:00:00 2001 From: Yatendra Goel Date: Fri, 28 Dec 2018 21:57:38 +0530 Subject: [PATCH 056/441] BAEL-1978: Added a test to demostrate classpath resource with relative path --- .../SpringResourceIntegrationTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java index 38e8304f0f..284776fdfa 100644 --- a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java +++ b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java @@ -7,6 +7,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLClassLoader; import java.nio.file.Files; import java.util.stream.Collectors; @@ -23,6 +25,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.springframework.util.ResourceUtils; +import com.baeldung.dependson.config.TestConfig; + /** * Test class illustrating various methods of accessing a file from the classpath using Resource. * @author tritty @@ -98,4 +102,19 @@ public class SpringResourceIntegrationTest { final String employees = new String(Files.readAllBytes(resource.toPath())); assertEquals(EMPLOYEES_EXPECTED, employees); } + + @Test + public void whenClassPathResourceWithAbsoultePath_thenReadSuccessful() throws IOException { + final File resource = new ClassPathResource("/data/employees.dat", this.getClass()).getFile(); + final String employees = new String(Files.readAllBytes(resource.toPath())); + assertEquals(EMPLOYEES_EXPECTED, employees); + } + + @Test + public void whenClassPathResourceWithRelativePath_thenReadSuccessful() throws IOException { +// final File resource = new ClassPathResource("../../../data/employees.dat", SpringResourceIntegrationTest.class).getFile(); + final File resource = new ClassPathResource("/data/employees.dat", SpringResourceIntegrationTest.class).getFile(); + final String employees = new String(Files.readAllBytes(resource.toPath())); + assertEquals(EMPLOYEES_EXPECTED, employees); + } } From c3eb5c939fff07533096eabb859096970eb147ad Mon Sep 17 00:00:00 2001 From: Yatendra Goel Date: Fri, 28 Dec 2018 22:00:35 +0530 Subject: [PATCH 057/441] BAEL-1978: Added a test to demostrate classpath resource with relative path --- .../com/baeldung/resource/SpringResourceIntegrationTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java index 284776fdfa..c1464feded 100644 --- a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java +++ b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java @@ -7,8 +7,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLClassLoader; import java.nio.file.Files; import java.util.stream.Collectors; @@ -25,8 +23,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.springframework.util.ResourceUtils; -import com.baeldung.dependson.config.TestConfig; - /** * Test class illustrating various methods of accessing a file from the classpath using Resource. * @author tritty From 3220d1b958446f47ac7d4a4c259f94405b306beb Mon Sep 17 00:00:00 2001 From: Loredana Date: Sat, 29 Dec 2018 00:27:55 +0200 Subject: [PATCH 058/441] fix spring-core mockito issue --- spring-core/pom.xml | 1 + .../com/baeldung/resource/SpringResourceIntegrationTest.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-core/pom.xml b/spring-core/pom.xml index 60f3262f08..f1e2e2a748 100644 --- a/spring-core/pom.xml +++ b/spring-core/pom.xml @@ -85,6 +85,7 @@ 1.16.12 2.5 1.5.2.RELEASE + 1.10.19 \ No newline at end of file diff --git a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java index c1464feded..a7a2a9032a 100644 --- a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java +++ b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java @@ -108,8 +108,7 @@ public class SpringResourceIntegrationTest { @Test public void whenClassPathResourceWithRelativePath_thenReadSuccessful() throws IOException { -// final File resource = new ClassPathResource("../../../data/employees.dat", SpringResourceIntegrationTest.class).getFile(); - final File resource = new ClassPathResource("/data/employees.dat", SpringResourceIntegrationTest.class).getFile(); + final File resource = new ClassPathResource("../../../data/employees.dat", SpringResourceIntegrationTest.class).getFile(); final String employees = new String(Files.readAllBytes(resource.toPath())); assertEquals(EMPLOYEES_EXPECTED, employees); } From a1b1e02e71df82eb3ff6d267efdd3db7643ea804 Mon Sep 17 00:00:00 2001 From: Emily Cheyne Date: Fri, 28 Dec 2018 16:11:16 -0700 Subject: [PATCH 059/441] BAEL-2421 Update readme (#6014) --- java-strings/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-strings/README.md b/java-strings/README.md index 4d735490ce..60131e392d 100644 --- a/java-strings/README.md +++ b/java-strings/README.md @@ -44,3 +44,4 @@ - [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) +- [Convert a Comma Separated String to a List in Java](https://www.baeldung.com/java-string-with-separator-to-list) From 2c801888e7f3e538f2371d6ad1627ebc761128ca Mon Sep 17 00:00:00 2001 From: FrancoCorleone Date: Sat, 29 Dec 2018 00:18:30 +0100 Subject: [PATCH 060/441] BAEL-2090 Insert with JPA * Adding inserts for JPA objects repositories * Refactor tests * Small refactor * Small refactor * Remove redundant @Repository annotation * Refactor tests * Change to simple entity manager implementation * Refactor changes * Remove Spring repositories, Add simple implementation using EntityManager * Remove redundant Interface * Remove redundant files * Update persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonInsertRepository.java Co-Authored-By: FrancoCorleone --- .../dao/repositories/InsertRepository.java | 5 -- .../PersonEntityManagerInsertRepository.java | 7 -- .../PersonEntityManagerRepository.java | 10 --- .../PersonQueryInsertRepository.java | 7 -- .../repositories/PersonQueryRepository.java | 16 ----- ...rsonEntityManagerInsertRepositoryImpl.java | 21 ------ ...yImpl.java => PersonInsertRepository.java} | 18 +++-- ...PersonInsertRepositoryIntegrationTest.java | 67 +++++++------------ 8 files changed, 35 insertions(+), 116 deletions(-) delete mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InsertRepository.java delete mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonEntityManagerInsertRepository.java delete mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonEntityManagerRepository.java delete mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonQueryInsertRepository.java delete mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonQueryRepository.java delete mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonEntityManagerInsertRepositoryImpl.java rename persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/{PersonQueryInsertRepositoryImpl.java => PersonInsertRepository.java} (60%) diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InsertRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InsertRepository.java deleted file mode 100644 index 6a74e067fe..0000000000 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InsertRepository.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baeldung.dao.repositories; - -public interface InsertRepository { - void insert(S entity); -} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonEntityManagerInsertRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonEntityManagerInsertRepository.java deleted file mode 100644 index 6d3cbb07df..0000000000 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonEntityManagerInsertRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.dao.repositories; - -import com.baeldung.domain.Person; - -public interface PersonEntityManagerInsertRepository { - void insert(Person person); -} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonEntityManagerRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonEntityManagerRepository.java deleted file mode 100644 index cbf3d59620..0000000000 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonEntityManagerRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.dao.repositories; - -import com.baeldung.domain.Person; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface PersonEntityManagerRepository extends JpaRepository, PersonEntityManagerInsertRepository { - -} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonQueryInsertRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonQueryInsertRepository.java deleted file mode 100644 index be01e9883a..0000000000 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonQueryInsertRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.dao.repositories; - -import com.baeldung.domain.Person; - -public interface PersonQueryInsertRepository { - void insert(Person person); -} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonQueryRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonQueryRepository.java deleted file mode 100644 index 1516c38443..0000000000 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/PersonQueryRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.dao.repositories; - -import com.baeldung.domain.Person; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -@Repository -public interface PersonQueryRepository extends JpaRepository, PersonQueryInsertRepository { - - @Modifying - @Query(value = "INSERT INTO person (id, first_name, last_name) VALUES (:id,:firstName,:lastName)", nativeQuery = true) - void insertWithAnnotation(@Param("id") Long id, @Param("firstName") String firstName, @Param("lastName") String lastName); -} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonEntityManagerInsertRepositoryImpl.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonEntityManagerInsertRepositoryImpl.java deleted file mode 100644 index c14cc44125..0000000000 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonEntityManagerInsertRepositoryImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.dao.repositories.impl; - -import com.baeldung.dao.repositories.PersonEntityManagerInsertRepository; -import com.baeldung.domain.Person; -import org.springframework.transaction.annotation.Transactional; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -@Transactional -public class PersonEntityManagerInsertRepositoryImpl implements PersonEntityManagerInsertRepository { - - @PersistenceContext - private EntityManager entityManager; - - @Override - public void insert(Person person) { - this.entityManager.persist(person); - } -} - diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonQueryInsertRepositoryImpl.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonInsertRepository.java similarity index 60% rename from persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonQueryInsertRepositoryImpl.java rename to persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonInsertRepository.java index 341db1615d..d809385456 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonQueryInsertRepositoryImpl.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/impl/PersonInsertRepository.java @@ -1,24 +1,30 @@ package com.baeldung.dao.repositories.impl; -import com.baeldung.dao.repositories.PersonQueryInsertRepository; import com.baeldung.domain.Person; +import org.springframework.stereotype.Repository; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.transaction.Transactional; -@Transactional -public class PersonQueryInsertRepositoryImpl implements PersonQueryInsertRepository { +@Repository +public class PersonInsertRepository { @PersistenceContext private EntityManager entityManager; - @Override - public void insert(Person person) { - entityManager.createNativeQuery("INSERT INTO person (id,first_name, last_name) VALUES (?,?,?)") + @Transactional + public void insertWithQuery(Person person) { + entityManager.createNativeQuery("INSERT INTO person (id, first_name, last_name) VALUES (?,?,?)") .setParameter(1, person.getId()) .setParameter(2, person.getFirstName()) .setParameter(3, person.getLastName()) .executeUpdate(); } + + @Transactional + public void insertWithEntityManager(Person person) { + this.entityManager.persist(person); + } + } diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/PersonInsertRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/PersonInsertRepositoryIntegrationTest.java index 476554f6d6..b248cf8bf1 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/PersonInsertRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/PersonInsertRepositoryIntegrationTest.java @@ -1,21 +1,24 @@ package com.baeldung.dao.repositories; +import com.baeldung.dao.repositories.impl.PersonInsertRepository; import com.baeldung.domain.Person; import org.junit.Test; -import org.junit.jupiter.api.BeforeEach; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.context.annotation.Import; import org.springframework.test.context.junit4.SpringRunner; -import java.util.Optional; +import javax.persistence.EntityExistsException; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceException; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @RunWith(SpringRunner.class) @DataJpaTest +@Import(PersonInsertRepository.class) public class PersonInsertRepositoryIntegrationTest { private static final Long ID = 1L; @@ -24,43 +27,23 @@ public class PersonInsertRepositoryIntegrationTest { private static final Person PERSON = new Person(ID, FIRST_NAME, LAST_NAME); @Autowired - private PersonQueryRepository personQueryRepository; + private PersonInsertRepository personInsertRepository; @Autowired - private PersonEntityManagerRepository personEntityManagerRepository; - - @BeforeEach - public void clearDB() { - personQueryRepository.deleteAll(); - } + private EntityManager entityManager; @Test public void givenPersonEntity_whenInsertWithNativeQuery_ThenPersonIsPersisted() { - insertPerson(); + insertWithQuery(); assertPersonPersisted(); } @Test - public void givenPersonEntity_whenInsertedTwiceWithNativeQuery_thenDataIntegrityViolationExceptionIsThrown() { - assertThatExceptionOfType(DataIntegrityViolationException.class).isThrownBy(() -> { - insertPerson(); - insertPerson(); - }); - } - - @Test - public void givenPersonEntity_whenInsertWithQueryAnnotation_thenPersonIsPersisted() { - insertPersonWithQueryAnnotation(); - - assertPersonPersisted(); - } - - @Test - public void givenPersonEntity_whenInsertedTwiceWithQueryAnnotation_thenDataIntegrityViolationExceptionIsThrown() { - assertThatExceptionOfType(DataIntegrityViolationException.class).isThrownBy(() -> { - insertPersonWithQueryAnnotation(); - insertPersonWithQueryAnnotation(); + public void givenPersonEntity_whenInsertedTwiceWithNativeQuery_thenPersistenceExceptionExceptionIsThrown() { + assertThatExceptionOfType(PersistenceException.class).isThrownBy(() -> { + insertWithQuery(); + insertWithQuery(); }); } @@ -72,31 +55,27 @@ public class PersonInsertRepositoryIntegrationTest { } @Test - public void givenPersonEntity_whenInsertedTwiceWithEntityManager_thenDataIntegrityViolationExceptionIsThrown() { - assertThatExceptionOfType(DataIntegrityViolationException.class).isThrownBy(() -> { + public void givenPersonEntity_whenInsertedTwiceWithEntityManager_thenEntityExistsExceptionIsThrown() { + assertThatExceptionOfType(EntityExistsException.class).isThrownBy(() -> { insertPersonWithEntityManager(); insertPersonWithEntityManager(); }); } - private void insertPerson() { - personQueryRepository.insert(PERSON); - } - - private void insertPersonWithQueryAnnotation() { - personQueryRepository.insertWithAnnotation(ID, FIRST_NAME, LAST_NAME); + private void insertWithQuery() { + personInsertRepository.insertWithQuery(PERSON); } private void insertPersonWithEntityManager() { - personEntityManagerRepository.insert(new Person(ID, FIRST_NAME, LAST_NAME)); + personInsertRepository.insertWithEntityManager(new Person(ID, FIRST_NAME, LAST_NAME)); } private void assertPersonPersisted() { - Optional personOptional = personQueryRepository.findById(PERSON.getId()); + Person person = entityManager.find(Person.class, ID); - assertThat(personOptional.isPresent()).isTrue(); - assertThat(personOptional.get().getId()).isEqualTo(PERSON.getId()); - assertThat(personOptional.get().getFirstName()).isEqualTo(PERSON.getFirstName()); - assertThat(personOptional.get().getLastName()).isEqualTo(PERSON.getLastName()); + assertThat(person).isNotNull(); + assertThat(person.getId()).isEqualTo(PERSON.getId()); + assertThat(person.getFirstName()).isEqualTo(PERSON.getFirstName()); + assertThat(person.getLastName()).isEqualTo(PERSON.getLastName()); } } From 33ba36dc4140f9dec604eea6adc0155b6c287643 Mon Sep 17 00:00:00 2001 From: Yatendra Goel Date: Sat, 29 Dec 2018 13:30:46 +0530 Subject: [PATCH 061/441] BAEL-2307: Added Code to add SAN needed by Chrome to the X509 Certificate --- .../keystore/JavaKeyStoreUnitTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core-java/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java b/core-java/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java index cb2a9f1c49..7473c52a35 100644 --- a/core-java/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java +++ b/core-java/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java @@ -4,15 +4,24 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; + import sun.security.x509.AlgorithmId; import sun.security.x509.CertificateAlgorithmId; import sun.security.x509.CertificateSerialNumber; import sun.security.x509.CertificateValidity; import sun.security.x509.CertificateVersion; import sun.security.x509.CertificateX509Key; +import sun.security.x509.SubjectAlternativeNameExtension; import sun.security.x509.X500Name; import sun.security.x509.X509CertImpl; import sun.security.x509.X509CertInfo; +import sun.security.x509.CertificateExtensions; +import sun.security.x509.GeneralNames; +import sun.security.x509.GeneralName; +import sun.security.x509.GeneralNameInterface; +import sun.security.x509.DNSName; +import sun.security.x509.IPAddressName; +import sun.security.util.DerOutputStream; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; @@ -188,6 +197,23 @@ public class JavaKeyStoreUnitTest { Date validTo = new Date(validFrom.getTime() + 50L * 365L * 24L * 60L * 60L * 1000L); //50 years CertificateValidity validity = new CertificateValidity(validFrom, validTo); certInfo.set(X509CertInfo.VALIDITY, validity); + + GeneralNameInterface dnsName = new DNSName("baeldung.com"); + DerOutputStream dnsNameOutputStream = new DerOutputStream(); + dnsName.encode(dnsNameOutputStream); + + GeneralNameInterface ipAddress = new IPAddressName("127.0.0.1"); + DerOutputStream ipAddressOutputStream = new DerOutputStream(); + ipAddress.encode(ipAddressOutputStream); + + GeneralNames generalNames = new GeneralNames(); + generalNames.add(new GeneralName(dnsName)); + generalNames.add(new GeneralName(ipAddress)); + + CertificateExtensions ext = new CertificateExtensions(); + ext.set(SubjectAlternativeNameExtension.NAME, new SubjectAlternativeNameExtension(generalNames)); + + certInfo.set(X509CertInfo.EXTENSIONS, ext); // Create certificate and sign it X509CertImpl cert = new X509CertImpl(certInfo); @@ -202,4 +228,5 @@ public class JavaKeyStoreUnitTest { return newCert; } + } \ No newline at end of file From cf3d7b69e6e43f9f4d232b97e69c09a400f3d24a Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sat, 29 Dec 2018 20:11:40 +0530 Subject: [PATCH 062/441] [BAEL-10836] - Moved Java8CollectionCleanupUnitTest, AddElementsUnitTest and articles --- core-java-collections-list/README.md | 1 - .../src/main/java/com/baeldung/list/Flower.java | 0 .../java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java | 0 .../src/test/java/com/baeldung/list/AddElementsUnitTest.java | 0 java-collections-conversions/README.md | 1 + 5 files changed, 1 insertion(+), 1 deletion(-) rename {core-java-8 => core-java-collections-list}/src/main/java/com/baeldung/list/Flower.java (100%) rename {core-java-8 => core-java-collections-list}/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java (100%) rename {core-java-8 => core-java-collections-list}/src/test/java/com/baeldung/list/AddElementsUnitTest.java (100%) diff --git a/core-java-collections-list/README.md b/core-java-collections-list/README.md index cb6999277c..aba53f5b30 100644 --- a/core-java-collections-list/README.md +++ b/core-java-collections-list/README.md @@ -17,7 +17,6 @@ - [Finding Max/Min of a List or Collection](http://www.baeldung.com/java-collection-min-max) - [Collections.emptyList() vs. New List Instance](https://www.baeldung.com/java-collections-emptylist-new-list) - [Remove All Occurrences of a Specific Value from a List](https://www.baeldung.com/java-remove-value-from-list) -- [Converting a Collection to ArrayList in Java](https://www.baeldung.com/java-convert-collection-arraylist) - [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality) - [Java 8 Streams: Find Items From One List Based On Values From Another List](https://www.baeldung.com/java-streams-find-list-items) - [A Guide to the Java LinkedList](http://www.baeldung.com/java-linkedlist) diff --git a/core-java-8/src/main/java/com/baeldung/list/Flower.java b/core-java-collections-list/src/main/java/com/baeldung/list/Flower.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/list/Flower.java rename to core-java-collections-list/src/main/java/com/baeldung/list/Flower.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java rename to core-java-collections-list/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/list/AddElementsUnitTest.java b/core-java-collections-list/src/test/java/com/baeldung/list/AddElementsUnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/list/AddElementsUnitTest.java rename to core-java-collections-list/src/test/java/com/baeldung/list/AddElementsUnitTest.java diff --git a/java-collections-conversions/README.md b/java-collections-conversions/README.md index 0f89e07d63..31fead3c42 100644 --- a/java-collections-conversions/README.md +++ b/java-collections-conversions/README.md @@ -10,3 +10,4 @@ - [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) - [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) \ No newline at end of file From 8b65216ba33e90c6f4c3d4cf3a3a85e773a85eed Mon Sep 17 00:00:00 2001 From: Emily Cheyne Date: Sat, 29 Dec 2018 08:13:10 -0700 Subject: [PATCH 063/441] BAEL-2436 update readme (#6019) --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index c066ccb50b..2b948a683a 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -22,3 +22,4 @@ - [Criteria API – An Example of IN Expressions](https://www.baeldung.com/jpa-criteria-api-in-expressions) - [Difference Between @JoinColumn and mappedBy](https://www.baeldung.com/jpa-joincolumn-vs-mappedby) - [Hibernate 5 Bootstrapping API](https://www.baeldung.com/hibernate-5-bootstrapping-api) +- [Criteria Queries Using JPA Metamodel](https://www.baeldung.com/hibernate-criteria-queries-metamodel) From c61ac5101e8732677f44b4b9efe5956dcdcb34ed Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sat, 29 Dec 2018 21:54:59 +0530 Subject: [PATCH 064/441] [BAEL-11401] - Moved articles out of core-java (part 2) --- core-java-networking/README.md | 3 +++ core-java-networking/pom.xml | 12 ++++++++++++ .../baeldung/http/FullResponseBuilder.java | 0 .../baeldung/http/ParameterStringBuilder.java | 0 .../java/com/baeldung/socket/EchoClient.java | 0 .../com/baeldung/socket/EchoMultiServer.java | 0 .../java/com/baeldung/socket/EchoServer.java | 0 .../java/com/baeldung/socket/GreetClient.java | 0 .../java/com/baeldung/socket/GreetServer.java | 0 .../EncoderDecoderUnitTest.java | 0 .../baeldung/http/HttpRequestLiveTest.java | 2 +- .../baeldung/socket/EchoIntegrationTest.java | 0 .../socket/GreetServerIntegrationTest.java | 0 .../SocketEchoMultiIntegrationTest.java | 0 core-java-perf/README.md | 4 ++++ .../java/com/baeldung/heapdump/HeapDump.java | 0 .../src/main/java/com/baeldung/jmx/Game.java | 0 .../main/java/com/baeldung/jmx/GameMBean.java | 0 .../baeldung/jmx/JMXTutorialMainlauncher.java | 0 .../memoryleaks/equalshashcode/Person.java | 0 .../equalshashcode/PersonOptimized.java | 0 .../memoryleaks/finalize/BulkyObject.java | 0 .../finalize/BulkyObjectOptimized.java | 0 .../memoryleaks/innerclass/BulkyObject.java | 0 .../innerclass/InnerClassDriver.java | 0 .../innerclass/InnerClassWrapper.java | 0 .../innerclass/StaticNestedClassWrapper.java | 0 .../internedstrings/InternedString.java | 0 .../ReadStringFromFileUtil.java | 0 .../internedstrings/StringObject.java | 0 .../staticfields/NonStaticFieldsDemo.java | 0 .../staticfields/StaticFieldsDemo.java | 0 .../OutOfMemoryGCLimitExceed.java | 0 core-java-perf/src/main/resources/logback.xml | 19 +++++++++++++++++++ .../PersonMemoryLeakUnitTest.java | 0 .../finalize/FinalizeMemoryLeakUnitTest.java | 0 .../StaticInnerClassMemoryLeakUnitTest.java | 0 .../StringInternMemoryLeakUnitTest.java | 0 .../NonStaticFieldsMemoryLeakUnitTest.java | 0 .../StaticFieldsMemoryLeakUnitTest.java | 0 core-java-sun/README.md | 1 + .../java/com/baeldung/unsafe/CASCounter.java | 0 .../com/baeldung/unsafe/OffHeapArray.java | 0 .../com/baeldung/unsafe/UnsafeUnitTest.java | 0 core-java/README.md | 8 -------- 45 files changed, 40 insertions(+), 9 deletions(-) rename {core-java => core-java-networking}/src/main/java/com/baeldung/http/FullResponseBuilder.java (100%) rename {core-java => core-java-networking}/src/main/java/com/baeldung/http/ParameterStringBuilder.java (100%) rename {core-java => core-java-networking}/src/main/java/com/baeldung/socket/EchoClient.java (100%) rename {core-java => core-java-networking}/src/main/java/com/baeldung/socket/EchoMultiServer.java (100%) rename {core-java => core-java-networking}/src/main/java/com/baeldung/socket/EchoServer.java (100%) rename {core-java => core-java-networking}/src/main/java/com/baeldung/socket/GreetClient.java (100%) rename {core-java => core-java-networking}/src/main/java/com/baeldung/socket/GreetServer.java (100%) rename {core-java => core-java-networking}/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java (100%) rename {core-java => core-java-networking}/src/test/java/com/baeldung/http/HttpRequestLiveTest.java (99%) rename {core-java => core-java-networking}/src/test/java/com/baeldung/socket/EchoIntegrationTest.java (100%) rename {core-java => core-java-networking}/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java (100%) rename {core-java => core-java-networking}/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/heapdump/HeapDump.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/jmx/Game.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/jmx/GameMBean.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/internedstrings/InternedString.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/internedstrings/ReadStringFromFileUtil.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/internedstrings/StringObject.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsDemo.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/memoryleaks/staticfields/StaticFieldsDemo.java (100%) rename {core-java => core-java-perf}/src/main/java/com/baeldung/outofmemoryerror/OutOfMemoryGCLimitExceed.java (100%) create mode 100644 core-java-perf/src/main/resources/logback.xml rename {core-java => core-java-perf}/src/test/java/com/baeldung/memoryleaks/equalshashcode/PersonMemoryLeakUnitTest.java (100%) rename {core-java => core-java-perf}/src/test/java/com/baeldung/memoryleaks/finalize/FinalizeMemoryLeakUnitTest.java (100%) rename {core-java => core-java-perf}/src/test/java/com/baeldung/memoryleaks/innerclass/StaticInnerClassMemoryLeakUnitTest.java (100%) rename {core-java => core-java-perf}/src/test/java/com/baeldung/memoryleaks/internedstrings/StringInternMemoryLeakUnitTest.java (100%) rename {core-java => core-java-perf}/src/test/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsMemoryLeakUnitTest.java (100%) rename {core-java => core-java-perf}/src/test/java/com/baeldung/memoryleaks/staticfields/StaticFieldsMemoryLeakUnitTest.java (100%) rename {core-java => core-java-sun}/src/test/java/com/baeldung/unsafe/CASCounter.java (100%) rename {core-java => core-java-sun}/src/test/java/com/baeldung/unsafe/OffHeapArray.java (100%) rename {core-java => core-java-sun}/src/test/java/com/baeldung/unsafe/UnsafeUnitTest.java (100%) diff --git a/core-java-networking/README.md b/core-java-networking/README.md index 4b77aa3c1f..b2367782b6 100644 --- a/core-java-networking/README.md +++ b/core-java-networking/README.md @@ -11,3 +11,6 @@ - [A Guide To HTTP Cookies In Java](http://www.baeldung.com/cookies-java) - [A Guide to the Java URL](http://www.baeldung.com/java-url) - [Working with Network Interfaces in Java](http://www.baeldung.com/java-network-interfaces) +- [A Guide to Java Sockets](http://www.baeldung.com/a-guide-to-java-sockets) +- [URL Encoding and Decoding in Java](http://www.baeldung.com/java-url-encoding-decoding) +- [How to Perform a Simple HTTP Request in Java](http://www.baeldung.com/java-http-request) \ No newline at end of file diff --git a/core-java-networking/pom.xml b/core-java-networking/pom.xml index c7fa2af180..d9c7c691e9 100644 --- a/core-java-networking/pom.xml +++ b/core-java-networking/pom.xml @@ -24,6 +24,16 @@ commons-io ${commons-io.version} + + org.springframework + spring-web + ${springframework.spring-web.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + @@ -33,5 +43,7 @@ 1.5.0-b01 2.5 + 3.5 + 4.3.4.RELEASE diff --git a/core-java/src/main/java/com/baeldung/http/FullResponseBuilder.java b/core-java-networking/src/main/java/com/baeldung/http/FullResponseBuilder.java similarity index 100% rename from core-java/src/main/java/com/baeldung/http/FullResponseBuilder.java rename to core-java-networking/src/main/java/com/baeldung/http/FullResponseBuilder.java diff --git a/core-java/src/main/java/com/baeldung/http/ParameterStringBuilder.java b/core-java-networking/src/main/java/com/baeldung/http/ParameterStringBuilder.java similarity index 100% rename from core-java/src/main/java/com/baeldung/http/ParameterStringBuilder.java rename to core-java-networking/src/main/java/com/baeldung/http/ParameterStringBuilder.java diff --git a/core-java/src/main/java/com/baeldung/socket/EchoClient.java b/core-java-networking/src/main/java/com/baeldung/socket/EchoClient.java similarity index 100% rename from core-java/src/main/java/com/baeldung/socket/EchoClient.java rename to core-java-networking/src/main/java/com/baeldung/socket/EchoClient.java diff --git a/core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java b/core-java-networking/src/main/java/com/baeldung/socket/EchoMultiServer.java similarity index 100% rename from core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java rename to core-java-networking/src/main/java/com/baeldung/socket/EchoMultiServer.java diff --git a/core-java/src/main/java/com/baeldung/socket/EchoServer.java b/core-java-networking/src/main/java/com/baeldung/socket/EchoServer.java similarity index 100% rename from core-java/src/main/java/com/baeldung/socket/EchoServer.java rename to core-java-networking/src/main/java/com/baeldung/socket/EchoServer.java diff --git a/core-java/src/main/java/com/baeldung/socket/GreetClient.java b/core-java-networking/src/main/java/com/baeldung/socket/GreetClient.java similarity index 100% rename from core-java/src/main/java/com/baeldung/socket/GreetClient.java rename to core-java-networking/src/main/java/com/baeldung/socket/GreetClient.java diff --git a/core-java/src/main/java/com/baeldung/socket/GreetServer.java b/core-java-networking/src/main/java/com/baeldung/socket/GreetServer.java similarity index 100% rename from core-java/src/main/java/com/baeldung/socket/GreetServer.java rename to core-java-networking/src/main/java/com/baeldung/socket/GreetServer.java diff --git a/core-java/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java b/core-java-networking/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java rename to core-java-networking/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/http/HttpRequestLiveTest.java b/core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java similarity index 99% rename from core-java/src/test/java/com/baeldung/http/HttpRequestLiveTest.java rename to core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java index 752a75daa5..bd6c0a4410 100644 --- a/core-java/src/test/java/com/baeldung/http/HttpRequestLiveTest.java +++ b/core-java-networking/src/test/java/com/baeldung/http/HttpRequestLiveTest.java @@ -1,6 +1,6 @@ package com.baeldung.http; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import java.io.BufferedReader; diff --git a/core-java/src/test/java/com/baeldung/socket/EchoIntegrationTest.java b/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/socket/EchoIntegrationTest.java rename to core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java diff --git a/core-java/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java b/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java rename to core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java diff --git a/core-java/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java b/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java rename to core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java diff --git a/core-java-perf/README.md b/core-java-perf/README.md index 6af1c82a0a..252ee4cc45 100644 --- a/core-java-perf/README.md +++ b/core-java-perf/README.md @@ -2,3 +2,7 @@ ### Relevant Articles: - [Verbose Garbage Collection in Java](https://www.baeldung.com/java-verbose-gc) +- [Different Ways to Capture Java Heap Dumps](https://www.baeldung.com/java-heap-dump-capture) +- [Understanding Memory Leaks in Java](https://www.baeldung.com/java-memory-leaks) +- [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded) +- [Basic Introduction to JMX](http://www.baeldung.com/java-management-extensions) \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/heapdump/HeapDump.java b/core-java-perf/src/main/java/com/baeldung/heapdump/HeapDump.java similarity index 100% rename from core-java/src/main/java/com/baeldung/heapdump/HeapDump.java rename to core-java-perf/src/main/java/com/baeldung/heapdump/HeapDump.java diff --git a/core-java/src/main/java/com/baeldung/jmx/Game.java b/core-java-perf/src/main/java/com/baeldung/jmx/Game.java similarity index 100% rename from core-java/src/main/java/com/baeldung/jmx/Game.java rename to core-java-perf/src/main/java/com/baeldung/jmx/Game.java diff --git a/core-java/src/main/java/com/baeldung/jmx/GameMBean.java b/core-java-perf/src/main/java/com/baeldung/jmx/GameMBean.java similarity index 100% rename from core-java/src/main/java/com/baeldung/jmx/GameMBean.java rename to core-java-perf/src/main/java/com/baeldung/jmx/GameMBean.java diff --git a/core-java/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java b/core-java-perf/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java similarity index 100% rename from core-java/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java rename to core-java-perf/src/main/java/com/baeldung/jmx/JMXTutorialMainlauncher.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/Person.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/equalshashcode/PersonOptimized.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObject.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/finalize/BulkyObjectOptimized.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/BulkyObject.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassDriver.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/InnerClassWrapper.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/innerclass/StaticNestedClassWrapper.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/internedstrings/InternedString.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/InternedString.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/internedstrings/InternedString.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/InternedString.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/internedstrings/ReadStringFromFileUtil.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/ReadStringFromFileUtil.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/internedstrings/ReadStringFromFileUtil.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/ReadStringFromFileUtil.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/internedstrings/StringObject.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/StringObject.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/internedstrings/StringObject.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/internedstrings/StringObject.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsDemo.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsDemo.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsDemo.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsDemo.java diff --git a/core-java/src/main/java/com/baeldung/memoryleaks/staticfields/StaticFieldsDemo.java b/core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/StaticFieldsDemo.java similarity index 100% rename from core-java/src/main/java/com/baeldung/memoryleaks/staticfields/StaticFieldsDemo.java rename to core-java-perf/src/main/java/com/baeldung/memoryleaks/staticfields/StaticFieldsDemo.java diff --git a/core-java/src/main/java/com/baeldung/outofmemoryerror/OutOfMemoryGCLimitExceed.java b/core-java-perf/src/main/java/com/baeldung/outofmemoryerror/OutOfMemoryGCLimitExceed.java similarity index 100% rename from core-java/src/main/java/com/baeldung/outofmemoryerror/OutOfMemoryGCLimitExceed.java rename to core-java-perf/src/main/java/com/baeldung/outofmemoryerror/OutOfMemoryGCLimitExceed.java diff --git a/core-java-perf/src/main/resources/logback.xml b/core-java-perf/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-perf/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/memoryleaks/equalshashcode/PersonMemoryLeakUnitTest.java b/core-java-perf/src/test/java/com/baeldung/memoryleaks/equalshashcode/PersonMemoryLeakUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/memoryleaks/equalshashcode/PersonMemoryLeakUnitTest.java rename to core-java-perf/src/test/java/com/baeldung/memoryleaks/equalshashcode/PersonMemoryLeakUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/memoryleaks/finalize/FinalizeMemoryLeakUnitTest.java b/core-java-perf/src/test/java/com/baeldung/memoryleaks/finalize/FinalizeMemoryLeakUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/memoryleaks/finalize/FinalizeMemoryLeakUnitTest.java rename to core-java-perf/src/test/java/com/baeldung/memoryleaks/finalize/FinalizeMemoryLeakUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/memoryleaks/innerclass/StaticInnerClassMemoryLeakUnitTest.java b/core-java-perf/src/test/java/com/baeldung/memoryleaks/innerclass/StaticInnerClassMemoryLeakUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/memoryleaks/innerclass/StaticInnerClassMemoryLeakUnitTest.java rename to core-java-perf/src/test/java/com/baeldung/memoryleaks/innerclass/StaticInnerClassMemoryLeakUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/memoryleaks/internedstrings/StringInternMemoryLeakUnitTest.java b/core-java-perf/src/test/java/com/baeldung/memoryleaks/internedstrings/StringInternMemoryLeakUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/memoryleaks/internedstrings/StringInternMemoryLeakUnitTest.java rename to core-java-perf/src/test/java/com/baeldung/memoryleaks/internedstrings/StringInternMemoryLeakUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsMemoryLeakUnitTest.java b/core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsMemoryLeakUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsMemoryLeakUnitTest.java rename to core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/NonStaticFieldsMemoryLeakUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/memoryleaks/staticfields/StaticFieldsMemoryLeakUnitTest.java b/core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/StaticFieldsMemoryLeakUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/memoryleaks/staticfields/StaticFieldsMemoryLeakUnitTest.java rename to core-java-perf/src/test/java/com/baeldung/memoryleaks/staticfields/StaticFieldsMemoryLeakUnitTest.java diff --git a/core-java-sun/README.md b/core-java-sun/README.md index 9cf8b26f1b..e2dba76b41 100644 --- a/core-java-sun/README.md +++ b/core-java-sun/README.md @@ -4,3 +4,4 @@ ### Relevant Articles: - [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin) +- [Guide to sun.misc.Unsafe](http://www.baeldung.com/java-unsafe) \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/unsafe/CASCounter.java b/core-java-sun/src/test/java/com/baeldung/unsafe/CASCounter.java similarity index 100% rename from core-java/src/test/java/com/baeldung/unsafe/CASCounter.java rename to core-java-sun/src/test/java/com/baeldung/unsafe/CASCounter.java diff --git a/core-java/src/test/java/com/baeldung/unsafe/OffHeapArray.java b/core-java-sun/src/test/java/com/baeldung/unsafe/OffHeapArray.java similarity index 100% rename from core-java/src/test/java/com/baeldung/unsafe/OffHeapArray.java rename to core-java-sun/src/test/java/com/baeldung/unsafe/OffHeapArray.java diff --git a/core-java/src/test/java/com/baeldung/unsafe/UnsafeUnitTest.java b/core-java-sun/src/test/java/com/baeldung/unsafe/UnsafeUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/unsafe/UnsafeUnitTest.java rename to core-java-sun/src/test/java/com/baeldung/unsafe/UnsafeUnitTest.java diff --git a/core-java/README.md b/core-java/README.md index b0e8f81e1f..21c58bb880 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -6,19 +6,14 @@ - [Java Timer](http://www.baeldung.com/java-timer-and-timertask) - [How to Run a Shell Command in Java](http://www.baeldung.com/run-shell-command-in-java) - [MD5 Hashing in Java](http://www.baeldung.com/java-md5) -- [A Guide to Java Sockets](http://www.baeldung.com/a-guide-to-java-sockets) - [How to Print Screen in Java](http://www.baeldung.com/print-screen-in-java) - [A Guide To Java Regular Expressions API](http://www.baeldung.com/regular-expressions-java) - [Getting Started with Java Properties](http://www.baeldung.com/java-properties) - [Pattern Search with Grep in Java](http://www.baeldung.com/grep-in-java) -- [URL Encoding and Decoding in Java](http://www.baeldung.com/java-url-encoding-decoding) - [How to Create an Executable JAR with Maven](http://www.baeldung.com/executable-jar-with-maven) -- [Basic Introduction to JMX](http://www.baeldung.com/java-management-extensions) - [Introduction to Nashorn](http://www.baeldung.com/java-nashorn) - [Java Money and the Currency API](http://www.baeldung.com/java-money-and-currency) - [JVM Log Forging](http://www.baeldung.com/jvm-log-forging) -- [Guide to sun.misc.Unsafe](http://www.baeldung.com/java-unsafe) -- [How to Perform a Simple HTTP Request in Java](http://www.baeldung.com/java-http-request) - [How to Add a Single Element to a Stream](http://www.baeldung.com/java-stream-append-prepend) - [How to Find all Getters Returning Null](http://www.baeldung.com/java-getters-returning-null) - [How to Get a Name of a Method Being Executed?](http://www.baeldung.com/java-name-of-executing-method) @@ -26,7 +21,6 @@ - [Guide to UUID in Java](http://www.baeldung.com/java-uuid) - [Guide to Escaping Characters in Java RegExps](http://www.baeldung.com/java-regexp-escape-char) - [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) -- [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded) - [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin) - [Quick Guide to Java Stack](http://www.baeldung.com/java-stack) - [Guide to java.util.Formatter](http://www.baeldung.com/java-string-formatter) @@ -57,11 +51,9 @@ - [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) - [Calculating the nth Root in Java](https://www.baeldung.com/java-nth-root) - [Convert Double to String, Removing Decimal Places](https://www.baeldung.com/java-double-to-string) -- [Different Ways to Capture Java Heap Dumps](https://www.baeldung.com/java-heap-dump-capture) - [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset) - [Hashing a Password in Java](https://www.baeldung.com/java-password-hashing) - [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties) -- [Understanding Memory Leaks in Java](https://www.baeldung.com/java-memory-leaks) - [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format) - [SSL Handshake Failures](https://www.baeldung.com/java-ssl-handshake-failures) - [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order) From 9def7653f7cd2ce7e53a3d40af5ddb3fb3620783 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sat, 29 Dec 2018 21:59:01 +0530 Subject: [PATCH 065/441] [BAEL-11401] - Removed spring web dependency from core-java --- core-java/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index 442d378dab..b4f0643aa8 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -121,11 +121,6 @@ jmh-generator-annprocess ${jmh-generator-annprocess.version} - - org.springframework - spring-web - ${springframework.spring-web.version} - com.h2database h2 @@ -500,7 +495,6 @@ 2.21.0 - 4.3.4.RELEASE 1.1 1.4.197 From ef0c49beaa4a49aa8390947ae2d606fa42ac61e2 Mon Sep 17 00:00:00 2001 From: eric-martin Date: Sat, 29 Dec 2018 10:32:29 -0600 Subject: [PATCH 066/441] Fixed TestLauncher test name and config property name --- .../junit-5/src/test/java/com/baeldung/TestLauncher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/TestLauncher.java b/testing-modules/junit-5/src/test/java/com/baeldung/TestLauncher.java index f9766d2bd9..2e477084aa 100644 --- a/testing-modules/junit-5/src/test/java/com/baeldung/TestLauncher.java +++ b/testing-modules/junit-5/src/test/java/com/baeldung/TestLauncher.java @@ -18,9 +18,9 @@ public class TestLauncher { //@formatter:off LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() - .selectors(selectClass("com.baeldung.EmployeesTest")) + .selectors(selectClass("com.baeldung.EmployeesUnitTest")) .configurationParameter("junit.conditions.deactivate", "com.baeldung.extensions.*") - .configurationParameter("junit.extensions.autodetection.enabled", "true") + .configurationParameter("junit.jupiter.extensions.autodetection.enabled", "true") .build(); //@formatter:on From d1fb8935e794e1c171754defb478762954f8d5cd Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 30 Dec 2018 00:00:21 +0530 Subject: [PATCH 067/441] [BAEL-10836] - Removed CollectionsEmpty from core-java-collections module --- .../java/collections/CollectionsEmpty.java | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsEmpty.java diff --git a/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsEmpty.java b/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsEmpty.java deleted file mode 100644 index 09ecebe47b..0000000000 --- a/core-java-collections/src/test/java/org/baeldung/java/collections/CollectionsEmpty.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.baeldung.java.collections; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.junit.Assert; -import org.junit.Test; - -class CollectionsEmpty { - - @Test - public void givenArrayList_whenAddingElement_addsNewElement() { - ArrayList mutableList = new ArrayList<>(); - mutableList.add("test"); - - Assert.assertEquals(mutableList.size(), 1); - Assert.assertEquals(mutableList.get(0), "test"); - } - - @Test(expected = UnsupportedOperationException.class) - public void givenCollectionsEmptyList_whenAddingElement_throwsUnsupportedOperationException() { - List immutableList = Collections.emptyList(); - immutableList.add("test"); - } - -} From b4ff5c46f08a21ea01ffdca6859286a3e351bdb3 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 30 Dec 2018 01:19:12 +0530 Subject: [PATCH 068/441] [BAEL-11402] - Moved articles out of core-java (part 3) --- core-java-io/README.md | 2 + core-java-io/pom.xml | 14 +++++ .../com/baeldung/extension/Extension.java | 0 .../baeldung/extension/ExtensionUnitTest.java | 0 .../java/mimetype/MimeTypeUnitTest.java | 0 .../src/test/resources/META-INF/mime.types | 0 .../src/test/resources/product.png | Bin core-java-security/README.md | 11 ++++ core-java-security/pom.xml | 55 ++++++++++++++++++ .../java/com/baeldung/cipher/Encryptor.java | 0 .../encrypt/FileEncrypterDecrypter.java | 0 .../com/baeldung/hashing/SHA256Hashing.java | 0 .../com/baeldung/keystore/JavaKeyStore.java | 0 .../passwordhashing/PBKDF2Hasher.java | 0 .../passwordhashing/SHA512Hasher.java | 0 .../passwordhashing/SimplePBKDF2Hasher.java | 0 .../com/baeldung/ssl/SecureConnection.java | 0 .../baeldung/ssl/example/SimpleClient.java | 0 .../baeldung/ssl/example/SimpleServer.java | 0 .../src/main/resources/logback.xml | 19 ++++++ .../baeldung/cipher/EncryptorUnitTest.java | 0 ...FileEncrypterDecrypterIntegrationTest.java | 0 .../hashing/SHA256HashingUnitTest.java | 0 .../keystore/JavaKeyStoreUnitTest.java | 0 .../passwordhashing/PBKDF2HasherUnitTest.java | 0 .../passwordhashing/SHA512HasherUnitTest.java | 0 .../baeldung/java/md5/JavaMD5UnitTest.java | 0 .../src/test/resources/test_md5.txt | 0 core-java/README.md | 9 --- core-java/pom.xml | 27 --------- guava/README.md | 1 - pom.xml | 2 + 32 files changed, 103 insertions(+), 37 deletions(-) rename {core-java => core-java-io}/src/main/java/com/baeldung/extension/Extension.java (100%) rename {core-java => core-java-io}/src/test/java/com/baeldung/extension/ExtensionUnitTest.java (100%) rename {core-java => core-java-io}/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java (100%) rename {core-java => core-java-io}/src/test/resources/META-INF/mime.types (100%) rename {core-java => core-java-io}/src/test/resources/product.png (100%) create mode 100644 core-java-security/README.md create mode 100644 core-java-security/pom.xml rename {core-java => core-java-security}/src/main/java/com/baeldung/cipher/Encryptor.java (100%) rename {core-java => core-java-security}/src/main/java/com/baeldung/encrypt/FileEncrypterDecrypter.java (100%) rename {core-java => core-java-security}/src/main/java/com/baeldung/hashing/SHA256Hashing.java (100%) rename {core-java => core-java-security}/src/main/java/com/baeldung/keystore/JavaKeyStore.java (100%) rename {core-java => core-java-security}/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java (100%) rename {core-java => core-java-security}/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java (100%) rename {core-java => core-java-security}/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java (100%) rename {core-java => core-java-security}/src/main/java/com/baeldung/ssl/SecureConnection.java (100%) rename {core-java => core-java-security}/src/main/java/com/baeldung/ssl/example/SimpleClient.java (100%) rename {core-java => core-java-security}/src/main/java/com/baeldung/ssl/example/SimpleServer.java (100%) create mode 100644 core-java-security/src/main/resources/logback.xml rename {core-java => core-java-security}/src/test/java/com/baeldung/cipher/EncryptorUnitTest.java (100%) rename {core-java => core-java-security}/src/test/java/com/baeldung/encrypt/FileEncrypterDecrypterIntegrationTest.java (100%) rename {core-java => core-java-security}/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java (100%) rename {core-java => core-java-security}/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java (100%) rename {core-java => core-java-security}/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java (100%) rename {core-java => core-java-security}/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java (100%) rename {core-java => core-java-security}/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java (100%) rename {core-java => core-java-security}/src/test/resources/test_md5.txt (100%) diff --git a/core-java-io/README.md b/core-java-io/README.md index 3d028783ed..2ad980ca6a 100644 --- a/core-java-io/README.md +++ b/core-java-io/README.md @@ -35,3 +35,5 @@ - [Guide to Java OutputStream](https://www.baeldung.com/java-outputstream) - [Reading a CSV File into an Array](https://www.baeldung.com/java-csv-file-array) - [Guide to BufferedReader](https://www.baeldung.com/java-buffered-reader) +- [How to Get the File Extension of a File in Java](http://www.baeldung.com/java-file-extension) +- [Getting a File’s Mime Type in Java](http://www.baeldung.com/java-file-mime-type) \ No newline at end of file diff --git a/core-java-io/pom.xml b/core-java-io/pom.xml index ac5f1f7c2e..1f2d52de81 100644 --- a/core-java-io/pom.xml +++ b/core-java-io/pom.xml @@ -160,6 +160,17 @@ ${opencsv.version} test + + + org.apache.tika + tika-core + ${tika.version} + + + net.sf.jmimemagic + jmimemagic + ${jmime-magic.version} + @@ -264,6 +275,9 @@ 2.1.0.1 1.19 2.4.5 + + 1.18 + 0.1.5 \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/extension/Extension.java b/core-java-io/src/main/java/com/baeldung/extension/Extension.java similarity index 100% rename from core-java/src/main/java/com/baeldung/extension/Extension.java rename to core-java-io/src/main/java/com/baeldung/extension/Extension.java diff --git a/core-java/src/test/java/com/baeldung/extension/ExtensionUnitTest.java b/core-java-io/src/test/java/com/baeldung/extension/ExtensionUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/extension/ExtensionUnitTest.java rename to core-java-io/src/test/java/com/baeldung/extension/ExtensionUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java b/core-java-io/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java rename to core-java-io/src/test/java/com/baeldung/java/mimetype/MimeTypeUnitTest.java diff --git a/core-java/src/test/resources/META-INF/mime.types b/core-java-io/src/test/resources/META-INF/mime.types similarity index 100% rename from core-java/src/test/resources/META-INF/mime.types rename to core-java-io/src/test/resources/META-INF/mime.types diff --git a/core-java/src/test/resources/product.png b/core-java-io/src/test/resources/product.png similarity index 100% rename from core-java/src/test/resources/product.png rename to core-java-io/src/test/resources/product.png diff --git a/core-java-security/README.md b/core-java-security/README.md new file mode 100644 index 0000000000..415171094b --- /dev/null +++ b/core-java-security/README.md @@ -0,0 +1,11 @@ +## Core Java Security + +### Relevant Articles: +- [MD5 Hashing in Java](http://www.baeldung.com/java-md5) +- [Guide to the Cipher Class](http://www.baeldung.com/java-cipher-class) +- [Introduction to SSL in Java](http://www.baeldung.com/java-ssl) +- [Java KeyStore API](http://www.baeldung.com/java-keystore) +- [Encrypting and Decrypting Files in Java](http://www.baeldung.com/java-cipher-input-output-stream) +- [Hashing a Password in Java](https://www.baeldung.com/java-password-hashing) +- [SSL Handshake Failures](https://www.baeldung.com/java-ssl-handshake-failures) +- [SHA-256 Hashing in Java](https://www.baeldung.com/sha-256-hashing-java) \ No newline at end of file diff --git a/core-java-security/pom.xml b/core-java-security/pom.xml new file mode 100644 index 0000000000..cf91121465 --- /dev/null +++ b/core-java-security/pom.xml @@ -0,0 +1,55 @@ + + 4.0.0 + com.baeldung + core-java-security + 0.1.0-SNAPSHOT + jar + core-java-security + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + commons-codec + commons-codec + ${commons-codec.version} + + + org.bouncycastle + bcprov-jdk15on + ${bouncycastle.version} + + + + + + + 3.8.1 + 1.55 + 1.10 + + + 3.10.0 + + + + diff --git a/core-java/src/main/java/com/baeldung/cipher/Encryptor.java b/core-java-security/src/main/java/com/baeldung/cipher/Encryptor.java similarity index 100% rename from core-java/src/main/java/com/baeldung/cipher/Encryptor.java rename to core-java-security/src/main/java/com/baeldung/cipher/Encryptor.java diff --git a/core-java/src/main/java/com/baeldung/encrypt/FileEncrypterDecrypter.java b/core-java-security/src/main/java/com/baeldung/encrypt/FileEncrypterDecrypter.java similarity index 100% rename from core-java/src/main/java/com/baeldung/encrypt/FileEncrypterDecrypter.java rename to core-java-security/src/main/java/com/baeldung/encrypt/FileEncrypterDecrypter.java diff --git a/core-java/src/main/java/com/baeldung/hashing/SHA256Hashing.java b/core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java similarity index 100% rename from core-java/src/main/java/com/baeldung/hashing/SHA256Hashing.java rename to core-java-security/src/main/java/com/baeldung/hashing/SHA256Hashing.java diff --git a/core-java/src/main/java/com/baeldung/keystore/JavaKeyStore.java b/core-java-security/src/main/java/com/baeldung/keystore/JavaKeyStore.java similarity index 100% rename from core-java/src/main/java/com/baeldung/keystore/JavaKeyStore.java rename to core-java-security/src/main/java/com/baeldung/keystore/JavaKeyStore.java diff --git a/core-java/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java b/core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java similarity index 100% rename from core-java/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java rename to core-java-security/src/main/java/com/baeldung/passwordhashing/PBKDF2Hasher.java diff --git a/core-java/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java b/core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java similarity index 100% rename from core-java/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java rename to core-java-security/src/main/java/com/baeldung/passwordhashing/SHA512Hasher.java diff --git a/core-java/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java b/core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java similarity index 100% rename from core-java/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java rename to core-java-security/src/main/java/com/baeldung/passwordhashing/SimplePBKDF2Hasher.java diff --git a/core-java/src/main/java/com/baeldung/ssl/SecureConnection.java b/core-java-security/src/main/java/com/baeldung/ssl/SecureConnection.java similarity index 100% rename from core-java/src/main/java/com/baeldung/ssl/SecureConnection.java rename to core-java-security/src/main/java/com/baeldung/ssl/SecureConnection.java diff --git a/core-java/src/main/java/com/baeldung/ssl/example/SimpleClient.java b/core-java-security/src/main/java/com/baeldung/ssl/example/SimpleClient.java similarity index 100% rename from core-java/src/main/java/com/baeldung/ssl/example/SimpleClient.java rename to core-java-security/src/main/java/com/baeldung/ssl/example/SimpleClient.java diff --git a/core-java/src/main/java/com/baeldung/ssl/example/SimpleServer.java b/core-java-security/src/main/java/com/baeldung/ssl/example/SimpleServer.java similarity index 100% rename from core-java/src/main/java/com/baeldung/ssl/example/SimpleServer.java rename to core-java-security/src/main/java/com/baeldung/ssl/example/SimpleServer.java diff --git a/core-java-security/src/main/resources/logback.xml b/core-java-security/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/core-java-security/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/cipher/EncryptorUnitTest.java b/core-java-security/src/test/java/com/baeldung/cipher/EncryptorUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/cipher/EncryptorUnitTest.java rename to core-java-security/src/test/java/com/baeldung/cipher/EncryptorUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/encrypt/FileEncrypterDecrypterIntegrationTest.java b/core-java-security/src/test/java/com/baeldung/encrypt/FileEncrypterDecrypterIntegrationTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/encrypt/FileEncrypterDecrypterIntegrationTest.java rename to core-java-security/src/test/java/com/baeldung/encrypt/FileEncrypterDecrypterIntegrationTest.java diff --git a/core-java/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java b/core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java rename to core-java-security/src/test/java/com/baeldung/hashing/SHA256HashingUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java b/core-java-security/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java rename to core-java-security/src/test/java/com/baeldung/keystore/JavaKeyStoreUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java b/core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java rename to core-java-security/src/test/java/com/baeldung/passwordhashing/PBKDF2HasherUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java b/core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java rename to core-java-security/src/test/java/com/baeldung/passwordhashing/SHA512HasherUnitTest.java diff --git a/core-java/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java b/core-java-security/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java similarity index 100% rename from core-java/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java rename to core-java-security/src/test/java/org/baeldung/java/md5/JavaMD5UnitTest.java diff --git a/core-java/src/test/resources/test_md5.txt b/core-java-security/src/test/resources/test_md5.txt similarity index 100% rename from core-java/src/test/resources/test_md5.txt rename to core-java-security/src/test/resources/test_md5.txt diff --git a/core-java/README.md b/core-java/README.md index 21c58bb880..a3dd7fb2b7 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -5,7 +5,6 @@ ### Relevant Articles: - [Java Timer](http://www.baeldung.com/java-timer-and-timertask) - [How to Run a Shell Command in Java](http://www.baeldung.com/run-shell-command-in-java) -- [MD5 Hashing in Java](http://www.baeldung.com/java-md5) - [How to Print Screen in Java](http://www.baeldung.com/print-screen-in-java) - [A Guide To Java Regular Expressions API](http://www.baeldung.com/regular-expressions-java) - [Getting Started with Java Properties](http://www.baeldung.com/java-properties) @@ -24,7 +23,6 @@ - [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin) - [Quick Guide to Java Stack](http://www.baeldung.com/java-stack) - [Guide to java.util.Formatter](http://www.baeldung.com/java-string-formatter) -- [Guide to the Cipher Class](http://www.baeldung.com/java-cipher-class) - [Compiling Java *.class Files with javac](http://www.baeldung.com/javac) - [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator) - [Introduction to Javadoc](http://www.baeldung.com/javadoc) @@ -35,27 +33,20 @@ - [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid) - [A Guide to the ResourceBundle](http://www.baeldung.com/java-resourcebundle) - [Class Loaders in Java](http://www.baeldung.com/java-classloaders) -- [Introduction to SSL in Java](http://www.baeldung.com/java-ssl) -- [Java KeyStore API](http://www.baeldung.com/java-keystore) - [Double-Checked Locking with Singleton](http://www.baeldung.com/java-singleton-double-checked-locking) - [Guide to Java Clock Class](http://www.baeldung.com/java-clock) - [Importance of Main Manifest Attribute in a Self-Executing JAR](http://www.baeldung.com/java-jar-executable-manifest-main-class) -- [How to Get the File Extension of a File in Java](http://www.baeldung.com/java-file-extension) - [Java Global Exception Handler](http://www.baeldung.com/java-global-exception-handler) -- [Encrypting and Decrypting Files in Java](http://www.baeldung.com/java-cipher-input-output-stream) - [How to Get the Size of an Object in Java](http://www.baeldung.com/java-size-of-object) - [Guide to Java Instrumentation](http://www.baeldung.com/java-instrumentation) -- [Getting a File’s Mime Type in Java](http://www.baeldung.com/java-file-mime-type) - [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) - [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) - [Calculating the nth Root in Java](https://www.baeldung.com/java-nth-root) - [Convert Double to String, Removing Decimal Places](https://www.baeldung.com/java-double-to-string) - [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset) -- [Hashing a Password in Java](https://www.baeldung.com/java-password-hashing) - [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties) - [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format) -- [SSL Handshake Failures](https://www.baeldung.com/java-ssl-handshake-failures) - [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order) - [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources) - [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class) diff --git a/core-java/pom.xml b/core-java/pom.xml index b4f0643aa8..6c58653d5a 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -24,11 +24,6 @@ commons-lang3 ${commons-lang3.version} - - org.bouncycastle - bcprov-jdk15on - ${bouncycastle.version} - org.unix4j unix4j-command @@ -75,12 +70,6 @@ ${assertj-core.version} test - - - commons-codec - commons-codec - ${commons-codec.version} - org.javamoney moneta @@ -126,17 +115,6 @@ h2 ${h2database.version} - - - org.apache.tika - tika-core - ${tika.version} - - - net.sf.jmimemagic - jmimemagic - ${jmime-magic.version} - org.javassist @@ -477,8 +455,6 @@ 3.5 - 1.55 - 1.10 2.5 3.6.1 1.0.3 @@ -509,9 +485,6 @@ 2.0.3.RELEASE 1.6.0 61.1 - - 1.18 - 0.1.5 3.21.0-GA diff --git a/guava/README.md b/guava/README.md index 0346d34903..60754dbe57 100644 --- a/guava/README.md +++ b/guava/README.md @@ -18,4 +18,3 @@ - [Hamcrest Text Matchers](http://www.baeldung.com/hamcrest-text-matchers) - [Quick Guide to the Guava RateLimiter](http://www.baeldung.com/guava-rate-limiter) - [Hamcrest File Matchers](https://www.baeldung.com/hamcrest-file-matchers) -- [SHA-256 Hashing in Java](https://www.baeldung.com/sha-256-hashing-java) diff --git a/pom.xml b/pom.xml index 923cbab302..e8ff86665c 100644 --- a/pom.xml +++ b/pom.xml @@ -383,6 +383,7 @@ core-java-concurrency-basic core-java-concurrency-collections core-java-io + core-java-security core-java-lang-syntax core-java-lang core-java-lang-oop @@ -1095,6 +1096,7 @@ core-java-concurrency-basic core-java-concurrency-collections core-java-io + core-java-security core-java-lang-syntax core-java-lang core-java-lang-oop From 40e26514f431478b98e98f42c4a61faed23f908e Mon Sep 17 00:00:00 2001 From: geroza Date: Sat, 29 Dec 2018 19:09:35 -0200 Subject: [PATCH 069/441] * Renamed IntegrationTests that needed manual configurations to run succesfully as ManualTests * Renamed Integrationtests that needed the project (or related project, in case of client-server) as LiveTests * Fixed migration of mustache module to make it compatible with spring-boot 2.1 --- mustache/pom.xml | 5 +++++ mustache/src/main/resources/application.properties | 1 + ...textIntegrationTest.java => SpringContextManualTest.java} | 2 +- ...textIntegrationTest.java => SpringContextManualTest.java} | 2 +- ...textIntegrationTest.java => SpringContextManualTest.java} | 2 +- ...textIntegrationTest.java => SpringContextManualTest.java} | 2 +- ...ontextIntegrationTest.java => SpringContextLiveTest.java} | 2 +- 7 files changed, 11 insertions(+), 5 deletions(-) rename spring-amqp-simple/src/test/java/org/baeldung/{SpringContextIntegrationTest.java => SpringContextManualTest.java} (90%) rename spring-kafka/src/test/java/org/baeldung/{SpringContextIntegrationTest.java => SpringContextManualTest.java} (90%) rename spring-remoting/remoting-amqp/remoting-amqp-server/src/test/java/org/baeldung/{SpringContextIntegrationTest.java => SpringContextManualTest.java} (90%) rename spring-remoting/remoting-jms/remoting-jms-server/src/test/java/org/baeldung/{SpringContextIntegrationTest.java => SpringContextManualTest.java} (90%) rename spring-remoting/remoting-rmi/remoting-rmi-client/src/test/java/org/baeldung/{SpringContextIntegrationTest.java => SpringContextLiveTest.java} (90%) diff --git a/mustache/pom.xml b/mustache/pom.xml index 0c35345100..1b89997996 100644 --- a/mustache/pom.xml +++ b/mustache/pom.xml @@ -30,6 +30,11 @@ log4j ${log4j.version} + + + org.springframework.boot + spring-boot-starter-web + org.springframework.boot diff --git a/mustache/src/main/resources/application.properties b/mustache/src/main/resources/application.properties index e69de29bb2..011bbae980 100644 --- a/mustache/src/main/resources/application.properties +++ b/mustache/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.mustache.suffix:.html \ No newline at end of file diff --git a/spring-amqp-simple/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-amqp-simple/src/test/java/org/baeldung/SpringContextManualTest.java similarity index 90% rename from spring-amqp-simple/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-amqp-simple/src/test/java/org/baeldung/SpringContextManualTest.java index f134074cf8..03cb34eeb5 100644 --- a/spring-amqp-simple/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-amqp-simple/src/test/java/org/baeldung/SpringContextManualTest.java @@ -9,7 +9,7 @@ import com.baeldung.springamqpsimple.SpringAmqpApplication; @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringAmqpApplication.class) -public class SpringContextIntegrationTest { +public class SpringContextManualTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { diff --git a/spring-kafka/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-kafka/src/test/java/org/baeldung/SpringContextManualTest.java similarity index 90% rename from spring-kafka/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-kafka/src/test/java/org/baeldung/SpringContextManualTest.java index 40bf86c76f..b8195633fd 100644 --- a/spring-kafka/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-kafka/src/test/java/org/baeldung/SpringContextManualTest.java @@ -9,7 +9,7 @@ import com.baeldung.spring.kafka.KafkaApplication; @RunWith(SpringRunner.class) @SpringBootTest(classes = KafkaApplication.class) -public class SpringContextIntegrationTest { +public class SpringContextManualTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { diff --git a/spring-remoting/remoting-amqp/remoting-amqp-server/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-remoting/remoting-amqp/remoting-amqp-server/src/test/java/org/baeldung/SpringContextManualTest.java similarity index 90% rename from spring-remoting/remoting-amqp/remoting-amqp-server/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-remoting/remoting-amqp/remoting-amqp-server/src/test/java/org/baeldung/SpringContextManualTest.java index 5dc6d1df75..a6ee0b6000 100644 --- a/spring-remoting/remoting-amqp/remoting-amqp-server/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-remoting/remoting-amqp/remoting-amqp-server/src/test/java/org/baeldung/SpringContextManualTest.java @@ -9,7 +9,7 @@ import com.baeldung.server.AmqpServer; @RunWith(SpringRunner.class) @SpringBootTest(classes = AmqpServer.class) -public class SpringContextIntegrationTest { +public class SpringContextManualTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { diff --git a/spring-remoting/remoting-jms/remoting-jms-server/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-remoting/remoting-jms/remoting-jms-server/src/test/java/org/baeldung/SpringContextManualTest.java similarity index 90% rename from spring-remoting/remoting-jms/remoting-jms-server/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-remoting/remoting-jms/remoting-jms-server/src/test/java/org/baeldung/SpringContextManualTest.java index 5c9cc5f872..b806f21c27 100644 --- a/spring-remoting/remoting-jms/remoting-jms-server/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-remoting/remoting-jms/remoting-jms-server/src/test/java/org/baeldung/SpringContextManualTest.java @@ -9,7 +9,7 @@ import com.baeldung.server.JmsServer; @SpringBootTest(classes = JmsServer.class) @RunWith(SpringRunner.class) -public class SpringContextIntegrationTest { +public class SpringContextManualTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { diff --git a/spring-remoting/remoting-rmi/remoting-rmi-client/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-remoting/remoting-rmi/remoting-rmi-client/src/test/java/org/baeldung/SpringContextLiveTest.java similarity index 90% rename from spring-remoting/remoting-rmi/remoting-rmi-client/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to spring-remoting/remoting-rmi/remoting-rmi-client/src/test/java/org/baeldung/SpringContextLiveTest.java index 3460792fc6..3bace4cd1e 100644 --- a/spring-remoting/remoting-rmi/remoting-rmi-client/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-remoting/remoting-rmi/remoting-rmi-client/src/test/java/org/baeldung/SpringContextLiveTest.java @@ -9,7 +9,7 @@ import com.baeldung.client.RmiClient; @SpringBootTest(classes = RmiClient.class) @RunWith(SpringRunner.class) -public class SpringContextIntegrationTest { +public class SpringContextLiveTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { From 676f55e8720e8ec6cc00a73e3bcb1526318a948e Mon Sep 17 00:00:00 2001 From: rahusriv Date: Sun, 30 Dec 2018 08:40:43 +0530 Subject: [PATCH 070/441] BAEL-2335 (#6015) * Making examples simple * Changing variable names --- .../ArrayListOfArrayList.java | 26 +++++++++---------- .../ThreeDimensionalArrayList.java | 16 ++++++------ 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java b/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java index 72045d6761..2c3da7b1fc 100644 --- a/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java +++ b/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java @@ -6,30 +6,28 @@ public class ArrayListOfArrayList { public static void main(String args[]) { - int vertex = 5; - ArrayList> graph = new ArrayList<>(vertex); + int numVertices = 3; + ArrayList> graph = new ArrayList<>(numVertices); //Initializing each element of ArrayList with ArrayList - for(int i=0; i< vertex; i++) { + for(int i=0; i< numVertices; i++) { graph.add(new ArrayList()); } //We can add any number of columns to each row graph.get(0).add(1); - graph.get(0).add(5); - graph.get(1).add(0); graph.get(1).add(2); + graph.get(2).add(0); + graph.get(1).add(0); graph.get(2).add(1); - graph.get(2).add(3); - graph.get(3).add(2); - graph.get(3).add(4); - graph.get(4).add(3); - graph.get(4).add(5); - + graph.get(0).add(2); + //Printing all the edges - for(int i=0; i listOfVertices = graph.get(vertexNo); + for(int i=0; i Date: Sun, 30 Dec 2018 00:38:11 -0300 Subject: [PATCH 071/441] BAEL-2444 Samples (#6002) --- core-java-8/pom.xml | 37 +++++++++++++- .../baeldung/time/LocalDateTimeUnitTest.java | 43 +++++++++++++++++ .../time/LocalDateTimeWithJMockUnitTest.java | 48 +++++++++++++++++++ 3 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java create mode 100644 core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml index 18bdaa15f4..112e8b764d 100644 --- a/core-java-8/pom.xml +++ b/core-java-8/pom.xml @@ -1,5 +1,5 @@ + 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 core-java-8 @@ -104,6 +104,24 @@ aspectjweaver ${asspectj.version} + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito2 + ${powermock.version} + test + + + org.jmockit + jmockit + ${jmockit.version} + test + @@ -119,7 +137,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 + ${maven-compiler-plugin.version} 1.8 1.8 @@ -142,6 +160,16 @@ + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar + + true + + @@ -159,9 +187,14 @@ 3.6.1 1.8.9 + 2.0.0-RC.4 + 1.44 1.7.0 1.19 1.19 2.0.4.RELEASE + + 3.8.0 + 2.22.1 diff --git a/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java b/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java new file mode 100644 index 0000000000..04c1a0b74e --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java @@ -0,0 +1,43 @@ +package com.baeldung.time; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.time.Clock; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; +import static org.powermock.api.mockito.PowerMockito.mockStatic; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ LocalDateTime.class }) +public class LocalDateTimeUnitTest { + + @Test + public void givenLocalDateTimeMock_whenNow_thenGetFixedLocalDateTime() { + Clock clock = Clock.fixed(Instant.parse("2014-12-22T10:15:30.00Z"), ZoneId.of("UTC")); + LocalDateTime dateTime = LocalDateTime.now(clock); + mockStatic(LocalDateTime.class); + when(LocalDateTime.now()).thenReturn(dateTime); + String dateTimeExpected = "2014-12-22T10:15:30"; + + LocalDateTime now = LocalDateTime.now(); + + assertThat(now).isEqualTo(dateTimeExpected); + } + + @Test + public void givenFixedClock_whenNow_thenGetFixedLocalDateTime() { + Clock clock = Clock.fixed(Instant.parse("2014-12-22T10:15:30.00Z"), ZoneId.of("UTC")); + String dateTimeExpected = "2014-12-22T10:15:30"; + + LocalDateTime dateTime = LocalDateTime.now(clock); + + assertThat(dateTime).isEqualTo(dateTimeExpected); + } +} diff --git a/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java b/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java new file mode 100644 index 0000000000..13861dfd0b --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/time/LocalDateTimeWithJMockUnitTest.java @@ -0,0 +1,48 @@ +package com.baeldung.time; + +import mockit.Expectations; +import mockit.Mock; +import mockit.MockUp; +import org.junit.jupiter.api.Test; + +import java.time.Clock; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; + +import static org.assertj.core.api.Assertions.assertThat; + +public class LocalDateTimeWithJMockUnitTest { + + @Test + public void givenLocalDateTimeWithJMock_whenNow_thenGetFixedLocalDateTime() { + Clock clock = Clock.fixed(Instant.parse("2014-12-21T10:15:30.00Z"), ZoneId.of("UTC")); + new MockUp() { + @Mock + public LocalDateTime now() { + return LocalDateTime.now(clock); + } + }; + String dateTimeExpected = "2014-12-21T10:15:30"; + + LocalDateTime now = LocalDateTime.now(); + + assertThat(now).isEqualTo(dateTimeExpected); + } + + @Test + public void givenLocalDateTimeWithExpectations_whenNow_thenGetFixedLocalDateTime() { + Clock clock = Clock.fixed(Instant.parse("2014-12-23T10:15:30.00Z"), ZoneId.of("UTC")); + LocalDateTime dateTimeExpected = LocalDateTime.now(clock); + new Expectations(LocalDateTime.class) { + { + LocalDateTime.now(); + result = dateTimeExpected; + } + }; + + LocalDateTime now = LocalDateTime.now(); + + assertThat(now).isEqualTo(dateTimeExpected); + } +} From a89983a65cbf165f0e18889b6e43b1a7ed686dd3 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Sun, 30 Dec 2018 14:19:24 +0400 Subject: [PATCH 072/441] move unmodifiable set code to java 9 module --- .../com/baeldung/java9}/set/UnmodifiableSet.java | 6 +++--- .../java/com/baeldung/java9/SetExamplesUnitTest.java | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) rename {core-java-collections/src/main/java/com/baeldung => core-java-9/src/main/java/com/baeldung/java9}/set/UnmodifiableSet.java (88%) diff --git a/core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java b/core-java-9/src/main/java/com/baeldung/java9/set/UnmodifiableSet.java similarity index 88% rename from core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java rename to core-java-9/src/main/java/com/baeldung/java9/set/UnmodifiableSet.java index 06f477c50a..7dbcd2a3a3 100644 --- a/core-java-collections/src/main/java/com/baeldung/set/UnmodifiableSet.java +++ b/core-java-9/src/main/java/com/baeldung/java9/set/UnmodifiableSet.java @@ -1,4 +1,4 @@ -package com.baeldung.set; +package com.baeldung.java9.set; import com.google.common.collect.ImmutableSet; @@ -21,8 +21,8 @@ public class UnmodifiableSet { } private static void java9Of() { - //Set immutable = Set.of("Canada", "USA"); - //System.out.println(immutable); + Set immutable = Set.of("Canada", "USA"); + System.out.println(immutable); } private static void guavaOf() { diff --git a/core-java-9/src/test/java/com/baeldung/java9/SetExamplesUnitTest.java b/core-java-9/src/test/java/com/baeldung/java9/SetExamplesUnitTest.java index 9e7e8e6e4b..28e71affcc 100644 --- a/core-java-9/src/test/java/com/baeldung/java9/SetExamplesUnitTest.java +++ b/core-java-9/src/test/java/com/baeldung/java9/SetExamplesUnitTest.java @@ -1,5 +1,7 @@ package com.baeldung.java9; +import java.util.Collections; +import java.util.HashSet; import java.util.Set; import org.junit.Test; @@ -23,4 +25,14 @@ public class SetExamplesUnitTest { Set intSet = Set.of(intArray); assertEquals(intSet.size(), intArray.length); } + + @Test(expected = UnsupportedOperationException.class) + public void testUnmodifiableSet() { + Set set = new HashSet<>(); + set.add("Canada"); + set.add("USA"); + + Set unmodifiableSet = Collections.unmodifiableSet(set); + unmodifiableSet.add("Costa Rica"); + } } From eb4928b972264c86472576a1673fa7245431a740 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 30 Dec 2018 16:30:36 +0530 Subject: [PATCH 073/441] [BAEL-11403] - Moved articles out of core-java (part 4) --- core-java-collections/README.md | 3 +- .../baeldung/iteratorguide/IteratorGuide.java | 0 core-java/README.md | 11 --- .../StringReplaceAndRemoveUnitTest.java | 83 ------------------- java-dates/README.md | 2 + .../zoneddatetime/OffsetDateTimeExample.java | 0 .../zoneddatetime/OffsetTimeExample.java | 0 .../zoneddatetime/ZoneDateTimeExample.java | 0 .../com/baeldung/date/DateDiffUnitTest.java | 2 + .../SimpleDateFormatUnitTest.java | 0 .../OffsetDateTimeExampleUnitTest.java | 0 .../OffsetTimeExampleUnitTest.java | 0 .../ZoneDateTimeExampleUnitTest.java | 0 java-numbers/README.md | 6 ++ .../java/com/baeldung/area/circle/Circle.java | 0 .../com/baeldung/area/circle/CircleArea.java | 0 .../root/calculator/NthRootCalculator.java | 0 .../java/com/baeldung/nth/root/main/Main.java | 0 .../DecimalFormatExamplesUnitTest.java | 0 .../com/baeldung/java/math/MathUnitTest.java | 0 .../calculator/NthRootCalculatorUnitTest.java | 0 .../baeldung/nth/root/main/MainUnitTest.java | 0 .../RemovingDecimalsManualTest.java | 0 .../RemovingDecimalsUnitTest.java | 0 java-strings/README.md | 2 + .../string/AppendCharAtPositionX.java | 0 .../string/AppendCharAtPositionXUnitTest.java | 0 .../DateToStringFormatterUnitTest.java | 9 +- 28 files changed, 19 insertions(+), 99 deletions(-) rename {core-java => core-java-collections}/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java (100%) delete mode 100644 core-java/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java rename {core-java => java-dates}/src/main/java/com/baeldung/zoneddatetime/OffsetDateTimeExample.java (100%) rename {core-java => java-dates}/src/main/java/com/baeldung/zoneddatetime/OffsetTimeExample.java (100%) rename {core-java => java-dates}/src/main/java/com/baeldung/zoneddatetime/ZoneDateTimeExample.java (100%) rename {core-java => java-dates}/src/test/java/com/baeldung/simpledateformat/SimpleDateFormatUnitTest.java (100%) rename {core-java => java-dates}/src/test/java/com/baeldung/zoneddatetime/OffsetDateTimeExampleUnitTest.java (100%) rename {core-java => java-dates}/src/test/java/com/baeldung/zoneddatetime/OffsetTimeExampleUnitTest.java (100%) rename {core-java => java-dates}/src/test/java/com/baeldung/zoneddatetime/ZoneDateTimeExampleUnitTest.java (100%) rename {core-java => java-numbers}/src/main/java/com/baeldung/area/circle/Circle.java (100%) rename {core-java => java-numbers}/src/main/java/com/baeldung/area/circle/CircleArea.java (100%) rename {core-java => java-numbers}/src/main/java/com/baeldung/nth/root/calculator/NthRootCalculator.java (100%) rename {core-java => java-numbers}/src/main/java/com/baeldung/nth/root/main/Main.java (100%) rename {core-java => java-numbers}/src/test/java/com/baeldung/decimalformat/DecimalFormatExamplesUnitTest.java (100%) rename {core-java => java-numbers}/src/test/java/com/baeldung/java/math/MathUnitTest.java (100%) rename {core-java => java-numbers}/src/test/java/com/baeldung/nth/root/calculator/NthRootCalculatorUnitTest.java (100%) rename {core-java => java-numbers}/src/test/java/com/baeldung/nth/root/main/MainUnitTest.java (100%) rename {core-java => java-numbers}/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsManualTest.java (100%) rename {core-java => java-numbers}/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsUnitTest.java (100%) rename {core-java => java-strings}/src/main/java/com/baeldung/string/AppendCharAtPositionX.java (100%) rename {core-java => java-strings}/src/test/java/com/baeldung/string/AppendCharAtPositionXUnitTest.java (100%) diff --git a/core-java-collections/README.md b/core-java-collections/README.md index 15be81156c..71d4e6b614 100644 --- a/core-java-collections/README.md +++ b/core-java-collections/README.md @@ -28,4 +28,5 @@ - [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) \ No newline at end of file +- [A Guide to EnumMap](https://www.baeldung.com/java-enum-map) +- [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator) \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java b/core-java-collections/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java similarity index 100% rename from core-java/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java rename to core-java-collections/src/main/java/com/baeldung/iteratorguide/IteratorGuide.java diff --git a/core-java/README.md b/core-java/README.md index 21c58bb880..4f03bac732 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -23,13 +23,10 @@ - [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) - [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin) - [Quick Guide to Java Stack](http://www.baeldung.com/java-stack) -- [Guide to java.util.Formatter](http://www.baeldung.com/java-string-formatter) - [Guide to the Cipher Class](http://www.baeldung.com/java-cipher-class) - [Compiling Java *.class Files with javac](http://www.baeldung.com/javac) -- [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator) - [Introduction to Javadoc](http://www.baeldung.com/javadoc) - [Guide to the Externalizable Interface in Java](http://www.baeldung.com/java-externalizable) -- [A Practical Guide to DecimalFormat](http://www.baeldung.com/java-decimalformat) - [How to Detect the OS Using Java](http://www.baeldung.com/java-detect-os) - [ASCII Art in Java](http://www.baeldung.com/ascii-art-in-java) - [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid) @@ -48,19 +45,11 @@ - [Getting a File’s Mime Type in Java](http://www.baeldung.com/java-file-mime-type) - [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) -- [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) -- [Calculating the nth Root in Java](https://www.baeldung.com/java-nth-root) -- [Convert Double to String, Removing Decimal Places](https://www.baeldung.com/java-double-to-string) -- [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset) - [Hashing a Password in Java](https://www.baeldung.com/java-password-hashing) - [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties) -- [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format) - [SSL Handshake Failures](https://www.baeldung.com/java-ssl-handshake-failures) -- [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order) - [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources) - [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class) - [Guide to Character Encoding](https://www.baeldung.com/java-char-encoding) -- [Calculate the Area of a Circle in Java](https://www.baeldung.com/java-calculate-circle-area) -- [A Guide to the Java Math Class](https://www.baeldung.com/java-lang-math) - [Graphs in Java](https://www.baeldung.com/java-graphs) - [Console I/O in Java](http://www.baeldung.com/java-console-input-output) diff --git a/core-java/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java b/core-java/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java deleted file mode 100644 index d952d2383b..0000000000 --- a/core-java/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.baeldung.string; - - -import org.apache.commons.lang3.StringUtils; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class StringReplaceAndRemoveUnitTest { - - - @Test - public void givenTestStrings_whenReplace_thenProcessedString() { - - String master = "Hello World Baeldung!"; - String target = "Baeldung"; - String replacement = "Java"; - String processed = master.replace(target, replacement); - assertTrue(processed.contains(replacement)); - assertFalse(processed.contains(target)); - - } - - @Test - public void givenTestStrings_whenReplaceAll_thenProcessedString() { - - String master2 = "Welcome to Baeldung, Hello World Baeldung"; - String regexTarget= "(Baeldung)$"; - String replacement = "Java"; - String processed2 = master2.replaceAll(regexTarget, replacement); - assertTrue(processed2.endsWith("Java")); - - } - - @Test - public void givenTestStrings_whenStringBuilderMethods_thenProcessedString() { - - String master = "Hello World Baeldung!"; - String target = "Baeldung"; - String replacement = "Java"; - - int startIndex = master.indexOf(target); - int stopIndex = startIndex + target.length(); - - StringBuilder builder = new StringBuilder(master); - - - builder.delete(startIndex, stopIndex); - assertFalse(builder.toString().contains(target)); - - - builder.replace(startIndex, stopIndex, replacement); - assertTrue(builder.toString().contains(replacement)); - - - } - - - @Test - public void givenTestStrings_whenStringUtilsMethods_thenProcessedStrings() { - - String master = "Hello World Baeldung!"; - String target = "Baeldung"; - String replacement = "Java"; - - String processed = StringUtils.replace(master, target, replacement); - assertTrue(processed.contains(replacement)); - - String master2 = "Hello World Baeldung!"; - String target2 = "baeldung"; - String processed2 = StringUtils.replaceIgnoreCase(master2, target2, replacement); - assertFalse(processed2.contains(target)); - - } - - - - - - - -} diff --git a/java-dates/README.md b/java-dates/README.md index 21e54082f4..ac3166d938 100644 --- a/java-dates/README.md +++ b/java-dates/README.md @@ -26,3 +26,5 @@ - [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) - [Convert between String and Timestamp](https://www.baeldung.com/java-string-to-timestamp) +- [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format) +- [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset) \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/zoneddatetime/OffsetDateTimeExample.java b/java-dates/src/main/java/com/baeldung/zoneddatetime/OffsetDateTimeExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/zoneddatetime/OffsetDateTimeExample.java rename to java-dates/src/main/java/com/baeldung/zoneddatetime/OffsetDateTimeExample.java diff --git a/core-java/src/main/java/com/baeldung/zoneddatetime/OffsetTimeExample.java b/java-dates/src/main/java/com/baeldung/zoneddatetime/OffsetTimeExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/zoneddatetime/OffsetTimeExample.java rename to java-dates/src/main/java/com/baeldung/zoneddatetime/OffsetTimeExample.java diff --git a/core-java/src/main/java/com/baeldung/zoneddatetime/ZoneDateTimeExample.java b/java-dates/src/main/java/com/baeldung/zoneddatetime/ZoneDateTimeExample.java similarity index 100% rename from core-java/src/main/java/com/baeldung/zoneddatetime/ZoneDateTimeExample.java rename to java-dates/src/main/java/com/baeldung/zoneddatetime/ZoneDateTimeExample.java diff --git a/java-dates/src/test/java/com/baeldung/date/DateDiffUnitTest.java b/java-dates/src/test/java/com/baeldung/date/DateDiffUnitTest.java index 1234a700de..a35699e469 100644 --- a/java-dates/src/test/java/com/baeldung/date/DateDiffUnitTest.java +++ b/java-dates/src/test/java/com/baeldung/date/DateDiffUnitTest.java @@ -8,6 +8,8 @@ import java.time.Duration; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.Period; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.Date; import java.util.Locale; diff --git a/core-java/src/test/java/com/baeldung/simpledateformat/SimpleDateFormatUnitTest.java b/java-dates/src/test/java/com/baeldung/simpledateformat/SimpleDateFormatUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/simpledateformat/SimpleDateFormatUnitTest.java rename to java-dates/src/test/java/com/baeldung/simpledateformat/SimpleDateFormatUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/zoneddatetime/OffsetDateTimeExampleUnitTest.java b/java-dates/src/test/java/com/baeldung/zoneddatetime/OffsetDateTimeExampleUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/zoneddatetime/OffsetDateTimeExampleUnitTest.java rename to java-dates/src/test/java/com/baeldung/zoneddatetime/OffsetDateTimeExampleUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/zoneddatetime/OffsetTimeExampleUnitTest.java b/java-dates/src/test/java/com/baeldung/zoneddatetime/OffsetTimeExampleUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/zoneddatetime/OffsetTimeExampleUnitTest.java rename to java-dates/src/test/java/com/baeldung/zoneddatetime/OffsetTimeExampleUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/zoneddatetime/ZoneDateTimeExampleUnitTest.java b/java-dates/src/test/java/com/baeldung/zoneddatetime/ZoneDateTimeExampleUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/zoneddatetime/ZoneDateTimeExampleUnitTest.java rename to java-dates/src/test/java/com/baeldung/zoneddatetime/ZoneDateTimeExampleUnitTest.java diff --git a/java-numbers/README.md b/java-numbers/README.md index 1138d9a74c..2b1131f325 100644 --- a/java-numbers/README.md +++ b/java-numbers/README.md @@ -13,3 +13,9 @@ - [Find All Pairs of Numbers in an Array That Add Up to a Given Sum](http://www.baeldung.com/java-algorithm-number-pairs-sum) - [Java – Random Long, Float, Integer and Double](http://www.baeldung.com/java-generate-random-long-float-integer-double) - [Using Math.sin with Degrees](https://www.baeldung.com/java-math-sin-degrees) +- [A Practical Guide to DecimalFormat](http://www.baeldung.com/java-decimalformat) +- [Calculating the nth Root in Java](https://www.baeldung.com/java-nth-root) +- [Convert Double to String, Removing Decimal Places](https://www.baeldung.com/java-double-to-string) +- [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order) +- [Calculate the Area of a Circle in Java](https://www.baeldung.com/java-calculate-circle-area) +- [A Guide to the Java Math Class](https://www.baeldung.com/java-lang-math) \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/area/circle/Circle.java b/java-numbers/src/main/java/com/baeldung/area/circle/Circle.java similarity index 100% rename from core-java/src/main/java/com/baeldung/area/circle/Circle.java rename to java-numbers/src/main/java/com/baeldung/area/circle/Circle.java diff --git a/core-java/src/main/java/com/baeldung/area/circle/CircleArea.java b/java-numbers/src/main/java/com/baeldung/area/circle/CircleArea.java similarity index 100% rename from core-java/src/main/java/com/baeldung/area/circle/CircleArea.java rename to java-numbers/src/main/java/com/baeldung/area/circle/CircleArea.java diff --git a/core-java/src/main/java/com/baeldung/nth/root/calculator/NthRootCalculator.java b/java-numbers/src/main/java/com/baeldung/nth/root/calculator/NthRootCalculator.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nth/root/calculator/NthRootCalculator.java rename to java-numbers/src/main/java/com/baeldung/nth/root/calculator/NthRootCalculator.java diff --git a/core-java/src/main/java/com/baeldung/nth/root/main/Main.java b/java-numbers/src/main/java/com/baeldung/nth/root/main/Main.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nth/root/main/Main.java rename to java-numbers/src/main/java/com/baeldung/nth/root/main/Main.java diff --git a/core-java/src/test/java/com/baeldung/decimalformat/DecimalFormatExamplesUnitTest.java b/java-numbers/src/test/java/com/baeldung/decimalformat/DecimalFormatExamplesUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/decimalformat/DecimalFormatExamplesUnitTest.java rename to java-numbers/src/test/java/com/baeldung/decimalformat/DecimalFormatExamplesUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/java/math/MathUnitTest.java b/java-numbers/src/test/java/com/baeldung/java/math/MathUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/java/math/MathUnitTest.java rename to java-numbers/src/test/java/com/baeldung/java/math/MathUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/nth/root/calculator/NthRootCalculatorUnitTest.java b/java-numbers/src/test/java/com/baeldung/nth/root/calculator/NthRootCalculatorUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/nth/root/calculator/NthRootCalculatorUnitTest.java rename to java-numbers/src/test/java/com/baeldung/nth/root/calculator/NthRootCalculatorUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/nth/root/main/MainUnitTest.java b/java-numbers/src/test/java/com/baeldung/nth/root/main/MainUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/nth/root/main/MainUnitTest.java rename to java-numbers/src/test/java/com/baeldung/nth/root/main/MainUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsManualTest.java b/java-numbers/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsManualTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsManualTest.java rename to java-numbers/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsManualTest.java diff --git a/core-java/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsUnitTest.java b/java-numbers/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsUnitTest.java rename to java-numbers/src/test/java/com/baeldung/removingdecimals/RemovingDecimalsUnitTest.java diff --git a/java-strings/README.md b/java-strings/README.md index 60131e392d..fa048dbb5a 100644 --- a/java-strings/README.md +++ b/java-strings/README.md @@ -45,3 +45,5 @@ - [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) - [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) +- [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/string/AppendCharAtPositionX.java b/java-strings/src/main/java/com/baeldung/string/AppendCharAtPositionX.java similarity index 100% rename from core-java/src/main/java/com/baeldung/string/AppendCharAtPositionX.java rename to java-strings/src/main/java/com/baeldung/string/AppendCharAtPositionX.java diff --git a/core-java/src/test/java/com/baeldung/string/AppendCharAtPositionXUnitTest.java b/java-strings/src/test/java/com/baeldung/string/AppendCharAtPositionXUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/string/AppendCharAtPositionXUnitTest.java rename to java-strings/src/test/java/com/baeldung/string/AppendCharAtPositionXUnitTest.java diff --git a/java-strings/src/test/java/com/baeldung/string/formatter/DateToStringFormatterUnitTest.java b/java-strings/src/test/java/com/baeldung/string/formatter/DateToStringFormatterUnitTest.java index f236c641c3..d760510c73 100644 --- a/java-strings/src/test/java/com/baeldung/string/formatter/DateToStringFormatterUnitTest.java +++ b/java-strings/src/test/java/com/baeldung/string/formatter/DateToStringFormatterUnitTest.java @@ -1,7 +1,6 @@ package com.baeldung.string.formatter; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.Assert.assertEquals; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -11,9 +10,11 @@ import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; +import java.util.Locale; import java.util.TimeZone; -import static org.junit.Assert.assertEquals; +import org.junit.BeforeClass; +import org.junit.Test; public class DateToStringFormatterUnitTest { @@ -40,7 +41,7 @@ public class DateToStringFormatterUnitTest { @Test public void whenDateConvertedUsingDateFormatToString_thenCorrect() { String formattedDate = DateFormat - .getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT) + .getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.US) .format(date); assertEquals(EXPECTED_STRING_DATE, formattedDate); From de80339a2a03ce98ba1b0c189a3e953d03ad4686 Mon Sep 17 00:00:00 2001 From: Emily Cheyne Date: Sun, 30 Dec 2018 09:12:21 -0700 Subject: [PATCH 074/441] BAEL-2090 update readme --- persistence-modules/spring-data-jpa/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-data-jpa/README.md b/persistence-modules/spring-data-jpa/README.md index e240ae6d33..3c71600565 100644 --- a/persistence-modules/spring-data-jpa/README.md +++ b/persistence-modules/spring-data-jpa/README.md @@ -17,6 +17,7 @@ - [Spring Data – CrudRepository save() Method](https://www.baeldung.com/spring-data-crud-repository-save) - [Limiting Query Results with JPA and Spring Data JPA](https://www.baeldung.com/jpa-limit-query-results) - [Sorting Query Results with Spring Data](https://www.baeldung.com/spring-data-sorting) +- [INSERT Statement in JPA](https://www.baeldung.com/jpa-insert) ### Eclipse Config After importing the project into Eclipse, you may see the following error: From 3bdd542dbf78acb998d64527ba49120c6eea3c9a Mon Sep 17 00:00:00 2001 From: Erhan KARAKAYA Date: Mon, 31 Dec 2018 03:48:20 +0300 Subject: [PATCH 075/441] Added @Value for map examples --- .../java/com/baeldung/value/ValuesApp.java | 28 +++++++++++++++++++ .../src/main/resources/values.properties | 3 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/spring-core/src/main/java/com/baeldung/value/ValuesApp.java b/spring-core/src/main/java/com/baeldung/value/ValuesApp.java index f525dfde89..33592ae38a 100644 --- a/spring-core/src/main/java/com/baeldung/value/ValuesApp.java +++ b/spring-core/src/main/java/com/baeldung/value/ValuesApp.java @@ -45,6 +45,27 @@ public class ValuesApp { @Value("#{'${listOfValues}'.split(',')}") private List valuesList; + + @Value("#{${valuesMap}}") + private Map valuesMap; + + @Value("#{${valuesMap}.key1}") + private Integer valuesMapKey1; + + @Value("#{${valuesMap}['unknownKey']}") + private Integer unknownMapKey; + + @Value("#{${unknownMap : {key1:'1', key2 : '2'}}}") + private Map unknownMap; + + @Value("#{${valuesMap}['unknownKey'] ?: 5}") + private Integer unknownMapKeyWithDefaultValue; + + @Value("#{${valuesMap}.?[value>'1']}") + private Map valuesMapFiltered; + + @Value("#{systemProperties}") + private Map systemPropertiesMap; public static void main(String[] args) { System.setProperty("systemValue", "Some system parameter value"); @@ -69,5 +90,12 @@ public class ValuesApp { System.out.println(spelSomeDefault); System.out.println(someBeanValue); System.out.println(valuesList); + System.out.println(valuesMap); + System.out.println(valuesMapKey1); + System.out.println(unknownMapKey); + System.out.println(unknownMap); + System.out.println(unknownMapKeyWithDefaultValue); + System.out.println(valuesMapFiltered); + System.out.println(systemPropertiesMap); } } diff --git a/spring-core/src/main/resources/values.properties b/spring-core/src/main/resources/values.properties index d7d61b8ee8..c6db5873fb 100644 --- a/spring-core/src/main/resources/values.properties +++ b/spring-core/src/main/resources/values.properties @@ -1,3 +1,4 @@ value.from.file=Value got from the file priority=Properties file -listOfValues=A,B,C \ No newline at end of file +listOfValues=A,B,C +valuesMap={key1:'1', key2 : '2', key3 : '3'} \ No newline at end of file From 90037051b917432008c0a39eca55cc6d86e109cb Mon Sep 17 00:00:00 2001 From: Erhan KARAKAYA Date: Mon, 31 Dec 2018 04:01:27 +0300 Subject: [PATCH 076/441] Added missing import --- spring-core/src/main/java/com/baeldung/value/ValuesApp.java | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-core/src/main/java/com/baeldung/value/ValuesApp.java b/spring-core/src/main/java/com/baeldung/value/ValuesApp.java index 33592ae38a..80893c1adf 100644 --- a/spring-core/src/main/java/com/baeldung/value/ValuesApp.java +++ b/spring-core/src/main/java/com/baeldung/value/ValuesApp.java @@ -2,6 +2,7 @@ package com.baeldung.value; import java.util.Arrays; import java.util.List; +import java.util.Map; import javax.annotation.PostConstruct; From 6c6046200060f121f040c16db6c8d7bdf7fa1922 Mon Sep 17 00:00:00 2001 From: Tom Hombergs Date: Mon, 31 Dec 2018 10:07:38 +0100 Subject: [PATCH 077/441] added README --- akka-http/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 akka-http/README.md diff --git a/akka-http/README.md b/akka-http/README.md new file mode 100644 index 0000000000..583d2efa74 --- /dev/null +++ b/akka-http/README.md @@ -0,0 +1,3 @@ +### Relevant articles + +- [Introduction to Akka HTTP](https://www.baeldung.com/akka-http) From 0cf67f5dbef3d8c1ef17d2478654469f17fb2472 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Mon, 31 Dec 2018 13:45:58 +0100 Subject: [PATCH 078/441] BAEL-2435 Change dependency Change the autoconfigure dependency to the starter dependency of Axon --- axon/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/axon/pom.xml b/axon/pom.xml index 03d2499a99..598dc820e5 100644 --- a/axon/pom.xml +++ b/axon/pom.xml @@ -16,7 +16,7 @@ org.axonframework - axon-spring-boot-autoconfigure + axon-spring-boot-starter ${axon.version} From 1ed8fcf9dcbed1aa5424715c0207bbeaf669773a Mon Sep 17 00:00:00 2001 From: Urvy Agrawal Date: Tue, 1 Jan 2019 02:56:19 +0530 Subject: [PATCH 079/441] BAEL-2323 Java Native Keyword (#6038) -Moved files to core-java-lang module --- .../native/nativedatetimeutils.dll | Bin .../com/baeldung/nativekeyword/DateTimeUtils.java | 0 .../com/baeldung/nativekeyword/NativeMainApp.java | 0 .../nativekeyword/DateTimeUtilsManualTest.java | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {core-java => core-java-lang}/native/nativedatetimeutils.dll (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java (100%) rename {core-java => core-java-lang}/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java (100%) diff --git a/core-java/native/nativedatetimeutils.dll b/core-java-lang/native/nativedatetimeutils.dll similarity index 100% rename from core-java/native/nativedatetimeutils.dll rename to core-java-lang/native/nativedatetimeutils.dll diff --git a/core-java/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java b/core-java-lang/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java rename to core-java-lang/src/main/java/com/baeldung/nativekeyword/DateTimeUtils.java diff --git a/core-java/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java b/core-java-lang/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java similarity index 100% rename from core-java/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java rename to core-java-lang/src/main/java/com/baeldung/nativekeyword/NativeMainApp.java diff --git a/core-java/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java b/core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java rename to core-java-lang/src/test/java/com/baeldung/nativekeyword/DateTimeUtilsManualTest.java From aeba601c1f5bd14ad061a18c69babe92db97735d Mon Sep 17 00:00:00 2001 From: codehunter34 Date: Wed, 26 Dec 2018 23:58:04 -0500 Subject: [PATCH 080/441] BAEL-2399: Guice vs Spring - Dependency Injection --- guice/pom.xml | 62 ++++++++++++------- .../{GuiceTests.java => GuiceUnitTest.java} | 2 +- .../{SpringTests.java => SpringUnitTest.java} | 2 +- 3 files changed, 41 insertions(+), 25 deletions(-) rename guice/src/test/java/com/baeldung/examples/{GuiceTests.java => GuiceUnitTest.java} (96%) rename guice/src/test/java/com/baeldung/examples/{SpringTests.java => SpringUnitTest.java} (96%) diff --git a/guice/pom.xml b/guice/pom.xml index f3e7873245..54532bc992 100644 --- a/guice/pom.xml +++ b/guice/pom.xml @@ -1,29 +1,45 @@ - - 4.0.0 - com.baeldung.examples.guice - guice - 1.0-SNAPSHOT - jar - guice + + 4.0.0 + com.baeldung.examples.guice + guice + 1.0-SNAPSHOT + jar + guice - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + - - - com.google.inject - guice - ${guice.version} - - + + + com.google.inject + guice + ${guice.version} + - - 4.1.0 - + + org.springframework + spring-context + ${spring.version} + + + + org.springframework + spring-test + ${springtest.version} + test + + + + + 4.1.0 + 5.1.3.RELEASE + 5.1.3.RELEASE + diff --git a/guice/src/test/java/com/baeldung/examples/GuiceTests.java b/guice/src/test/java/com/baeldung/examples/GuiceUnitTest.java similarity index 96% rename from guice/src/test/java/com/baeldung/examples/GuiceTests.java rename to guice/src/test/java/com/baeldung/examples/GuiceUnitTest.java index b87289a1a4..ebc35de405 100644 --- a/guice/src/test/java/com/baeldung/examples/GuiceTests.java +++ b/guice/src/test/java/com/baeldung/examples/GuiceUnitTest.java @@ -15,7 +15,7 @@ import com.baeldung.examples.guice.modules.GuiceModule; import com.google.inject.Guice; import com.google.inject.Injector; -public class GuiceTests { +public class GuiceUnitTest { @Test public void givenAccountFieldInjectedInGuiceUser_WhenGetAccountInvoked_ThenReturnValueIsNotNull() { diff --git a/guice/src/test/java/com/baeldung/examples/SpringTests.java b/guice/src/test/java/com/baeldung/examples/SpringUnitTest.java similarity index 96% rename from guice/src/test/java/com/baeldung/examples/SpringTests.java rename to guice/src/test/java/com/baeldung/examples/SpringUnitTest.java index 327e409cc1..0bd6770909 100644 --- a/guice/src/test/java/com/baeldung/examples/SpringTests.java +++ b/guice/src/test/java/com/baeldung/examples/SpringUnitTest.java @@ -18,7 +18,7 @@ import com.baeldung.examples.spring.UserService; @RunWith(SpringRunner.class) @ContextConfiguration(classes = { AppConfig.class }) -public class SpringTests { +public class SpringUnitTest { @Autowired ApplicationContext context; From bd63df8caf05acee9307f84f94c83a304cbc401b Mon Sep 17 00:00:00 2001 From: codehunter34 Date: Tue, 1 Jan 2019 02:46:06 -0500 Subject: [PATCH 081/441] BAEL-2399: Guice vs Spring - Dependency Injection --- .../main/java/com/baeldung/examples/common/PersonDao.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 guice/src/main/java/com/baeldung/examples/common/PersonDao.java diff --git a/guice/src/main/java/com/baeldung/examples/common/PersonDao.java b/guice/src/main/java/com/baeldung/examples/common/PersonDao.java new file mode 100644 index 0000000000..980fee0252 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/common/PersonDao.java @@ -0,0 +1,5 @@ +package com.baeldung.examples.common; + +public interface PersonDao { + +} From d740cb2da09e0dfeef3ae166473785aa92f3a443 Mon Sep 17 00:00:00 2001 From: codehunter34 Date: Tue, 1 Jan 2019 02:46:06 -0500 Subject: [PATCH 082/441] BAEL-2399: Guice vs Spring - Dependency Injection --- .../java/com/baeldung/examples/common/PersonDaoImpl.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 guice/src/main/java/com/baeldung/examples/common/PersonDaoImpl.java diff --git a/guice/src/main/java/com/baeldung/examples/common/PersonDaoImpl.java b/guice/src/main/java/com/baeldung/examples/common/PersonDaoImpl.java new file mode 100644 index 0000000000..971db5aa87 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/common/PersonDaoImpl.java @@ -0,0 +1,8 @@ +package com.baeldung.examples.common; + +import org.springframework.stereotype.Component; + +@Component +public class PersonDaoImpl implements PersonDao { + +} \ No newline at end of file From 3ac96662fc8d9f83936f21fc688a13ffd648af40 Mon Sep 17 00:00:00 2001 From: codehunter34 Date: Tue, 1 Jan 2019 02:46:06 -0500 Subject: [PATCH 083/441] BAEL-2399: Guice vs Spring - Dependency Injection --- .../examples/common/PersonDaoImpl.java | 8 ++++++++ .../examples/guice/GuicePersonService.java | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 guice/src/main/java/com/baeldung/examples/common/PersonDaoImpl.java create mode 100644 guice/src/main/java/com/baeldung/examples/guice/GuicePersonService.java diff --git a/guice/src/main/java/com/baeldung/examples/common/PersonDaoImpl.java b/guice/src/main/java/com/baeldung/examples/common/PersonDaoImpl.java new file mode 100644 index 0000000000..971db5aa87 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/common/PersonDaoImpl.java @@ -0,0 +1,8 @@ +package com.baeldung.examples.common; + +import org.springframework.stereotype.Component; + +@Component +public class PersonDaoImpl implements PersonDao { + +} \ No newline at end of file diff --git a/guice/src/main/java/com/baeldung/examples/guice/GuicePersonService.java b/guice/src/main/java/com/baeldung/examples/guice/GuicePersonService.java new file mode 100644 index 0000000000..ce12e3e528 --- /dev/null +++ b/guice/src/main/java/com/baeldung/examples/guice/GuicePersonService.java @@ -0,0 +1,19 @@ +package com.baeldung.examples.guice; + +import com.baeldung.examples.common.PersonDao; +import com.google.inject.Inject; + +public class GuicePersonService { + + @Inject + private PersonDao personDao; + + public PersonDao getPersonDao() { + return personDao; + } + + public void setPersonDao(PersonDao personDao) { + this.personDao = personDao; + } + +} From c39fe1c85ca175a028521f8bf77ef9a906e24a6f Mon Sep 17 00:00:00 2001 From: Markus Gulden <> Date: Tue, 1 Jan 2019 15:40:15 +0100 Subject: [PATCH 084/441] BAEL-2321 --- .../04_Custom/connect-distributed.properties | 88 ----------------- .../04_Custom/connect-mongodb-sink.json | 30 +++--- .../04_Custom/connect-mqtt-source.json | 8 +- .../04_Custom/docker-compose.yaml | 94 +++++++++++++++++++ 4 files changed, 110 insertions(+), 110 deletions(-) delete mode 100644 libraries-data/src/main/kafka-connect/04_Custom/connect-distributed.properties create mode 100644 libraries-data/src/main/kafka-connect/04_Custom/docker-compose.yaml diff --git a/libraries-data/src/main/kafka-connect/04_Custom/connect-distributed.properties b/libraries-data/src/main/kafka-connect/04_Custom/connect-distributed.properties deleted file mode 100644 index 5b91baddbd..0000000000 --- a/libraries-data/src/main/kafka-connect/04_Custom/connect-distributed.properties +++ /dev/null @@ -1,88 +0,0 @@ -## -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -## - -# This file contains some of the configurations for the Kafka Connect distributed worker. This file is intended -# to be used with the examples, and some settings may differ from those used in a production system, especially -# the `bootstrap.servers` and those specifying replication factors. - -# A list of host/port pairs to use for establishing the initial connection to the Kafka cluster. -bootstrap.servers=localhost:9092 - -# unique name for the cluster, used in forming the Connect cluster group. Note that this must not conflict with consumer group IDs -group.id=connect-cluster - -# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will -# need to configure these based on the format they want their data in when loaded from or stored into Kafka -key.converter=org.apache.kafka.connect.json.JsonConverter -value.converter=org.apache.kafka.connect.json.JsonConverter -# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply -# it to -key.converter.schemas.enable=true -value.converter.schemas.enable=true - -# Topic to use for storing offsets. This topic should have many partitions and be replicated and compacted. -# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create -# the topic before starting Kafka Connect if a specific topic configuration is needed. -# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value. -# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able -# to run this example on a single-broker cluster and so here we instead set the replication factor to 1. -offset.storage.topic=connect-offsets -offset.storage.replication.factor=1 -#offset.storage.partitions=25 - -# Topic to use for storing connector and task configurations; note that this should be a single partition, highly replicated, -# and compacted topic. Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create -# the topic before starting Kafka Connect if a specific topic configuration is needed. -# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value. -# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able -# to run this example on a single-broker cluster and so here we instead set the replication factor to 1. -config.storage.topic=connect-configs -config.storage.replication.factor=1 - -# Topic to use for storing statuses. This topic can have multiple partitions and should be replicated and compacted. -# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create -# the topic before starting Kafka Connect if a specific topic configuration is needed. -# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value. -# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able -# to run this example on a single-broker cluster and so here we instead set the replication factor to 1. -status.storage.topic=connect-status -status.storage.replication.factor=1 -#status.storage.partitions=5 - -# Flush much faster than normal, which is useful for testing/debugging -offset.flush.interval.ms=10000 - -# These are provided to inform the user about the presence of the REST host and port configs -# Hostname & Port for the REST API to listen on. If this is set, it will bind to the interface used to listen to requests. -#rest.host.name= -#rest.port=8083 - -# The Hostname & Port that will be given out to other workers to connect to i.e. URLs that are routable from other servers. -#rest.advertised.host.name= -#rest.advertised.port= - -# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins -# (connectors, converters, transformations). The list should consist of top level directories that include -# any combination of: -# a) directories immediately containing jars with plugins and their dependencies -# b) uber-jars with plugins and their dependencies -# c) directories immediately containing the package directory structure of classes of plugins and their dependencies -# Examples: -# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors, -# Replace the relative path below with an absolute path if you are planning to start Kafka Connect from within a -# directory other than the home directory of Confluent Platform. -plugin.path=./share/java diff --git a/libraries-data/src/main/kafka-connect/04_Custom/connect-mongodb-sink.json b/libraries-data/src/main/kafka-connect/04_Custom/connect-mongodb-sink.json index 333768e4b7..852f400fc6 100644 --- a/libraries-data/src/main/kafka-connect/04_Custom/connect-mongodb-sink.json +++ b/libraries-data/src/main/kafka-connect/04_Custom/connect-mongodb-sink.json @@ -1,22 +1,14 @@ { - "firstName": "John", - "lastName": "Smith", - "age": 25, - "address": { - "streetAddress": "21 2nd Street", - "city": "New York", - "state": "NY", - "postalCode": "10021" - }, - "phoneNumber": [{ - "type": "home", - "number": "212 555-1234" - }, { - "type": "fax", - "number": "646 555-4567" - } - ], - "gender": { - "type": "male" + "name": "mongodb-sink", + "config": { + "connector.class": "at.grahsl.kafka.connect.mongodb.MongoDbSinkConnector", + "tasks.max": 1, + "topics": "connect-custom", + "mongodb.connection.uri": "mongodb://mongo-db/test?retryWrites=true", + "mongodb.collection": "MyCollection", + "key.converter": "org.apache.kafka.connect.json.JsonConverter", + "key.converter.schemas.enable": false, + "value.converter": "org.apache.kafka.connect.json.JsonConverter", + "value.converter.schemas.enable": false } } diff --git a/libraries-data/src/main/kafka-connect/04_Custom/connect-mqtt-source.json b/libraries-data/src/main/kafka-connect/04_Custom/connect-mqtt-source.json index 02d87c5ad7..c76d326c0a 100644 --- a/libraries-data/src/main/kafka-connect/04_Custom/connect-mqtt-source.json +++ b/libraries-data/src/main/kafka-connect/04_Custom/connect-mqtt-source.json @@ -3,9 +3,11 @@ "config": { "connector.class": "io.confluent.connect.mqtt.MqttSourceConnector", "tasks.max": 1, - "mqtt.server.uri": "ws://broker.hivemq.com:8000/mqtt", + "mqtt.server.uri": "tcp://mosquitto:1883", "mqtt.topics": "baeldung", "kafka.topic": "connect-custom", - "value.converter": "org.apache.kafka.connect.converters.ByteArrayConverter" + "value.converter": "org.apache.kafka.connect.converters.ByteArrayConverter", + "confluent.topic.bootstrap.servers": "kafka:9092", + "confluent.topic.replication.factor": 1 } -} +} \ No newline at end of file diff --git a/libraries-data/src/main/kafka-connect/04_Custom/docker-compose.yaml b/libraries-data/src/main/kafka-connect/04_Custom/docker-compose.yaml new file mode 100644 index 0000000000..26cd653335 --- /dev/null +++ b/libraries-data/src/main/kafka-connect/04_Custom/docker-compose.yaml @@ -0,0 +1,94 @@ +version: '3.3' + +services: + mosquitto: + image: eclipse-mosquitto:1.5.5 + hostname: mosquitto + container_name: mosquitto + expose: + - "1883" + ports: + - "1883:1883" + zookeeper: + image: zookeeper:3.4.9 + restart: unless-stopped + hostname: zookeeper + container_name: zookeeper + ports: + - "2181:2181" + environment: + ZOO_MY_ID: 1 + ZOO_PORT: 2181 + ZOO_SERVERS: server.1=zookeeper:2888:3888 + volumes: + - ./zookeeper/data:/data + - ./zookeeper/datalog:/datalog + kafka: + image: confluentinc/cp-kafka:5.1.0 + hostname: kafka + container_name: kafka + ports: + - "9092:9092" + environment: + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092 + KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" + KAFKA_BROKER_ID: 1 + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 + volumes: + - ./kafka/data:/var/lib/kafka/data + depends_on: + - zookeeper + kafka-connect: + image: confluentinc/cp-kafka-connect:5.1.0 + hostname: kafka-connect + container_name: kafka-connect + ports: + - "8083:8083" + environment: + CONNECT_BOOTSTRAP_SERVERS: "kafka:9092" + CONNECT_REST_ADVERTISED_HOST_NAME: connect + CONNECT_REST_PORT: 8083 + CONNECT_GROUP_ID: compose-connect-group + CONNECT_CONFIG_STORAGE_TOPIC: docker-connect-configs + CONNECT_OFFSET_STORAGE_TOPIC: docker-connect-offsets + CONNECT_STATUS_STORAGE_TOPIC: docker-connect-status + CONNECT_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter + CONNECT_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter + CONNECT_INTERNAL_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter" + CONNECT_INTERNAL_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter" + CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: "1" + CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: "1" + CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: "1" + CONNECT_PLUGIN_PATH: '/usr/share/java,/etc/kafka-connect/jars' + CONNECT_CONFLUENT_TOPIC_REPLICATION_FACTOR: 1 + volumes: + - /tmp/custom/jars:/etc/kafka-connect/jars + depends_on: + - zookeeper + - kafka + - mosquitto + mongo-db: + image: mongo:4.0.5 + hostname: mongo-db + container_name: mongo-db + expose: + - "27017" + ports: + - "27017:27017" + command: --bind_ip_all --smallfiles + volumes: + - ./mongo-db:/data + mongoclient: + image: mongoclient/mongoclient:2.2.0 + container_name: mongoclient + hostname: mongoclient + depends_on: + - mongo-db + ports: + - 3000:3000 + environment: + MONGO_URL: "mongodb://mongo-db:27017" + PORT: 3000 + expose: + - "3000" \ No newline at end of file From c560a37b70907834f90d73eca63c612e27cd1826 Mon Sep 17 00:00:00 2001 From: Loredana Date: Tue, 1 Jan 2019 22:44:53 +0200 Subject: [PATCH 085/441] add start class --- spring-boot-security/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-boot-security/pom.xml b/spring-boot-security/pom.xml index d5c7976ba2..b87189757a 100644 --- a/spring-boot-security/pom.xml +++ b/spring-boot-security/pom.xml @@ -66,4 +66,8 @@ + + com.baeldung.springbootsecurity.basic_auth.SpringBootSecurityApplication + + From 0d5483e1bf74b0d00aa314d7f8a84f5feb710e81 Mon Sep 17 00:00:00 2001 From: rahusriv Date: Wed, 2 Jan 2019 08:26:43 +0530 Subject: [PATCH 086/441] Rahul/multidimensional/pr3 (#6040) * Making examples simple * Changing variable names * Modificatons in naming * Giving extra spaces --- .../ArrayListOfArrayList.java | 21 ++++++++++--------- .../ThreeDimensionalArrayList.java | 10 ++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java b/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java index 2c3da7b1fc..e11f8e8ba0 100644 --- a/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java +++ b/core-java-collections-list/src/main/java/com/baeldung/list/multidimensional/ArrayListOfArrayList.java @@ -6,11 +6,11 @@ public class ArrayListOfArrayList { public static void main(String args[]) { - int numVertices = 3; - ArrayList> graph = new ArrayList<>(numVertices); + int vertexCount = 3; + ArrayList> graph = new ArrayList<>(vertexCount); //Initializing each element of ArrayList with ArrayList - for(int i=0; i< numVertices; i++) { + for(int i = 0; i< vertexCount; i++) { graph.add(new ArrayList()); } @@ -21,13 +21,14 @@ public class ArrayListOfArrayList { graph.get(1).add(0); graph.get(2).add(1); graph.get(0).add(2); - - //Printing all the edges - for(int vertexNo=0; vertexNo listOfVertices = graph.get(vertexNo); - for(int i=0; i > > space = new ArrayList<>(x_axis_length); //Initializing each element of ArrayList with ArrayList< ArrayList > - for(int i=0; i< x_axis_length; i++) { + for(int i = 0; i < x_axis_length; i++) { space.add(new ArrayList< ArrayList >(y_axis_length)); - for(int j =0; j< y_axis_length; j++) { + for(int j = 0; j < y_axis_length; j++) { space.get(i).add(new ArrayList(z_axis_length)); } } @@ -33,9 +33,9 @@ public class ThreeDimensionalArrayList { space.get(1).get(1).add(1,"Yellow"); //Printing colors for all the points - for(int i=0; i Date: Wed, 2 Jan 2019 13:36:50 +0200 Subject: [PATCH 087/441] Update README.md --- core-java/README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/core-java/README.md b/core-java/README.md index 3c5d1941d6..03b77186b0 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -22,7 +22,6 @@ - [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) - [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin) - [Quick Guide to Java Stack](http://www.baeldung.com/java-stack) -- [Guide to java.util.Formatter](http://www.baeldung.com/java-string-formatter) - [Compiling Java *.class Files with javac](http://www.baeldung.com/javac) - [Introduction to Javadoc](http://www.baeldung.com/javadoc) - [Guide to the Externalizable Interface in Java](http://www.baeldung.com/java-externalizable) @@ -40,13 +39,7 @@ - [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) - [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties) -- [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) -- [Calculating the nth Root in Java](https://www.baeldung.com/java-nth-root) -- [Convert Double to String, Removing Decimal Places](https://www.baeldung.com/java-double-to-string) -- [ZoneOffset in Java](https://www.baeldung.com/java-zone-offset) - [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties) -- [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format) -- [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order) - [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources) - [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class) - [Guide to Character Encoding](https://www.baeldung.com/java-char-encoding) From e464591902afaa61de6035486a8240a87e046b38 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 2 Jan 2019 14:39:01 +0200 Subject: [PATCH 088/441] Update README.md --- core-java-collections/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-collections/README.md b/core-java-collections/README.md index 71d4e6b614..1a90d01a82 100644 --- a/core-java-collections/README.md +++ b/core-java-collections/README.md @@ -29,4 +29,4 @@ - [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) \ No newline at end of file +- [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator) From 1db24b5c06076b85d4a2c3ab4b3caddd74df8154 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 2 Jan 2019 15:45:28 +0200 Subject: [PATCH 089/441] Update README.md --- core-java-8/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core-java-8/README.md b/core-java-8/README.md index e5fa953cc7..f9af585ab3 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -33,3 +33,7 @@ - [Java Primitives versus Objects](https://www.baeldung.com/java-primitives-vs-objects) - [How to Use if/else Logic in Java 8 Streams](https://www.baeldung.com/java-8-streams-if-else-logic) - [How to Replace Many if Statements in Java](https://www.baeldung.com/java-replace-if-statements) +- [Java @Override Annotation](https://www.baeldung.com/java-override) +- [Java @SuppressWarnings Annotation](https://www.baeldung.com/java-suppresswarnings) +- [Java @SafeVarargs Annotation](https://www.baeldung.com/java-safevarargs) +- [Java @Deprecated Annotation](https://www.baeldung.com/java-deprecated) From 66016332f82446179aaae1ed5bd41c15b26773c0 Mon Sep 17 00:00:00 2001 From: Mikhail Chugunov Date: Wed, 2 Jan 2019 19:09:00 +0300 Subject: [PATCH 090/441] BAEL-2475: Add sample code and tests --- .../immutable/MaritalAwarePerson.java | 58 +++++++++++++++++++ .../deserialization/immutable/Person.java | 24 ++++++++ ...mmutableObjectDeserializationUnitTest.java | 40 +++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/MaritalAwarePerson.java create mode 100644 jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Person.java create mode 100644 jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java diff --git a/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/MaritalAwarePerson.java b/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/MaritalAwarePerson.java new file mode 100644 index 0000000000..cb593b3bb7 --- /dev/null +++ b/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/MaritalAwarePerson.java @@ -0,0 +1,58 @@ +package com.baeldung.jackson.deserialization.immutable; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; + +@JsonDeserialize(builder = MaritalAwarePerson.Builder.class) +public class MaritalAwarePerson { + + private final String name; + private final int age; + private final Boolean married; + + private MaritalAwarePerson(String name, int age, Boolean married) { + this.name = name; + this.age = age; + this.married = married; + } + + public String getName() { + return name; + } + + public int getAge() { + return age; + } + + public Boolean getMarried() { + return married; + } + + @JsonPOJOBuilder + static class Builder { + String name; + int age; + Boolean married; + + Builder withName(String name) { + this.name = name; + return this; + } + + Builder withAge(int age) { + this.age = age; + return this; + } + + Builder withMarried(boolean married) { + this.married = married; + return this; + } + + public MaritalAwarePerson build() { + return new MaritalAwarePerson(name, age, married); + } + + + } +} diff --git a/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Person.java b/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Person.java new file mode 100644 index 0000000000..0214f93ca9 --- /dev/null +++ b/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Person.java @@ -0,0 +1,24 @@ +package com.baeldung.jackson.deserialization.immutable; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Person { + + private final String name; + private final int age; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + public Person(@JsonProperty("name") String name, @JsonProperty("age") int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public int getAge() { + return age; + } +} diff --git a/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java b/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java new file mode 100644 index 0000000000..348ece4a09 --- /dev/null +++ b/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.jackson.deserialization.immutable; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.*; + +public class ImmutableObjectDeserializationUnitTest { + + @Test + public void testPublicConstructor() throws IOException { + final String json = "{\"name\":\"Frank\",\"age\":50}"; + Person person = new ObjectMapper().readValue(json, Person.class); + + assertEquals("Frank", person.getName()); + assertEquals(50, person.getAge()); + } + + @Test + public void testBuilderNullField() throws IOException { + final String json = "{\"name\":\"Frank\",\"age\":50}"; + MaritalAwarePerson person = new ObjectMapper().readValue(json, MaritalAwarePerson.class); + + assertEquals("Frank", person.getName()); + assertEquals(50, person.getAge()); + assertNull(person.getMarried()); + } + + @Test + public void testBuilderAllFields() throws IOException { + final String json = "{\"name\":\"Frank\",\"age\":50,\"married\":true}"; + MaritalAwarePerson person = new ObjectMapper().readValue(json, MaritalAwarePerson.class); + + assertEquals("Frank", person.getName()); + assertEquals(50, person.getAge()); + assertTrue(person.getMarried()); + } +} From 2e436ce3e8e31c6791257f624b9661b4ba3368b3 Mon Sep 17 00:00:00 2001 From: Mikhail Chugunov Date: Wed, 2 Jan 2019 19:14:09 +0300 Subject: [PATCH 091/441] BAEL-2475: Rename tests --- .../immutable/ImmutableObjectDeserializationUnitTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java b/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java index 348ece4a09..5c33a2da26 100644 --- a/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java +++ b/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java @@ -10,7 +10,7 @@ import static org.junit.Assert.*; public class ImmutableObjectDeserializationUnitTest { @Test - public void testPublicConstructor() throws IOException { + public void whenPublicConstructorIsUsed_thenObjectIsDeserialized() throws IOException { final String json = "{\"name\":\"Frank\",\"age\":50}"; Person person = new ObjectMapper().readValue(json, Person.class); @@ -19,7 +19,7 @@ public class ImmutableObjectDeserializationUnitTest { } @Test - public void testBuilderNullField() throws IOException { + public void whenBuilderIsUsedAndFieldIsNull_thenObjectIsDeserialized() throws IOException { final String json = "{\"name\":\"Frank\",\"age\":50}"; MaritalAwarePerson person = new ObjectMapper().readValue(json, MaritalAwarePerson.class); @@ -29,7 +29,7 @@ public class ImmutableObjectDeserializationUnitTest { } @Test - public void testBuilderAllFields() throws IOException { + public void whenBuilderIsUsedAndAllFieldsPresent_thenObjectIsDeserialized() throws IOException { final String json = "{\"name\":\"Frank\",\"age\":50,\"married\":true}"; MaritalAwarePerson person = new ObjectMapper().readValue(json, MaritalAwarePerson.class); From 75bf7ba5155da5fd1b8240080e35c4f0adb8781f Mon Sep 17 00:00:00 2001 From: Varun Jain Date: Wed, 2 Jan 2019 22:11:21 +0530 Subject: [PATCH 092/441] BAEL-2536-check-for-a-panagram-string --- .../java/com/baeldung/string/Panagram.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 java-strings/src/main/java/com/baeldung/string/Panagram.java diff --git a/java-strings/src/main/java/com/baeldung/string/Panagram.java b/java-strings/src/main/java/com/baeldung/string/Panagram.java new file mode 100644 index 0000000000..d000b4455e --- /dev/null +++ b/java-strings/src/main/java/com/baeldung/string/Panagram.java @@ -0,0 +1,60 @@ +package com.baeldung.string; + +import java.util.Arrays; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class Panagram { + + public static boolean isPanagram(String str) { + if (str == null) + return false; + Boolean[] alphabetMarker = new Boolean[26]; + Arrays.fill(alphabetMarker, false); + int alphabetIndex = 0; + str = str.toUpperCase(); + for (int i = 0; i < str.length(); i++) { + if ('A' <= str.charAt(i) && str.charAt(i) <= 'Z') { + alphabetIndex = str.charAt(i) - 'A'; + alphabetMarker[alphabetIndex] = true; + } + } + for (boolean index : alphabetMarker) { + if (!index) + return false; + } + return true; + } + + public static boolean isPanagramWithStreams(String str) { + if (str == null) + return false; + + // filtered character stream + str = str.toUpperCase(); + Stream filteredCharStream = str.chars() + .filter(item -> ((item >= 'A' && item <= 'Z') || (item >= 'a' && item <= 'z'))) + .mapToObj(c -> (char) c); + Map alphabetMap = filteredCharStream.collect(Collectors.toMap(item -> item, k -> Boolean.TRUE, (p1, p2) -> p1)); + + return (alphabetMap.size() == 26); + } + + public static boolean isPerfectPanagram(String str) { + if (str == null) + return false; + + // filtered character stream + str = str.toUpperCase(); + Stream filteredCharStream = str.chars() + .filter(item -> ((item >= 'A' && item <= 'Z') || (item >= 'a' && item <= 'z'))) + .mapToObj(c -> (char) c); + Map alphabetFrequencyMap = filteredCharStream.collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); + + return (alphabetFrequencyMap.size() == 26 && alphabetFrequencyMap.values() + .stream() + .allMatch(item -> item == 1)); + } +} From 725076b8ee4593c3dbccd6b5006edc657e0c0bbb Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Wed, 2 Jan 2019 22:18:53 +0400 Subject: [PATCH 093/441] performance tests tune up --- .../com/baeldung/performance/ArrayListBenchmark.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java b/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java index 1eeb17df87..331ae8d908 100644 --- a/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java +++ b/core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java @@ -9,7 +9,7 @@ import java.util.*; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) -@OutputTimeUnit(TimeUnit.MICROSECONDS) +@OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 10) public class ArrayListBenchmark { @@ -63,6 +63,7 @@ public class ArrayListBenchmark { public Employee testGet(ArrayListBenchmark.MyState state) { return state.employeeList.get(state.employeeIndex); } + @Benchmark public Employee testVectorGet(ArrayListBenchmark.MyState state) { return state.employeeVector.get(state.employeeIndex); @@ -78,14 +79,9 @@ public class ArrayListBenchmark { state.employeeList.add(new Employee(state.iterations + 1, "John")); } - @Benchmark - public void testAddVector(ArrayListBenchmark.MyState state) { - state.employeeVector.add(new Employee(state.iterations + 1, "John")); - } - public static void main(String[] args) throws Exception { Options options = new OptionsBuilder() - .include(ArrayListBenchmark.class.getSimpleName()).threads(1) + .include(ArrayListBenchmark.class.getSimpleName()).threads(3) .forks(1).shouldFailOnError(true) .shouldDoGC(true) .jvmArgs("-server").build(); From 9a8e006d73870b24c3116575ad56b97b319ab8ee Mon Sep 17 00:00:00 2001 From: Loredana Date: Wed, 2 Jan 2019 21:58:02 +0200 Subject: [PATCH 094/441] fix abstract factory ex --- .../creational/abstractfactory/AbstractFactory.java | 5 ++--- .../abstractfactory/AbstractPatternDriver.java | 4 ++-- .../creational/abstractfactory/AnimalFactory.java | 9 ++------- .../creational/abstractfactory/ColorFactory.java | 9 ++------- .../abstractfactory/AbstractPatternIntegrationTest.java | 4 ++-- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractFactory.java b/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractFactory.java index 5b4bf08006..88e819c066 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractFactory.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractFactory.java @@ -1,6 +1,5 @@ package com.baeldung.creational.abstractfactory; -public interface AbstractFactory { - Animal getAnimal(String toyType) ; - Color getColor(String colorType); +public interface AbstractFactory { + T create(String type) ; } \ No newline at end of file diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractPatternDriver.java b/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractPatternDriver.java index 68759d5aff..c1501091c5 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractPatternDriver.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AbstractPatternDriver.java @@ -6,10 +6,10 @@ public class AbstractPatternDriver { //creating a brown toy dog abstractFactory = FactoryProvider.getFactory("Toy"); - Animal toy = abstractFactory.getAnimal("Dog"); + Animal toy =(Animal) abstractFactory.create("Dog"); abstractFactory = FactoryProvider.getFactory("Color"); - Color color = abstractFactory.getColor("Brown"); + Color color =(Color) abstractFactory.create("Brown"); String result = "A " + toy.getType() + " with " + color.getColor() + " color " + toy.makeSound(); diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AnimalFactory.java b/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AnimalFactory.java index bbc3eb7a82..4b46261571 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AnimalFactory.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/AnimalFactory.java @@ -1,9 +1,9 @@ package com.baeldung.creational.abstractfactory; -public class AnimalFactory implements AbstractFactory { +public class AnimalFactory implements AbstractFactory { @Override - public Animal getAnimal(String animalType) { + public Animal create(String animalType) { if ("Dog".equalsIgnoreCase(animalType)) { return new Dog(); } else if ("Duck".equalsIgnoreCase(animalType)) { @@ -13,9 +13,4 @@ public class AnimalFactory implements AbstractFactory { return null; } - @Override - public Color getColor(String color) { - throw new UnsupportedOperationException(); - } - } diff --git a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/ColorFactory.java b/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/ColorFactory.java index 8b7e4f8086..3d9c5c18a3 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/ColorFactory.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/creational/abstractfactory/ColorFactory.java @@ -1,9 +1,9 @@ package com.baeldung.creational.abstractfactory; -public class ColorFactory implements AbstractFactory { +public class ColorFactory implements AbstractFactory { @Override - public Color getColor(String colorType) { + public Color create(String colorType) { if ("Brown".equalsIgnoreCase(colorType)) { return new Brown(); } else if ("White".equalsIgnoreCase(colorType)) { @@ -13,9 +13,4 @@ public class ColorFactory implements AbstractFactory { return null; } - @Override - public Animal getAnimal(String toyType) { - throw new UnsupportedOperationException(); - } - } diff --git a/patterns/design-patterns/src/test/java/com/baeldung/creational/abstractfactory/AbstractPatternIntegrationTest.java b/patterns/design-patterns/src/test/java/com/baeldung/creational/abstractfactory/AbstractPatternIntegrationTest.java index 6d1a4ad8fd..4f02249a4b 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/creational/abstractfactory/AbstractPatternIntegrationTest.java +++ b/patterns/design-patterns/src/test/java/com/baeldung/creational/abstractfactory/AbstractPatternIntegrationTest.java @@ -11,10 +11,10 @@ public class AbstractPatternIntegrationTest { //creating a brown toy dog abstractFactory = FactoryProvider.getFactory("Toy"); - Animal toy = abstractFactory.getAnimal("Dog"); + Animal toy = (Animal) abstractFactory.create("Dog"); abstractFactory = FactoryProvider.getFactory("Color"); - Color color = abstractFactory.getColor("Brown"); + Color color =(Color) abstractFactory.create("Brown"); String result = "A " + toy.getType() + " with " + color.getColor() + " color " + toy.makeSound(); assertEquals("A Dog with brown color Barks", result); From 23de38295f0efe7c3f7767b4cee3ce92bd3ce43b Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 2 Jan 2019 22:49:58 +0200 Subject: [PATCH 095/441] Update README.md --- core-java-8/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-8/README.md b/core-java-8/README.md index f9af585ab3..892dc71f76 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -37,3 +37,4 @@ - [Java @SuppressWarnings Annotation](https://www.baeldung.com/java-suppresswarnings) - [Java @SafeVarargs Annotation](https://www.baeldung.com/java-safevarargs) - [Java @Deprecated Annotation](https://www.baeldung.com/java-deprecated) +- [Java 8 Predicate Chain](https://www.baeldung.com/java-predicate-chain) From f912eaf5d98c8d51f444b9cca4ecd9523f89bf94 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 2 Jan 2019 22:50:52 +0200 Subject: [PATCH 096/441] Update README.md --- core-java-lang/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-lang/README.md b/core-java-lang/README.md index 52dfe708a3..f7aa47008d 100644 --- a/core-java-lang/README.md +++ b/core-java-lang/README.md @@ -33,3 +33,4 @@ - [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) +- [Guide to Java Packages](https://www.baeldung.com/java-packages) From 53b0c016fff0863cc47342edb2c1892ef89bb9bf Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 2 Jan 2019 22:53:09 +0200 Subject: [PATCH 097/441] Update README.md --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index 2b948a683a..e973907248 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -23,3 +23,4 @@ - [Difference Between @JoinColumn and mappedBy](https://www.baeldung.com/jpa-joincolumn-vs-mappedby) - [Hibernate 5 Bootstrapping API](https://www.baeldung.com/hibernate-5-bootstrapping-api) - [Criteria Queries Using JPA Metamodel](https://www.baeldung.com/hibernate-criteria-queries-metamodel) +- [Guide to the Hibernate EntityManager](https://www.baeldung.com/hibernate-entitymanager) From 13e4081fc7a22111cfbf4c075dfd87eaab3471f1 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 2 Jan 2019 22:53:54 +0200 Subject: [PATCH 098/441] Update README.md --- java-collections-maps/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-collections-maps/README.md b/java-collections-maps/README.md index a6037a3c57..0b76ca1959 100644 --- a/java-collections-maps/README.md +++ b/java-collections-maps/README.md @@ -17,3 +17,4 @@ - [Finding the Highest Value in a Java Map](https://www.baeldung.com/java-find-map-max) - [Merging Two Maps with Java 8](https://www.baeldung.com/java-merge-maps) - [How to Check If a Key Exists in a Map](https://www.baeldung.com/java-map-key-exists) +- [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps) From 1a76da2f8f589204f57fc1d7a6e9b7bf45c37c72 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 2 Jan 2019 22:54:36 +0200 Subject: [PATCH 099/441] Update README.md --- core-java-lang/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-lang/README.md b/core-java-lang/README.md index 52dfe708a3..d5ad7d8e7c 100644 --- a/core-java-lang/README.md +++ b/core-java-lang/README.md @@ -33,3 +33,4 @@ - [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) From 7b666654ec11d8e4b524d3fc44be572f6101d8ed Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 2 Jan 2019 22:56:06 +0200 Subject: [PATCH 100/441] Update README.md --- persistence-modules/java-jpa/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index 9a90216519..2eea5e60b4 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -2,4 +2,5 @@ - [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) -- [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) +- [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) From 6903a0c2bbdd72081fa8cac9f16d35f78bd05340 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 2 Jan 2019 22:56:48 +0200 Subject: [PATCH 101/441] Update README.md --- spring-5-security-oauth/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5-security-oauth/README.md b/spring-5-security-oauth/README.md index f13925992b..5a444d4784 100644 --- a/spring-5-security-oauth/README.md +++ b/spring-5-security-oauth/README.md @@ -2,3 +2,4 @@ - [Spring Security 5 -OAuth2 Login](http://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) From bbb6c93598e4c401ee000392a69f96a8badaa4b6 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Wed, 2 Jan 2019 22:13:35 -0200 Subject: [PATCH 102/441] [BAEL-2315] spring-5-reactive-oauth & spring-5-security-oauth | WebClient and OAuth2 support (#6053) * Cleaned shared properties in spring-5-security-oauth module, and made some final tunings on authorization service and the resource server * Added and modified example for webclient-oauth2 * Cleaned authorization service and resource service for webclient and oauth2 article * Added examples for auth code with client and with login cleaned properties and packages * Added examples fow webclient + oauth2 --- .../Spring5ReactiveOauthApplication.java | 2 + .../OauthClientApplication.java | 24 +++++++ .../configuration/WebClientConfig.java | 20 ++++++ .../configuration/WebSecurityConfig.java | 22 ++++++ .../web/ClientRestController.java | 53 +++++++++++++++ .../OauthClientApplication.java | 24 +++++++ .../configuration/WebClientConfig.java | 31 +++++++++ .../configuration/WebSecurityConfig.java | 20 ++++++ .../web/ClientRestController.java | 68 +++++++++++++++++++ .../ClientCredentialsOauthApplication.java | 26 +++++++ .../configuration/WebClientConfig.java | 22 ++++++ .../service/WebClientChonJob.java | 33 +++++++++ .../ManualRequestApplication.java | 23 +++++++ .../configure/WebClientConfig.java | 16 +++++ .../configure/WebSecurityConfig.java | 17 +++++ .../web/ManualOauthRequestController.java | 57 ++++++++++++++++ .../src/main/resources/application.yml | 23 +------ .../main/resources/default-application.yml | 20 ++++++ ...nt-auth-code-client-application.properties | 10 +++ ...ent-auth-code-login-application.properties | 10 +++ ...t-credentials-oauth-application.properties | 4 ++ .../OAuth2ClientCredentialsLiveTest.java | 52 ++++++++++++++ .../OAuth2ManualRequestLiveTest.java | 43 ++++++++++++ .../webclient/utils/ListAppender.java | 25 +++++++ .../src/test/resources/logback-test.xml | 16 +++++ .../oauth2/SpringOAuthApplication.java | 2 + .../ExtractorsApplication.java | 2 + .../AuthorizationServerApplication.java | 17 +++++ .../configuration/WebSecurityConfig.java | 26 +++++++ .../ResourceServerApplication.java | 17 +++++ .../configuration/AuthorizationConfigs.java | 29 ++++++++ .../web/ResourceRestController.java | 23 +++++++ .../src/main/resources/application.properties | 2 - .../resources/default-application.properties | 1 + ...lient-authorization-application.properties | 13 ++++ ...webclient-resources-application.properties | 6 ++ 36 files changed, 777 insertions(+), 22 deletions(-) create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebClientConfig.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebSecurityConfig.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientApplication.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebClientConfig.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebSecurityConfig.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/configuration/WebClientConfig.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebClientConfig.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebSecurityConfig.java create mode 100644 spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java create mode 100644 spring-5-reactive-oauth/src/main/resources/default-application.yml create mode 100644 spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties create mode 100644 spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties create mode 100644 spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties create mode 100644 spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java create mode 100644 spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java create mode 100644 spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/utils/ListAppender.java create mode 100644 spring-5-reactive-oauth/src/test/resources/logback-test.xml create mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/AuthorizationServerApplication.java create mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/configuration/WebSecurityConfig.java create mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/ResourceServerApplication.java create mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/configuration/AuthorizationConfigs.java create mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/web/ResourceRestController.java create mode 100644 spring-5-security-oauth/src/main/resources/default-application.properties create mode 100644 spring-5-security-oauth/src/main/resources/webclient-authorization-application.properties create mode 100644 spring-5-security-oauth/src/main/resources/webclient-resources-application.properties diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthApplication.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthApplication.java index 602ded6b9e..b95517200e 100644 --- a/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthApplication.java +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthApplication.java @@ -3,11 +3,13 @@ package com.baeldung.reactive.oauth; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.PropertySource; import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository; import org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction; import org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizedClientRepository; import org.springframework.web.reactive.function.client.WebClient; +@PropertySource("classpath:default-application.yml") @SpringBootApplication public class Spring5ReactiveOauthApplication { diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java new file mode 100644 index 0000000000..7bae78bb14 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java @@ -0,0 +1,24 @@ +package com.baeldung.webclient.authorizationcodeclient; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; + +/** + * + * Note: This app is configured to use the authorization service and the resource service located in module spring-5-security-oauth + * + * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using user credentials (bael-user/bael-password) and client configurations (bael-client-id/bael-secret) handled by the auth server + * + * @author rozagerardo + * + */ +@PropertySource("classpath:webclient-auth-code-client-application.properties") +@SpringBootApplication +public class OauthClientApplication { + + public static void main(String[] args) { + SpringApplication.run(OauthClientApplication.class, args); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebClientConfig.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebClientConfig.java new file mode 100644 index 0000000000..884a3c145d --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebClientConfig.java @@ -0,0 +1,20 @@ +package com.baeldung.webclient.authorizationcodeclient.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository; +import org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction; +import org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizedClientRepository; +import org.springframework.web.reactive.function.client.WebClient; + +@Configuration +public class WebClientConfig { + + @Bean + WebClient webClientForAuthorized(ReactiveClientRegistrationRepository clientRegistrations, ServerOAuth2AuthorizedClientRepository authorizedClients) { + ServerOAuth2AuthorizedClientExchangeFilterFunction oauth = new ServerOAuth2AuthorizedClientExchangeFilterFunction(clientRegistrations, authorizedClients); + return WebClient.builder() + .filter(oauth) + .build(); + } +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebSecurityConfig.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebSecurityConfig.java new file mode 100644 index 0000000000..4271ae96cf --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebSecurityConfig.java @@ -0,0 +1,22 @@ +package com.baeldung.webclient.authorizationcodeclient.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.web.server.SecurityWebFilterChain; + +@Configuration +public class WebSecurityConfig { + @Bean + public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { + http.authorizeExchange() + .anyExchange() + .authenticated() + .and() + .oauth2Client() + .and() + .formLogin(); + return http.build(); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java new file mode 100644 index 0000000000..c36b7d1dea --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java @@ -0,0 +1,53 @@ +package com.baeldung.webclient.authorizationcodeclient.web; + +import static org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction.clientRegistrationId; +import static org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; +import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.reactive.function.client.WebClient; + +import reactor.core.publisher.Mono; + +@RestController +public class ClientRestController { + + private static final String RESOURCE_URI = "http://localhost:8084/retrieve-resource"; + + @Autowired + WebClient webClient; + + @GetMapping("/auth-code") + Mono useOauthWithAuthCode() { + Mono retrievedResource = webClient.get() + .uri(RESOURCE_URI) + .retrieve() + .bodyToMono(String.class); + return retrievedResource.map(string -> "We retrieved the following resource using Oauth: " + string); + } + + @GetMapping("/auth-code-annotated") + Mono useOauthWithAuthCodeAndAnnotation(@RegisteredOAuth2AuthorizedClient("bael") OAuth2AuthorizedClient authorizedClient) { + Mono retrievedResource = webClient.get() + .uri(RESOURCE_URI) + .attributes(oauth2AuthorizedClient(authorizedClient)) + .retrieve() + .bodyToMono(String.class); + return retrievedResource.map(string -> "We retrieved the following resource using Oauth: " + string + ". Principal associated: " + authorizedClient.getPrincipalName() + ". Token will expire at: " + authorizedClient.getAccessToken() + .getExpiresAt()); + } + + @GetMapping("/auth-code-explicit-client") + Mono useOauthWithExpicitClient() { + Mono retrievedResource = webClient.get() + .uri(RESOURCE_URI) + .attributes(clientRegistrationId("bael")) + .retrieve() + .bodyToMono(String.class); + return retrievedResource.map(string -> "We retrieved the following resource using Oauth: " + string); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientApplication.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientApplication.java new file mode 100644 index 0000000000..9dd6dd1bde --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientApplication.java @@ -0,0 +1,24 @@ +package com.baeldung.webclient.authorizationcodelogin; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; + +/** + * + * Note: This app is configured to use the authorization service and the resource service located in module spring-5-security-oauth + * + * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using user credentials (bael-user/bael-password) and client configurations (bael-client-id/bael-secret) handled by the auth server + * + * @author rozagerardo + * + */ +@PropertySource("classpath:webclient-auth-code-login-application.properties") +@SpringBootApplication +public class OauthClientApplication { + + public static void main(String[] args) { + SpringApplication.run(OauthClientApplication.class, args); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebClientConfig.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebClientConfig.java new file mode 100644 index 0000000000..15458cc60a --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebClientConfig.java @@ -0,0 +1,31 @@ +package com.baeldung.webclient.authorizationcodelogin.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository; +import org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction; +import org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizedClientRepository; +import org.springframework.web.reactive.function.client.WebClient; + +@Configuration +public class WebClientConfig { + + @Bean + @Primary + WebClient webClientForAuthorized(ReactiveClientRegistrationRepository clientRegistrations, ServerOAuth2AuthorizedClientRepository authorizedClients) { + ServerOAuth2AuthorizedClientExchangeFilterFunction oauth = new ServerOAuth2AuthorizedClientExchangeFilterFunction(clientRegistrations, authorizedClients); + oauth.setDefaultOAuth2AuthorizedClient(true); + return WebClient.builder() + .filter(oauth) + .build(); + } + + @Bean + WebClient otherWebClient(ReactiveClientRegistrationRepository clientRegistrations, ServerOAuth2AuthorizedClientRepository authorizedClients) { + ServerOAuth2AuthorizedClientExchangeFilterFunction oauth = new ServerOAuth2AuthorizedClientExchangeFilterFunction(clientRegistrations, authorizedClients); + return WebClient.builder() + .filter(oauth) + .build(); + } +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebSecurityConfig.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebSecurityConfig.java new file mode 100644 index 0000000000..f45fc09222 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebSecurityConfig.java @@ -0,0 +1,20 @@ +package com.baeldung.webclient.authorizationcodelogin.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.web.server.SecurityWebFilterChain; + +@Configuration +public class WebSecurityConfig { + @Bean + public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { + http.authorizeExchange() + .anyExchange() + .authenticated() + .and() + .oauth2Login(); + return http.build(); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java new file mode 100644 index 0000000000..55e0096525 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java @@ -0,0 +1,68 @@ +package com.baeldung.webclient.authorizationcodelogin.web; + +import static org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction.clientRegistrationId; +import static org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; +import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.reactive.function.client.WebClient; + +import reactor.core.publisher.Mono; + +@RestController +public class ClientRestController { + + private static final String RESOURCE_URI = "http://localhost:8084/retrieve-resource"; + + @Autowired + WebClient webClient; + + @Autowired + @Qualifier("otherWebClient") + WebClient otherWebClient; + + @GetMapping("/auth-code") + Mono useOauthWithAuthCode() { + Mono retrievedResource = webClient.get() + .uri(RESOURCE_URI) + .retrieve() + .bodyToMono(String.class); + return retrievedResource.map(string -> "We retrieved the following resource using Oauth: " + string); + } + + @GetMapping("/auth-code-no-client") + Mono useOauthWithNoClient() { + // This call will fail, since we don't have the client properly set for this webClient + Mono retrievedResource = otherWebClient.get() + .uri(RESOURCE_URI) + .retrieve() + .bodyToMono(String.class); + return retrievedResource.map(string -> "We retrieved the following resource using Oauth: " + string); + } + + @GetMapping("/auth-code-annotated") + Mono useOauthWithAuthCodeAndAnnotation(@RegisteredOAuth2AuthorizedClient("bael") OAuth2AuthorizedClient authorizedClient) { + Mono retrievedResource = otherWebClient.get() + .uri(RESOURCE_URI) + .attributes(oauth2AuthorizedClient(authorizedClient)) + .retrieve() + .bodyToMono(String.class); + return retrievedResource.map(string -> "We retrieved the following resource using Oauth: " + string + ". Principal associated: " + authorizedClient.getPrincipalName() + ". Token will expire at: " + authorizedClient.getAccessToken() + .getExpiresAt()); + } + + @GetMapping("/auth-code-explicit-client") + Mono useOauthWithExpicitClient() { + Mono retrievedResource = otherWebClient.get() + .uri(RESOURCE_URI) + .attributes(clientRegistrationId("bael")) + .retrieve() + .bodyToMono(String.class); + return retrievedResource.map(string -> "We retrieved the following resource using Oauth: " + string); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java new file mode 100644 index 0000000000..d1b9f7f744 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java @@ -0,0 +1,26 @@ +package com.baeldung.webclient.clientcredentials; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * + * Note: This app is configured to use the authorization service and the resource service located in module spring-5-security-oauth + * + * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using credentials handled by the auth server (bael-user/bael-password) + * + * @author rozagerardo + * + */ +@PropertySource("classpath:webclient-client-credentials-oauth-application.properties") +@EnableScheduling +@SpringBootApplication +public class ClientCredentialsOauthApplication { + + public static void main(String[] args) { + SpringApplication.run(ClientCredentialsOauthApplication.class, args); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/configuration/WebClientConfig.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/configuration/WebClientConfig.java new file mode 100644 index 0000000000..8ffc92b4cd --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/configuration/WebClientConfig.java @@ -0,0 +1,22 @@ +package com.baeldung.webclient.clientcredentials.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository; +import org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction; +import org.springframework.security.oauth2.client.web.server.UnAuthenticatedServerOAuth2AuthorizedClientRepository; +import org.springframework.web.reactive.function.client.WebClient; + +@Configuration +public class WebClientConfig { + + @Bean + WebClient webClient(ReactiveClientRegistrationRepository clientRegistrations) { + ServerOAuth2AuthorizedClientExchangeFilterFunction oauth = new ServerOAuth2AuthorizedClientExchangeFilterFunction(clientRegistrations, new UnAuthenticatedServerOAuth2AuthorizedClientRepository()); + oauth.setDefaultClientRegistrationId("bael"); + return WebClient.builder() + .filter(oauth) + .build(); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java new file mode 100644 index 0000000000..dc38ce3f9e --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java @@ -0,0 +1,33 @@ +package com.baeldung.webclient.clientcredentials.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; +import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.client.WebClient; + +@Component +public class WebClientChonJob { + + Logger logger = LoggerFactory.getLogger(WebClientChonJob.class); + + private static final String RESOURCE_URI = "http://localhost:8084/retrieve-resource"; + + @Autowired + private WebClient webClient; + + @Scheduled(fixedRate = 1000) + public void logResourceServiceResponse() { + + webClient.get() + .uri(RESOURCE_URI) + .retrieve() + .bodyToMono(String.class) + .map(string -> "We retrieved the following resource using Client Credentials Grant Type: " + string) + .subscribe(logger::info); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java new file mode 100644 index 0000000000..c2762ad559 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java @@ -0,0 +1,23 @@ +package com.baeldung.webclient.manualrequest; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; + +/** + * + * Note: This app is configured to use the authorization service and the resource service located in module spring-5-security-oauth + * + * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using user credentials (bael-user/bael-password) and client configurations (bael-client-id/bael-secret) handled by the auth server + * + * @author rozagerardo + * + */ +@SpringBootApplication +public class ManualRequestApplication { + + public static void main(String[] args) { + SpringApplication.run(ManualRequestApplication.class, args); + } + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebClientConfig.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebClientConfig.java new file mode 100644 index 0000000000..51fc60821a --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebClientConfig.java @@ -0,0 +1,16 @@ +package com.baeldung.webclient.manualrequest.configure; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.client.WebClient; + +@Configuration +public class WebClientConfig { + + @Bean + public WebClient configureWebClient() { + return WebClient.builder() + .build(); + }; + +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebSecurityConfig.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebSecurityConfig.java new file mode 100644 index 0000000000..1753681db8 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebSecurityConfig.java @@ -0,0 +1,17 @@ +package com.baeldung.webclient.manualrequest.configure; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.web.server.SecurityWebFilterChain; + +@Configuration +public class WebSecurityConfig { + @Bean + public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { + http.authorizeExchange() + .anyExchange() + .permitAll(); + return http.build(); + } +} diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java new file mode 100644 index 0000000000..9f9d6d3167 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java @@ -0,0 +1,57 @@ +package com.baeldung.webclient.manualrequest.web; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames; +import org.springframework.util.Base64Utils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.WebClient; + +import com.fasterxml.jackson.databind.JsonNode; +import com.nimbusds.oauth2.sdk.GrantType; + +import reactor.core.publisher.Mono; + +@RestController +public class ManualOauthRequestController { + + private static Logger logger = LoggerFactory.getLogger(ManualOauthRequestController.class); + + private static final String TOKEN_ENDPOINT = "localhost:8085/oauth/token"; + private static final String RESOURCE_ENDPOINT = "localhost:8084/retrieve-resource"; + private static final String CLIENT_ID = "bael-client-id"; + private static final String CLIENT_SECRET = "bael-secret"; + + @Autowired + WebClient client; + + @GetMapping("/manual-request-oauth") + public Mono obtainSecuredResource() { + logger.info("Creating web client..."); + Mono resource = client.post() + .uri(TOKEN_ENDPOINT) + .header(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils.encodeToString((CLIENT_ID + ":" + CLIENT_SECRET).getBytes())) + .body(BodyInserters.fromFormData(OAuth2ParameterNames.GRANT_TYPE, GrantType.CLIENT_CREDENTIALS.getValue())) + .retrieve() + .bodyToMono(JsonNode.class) + .flatMap(tokenResponse -> { + String accessTokenValue = tokenResponse.get("access_token") + .textValue(); + logger.info("Retrieved the following access token: {}", accessTokenValue); + return client.get() + .uri(RESOURCE_ENDPOINT) + .headers(h -> h.setBearerAuth(accessTokenValue)) + .retrieve() + .bodyToMono(String.class); + }); + logger.info("non-blocking Oauth calls registered..."); + return resource.map(res -> "Retrieved the resource using a manual approach: " + res); + + } + +} diff --git a/spring-5-reactive-oauth/src/main/resources/application.yml b/spring-5-reactive-oauth/src/main/resources/application.yml index e35e19b344..bec62fdd33 100644 --- a/spring-5-reactive-oauth/src/main/resources/application.yml +++ b/spring-5-reactive-oauth/src/main/resources/application.yml @@ -1,20 +1,3 @@ -spring: - security: - oauth2: - client: - registration: - google: - client-id: YOUR_APP_CLIENT_ID - client-secret: YOUR_APP_CLIENT_SECRET - custom: - client-id: fooClientIdPassword - client-secret: secret - scopes: read,foo - authorization-grant-type: authorization_code - redirect-uri-template: http://localhost:8080/login/oauth2/code/custom - provider: - custom: - authorization-uri: http://localhost:8081/spring-security-oauth-server/oauth/authorize - token-uri: http://localhost:8081/spring-security-oauth-server/oauth/token - user-info-uri: http://localhost:8088/spring-security-oauth-resource/users/extra - user-name-attribute: user_name \ No newline at end of file +logging: + level: + root: DEBUG \ No newline at end of file diff --git a/spring-5-reactive-oauth/src/main/resources/default-application.yml b/spring-5-reactive-oauth/src/main/resources/default-application.yml new file mode 100644 index 0000000000..e35e19b344 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/resources/default-application.yml @@ -0,0 +1,20 @@ +spring: + security: + oauth2: + client: + registration: + google: + client-id: YOUR_APP_CLIENT_ID + client-secret: YOUR_APP_CLIENT_SECRET + custom: + client-id: fooClientIdPassword + client-secret: secret + scopes: read,foo + authorization-grant-type: authorization_code + redirect-uri-template: http://localhost:8080/login/oauth2/code/custom + provider: + custom: + authorization-uri: http://localhost:8081/spring-security-oauth-server/oauth/authorize + token-uri: http://localhost:8081/spring-security-oauth-server/oauth/token + user-info-uri: http://localhost:8088/spring-security-oauth-resource/users/extra + user-name-attribute: user_name \ No newline at end of file diff --git a/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties b/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties new file mode 100644 index 0000000000..612777a06d --- /dev/null +++ b/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties @@ -0,0 +1,10 @@ +spring.security.oauth2.client.registration.bael.client-name=bael +spring.security.oauth2.client.registration.bael.client-id=bael-client-id +spring.security.oauth2.client.registration.bael.client-secret=bael-secret +spring.security.oauth2.client.registration.bael.authorization-grant-type=authorization_code +spring.security.oauth2.client.registration.bael.redirect-uri=http://localhost:8080/authorize/oauth2/code/bael + +spring.security.oauth2.client.provider.bael.token-uri=http://localhost:8085/oauth/token +spring.security.oauth2.client.provider.bael.authorization-uri=http://localhost:8085/oauth/authorize + +spring.security.user.password=pass diff --git a/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties b/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties new file mode 100644 index 0000000000..edd5b80b13 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties @@ -0,0 +1,10 @@ +spring.security.oauth2.client.registration.bael.client-name=bael +spring.security.oauth2.client.registration.bael.client-id=bael-client-id +spring.security.oauth2.client.registration.bael.client-secret=bael-secret +spring.security.oauth2.client.registration.bael.authorization-grant-type=authorization_code +spring.security.oauth2.client.registration.bael.redirect-uri=http://localhost:8080/login/oauth2/code/bael + +spring.security.oauth2.client.provider.bael.token-uri=http://localhost:8085/oauth/token +spring.security.oauth2.client.provider.bael.authorization-uri=http://localhost:8085/oauth/authorize +spring.security.oauth2.client.provider.bael.user-info-uri=http://localhost:8084/user +spring.security.oauth2.client.provider.bael.user-name-attribute=name diff --git a/spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties b/spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties new file mode 100644 index 0000000000..f82f74ec48 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties @@ -0,0 +1,4 @@ +spring.security.oauth2.client.registration.bael.authorization-grant-type=client_credentials +spring.security.oauth2.client.registration.bael.client-id=bael-client-id +spring.security.oauth2.client.registration.bael.client-secret=bael-secret +spring.security.oauth2.client.provider.bael.token-uri=http://localhost:8085/oauth/token diff --git a/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java new file mode 100644 index 0000000000..e31815c3f8 --- /dev/null +++ b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java @@ -0,0 +1,52 @@ +package com.baeldung.webclient.clientcredentials; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Collection; +import java.util.stream.Collectors; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.webclient.clientcredentials.service.WebClientChonJob; +import com.baeldung.webclient.utils.ListAppender; + +import ch.qos.logback.classic.spi.ILoggingEvent; + +/** + * + * Note: this Live test requires the Authorization Service and the Resource service located in the spring-5-security-oauth module + * + * @author ger + * + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = { ClientCredentialsOauthApplication.class }) +public class OAuth2ClientCredentialsLiveTest { + + @Autowired + WebClientChonJob service; + + @Before + public void clearLogList() { + ListAppender.clearEventList(); + } + + @Test + public void givenFooWithNullId_whenProcessFoo_thenLogsWithDebugTrace() throws Exception { + service.logResourceServiceResponse(); + + Thread.sleep(3000); + + Collection allLoggedEntries = ListAppender.getEvents() + .stream() + .map(ILoggingEvent::getFormattedMessage) + .collect(Collectors.toList()); + assertThat(allLoggedEntries).anyMatch(entry -> entry.contains("We retrieved the following resource using Client Credentials Grant Type: This is the resource!")); + } + +} diff --git a/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java new file mode 100644 index 0000000000..94aa580f0a --- /dev/null +++ b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java @@ -0,0 +1,43 @@ +package com.baeldung.webclient.manualrequest; + +import org.junit.Before; +import org.junit.Test; +import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.test.web.reactive.server.WebTestClient.ResponseSpec; + +/** + * + * Note: this Live test requires not only the corresponding application running, + * but also the Authorization Service and the Resource service located in the spring-5-security-oauth module. + * + * + * @author ger + * + */ +public class OAuth2ManualRequestLiveTest { + + private static final String BASE_URL = "http://localhost:8080"; + private static final String MANUAL_REQUEST_URI = "/manual-request-oauth"; + + private static WebTestClient client; + + @Before + public void setup() { + client = WebTestClient.bindToServer() + .baseUrl(BASE_URL) + .build(); + } + + @Test + public void whenRequestingDebugHookOn_thenObtainExpectedMessage() { + ResponseSpec response = client.get() + .uri(MANUAL_REQUEST_URI) + .exchange(); + + response.expectStatus() + .isOk() + .expectBody(String.class) + .isEqualTo("Retrieved the resource using a manual approach: This is the resource!"); + } + +} diff --git a/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/utils/ListAppender.java b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/utils/ListAppender.java new file mode 100644 index 0000000000..6f8fbe004a --- /dev/null +++ b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/utils/ListAppender.java @@ -0,0 +1,25 @@ +package com.baeldung.webclient.utils; + +import java.util.ArrayList; +import java.util.List; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.AppenderBase; + +public class ListAppender extends AppenderBase { + + static private List events = new ArrayList<>(); + + @Override + protected void append(ILoggingEvent eventObject) { + events.add(eventObject); + } + + public static List getEvents() { + return events; + } + + public static void clearEventList() { + events.clear(); + } +} \ No newline at end of file diff --git a/spring-5-reactive-oauth/src/test/resources/logback-test.xml b/spring-5-reactive-oauth/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..891c54bfd3 --- /dev/null +++ b/spring-5-reactive-oauth/src/test/resources/logback-test.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java b/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java index 557c23b368..1478b03d2e 100644 --- a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java +++ b/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java @@ -2,7 +2,9 @@ package com.baeldung.oauth2; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; +@PropertySource("classpath:default-application.properties") @SpringBootApplication public class SpringOAuthApplication { diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java b/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java index 6ab4d525bf..174e5b0fdf 100644 --- a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java +++ b/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java @@ -3,10 +3,12 @@ package com.baeldung.oauth2extractors; import org.apache.logging.log4j.util.Strings; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.AbstractEnvironment; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +@PropertySource("classpath:default-application.properties") @SpringBootApplication @Controller public class ExtractorsApplication { diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/AuthorizationServerApplication.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/AuthorizationServerApplication.java new file mode 100644 index 0000000000..d72704386c --- /dev/null +++ b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/AuthorizationServerApplication.java @@ -0,0 +1,17 @@ +package com.baeldung.webclient.authorizationserver; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; +import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; + +@EnableAuthorizationServer +@PropertySource("classpath:webclient-authorization-application.properties") +@SpringBootApplication +public class AuthorizationServerApplication { + + public static void main(String[] args) { + SpringApplication.run(AuthorizationServerApplication.class, args); + } + +} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/configuration/WebSecurityConfig.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/configuration/WebSecurityConfig.java new file mode 100644 index 0000000000..5dd15f1b8c --- /dev/null +++ b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/configuration/WebSecurityConfig.java @@ -0,0 +1,26 @@ +package com.baeldung.webclient.authorizationserver.configuration; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@EnableWebSecurity +@Configuration +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests() + .antMatchers("/login", "/user") + .permitAll() + .and() + .authorizeRequests() + .anyRequest() + .authenticated() + .and() + .formLogin() + .and() + .httpBasic(); + } +} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/ResourceServerApplication.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/ResourceServerApplication.java new file mode 100644 index 0000000000..50ad293ef8 --- /dev/null +++ b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/ResourceServerApplication.java @@ -0,0 +1,17 @@ +package com.baeldung.webclient.resourceserver; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; +import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; + +@EnableResourceServer +@PropertySource("webclient-resources-application.properties") +@SpringBootApplication +public class ResourceServerApplication { + + public static void main(String[] args) { + SpringApplication.run(ResourceServerApplication.class, args); + } + +} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/configuration/AuthorizationConfigs.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/configuration/AuthorizationConfigs.java new file mode 100644 index 0000000000..5aea1983db --- /dev/null +++ b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/configuration/AuthorizationConfigs.java @@ -0,0 +1,29 @@ +package com.baeldung.webclient.resourceserver.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.oauth2.provider.token.RemoteTokenServices; +import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices; + +@Configuration +public class AuthorizationConfigs { + + @Value("${oauth.authserver.client-id}") + String clientId; + + @Value("${oauth.authserver.client-secret}") + String clientSecret; + + @Value("${oauth.authserver.check-token-endpoint}") + String checkTokenEndpoint; + + @Bean + public ResourceServerTokenServices tokenSvc() { + RemoteTokenServices remoteService = new RemoteTokenServices(); + remoteService.setCheckTokenEndpointUrl(checkTokenEndpoint); + remoteService.setClientId(clientId); + remoteService.setClientSecret(clientSecret); + return remoteService; + } +} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/web/ResourceRestController.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/web/ResourceRestController.java new file mode 100644 index 0000000000..aef0fb4d7d --- /dev/null +++ b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/web/ResourceRestController.java @@ -0,0 +1,23 @@ +package com.baeldung.webclient.resourceserver.web; + +import java.security.Principal; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ResourceRestController { + + @GetMapping("/retrieve-resource") + public String retrieveResource() { + return "This is the resource!"; + } + + @GetMapping("/user") + @ResponseBody + public Principal user(Principal user) { + return user; + } + +} diff --git a/spring-5-security-oauth/src/main/resources/application.properties b/spring-5-security-oauth/src/main/resources/application.properties index 5912b0f755..c84e745918 100644 --- a/spring-5-security-oauth/src/main/resources/application.properties +++ b/spring-5-security-oauth/src/main/resources/application.properties @@ -1,5 +1,3 @@ -server.port=8081 - logging.level.root=INFO logging.level.com.baeldung.dsl.ClientErrorLoggingFilter=DEBUG \ No newline at end of file diff --git a/spring-5-security-oauth/src/main/resources/default-application.properties b/spring-5-security-oauth/src/main/resources/default-application.properties new file mode 100644 index 0000000000..bafddced85 --- /dev/null +++ b/spring-5-security-oauth/src/main/resources/default-application.properties @@ -0,0 +1 @@ +server.port=8081 \ No newline at end of file diff --git a/spring-5-security-oauth/src/main/resources/webclient-authorization-application.properties b/spring-5-security-oauth/src/main/resources/webclient-authorization-application.properties new file mode 100644 index 0000000000..9531045359 --- /dev/null +++ b/spring-5-security-oauth/src/main/resources/webclient-authorization-application.properties @@ -0,0 +1,13 @@ +server.port=8085 + +security.oauth2.client.client-id=bael-client-id +security.oauth2.client.client-secret=bael-secret +security.oauth2.client.scope=read,write + +security.oauth2.authorization.check-token-access=isAuthenticated() + +spring.security.user.name=bael-user +spring.security.user.password=bael-password + +security.oauth2.client.registered-redirect-uri=http://localhost:8080/login/oauth2/code/bael, http://localhost:8080/authorize/oauth2/code/bael +security.oauth2.client.use-current-uri=false \ No newline at end of file diff --git a/spring-5-security-oauth/src/main/resources/webclient-resources-application.properties b/spring-5-security-oauth/src/main/resources/webclient-resources-application.properties new file mode 100644 index 0000000000..1cfb9ca12d --- /dev/null +++ b/spring-5-security-oauth/src/main/resources/webclient-resources-application.properties @@ -0,0 +1,6 @@ +server.port=8084 + +#spring.security.oauth2.resourceserver.jwt.issuer-uri=localhost:8085 +oauth.authserver.client-id=bael-client-id +oauth.authserver.client-secret=bael-secret +oauth.authserver.check-token-endpoint=http://localhost:8085/oauth/check_token From eacc84a450dad6e85354ea7e3acf72e902dcae19 Mon Sep 17 00:00:00 2001 From: Varun Jain Date: Thu, 3 Jan 2019 08:08:25 +0530 Subject: [PATCH 103/441] BAEL-2536-added-unit-tests-for-panagram --- .../com/baeldung/string/PanagramUnitTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 java-strings/src/test/java/com/baeldung/string/PanagramUnitTest.java diff --git a/java-strings/src/test/java/com/baeldung/string/PanagramUnitTest.java b/java-strings/src/test/java/com/baeldung/string/PanagramUnitTest.java new file mode 100644 index 0000000000..81d46956e2 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/PanagramUnitTest.java @@ -0,0 +1,44 @@ +package com.baeldung.string; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + + +public class PanagramUnitTest { + + @Test + public void givenValidString_isPanagram_shouldReturnSuccess() { + String input = "Two driven jocks help fax my big quiz"; + assertTrue(Panagram.isPanagram(input)); + assertTrue(Panagram.isPanagramWithStreams(input)); + } + + @Test + public void givenNullString_isPanagram_shouldReturnFailure() { + String input = null; + assertFalse(Panagram.isPanagram(input)); + assertFalse(Panagram.isPanagramWithStreams(input)); + assertFalse(Panagram.isPerfectPanagram(input)); + } + + @Test + public void givenPerfectPanagramString_isPerfectPanagram_shouldReturnSuccess() { + String input = "abcdefghijklmNoPqrStuVwxyz"; + assertTrue(Panagram.isPerfectPanagram(input)); + } + + @Test + public void givenNonPanagramString_isPanagram_shouldReturnFailure() { + String input = "invalid panagram"; + assertFalse(Panagram.isPanagram(input)); + assertFalse(Panagram.isPanagramWithStreams(input)); + } + + @Test + public void givenPanagram_isPerfectPanagram_shouldReturnFailure() { + String input = "Two driven jocks help fax my big quiz"; + assertFalse(Panagram.isPerfectPanagram(input)); + } + +} From 34b90a33aac7df4feae5867355d72bb54ed4a045 Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Thu, 3 Jan 2019 14:15:43 +0100 Subject: [PATCH 104/441] BAEL-2483 --- .../java/com/baeldung/annotation/MyBean.java | 26 +++++++++++++++++++ .../com/baeldung/annotation/TestBean.java | 8 ++++++ 2 files changed, 34 insertions(+) create mode 100644 spring-core/src/main/java/com/baeldung/annotation/MyBean.java create mode 100644 spring-core/src/main/java/com/baeldung/annotation/TestBean.java diff --git a/spring-core/src/main/java/com/baeldung/annotation/MyBean.java b/spring-core/src/main/java/com/baeldung/annotation/MyBean.java new file mode 100644 index 0000000000..9a1fd3beec --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/annotation/MyBean.java @@ -0,0 +1,26 @@ +package com.baeldung.annotation; + +import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + +@Component +public class MyBean { + + private final TestBean testBean; + + public MyBean(TestBean testBean) { + this.testBean = testBean; + System.out.println("Hello from constructor"); + } + + @PostConstruct + private void postConstruct() { + System.out.println("Hello from @PostConstruct method"); + } + + @PreDestroy + public void preDestroy() { + System.out.println("Bean is being destroyed"); + } +} \ No newline at end of file diff --git a/spring-core/src/main/java/com/baeldung/annotation/TestBean.java b/spring-core/src/main/java/com/baeldung/annotation/TestBean.java new file mode 100644 index 0000000000..0539e10751 --- /dev/null +++ b/spring-core/src/main/java/com/baeldung/annotation/TestBean.java @@ -0,0 +1,8 @@ +package com.baeldung.annotation; + +import org.springframework.stereotype.Component; + +@Component +public class TestBean { + +} \ No newline at end of file From bdcc961542282c5411d2ad7e6196dccccb9e075f Mon Sep 17 00:00:00 2001 From: ramansahasi Date: Thu, 3 Jan 2019 20:19:51 +0530 Subject: [PATCH 105/441] BAEL-2392_Java_String_interview_questions second commit (#6064) --- .../string/interview/LocaleUnitTest.java | 19 +++++++++++ .../interview/StringAnagramUnitTest.java | 29 +++++++++++++++++ .../interview/StringChangeCaseUnitTest.java | 20 ++++++++++++ .../StringCountOccurrencesUnitTest.java | 28 ++++++++++++++++ .../interview/StringFormatUnitTest.java | 14 ++++++++ .../interview/StringInternUnitTest.java | 17 ++++++++++ .../interview/StringJoinerUnitTest.java | 18 +++++++++++ .../interview/StringPalindromeUnitTest.java | 29 +++++++++++++++++ .../interview/StringReverseUnitTest.java | 13 ++++++++ .../string/interview/StringSplitUnitTest.java | 32 +++++++++++++++++++ .../interview/StringToByteArrayUnitTest.java | 24 ++++++++++++++ .../interview/StringToCharArrayUnitTest.java | 17 ++++++++++ .../interview/StringToIntegerUnitTest.java | 15 +++++++++ 13 files changed, 275 insertions(+) create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/LocaleUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringAnagramUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringChangeCaseUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringCountOccurrencesUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringFormatUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringInternUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringJoinerUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringPalindromeUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringReverseUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringSplitUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringToByteArrayUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringToCharArrayUnitTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/interview/StringToIntegerUnitTest.java diff --git a/java-strings/src/test/java/com/baeldung/string/interview/LocaleUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/LocaleUnitTest.java new file mode 100644 index 0000000000..1d221056fd --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/LocaleUnitTest.java @@ -0,0 +1,19 @@ +package com.baeldung.string.interview; + +import java.math.BigDecimal; +import java.text.NumberFormat; +import java.util.Locale; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class LocaleUnitTest { + @Test + public void whenUsingLocal_thenCorrectResultsForDifferentLocale() { + Locale usLocale = Locale.US; + BigDecimal number = new BigDecimal(102_300.456d); + + NumberFormat usNumberFormat = NumberFormat.getCurrencyInstance(usLocale); + assertEquals(usNumberFormat.format(number), "$102,300.46"); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringAnagramUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringAnagramUnitTest.java new file mode 100644 index 0000000000..aadfade737 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringAnagramUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.string.interview; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Arrays; + +import org.junit.Test; + +public class StringAnagramUnitTest { + public boolean isAnagram(String s1, String s2) { + if(s1.length() != s2.length()) + return false; + + char[] arr1 = s1.toCharArray(); + char[] arr2 = s2.toCharArray(); + + Arrays.sort(arr1); + Arrays.sort(arr2); + + return Arrays.equals(arr1, arr2); + } + + @Test + public void whenTestAnagrams_thenTestingCorrectly() { + assertThat(isAnagram("car", "arc")).isTrue(); + assertThat(isAnagram("west", "stew")).isTrue(); + assertThat(isAnagram("west", "east")).isFalse(); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringChangeCaseUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringChangeCaseUnitTest.java new file mode 100644 index 0000000000..2c7ec500fe --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringChangeCaseUnitTest.java @@ -0,0 +1,20 @@ +package com.baeldung.string.interview; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class StringChangeCaseUnitTest { + @Test + public void givenString_whenChangingToUppercase_thenCaseChanged() { + String s = "Welcome to Baeldung!"; + assertEquals("WELCOME TO BAELDUNG!", s.toUpperCase()); + } + + + @Test + public void givenString_whenChangingToLowerrcase_thenCaseChanged() { + String s = "Welcome to Baeldung!"; + assertEquals("welcome to baeldung!", s.toLowerCase()); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringCountOccurrencesUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringCountOccurrencesUnitTest.java new file mode 100644 index 0000000000..6c17643ac8 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringCountOccurrencesUnitTest.java @@ -0,0 +1,28 @@ +package com.baeldung.string.interview; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class StringCountOccurrencesUnitTest { + public int countOccurrences(String s, char c) { + int count = 0; + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) == c) { + count++; + } + } + return count; + } + + @Test + public void givenString_whenCountingFrequencyOfChar_thenCountCorrect() { + assertEquals(3, countOccurrences("united states", 't')); + } + + public void givenString_whenUsingJava8_thenCountingOfCharCorrect() { + String str = "united states"; + long count = str.chars().filter(ch -> (char)ch == 't').count(); + assertEquals(3, count); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringFormatUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringFormatUnitTest.java new file mode 100644 index 0000000000..787017791c --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringFormatUnitTest.java @@ -0,0 +1,14 @@ +package com.baeldung.string.interview; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class StringFormatUnitTest { + @Test + public void givenString_whenUsingStringFormat_thenStringFormatted() { + String title = "Baeldung"; + String formatted = String.format("Title is %s", title); + assertEquals(formatted, "Title is Baeldung"); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringInternUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringInternUnitTest.java new file mode 100644 index 0000000000..c5bffb7573 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringInternUnitTest.java @@ -0,0 +1,17 @@ +package com.baeldung.string.interview; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class StringInternUnitTest { + @Test + public void whenCallingStringIntern_thenStringsInterned() { + String s1 = "Baeldung"; + String s2 = new String("Baeldung"); + String s3 = new String("Baeldung").intern(); + + assertThat(s1 == s2).isFalse(); + assertThat(s1 == s3).isTrue(); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringJoinerUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringJoinerUnitTest.java new file mode 100644 index 0000000000..d44c7478e4 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringJoinerUnitTest.java @@ -0,0 +1,18 @@ +package com.baeldung.string.interview; + +import java.util.StringJoiner; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class StringJoinerUnitTest { + @Test + public void whenUsingStringJoiner_thenStringsJoined() { + StringJoiner joiner = new StringJoiner(",", "[", "]"); + joiner.add("Red") + .add("Green") + .add("Blue"); + + assertEquals(joiner.toString(), "[Red,Green,Blue]"); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringPalindromeUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringPalindromeUnitTest.java new file mode 100644 index 0000000000..79ed14cd99 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringPalindromeUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.string.interview; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class StringPalindromeUnitTest { + + public boolean isPalindrome(String text) { + int forward = 0; + int backward = text.length() - 1; + while (backward > forward) { + char forwardChar = text.charAt(forward++); + char backwardChar = text.charAt(backward--); + if (forwardChar != backwardChar) + return false; + } + return true; + } + + @Test + public void givenIsPalindromeMethod_whenCheckingString_thenFindIfPalindrome() { + assertThat(isPalindrome("madam")).isTrue(); + assertThat(isPalindrome("radar")).isTrue(); + assertThat(isPalindrome("level")).isTrue(); + + assertThat(isPalindrome("baeldung")).isFalse(); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringReverseUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringReverseUnitTest.java new file mode 100644 index 0000000000..bb9b45dc97 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringReverseUnitTest.java @@ -0,0 +1,13 @@ +package com.baeldung.string.interview; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class StringReverseUnitTest { + @Test + public void whenUsingInbuildMethods_thenStringReversed() { + String reversed = new StringBuilder("baeldung").reverse().toString(); + assertEquals("gnudleab", reversed); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringSplitUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringSplitUnitTest.java new file mode 100644 index 0000000000..e1cea62462 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringSplitUnitTest.java @@ -0,0 +1,32 @@ +package com.baeldung.string.interview; + +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; +import static org.junit.Assert.assertArrayEquals; + +public class StringSplitUnitTest { + @Test + public void givenCoreJava_whenSplittingStrings_thenSplitted() { + String expected[] = { + "john", + "peter", + "mary" + }; + + String[] splitted = "john,peter,mary".split(","); + assertArrayEquals( expected, splitted ); + } + + @Test + public void givenApacheCommons_whenSplittingStrings_thenSplitted() { + String expected[] = { + "john", + "peter", + "mary" + }; + String[] splitted = StringUtils.split("john peter mary"); + assertArrayEquals( expected, splitted ); + } + + +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringToByteArrayUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringToByteArrayUnitTest.java new file mode 100644 index 0000000000..aee4eedcd6 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringToByteArrayUnitTest.java @@ -0,0 +1,24 @@ +package com.baeldung.string.interview; + +import static org.junit.Assert.assertArrayEquals; + +import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; + +import org.junit.Test; + +public class StringToByteArrayUnitTest { + @Test + public void whenGetBytes_thenCorrect() throws UnsupportedEncodingException { + byte[] byteArray1 = "abcd".getBytes(); + byte[] byteArray2 = "efgh".getBytes(StandardCharsets.US_ASCII); + byte[] byteArray3 = "ijkl".getBytes("UTF-8"); + byte[] expected1 = new byte[] { 97, 98, 99, 100 }; + byte[] expected2 = new byte[] { 101, 102, 103, 104 }; + byte[] expected3 = new byte[] { 105, 106, 107, 108 }; + + assertArrayEquals(expected1, byteArray1); + assertArrayEquals(expected2, byteArray2); + assertArrayEquals(expected3, byteArray3); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringToCharArrayUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringToCharArrayUnitTest.java new file mode 100644 index 0000000000..1322d0fa82 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringToCharArrayUnitTest.java @@ -0,0 +1,17 @@ +package com.baeldung.string.interview; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; + +import org.junit.Test; + +public class StringToCharArrayUnitTest { + @Test + public void whenConvertingStringToCharArray_thenConversionSuccessful() { + String beforeConvStr = "hello"; + char[] afterConvCharArr = { 'h', 'e', 'l', 'l', 'o' }; + + assertEquals(Arrays.equals(beforeConvStr.toCharArray(), afterConvCharArr), true); + } +} diff --git a/java-strings/src/test/java/com/baeldung/string/interview/StringToIntegerUnitTest.java b/java-strings/src/test/java/com/baeldung/string/interview/StringToIntegerUnitTest.java new file mode 100644 index 0000000000..a905438a84 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/interview/StringToIntegerUnitTest.java @@ -0,0 +1,15 @@ +package com.baeldung.string.interview; + +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class StringToIntegerUnitTest { + @Test + public void givenString_whenParsingInt_shouldConvertToInt() { + String givenString = "42"; + + int result = Integer.parseInt(givenString); + + assertThat(result).isEqualTo(42); + } +} From 4eb3f2943038f3b0635e8267b7e9a666af6281d9 Mon Sep 17 00:00:00 2001 From: Varun Jain Date: Thu, 3 Jan 2019 22:42:26 +0530 Subject: [PATCH 106/441] BAEL-2536-addressed review comments --- .../string/{Panagram.java => Pangram.java} | 21 ++++++++++--------- ...gramUnitTest.java => PangramUnitTest.java} | 20 +++++++++--------- 2 files changed, 21 insertions(+), 20 deletions(-) rename java-strings/src/main/java/com/baeldung/string/{Panagram.java => Pangram.java} (71%) rename java-strings/src/test/java/com/baeldung/string/{PanagramUnitTest.java => PangramUnitTest.java} (61%) diff --git a/java-strings/src/main/java/com/baeldung/string/Panagram.java b/java-strings/src/main/java/com/baeldung/string/Pangram.java similarity index 71% rename from java-strings/src/main/java/com/baeldung/string/Panagram.java rename to java-strings/src/main/java/com/baeldung/string/Pangram.java index d000b4455e..48e31b2157 100644 --- a/java-strings/src/main/java/com/baeldung/string/Panagram.java +++ b/java-strings/src/main/java/com/baeldung/string/Pangram.java @@ -6,12 +6,13 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -public class Panagram { +public class Pangram { + private static final int ALPHABET_COUNT = 26; public static boolean isPanagram(String str) { if (str == null) return false; - Boolean[] alphabetMarker = new Boolean[26]; + Boolean[] alphabetMarker = new Boolean[ALPHABET_COUNT]; Arrays.fill(alphabetMarker, false); int alphabetIndex = 0; str = str.toUpperCase(); @@ -33,13 +34,13 @@ public class Panagram { return false; // filtered character stream - str = str.toUpperCase(); - Stream filteredCharStream = str.chars() - .filter(item -> ((item >= 'A' && item <= 'Z') || (item >= 'a' && item <= 'z'))) + String strUpper = str.toUpperCase(); + Stream filteredCharStream = strUpper.chars() + .filter(item -> ((item >= 'A' && item <= 'Z'))) .mapToObj(c -> (char) c); Map alphabetMap = filteredCharStream.collect(Collectors.toMap(item -> item, k -> Boolean.TRUE, (p1, p2) -> p1)); - return (alphabetMap.size() == 26); + return (alphabetMap.size() == ALPHABET_COUNT); } public static boolean isPerfectPanagram(String str) { @@ -47,13 +48,13 @@ public class Panagram { return false; // filtered character stream - str = str.toUpperCase(); - Stream filteredCharStream = str.chars() - .filter(item -> ((item >= 'A' && item <= 'Z') || (item >= 'a' && item <= 'z'))) + String strUpper = str.toUpperCase(); + Stream filteredCharStream = strUpper.chars() + .filter(item -> ((item >= 'A' && item <= 'Z'))) .mapToObj(c -> (char) c); Map alphabetFrequencyMap = filteredCharStream.collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); - return (alphabetFrequencyMap.size() == 26 && alphabetFrequencyMap.values() + return (alphabetFrequencyMap.size() == ALPHABET_COUNT && alphabetFrequencyMap.values() .stream() .allMatch(item -> item == 1)); } diff --git a/java-strings/src/test/java/com/baeldung/string/PanagramUnitTest.java b/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java similarity index 61% rename from java-strings/src/test/java/com/baeldung/string/PanagramUnitTest.java rename to java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java index 81d46956e2..150f27d7c0 100644 --- a/java-strings/src/test/java/com/baeldung/string/PanagramUnitTest.java +++ b/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java @@ -5,40 +5,40 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; -public class PanagramUnitTest { +public class PangramUnitTest { @Test public void givenValidString_isPanagram_shouldReturnSuccess() { String input = "Two driven jocks help fax my big quiz"; - assertTrue(Panagram.isPanagram(input)); - assertTrue(Panagram.isPanagramWithStreams(input)); + assertTrue(Pangram.isPanagram(input)); + assertTrue(Pangram.isPanagramWithStreams(input)); } @Test public void givenNullString_isPanagram_shouldReturnFailure() { String input = null; - assertFalse(Panagram.isPanagram(input)); - assertFalse(Panagram.isPanagramWithStreams(input)); - assertFalse(Panagram.isPerfectPanagram(input)); + assertFalse(Pangram.isPanagram(input)); + assertFalse(Pangram.isPanagramWithStreams(input)); + assertFalse(Pangram.isPerfectPanagram(input)); } @Test public void givenPerfectPanagramString_isPerfectPanagram_shouldReturnSuccess() { String input = "abcdefghijklmNoPqrStuVwxyz"; - assertTrue(Panagram.isPerfectPanagram(input)); + assertTrue(Pangram.isPerfectPanagram(input)); } @Test public void givenNonPanagramString_isPanagram_shouldReturnFailure() { String input = "invalid panagram"; - assertFalse(Panagram.isPanagram(input)); - assertFalse(Panagram.isPanagramWithStreams(input)); + assertFalse(Pangram.isPanagram(input)); + assertFalse(Pangram.isPanagramWithStreams(input)); } @Test public void givenPanagram_isPerfectPanagram_shouldReturnFailure() { String input = "Two driven jocks help fax my big quiz"; - assertFalse(Panagram.isPerfectPanagram(input)); + assertFalse(Pangram.isPerfectPanagram(input)); } } From 693da95f44bdd66609acc103824ad49b38f91141 Mon Sep 17 00:00:00 2001 From: Varun Jain Date: Thu, 3 Jan 2019 22:44:52 +0530 Subject: [PATCH 107/441] BAEL-2536-updated Panagram to Pangram --- .../main/java/com/baeldung/string/Pangram.java | 10 +++++----- .../com/baeldung/string/PangramUnitTest.java | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/Pangram.java b/java-strings/src/main/java/com/baeldung/string/Pangram.java index 48e31b2157..8498a7074a 100644 --- a/java-strings/src/main/java/com/baeldung/string/Pangram.java +++ b/java-strings/src/main/java/com/baeldung/string/Pangram.java @@ -9,7 +9,7 @@ import java.util.stream.Stream; public class Pangram { private static final int ALPHABET_COUNT = 26; - public static boolean isPanagram(String str) { + public static boolean isPangram(String str) { if (str == null) return false; Boolean[] alphabetMarker = new Boolean[ALPHABET_COUNT]; @@ -29,10 +29,10 @@ public class Pangram { return true; } - public static boolean isPanagramWithStreams(String str) { + public static boolean isPangramWithStreams(String str) { if (str == null) return false; - + // filtered character stream String strUpper = str.toUpperCase(); Stream filteredCharStream = strUpper.chars() @@ -43,10 +43,10 @@ public class Pangram { return (alphabetMap.size() == ALPHABET_COUNT); } - public static boolean isPerfectPanagram(String str) { + public static boolean isPerfectPangram(String str) { if (str == null) return false; - + // filtered character stream String strUpper = str.toUpperCase(); Stream filteredCharStream = strUpper.chars() diff --git a/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java b/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java index 150f27d7c0..67523a4524 100644 --- a/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java +++ b/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java @@ -10,35 +10,35 @@ public class PangramUnitTest { @Test public void givenValidString_isPanagram_shouldReturnSuccess() { String input = "Two driven jocks help fax my big quiz"; - assertTrue(Pangram.isPanagram(input)); - assertTrue(Pangram.isPanagramWithStreams(input)); + assertTrue(Pangram.isPangram(input)); + assertTrue(Pangram.isPangramWithStreams(input)); } @Test public void givenNullString_isPanagram_shouldReturnFailure() { String input = null; - assertFalse(Pangram.isPanagram(input)); - assertFalse(Pangram.isPanagramWithStreams(input)); - assertFalse(Pangram.isPerfectPanagram(input)); + assertFalse(Pangram.isPangram(input)); + assertFalse(Pangram.isPangramWithStreams(input)); + assertFalse(Pangram.isPerfectPangram(input)); } @Test public void givenPerfectPanagramString_isPerfectPanagram_shouldReturnSuccess() { String input = "abcdefghijklmNoPqrStuVwxyz"; - assertTrue(Pangram.isPerfectPanagram(input)); + assertTrue(Pangram.isPerfectPangram(input)); } @Test public void givenNonPanagramString_isPanagram_shouldReturnFailure() { String input = "invalid panagram"; - assertFalse(Pangram.isPanagram(input)); - assertFalse(Pangram.isPanagramWithStreams(input)); + assertFalse(Pangram.isPangram(input)); + assertFalse(Pangram.isPangramWithStreams(input)); } @Test public void givenPanagram_isPerfectPanagram_shouldReturnFailure() { String input = "Two driven jocks help fax my big quiz"; - assertFalse(Pangram.isPerfectPanagram(input)); + assertFalse(Pangram.isPerfectPangram(input)); } } From cd3f0fcb1f1a4e782a470ad66da197be0a2aab1b Mon Sep 17 00:00:00 2001 From: Dhananjay Singh Date: Fri, 4 Jan 2019 05:10:26 +0530 Subject: [PATCH 108/441] BAEL-2391 Two pointer technique * two pointer technique * Corrected two sum * Changed asserts in unit test --- .../LinkedListFindMiddle.java | 16 ++++++ .../twopointertechnique/MyNode.java | 20 +++++++ .../twopointertechnique/RotateArray.java | 22 ++++++++ .../twopointertechnique/TwoSum.java | 38 +++++++++++++ .../LinkedListFindMiddleUnitTest.java | 37 ++++++++++++ .../RotateArrayUnitTest.java | 26 +++++++++ .../twopointertechnique/TwoSumUnitTest.java | 56 +++++++++++++++++++ 7 files changed, 215 insertions(+) create mode 100644 algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/LinkedListFindMiddle.java create mode 100644 algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/MyNode.java create mode 100644 algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/RotateArray.java create mode 100644 algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/TwoSum.java create mode 100644 algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/LinkedListFindMiddleUnitTest.java create mode 100644 algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/RotateArrayUnitTest.java create mode 100644 algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/TwoSumUnitTest.java diff --git a/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/LinkedListFindMiddle.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/LinkedListFindMiddle.java new file mode 100644 index 0000000000..a7031f4fba --- /dev/null +++ b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/LinkedListFindMiddle.java @@ -0,0 +1,16 @@ +package com.baeldung.algorithms.twopointertechnique; + +public class LinkedListFindMiddle { + + public T findMiddle(MyNode head) { + MyNode slowPointer = head; + MyNode fastPointer = head; + + while (fastPointer.next != null && fastPointer.next.next != null) { + fastPointer = fastPointer.next.next; + slowPointer = slowPointer.next; + } + return slowPointer.data; + } + +} diff --git a/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/MyNode.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/MyNode.java new file mode 100644 index 0000000000..7d93f03ef9 --- /dev/null +++ b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/MyNode.java @@ -0,0 +1,20 @@ +package com.baeldung.algorithms.twopointertechnique; + +public class MyNode { + MyNode next; + E data; + + public MyNode(E value) { + data = value; + next = null; + } + + public MyNode(E value, MyNode n) { + data = value; + next = n; + } + + public void setNext(MyNode n) { + next = n; + } +} diff --git a/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/RotateArray.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/RotateArray.java new file mode 100644 index 0000000000..b4e3698c01 --- /dev/null +++ b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/RotateArray.java @@ -0,0 +1,22 @@ +package com.baeldung.algorithms.twopointertechnique; + +public class RotateArray { + + public void rotate(int[] input, int step) { + step %= input.length; + reverse(input, 0, input.length - 1); + reverse(input, 0, step - 1); + reverse(input, step, input.length - 1); + } + + private void reverse(int[] input, int start, int end) { + while (start < end) { + int temp = input[start]; + input[start] = input[end]; + input[end] = temp; + start++; + end--; + } + } + +} diff --git a/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/TwoSum.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/TwoSum.java new file mode 100644 index 0000000000..14eceaa1bd --- /dev/null +++ b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/twopointertechnique/TwoSum.java @@ -0,0 +1,38 @@ +package com.baeldung.algorithms.twopointertechnique; + +public class TwoSum { + + public boolean twoSum(int[] input, int targetValue) { + + int pointerOne = 0; + int pointerTwo = input.length - 1; + + while (pointerOne < pointerTwo) { + int sum = input[pointerOne] + input[pointerTwo]; + + if (sum == targetValue) { + return true; + } else if (sum < targetValue) { + pointerOne++; + } else { + pointerTwo--; + } + } + + return false; + } + + public boolean twoSumSlow(int[] input, int targetValue) { + + for (int i = 0; i < input.length; i++) { + for (int j = 1; j < input.length; j++) { + if (input[i] + input[j] == targetValue) { + return true; + } + } + } + + return false; + } + +} diff --git a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/LinkedListFindMiddleUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/LinkedListFindMiddleUnitTest.java new file mode 100644 index 0000000000..422a53fa3e --- /dev/null +++ b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/LinkedListFindMiddleUnitTest.java @@ -0,0 +1,37 @@ +package com.baeldung.algorithms.twopointertechnique; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class LinkedListFindMiddleUnitTest { + + LinkedListFindMiddle linkedListFindMiddle = new LinkedListFindMiddle(); + + @Test + public void givenLinkedListOfMyNodes_whenLinkedListFindMiddle_thenCorrect() { + + MyNode head = createNodesList(8); + + assertThat(linkedListFindMiddle.findMiddle(head)).isEqualTo("4"); + + head = createNodesList(9); + + assertThat(linkedListFindMiddle.findMiddle(head)).isEqualTo("5"); + } + + private static MyNode createNodesList(int n) { + + MyNode head = new MyNode("1"); + MyNode current = head; + + for (int i = 2; i <= n; i++) { + MyNode newNode = new MyNode(String.valueOf(i)); + current.setNext(newNode); + current = newNode; + } + + return head; + } + +} diff --git a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/RotateArrayUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/RotateArrayUnitTest.java new file mode 100644 index 0000000000..da227ae751 --- /dev/null +++ b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/RotateArrayUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.algorithms.twopointertechnique; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class RotateArrayUnitTest { + + private RotateArray rotateArray = new RotateArray(); + + private int[] inputArray; + + private int step; + + @Test + public void givenAnArrayOfIntegers_whenRotateKsteps_thenCorrect() { + + inputArray = new int[] { 1, 2, 3, 4, 5, 6, 7 }; + step = 4; + + rotateArray.rotate(inputArray, step); + + assertThat(inputArray).containsExactly(new int[] { 4, 5, 6, 7, 1, 2, 3 }); + } + +} diff --git a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/TwoSumUnitTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/TwoSumUnitTest.java new file mode 100644 index 0000000000..aa76f8e1cf --- /dev/null +++ b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/twopointertechnique/TwoSumUnitTest.java @@ -0,0 +1,56 @@ +package com.baeldung.algorithms.twopointertechnique; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class TwoSumUnitTest { + + private TwoSum twoSum = new TwoSum(); + + private int[] sortedArray; + + private int targetValue; + + @Test + public void givenASortedArrayOfIntegers_whenTwoSumSlow_thenPairExists() { + + sortedArray = new int[] { 0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9 }; + + targetValue = 12; + + assertTrue(twoSum.twoSumSlow(sortedArray, targetValue)); + } + + @Test + public void givenASortedArrayOfIntegers_whenTwoSumSlow_thenPairDoesNotExists() { + + sortedArray = new int[] { 0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9 }; + + targetValue = 20; + + assertFalse(twoSum.twoSumSlow(sortedArray, targetValue)); + } + + @Test + public void givenASortedArrayOfIntegers_whenTwoSum_thenPairExists() { + + sortedArray = new int[] { 0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9 }; + + targetValue = 12; + + assertTrue(twoSum.twoSum(sortedArray, targetValue)); + } + + @Test + public void givenASortedArrayOfIntegers_whenTwoSum_thenPairDoesNotExists() { + + sortedArray = new int[] { 0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9 }; + + targetValue = 20; + + assertFalse(twoSum.twoSum(sortedArray, targetValue)); + } + +} From b62edd2503d91dca0096f7a39379bb03f7cdbbf7 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:16:51 +0530 Subject: [PATCH 109/441] backlink added --- core-kotlin/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin/README.md b/core-kotlin/README.md index 05f07e7e7e..de989ce141 100644 --- a/core-kotlin/README.md +++ b/core-kotlin/README.md @@ -47,3 +47,4 @@ - [Dependency Injection for Kotlin with Injekt](https://www.baeldung.com/kotlin-dependency-injection-with-injekt) - [Implementing a Binary Tree in Kotlin](https://www.baeldung.com/kotlin-binary-tree) - [Generate a Random Alphanumeric String in Kotlin](https://www.baeldung.com/kotlin-random-alphanumeric-string) +- [Kotlin Contracts](https://www.baeldung.com/kotlin-contracts) From 8d3e2c9b0791cc48dc9c5141974d2f792eb16983 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:20:24 +0530 Subject: [PATCH 110/441] backlink added --- core-kotlin/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin/README.md b/core-kotlin/README.md index de989ce141..609a30a1a8 100644 --- a/core-kotlin/README.md +++ b/core-kotlin/README.md @@ -48,3 +48,4 @@ - [Implementing a Binary Tree in Kotlin](https://www.baeldung.com/kotlin-binary-tree) - [Generate a Random Alphanumeric String in Kotlin](https://www.baeldung.com/kotlin-random-alphanumeric-string) - [Kotlin Contracts](https://www.baeldung.com/kotlin-contracts) +- [Operator Overloading in Kotlin](https://www.baeldung.com/kotlin-operator-overloading) From 58ddffc6cb344776aee93a625bf9804068934a7d Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:24:15 +0530 Subject: [PATCH 111/441] backlink-added --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index e973907248..d1ebff1d8a 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -24,3 +24,4 @@ - [Hibernate 5 Bootstrapping API](https://www.baeldung.com/hibernate-5-bootstrapping-api) - [Criteria Queries Using JPA Metamodel](https://www.baeldung.com/hibernate-criteria-queries-metamodel) - [Guide to the Hibernate EntityManager](https://www.baeldung.com/hibernate-entitymanager) +- [Get All Data from a Table with Hibernate](https://www.baeldung.com/hibernate-select-all) From b2d0f6cc832bb310028d755f4dc45f3e8df9fb1c Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:26:20 +0530 Subject: [PATCH 112/441] backlink added --- java-strings/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java-strings/README.md b/java-strings/README.md index fa048dbb5a..a86f6e73c3 100644 --- a/java-strings/README.md +++ b/java-strings/README.md @@ -46,4 +46,5 @@ - [Replace a Character at a Specific Index in a String in Java](https://www.baeldung.com/java-replace-character-at-index) - [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) -- [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) \ No newline at end of file +- [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) +- [Remove Leading and Trailing Characters from a String](https://www.baeldung.com/java-remove-trailing-characters) From 703890941d21986f26504f52eea68484446c960a Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:28:11 +0530 Subject: [PATCH 113/441] back-link added --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 03b77186b0..5aee69d9a9 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -45,3 +45,4 @@ - [Guide to Character Encoding](https://www.baeldung.com/java-char-encoding) - [Graphs in Java](https://www.baeldung.com/java-graphs) - [Console I/O in Java](http://www.baeldung.com/java-console-input-output) +- [Formatting with printf() in Java](https://www.baeldung.com/java-printstream-printf) From 48f3db9713b4797973df4092e1500f1d5d315aed Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:30:45 +0530 Subject: [PATCH 114/441] back-link added --- java-collections-maps/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-collections-maps/README.md b/java-collections-maps/README.md index 0b76ca1959..b4ab270448 100644 --- a/java-collections-maps/README.md +++ b/java-collections-maps/README.md @@ -18,3 +18,4 @@ - [Merging Two Maps with Java 8](https://www.baeldung.com/java-merge-maps) - [How to Check If a Key Exists in a Map](https://www.baeldung.com/java-map-key-exists) - [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps) +- [Immutable Map Implementations in Java](https://www.baeldung.com/java-immutable-maps) From e20cf9ac43a05ae558d68aba8cf031c0cd459264 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:32:02 +0530 Subject: [PATCH 115/441] back-link added --- algorithms-miscellaneous-1/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/algorithms-miscellaneous-1/README.md b/algorithms-miscellaneous-1/README.md index a725bbd141..59765588b0 100644 --- a/algorithms-miscellaneous-1/README.md +++ b/algorithms-miscellaneous-1/README.md @@ -12,4 +12,5 @@ - [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters) - [Find the Middle Element of a Linked List](http://www.baeldung.com/java-linked-list-middle-element) - [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial) -- [Find Substrings That Are Palindromes in Java](https://www.baeldung.com/java-palindrome-substrings) \ No newline at end of file +- [Find Substrings That Are Palindromes in Java](https://www.baeldung.com/java-palindrome-substrings) +- [Find the Longest Substring without Repeating Characters](https://www.baeldung.com/java-longest-substring-without-repeated-characters) From 129630109b387ace7543e0d000d7bdd9d2ff5d7d Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:35:15 +0530 Subject: [PATCH 116/441] back-link added --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index d1ebff1d8a..5f826eec73 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -25,3 +25,4 @@ - [Criteria Queries Using JPA Metamodel](https://www.baeldung.com/hibernate-criteria-queries-metamodel) - [Guide to the Hibernate EntityManager](https://www.baeldung.com/hibernate-entitymanager) - [Get All Data from a Table with Hibernate](https://www.baeldung.com/hibernate-select-all) +- [One-to-One Relationship in JPA](https://www.baeldung.com/jpa-one-to-one) From c91211b4e67841dac61be31bd823f3a7831103a9 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:36:49 +0530 Subject: [PATCH 117/441] back-link added --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index 5f826eec73..fbcf1c94bb 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -26,3 +26,4 @@ - [Guide to the Hibernate EntityManager](https://www.baeldung.com/hibernate-entitymanager) - [Get All Data from a Table with Hibernate](https://www.baeldung.com/hibernate-select-all) - [One-to-One Relationship in JPA](https://www.baeldung.com/jpa-one-to-one) +- [Hibernate Named Query](https://www.baeldung.com/hibernate-named-query) From ca08f5ff9d0c1c2c2502e501aa9d57927e65562d Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:38:08 +0530 Subject: [PATCH 118/441] back-link added --- spring-5-reactive/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5-reactive/README.md b/spring-5-reactive/README.md index 2a4ee017f4..c39bb616f8 100644 --- a/spring-5-reactive/README.md +++ b/spring-5-reactive/README.md @@ -18,3 +18,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) - [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) - [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) From 52269334d931b748fbb0e338cbfdf2394487050f Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:41:30 +0530 Subject: [PATCH 119/441] back-link added --- java-streams/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-streams/README.md b/java-streams/README.md index 2550f08650..33ca2619a8 100644 --- a/java-streams/README.md +++ b/java-streams/README.md @@ -14,3 +14,4 @@ - [Primitive Type Streams in Java 8](http://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) From 45924c75ead9d0add259a42b2ad6927440aaece5 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:42:37 +0530 Subject: [PATCH 120/441] backlink added --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index fbcf1c94bb..512370e853 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -27,3 +27,4 @@ - [Get All Data from a Table with Hibernate](https://www.baeldung.com/hibernate-select-all) - [One-to-One Relationship in JPA](https://www.baeldung.com/jpa-one-to-one) - [Hibernate Named Query](https://www.baeldung.com/hibernate-named-query) +- [Using c3p0 with Hibernate](https://www.baeldung.com/hibernate-c3p0) From c5ddf0178f658ac74cd6e5c6f625722b7f824be9 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:44:10 +0530 Subject: [PATCH 121/441] backlink added --- spring-boot-ops/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-ops/README.md b/spring-boot-ops/README.md index c125c96c36..553b02ebf0 100644 --- a/spring-boot-ops/README.md +++ b/spring-boot-ops/README.md @@ -9,4 +9,4 @@ - [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) - + - [Programmatically Restarting a Spring Boot Application](https://www.baeldung.com/java-restart-spring-boot-app) From 83795f942119caae01148be5417690a0d6d8cc81 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:46:02 +0530 Subject: [PATCH 122/441] Backlink added --- persistence-modules/spring-data-jpa/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-data-jpa/README.md b/persistence-modules/spring-data-jpa/README.md index 3c71600565..976a692699 100644 --- a/persistence-modules/spring-data-jpa/README.md +++ b/persistence-modules/spring-data-jpa/README.md @@ -18,6 +18,7 @@ - [Limiting Query Results with JPA and Spring Data JPA](https://www.baeldung.com/jpa-limit-query-results) - [Sorting Query Results with Spring Data](https://www.baeldung.com/spring-data-sorting) - [INSERT Statement in JPA](https://www.baeldung.com/jpa-insert) +- [Pagination and Sorting using Spring Data JPA](https://www.baeldung.com/spring-data-jpa-pagination-sorting) ### Eclipse Config After importing the project into Eclipse, you may see the following error: From 25eed099f34cb085a08b4a2a027677fb36051b60 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:47:44 +0530 Subject: [PATCH 123/441] backlink added --- core-kotlin/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin/README.md b/core-kotlin/README.md index 609a30a1a8..0ce4b74d91 100644 --- a/core-kotlin/README.md +++ b/core-kotlin/README.md @@ -49,3 +49,4 @@ - [Generate a Random Alphanumeric String in Kotlin](https://www.baeldung.com/kotlin-random-alphanumeric-string) - [Kotlin Contracts](https://www.baeldung.com/kotlin-contracts) - [Operator Overloading in Kotlin](https://www.baeldung.com/kotlin-operator-overloading) +- [Inline Classes in Kotlin](https://www.baeldung.com/kotlin-inline-classes) From 1c120d1886b8399f8ce9c2d287d3b25c09245fa0 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:49:44 +0530 Subject: [PATCH 124/441] backlink added --- core-java-11/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-11/README.md b/core-java-11/README.md index 181ada3f45..c8039f4bc5 100644 --- a/core-java-11/README.md +++ b/core-java-11/README.md @@ -2,4 +2,4 @@ - [Java 11 Single File Source Code](https://www.baeldung.com/java-single-file-source-code) - [Java 11 Local Variable Syntax for Lambda Parameters](https://www.baeldung.com/java-var-lambda-params) - +- [Java 11 String API Additions](https://www.baeldung.com/java-11-string-api) From cd5d9da8c072a9bf86d2552d0a36cac7c415cca1 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:53:20 +0530 Subject: [PATCH 125/441] Backlink added --- lombok-custom/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 lombok-custom/README.md diff --git a/lombok-custom/README.md b/lombok-custom/README.md new file mode 100644 index 0000000000..bfc784ea7e --- /dev/null +++ b/lombok-custom/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Implementing a Custom Lombok Annotation](https://www.baeldung.com/lombok-custom-annotation) From c8fcad8b6a0bda2fae75090d0171e7799921e2b8 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:54:37 +0530 Subject: [PATCH 126/441] backlink added --- core-java-arrays/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-arrays/README.md b/core-java-arrays/README.md index 56110585ac..400dd7793c 100644 --- a/core-java-arrays/README.md +++ b/core-java-arrays/README.md @@ -13,3 +13,4 @@ - [How to Invert an Array in Java](http://www.baeldung.com/java-invert-array) - [Array Operations in Java](http://www.baeldung.com/java-common-array-operations) - [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection) +- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays) From e67486cf739cf245ede5757332bc84c340e6c6b3 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:55:40 +0530 Subject: [PATCH 127/441] backlink added --- gson/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/gson/README.md b/gson/README.md index e1eb155f43..4edd7158d4 100644 --- a/gson/README.md +++ b/gson/README.md @@ -9,3 +9,4 @@ - [Exclude Fields from Serialization in Gson](http://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) From e67dae8b6b0483791aab0a1c7e151a2a91bdf6c1 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:56:40 +0530 Subject: [PATCH 128/441] backlink added --- jee-7/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jee-7/README.md b/jee-7/README.md index a2493e561b..a783e7860e 100644 --- a/jee-7/README.md +++ b/jee-7/README.md @@ -5,3 +5,4 @@ - [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) +- [Java EE 7 Batch Processing](https://www.baeldung.com/java-ee-7-batch-processing) From c31163f54f5ecd7dfd79ced4c761b5dbf28168a9 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:57:55 +0530 Subject: [PATCH 129/441] backlink added --- core-kotlin/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin/README.md b/core-kotlin/README.md index 0ce4b74d91..225ad87e87 100644 --- a/core-kotlin/README.md +++ b/core-kotlin/README.md @@ -50,3 +50,4 @@ - [Kotlin Contracts](https://www.baeldung.com/kotlin-contracts) - [Operator Overloading in Kotlin](https://www.baeldung.com/kotlin-operator-overloading) - [Inline Classes in Kotlin](https://www.baeldung.com/kotlin-inline-classes) +- [Creating Java static final Equivalents in Kotlin](https://www.baeldung.com/kotlin-java-static-final) From 5e7ca37b760c7e570ede5b0f1cd25bf103d6007d Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 17:58:56 +0530 Subject: [PATCH 130/441] Backlink added --- spring-cloud/spring-cloud-kubernetes/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/spring-cloud-kubernetes/README.md b/spring-cloud/spring-cloud-kubernetes/README.md index 295ead1c2f..2387758626 100644 --- a/spring-cloud/spring-cloud-kubernetes/README.md +++ b/spring-cloud/spring-cloud-kubernetes/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Running Spring Boot Applications With Minikube](https://www.baeldung.com/spring-boot-minikube) +- [Self-Healing Applications with Kubernetes and Spring Boot](https://www.baeldung.com/spring-boot-kubernetes-self-healing-apps) From eaa57758366e7d08d788929b59528fa112179824 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 18:00:24 +0530 Subject: [PATCH 131/441] backlink added --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index 512370e853..03bdd9b759 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -28,3 +28,4 @@ - [One-to-One Relationship in JPA](https://www.baeldung.com/jpa-one-to-one) - [Hibernate Named Query](https://www.baeldung.com/hibernate-named-query) - [Using c3p0 with Hibernate](https://www.baeldung.com/hibernate-c3p0) +- [Persist a JSON Object Using Hibernate](https://www.baeldung.com/hibernate-persist-json-object) From 6afe91c171f28aa0c6f70e2afc9c2252b82652e3 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 18:01:35 +0530 Subject: [PATCH 132/441] backlink added --- core-java-collections/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-collections/README.md b/core-java-collections/README.md index 1a90d01a82..f549adaa4f 100644 --- a/core-java-collections/README.md +++ b/core-java-collections/README.md @@ -30,3 +30,4 @@ - [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) +- [Intersection of Two Lists in Java](https://www.baeldung.com/java-lists-intersection) From 8b2af060dfb5befd3c2d0423aee9052f5d707b81 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 18:03:13 +0530 Subject: [PATCH 133/441] backlink added --- akka-http/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 akka-http/README.md diff --git a/akka-http/README.md b/akka-http/README.md new file mode 100644 index 0000000000..3831b5079f --- /dev/null +++ b/akka-http/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Introduction to Akka HTTP](https://www.baeldung.com/akka-http) From 35744e704426ddc034a5248c62c912e243c02722 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 18:04:15 +0530 Subject: [PATCH 134/441] backlink added --- core-java-collections/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-collections/README.md b/core-java-collections/README.md index f549adaa4f..bde0f9fdb9 100644 --- a/core-java-collections/README.md +++ b/core-java-collections/README.md @@ -31,3 +31,4 @@ - [A Guide to EnumMap](https://www.baeldung.com/java-enum-map) - [A Guide to Iterator in Java](http://www.baeldung.com/java-iterator) - [Intersection of Two Lists in Java](https://www.baeldung.com/java-lists-intersection) +- [Differences Between HashMap and Hashtable](https://www.baeldung.com/hashmap-hashtable-differences) From dd45e825d455ffa6d5d41869f144030202feb576 Mon Sep 17 00:00:00 2001 From: collaboratewithakash <38683470+collaboratewithakash@users.noreply.github.com> Date: Fri, 4 Jan 2019 18:06:27 +0530 Subject: [PATCH 135/441] backlink added --- java-strings/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-strings/README.md b/java-strings/README.md index a86f6e73c3..08fbec35ab 100644 --- a/java-strings/README.md +++ b/java-strings/README.md @@ -48,3 +48,4 @@ - [Guide to java.util.Formatter](http://www.baeldung.com/java-string-formatter) - [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) - [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) From d5ab82475deb7e451db519bfbd37092f1e6f6f5b Mon Sep 17 00:00:00 2001 From: Olaniyi Anjola Date: Fri, 4 Jan 2019 11:44:24 -0500 Subject: [PATCH 136/441] BAEL-2452: Using curl from Java (#6043) * BAEL-2452: Using curl from Java * A re-do of the examples using tests, instead of main class * Fix un-used variable --- .../baeldung/curltojava/JavaCurlExamples.java | 29 ++++++++++ .../curltojava/JavaCurlExamplesUnitTest.java | 55 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/curltojava/JavaCurlExamples.java create mode 100644 core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesUnitTest.java diff --git a/core-java/src/main/java/com/baeldung/curltojava/JavaCurlExamples.java b/core-java/src/main/java/com/baeldung/curltojava/JavaCurlExamples.java new file mode 100644 index 0000000000..166b0ecb13 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/curltojava/JavaCurlExamples.java @@ -0,0 +1,29 @@ +package com.baeldung.curltojava; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class JavaCurlExamples { + + public static String inputStreamToString(InputStream inputStream) { + final int bufferSize = 8 * 1024; + byte[] buffer = new byte[bufferSize]; + final StringBuilder builder = new StringBuilder(); + try (BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, bufferSize)) { + while (bufferedInputStream.read(buffer) != -1) { + builder.append(new String(buffer)); + } + } catch (IOException ex) { + Logger.getLogger(JavaCurlExamples.class.getName()).log(Level.SEVERE, null, ex); + } + return builder.toString(); + } + + public static void consumeInputStream(InputStream inputStream) { + inputStreamToString(inputStream); + } + +} diff --git a/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesUnitTest.java b/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesUnitTest.java new file mode 100644 index 0000000000..4e82059f2b --- /dev/null +++ b/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesUnitTest.java @@ -0,0 +1,55 @@ +package com.baeldung.curltojava; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +import org.junit.Assert; +import org.junit.Test; + +public class JavaCurlExamplesUnitTest { + + + @Test + public void givenCommand_whenCalled_thenProduceZeroExitCode() throws IOException { + String command = "curl --location --request GET \"https://postman-echo.com/get?foo1=bar1&foo2=bar2\""; + ProcessBuilder processBuilder = new ProcessBuilder(command.replaceAll("\"", "").split(" ")); + processBuilder.directory(new File("/home/")); + Process process = processBuilder.start(); + InputStream inputStream = process.getInputStream(); + // Consume the inputStream so the process can exit + JavaCurlExamples.consumeInputStream(inputStream); + int exitCode = process.exitValue(); + + Assert.assertEquals(0, exitCode); + } + + @Test + public void givenNewCommands_whenCalled_thenCheckIfIsAlive() throws IOException { + String command = "curl --location --request GET \"https://postman-echo.com/get?foo1=bar1&foo2=bar2\""; + ProcessBuilder processBuilder = new ProcessBuilder(command.replaceAll("\"", "").split(" ")); + processBuilder.directory(new File("/home/")); + Process process = processBuilder.start(); + + // Re-use processBuilder + processBuilder.command(new String[]{"newCommand", "arguments"}); + + Assert.assertEquals(true, process.isAlive()); + } + + @Test + public void whenRequestGet_thenReturnSuccessResponseCode() throws IOException { + String url = "https://postman-echo.com/get?foo1=bar1&foo2=bar2"; + URL urlObj = new URL(url); + HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection(); + connection.setDoOutput(true); + connection.setInstanceFollowRedirects(false); + connection.setRequestMethod("GET"); + connection.connect(); + + Assert.assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode()); + } + +} From 082724abecd4bc514baadc96b4a3046570254609 Mon Sep 17 00:00:00 2001 From: Varun Jain Date: Sat, 5 Jan 2019 10:38:13 +0530 Subject: [PATCH 137/441] BAEL-2536-addressed review comments --- .../java/com/baeldung/string/Pangram.java | 6 ++-- .../com/baeldung/string/PangramUnitTest.java | 29 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/Pangram.java b/java-strings/src/main/java/com/baeldung/string/Pangram.java index 8498a7074a..c09b0c1d29 100644 --- a/java-strings/src/main/java/com/baeldung/string/Pangram.java +++ b/java-strings/src/main/java/com/baeldung/string/Pangram.java @@ -15,10 +15,10 @@ public class Pangram { Boolean[] alphabetMarker = new Boolean[ALPHABET_COUNT]; Arrays.fill(alphabetMarker, false); int alphabetIndex = 0; - str = str.toUpperCase(); + String strUpper = str.toUpperCase(); for (int i = 0; i < str.length(); i++) { - if ('A' <= str.charAt(i) && str.charAt(i) <= 'Z') { - alphabetIndex = str.charAt(i) - 'A'; + if ('A' <= strUpper.charAt(i) && strUpper.charAt(i) <= 'Z') { + alphabetIndex = strUpper.charAt(i) - 'A'; alphabetMarker[alphabetIndex] = true; } } diff --git a/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java b/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java index 67523a4524..36e603b535 100644 --- a/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java +++ b/java-strings/src/test/java/com/baeldung/string/PangramUnitTest.java @@ -4,39 +4,38 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; - public class PangramUnitTest { - + @Test - public void givenValidString_isPanagram_shouldReturnSuccess() { + public void givenValidString_isPangram_shouldReturnSuccess() { String input = "Two driven jocks help fax my big quiz"; - assertTrue(Pangram.isPangram(input)); - assertTrue(Pangram.isPangramWithStreams(input)); + assertTrue(Pangram.isPangram(input)); + assertTrue(Pangram.isPangramWithStreams(input)); } - + @Test - public void givenNullString_isPanagram_shouldReturnFailure() { + public void givenNullString_isPangram_shouldReturnFailure() { String input = null; assertFalse(Pangram.isPangram(input)); assertFalse(Pangram.isPangramWithStreams(input)); assertFalse(Pangram.isPerfectPangram(input)); } - + @Test - public void givenPerfectPanagramString_isPerfectPanagram_shouldReturnSuccess() { + public void givenPerfectPangramString_isPerfectPangram_shouldReturnSuccess() { String input = "abcdefghijklmNoPqrStuVwxyz"; - assertTrue(Pangram.isPerfectPangram(input)); + assertTrue(Pangram.isPerfectPangram(input)); } - + @Test - public void givenNonPanagramString_isPanagram_shouldReturnFailure() { - String input = "invalid panagram"; + public void givenNonPangramString_isPangram_shouldReturnFailure() { + String input = "invalid pangram"; assertFalse(Pangram.isPangram(input)); assertFalse(Pangram.isPangramWithStreams(input)); } - + @Test - public void givenPanagram_isPerfectPanagram_shouldReturnFailure() { + public void givenPangram_isPerfectPangram_shouldReturnFailure() { String input = "Two driven jocks help fax my big quiz"; assertFalse(Pangram.isPerfectPangram(input)); } From 833285f2ba1407fda131542e2c261d5763f2f656 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 5 Jan 2019 11:12:31 +0200 Subject: [PATCH 138/441] Update README.md --- core-java-collections-list/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-java-collections-list/README.md b/core-java-collections-list/README.md index aba53f5b30..a35e714006 100644 --- a/core-java-collections-list/README.md +++ b/core-java-collections-list/README.md @@ -24,4 +24,5 @@ - [Java List Initialization in One Line](https://www.baeldung.com/java-init-list-one-line) - [Ways to Iterate Over a List in Java](https://www.baeldung.com/java-iterate-list) - [ClassCastException: Arrays$ArrayList cannot be cast to ArrayList](https://www.baeldung.com/java-classcastexception-arrays-arraylist) -- [Flattening Nested Collections in Java](http://www.baeldung.com/java-flatten-nested-collections) \ No newline at end of file +- [Flattening Nested Collections in Java](http://www.baeldung.com/java-flatten-nested-collections) +- [Intersection of Two Lists in Java](https://www.baeldung.com/java-lists-intersection) From ceb41607f0d406080bffe30fad8f450feab0f06f Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 5 Jan 2019 11:13:39 +0200 Subject: [PATCH 139/441] Update README.md --- core-java-collections/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-collections/README.md b/core-java-collections/README.md index bde0f9fdb9..be83621429 100644 --- a/core-java-collections/README.md +++ b/core-java-collections/README.md @@ -30,5 +30,4 @@ - [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) -- [Intersection of Two Lists in Java](https://www.baeldung.com/java-lists-intersection) - [Differences Between HashMap and Hashtable](https://www.baeldung.com/hashmap-hashtable-differences) From b1352b58e08542038ab4973a16617a205e1b3226 Mon Sep 17 00:00:00 2001 From: Kumar Chandrakant Date: Sat, 5 Jan 2019 17:52:23 +0530 Subject: [PATCH 140/441] Adding files for the tutorial BAEL-2301 (#6066) --- apache-spark/pom.xml | 68 ++++++++- .../java/com/baeldung/data/pipeline/Word.java | 25 ++++ .../data/pipeline/WordCountingApp.java | 116 +++++++++++++++ .../WordCountingAppWithCheckpoint.java | 140 ++++++++++++++++++ 4 files changed, 345 insertions(+), 4 deletions(-) create mode 100644 apache-spark/src/main/java/com/baeldung/data/pipeline/Word.java create mode 100644 apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java create mode 100644 apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java diff --git a/apache-spark/pom.xml b/apache-spark/pom.xml index 290b63a14d..b05b97198d 100644 --- a/apache-spark/pom.xml +++ b/apache-spark/pom.xml @@ -15,16 +15,76 @@ - org.apache.spark - spark-core_2.10 + spark-core_2.11 ${org.apache.spark.spark-core.version} + provided + + org.apache.spark + spark-sql_2.11 + ${org.apache.spark.spark-sql.version} + provided + + + org.apache.spark + spark-streaming_2.11 + ${org.apache.spark.spark-streaming.version} + provided + + + org.apache.spark + spark-streaming-kafka-0-10_2.11 + ${org.apache.spark.spark-streaming-kafka.version} + + + com.datastax.spark + spark-cassandra-connector_2.11 + ${com.datastax.spark.spark-cassandra-connector.version} + + + com.datastax.spark + spark-cassandra-connector-java_2.11 + ${com.datastax.spark.spark-cassandra-connector-java.version} + - + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.2 + + 1.8 + 1.8 + + + + maven-assembly-plugin + + + package + + single + + + + + + jar-with-dependencies + + + + + - 2.2.0 + 2.3.0 + 2.3.0 + 2.3.0 + 2.3.0 + 2.3.0 + 1.5.2 diff --git a/apache-spark/src/main/java/com/baeldung/data/pipeline/Word.java b/apache-spark/src/main/java/com/baeldung/data/pipeline/Word.java new file mode 100644 index 0000000000..b0caa468b1 --- /dev/null +++ b/apache-spark/src/main/java/com/baeldung/data/pipeline/Word.java @@ -0,0 +1,25 @@ +package com.baeldung.data.pipeline; + +import java.io.Serializable; + +public class Word implements Serializable { + private static final long serialVersionUID = 1L; + private String word; + private int count; + Word(String word, int count) { + this.word = word; + this.count = count; + } + public String getWord() { + return word; + } + public void setWord(String word) { + this.word = word; + } + public int getCount() { + return count; + } + public void setCount(int count) { + this.count = count; + } +} \ No newline at end of file diff --git a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java new file mode 100644 index 0000000000..08695b3631 --- /dev/null +++ b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java @@ -0,0 +1,116 @@ +package com.baeldung.data.pipeline; + +import static com.datastax.spark.connector.japi.CassandraJavaUtil.javaFunctions; +import static com.datastax.spark.connector.japi.CassandraJavaUtil.mapToRow; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.common.serialization.StringDeserializer; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaPairRDD; +import org.apache.spark.api.java.JavaRDD; +import org.apache.spark.api.java.function.FlatMapFunction; +import org.apache.spark.api.java.function.Function; +import org.apache.spark.api.java.function.Function2; +import org.apache.spark.api.java.function.PairFunction; +import org.apache.spark.api.java.function.VoidFunction; +import org.apache.spark.streaming.Durations; +import org.apache.spark.streaming.api.java.JavaDStream; +import org.apache.spark.streaming.api.java.JavaInputDStream; +import org.apache.spark.streaming.api.java.JavaPairDStream; +import org.apache.spark.streaming.api.java.JavaStreamingContext; +import org.apache.spark.streaming.kafka010.ConsumerStrategies; +import org.apache.spark.streaming.kafka010.KafkaUtils; +import org.apache.spark.streaming.kafka010.LocationStrategies; + +import scala.Tuple2; + +public class WordCountingApp { + + @SuppressWarnings("serial") + public static void main(String[] args) throws InterruptedException { + Logger.getLogger("org") + .setLevel(Level.OFF); + Logger.getLogger("akka") + .setLevel(Level.OFF); + + Map kafkaParams = new HashMap<>(); + kafkaParams.put("bootstrap.servers", "localhost:9092"); + kafkaParams.put("key.deserializer", StringDeserializer.class); + kafkaParams.put("value.deserializer", StringDeserializer.class); + kafkaParams.put("group.id", "use_a_separate_group_id_for_each_stream"); + kafkaParams.put("auto.offset.reset", "latest"); + kafkaParams.put("enable.auto.commit", false); + + Collection topics = Arrays.asList("messages"); + + SparkConf sparkConf = new SparkConf(); + sparkConf.setMaster("local[2]"); + sparkConf.setAppName("WordCountingApp"); + sparkConf.set("spark.cassandra.connection.host", "127.0.0.1"); + + JavaStreamingContext streamingContext = new JavaStreamingContext(sparkConf, Durations.seconds(1)); + + JavaInputDStream> messages = KafkaUtils.createDirectStream(streamingContext, LocationStrategies.PreferConsistent(), ConsumerStrategies. Subscribe(topics, kafkaParams)); + + JavaPairDStream results = messages.mapToPair(new PairFunction, String, String>() { + @Override + public Tuple2 call(ConsumerRecord record) { + return new Tuple2<>(record.key(), record.value()); + } + }); + + JavaDStream lines = results.map(new Function, String>() { + @Override + public String call(Tuple2 tuple2) { + return tuple2._2(); + } + }); + + JavaDStream words = lines.flatMap(new FlatMapFunction() { + @Override + public Iterator call(String x) { + return Arrays.asList(x.split("\\s+")) + .iterator(); + } + }); + + JavaPairDStream wordCounts = words.mapToPair(new PairFunction() { + @Override + public Tuple2 call(String s) { + return new Tuple2<>(s, 1); + } + }) + .reduceByKey(new Function2() { + @Override + public Integer call(Integer i1, Integer i2) { + return i1 + i2; + } + }); + + wordCounts.foreachRDD(new VoidFunction>() { + @Override + public void call(JavaPairRDD javaRdd) throws Exception { + Map wordCountMap = javaRdd.collectAsMap(); + for (String key : wordCountMap.keySet()) { + List words = Arrays.asList(new Word(key, wordCountMap.get(key))); + JavaRDD rdd = streamingContext.sparkContext() + .parallelize(words); + javaFunctions(rdd).writerBuilder("vocabulary", "words", mapToRow(Word.class)) + .saveToCassandra(); + } + } + }); + + streamingContext.start(); + streamingContext.awaitTermination(); + } +} \ No newline at end of file diff --git a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java new file mode 100644 index 0000000000..e20b910635 --- /dev/null +++ b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java @@ -0,0 +1,140 @@ +package com.baeldung.data.pipeline; + +import static com.datastax.spark.connector.japi.CassandraJavaUtil.javaFunctions; +import static com.datastax.spark.connector.japi.CassandraJavaUtil.mapToRow; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.common.serialization.StringDeserializer; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaPairRDD; +import org.apache.spark.api.java.JavaRDD; +import org.apache.spark.api.java.JavaSparkContext; +import org.apache.spark.api.java.Optional; +import org.apache.spark.api.java.function.FlatMapFunction; +import org.apache.spark.api.java.function.Function; +import org.apache.spark.api.java.function.Function2; +import org.apache.spark.api.java.function.Function3; +import org.apache.spark.api.java.function.PairFunction; +import org.apache.spark.api.java.function.VoidFunction; +import org.apache.spark.streaming.Durations; +import org.apache.spark.streaming.State; +import org.apache.spark.streaming.StateSpec; +import org.apache.spark.streaming.api.java.JavaDStream; +import org.apache.spark.streaming.api.java.JavaInputDStream; +import org.apache.spark.streaming.api.java.JavaMapWithStateDStream; +import org.apache.spark.streaming.api.java.JavaPairDStream; +import org.apache.spark.streaming.api.java.JavaStreamingContext; +import org.apache.spark.streaming.kafka010.ConsumerStrategies; +import org.apache.spark.streaming.kafka010.KafkaUtils; +import org.apache.spark.streaming.kafka010.LocationStrategies; + +import scala.Tuple2; + +public class WordCountingAppWithCheckpoint { + + public static JavaSparkContext sparkContext; + + @SuppressWarnings("serial") + public static void main(String[] args) throws InterruptedException { + + Logger.getLogger("org") + .setLevel(Level.OFF); + Logger.getLogger("akka") + .setLevel(Level.OFF); + + Map kafkaParams = new HashMap<>(); + kafkaParams.put("bootstrap.servers", "localhost:9092"); + kafkaParams.put("key.deserializer", StringDeserializer.class); + kafkaParams.put("value.deserializer", StringDeserializer.class); + kafkaParams.put("group.id", "use_a_separate_group_id_for_each_stream"); + kafkaParams.put("auto.offset.reset", "latest"); + kafkaParams.put("enable.auto.commit", false); + + Collection topics = Arrays.asList("messages"); + + SparkConf sparkConf = new SparkConf(); + sparkConf.setMaster("local[2]"); + sparkConf.setAppName("WordCountingAppWithCheckpoint"); + sparkConf.set("spark.cassandra.connection.host", "127.0.0.1"); + + JavaStreamingContext streamingContext = new JavaStreamingContext(sparkConf, Durations.seconds(1)); + + sparkContext = streamingContext.sparkContext(); + + streamingContext.checkpoint("./.checkpoint"); + + JavaInputDStream> messages = KafkaUtils.createDirectStream(streamingContext, LocationStrategies.PreferConsistent(), ConsumerStrategies. Subscribe(topics, kafkaParams)); + + JavaPairDStream results = messages.mapToPair(new PairFunction, String, String>() { + @Override + public Tuple2 call(ConsumerRecord record) { + return new Tuple2<>(record.key(), record.value()); + } + }); + + JavaDStream lines = results.map(new Function, String>() { + @Override + public String call(Tuple2 tuple2) { + return tuple2._2(); + } + }); + + JavaDStream words = lines.flatMap(new FlatMapFunction() { + @Override + public Iterator call(String x) { + return Arrays.asList(x.split("\\s+")) + .iterator(); + } + }); + + JavaPairDStream wordCounts = words.mapToPair(new PairFunction() { + @Override + public Tuple2 call(String s) { + return new Tuple2<>(s, 1); + } + }) + .reduceByKey(new Function2() { + @Override + public Integer call(Integer i1, Integer i2) { + return i1 + i2; + } + }); + + Function3, State, Tuple2> mappingFunc = (word, one, state) -> { + int sum = one.orElse(0) + (state.exists() ? state.get() : 0); + Tuple2 output = new Tuple2<>(word, sum); + state.update(sum); + return output; + }; + + JavaPairRDD initialRDD = JavaPairRDD.fromJavaRDD(sparkContext.emptyRDD()); + + JavaMapWithStateDStream> cumulativeWordCounts = wordCounts.mapWithState(StateSpec.function(mappingFunc) + .initialState(initialRDD)); + + cumulativeWordCounts.foreachRDD(new VoidFunction>>() { + @Override + public void call(JavaRDD> javaRdd) throws Exception { + List> wordCountList = javaRdd.collect(); + for (Tuple2 tuple : wordCountList) { + List words = Arrays.asList(new Word(tuple._1, tuple._2)); + JavaRDD rdd = sparkContext.parallelize(words); + javaFunctions(rdd).writerBuilder("vocabulary", "words", mapToRow(Word.class)) + .saveToCassandra(); + } + } + }); + + streamingContext.start(); + streamingContext.awaitTermination(); + } +} \ No newline at end of file From e3e1c84b24458a2a37799568fcdfe06acf3453e6 Mon Sep 17 00:00:00 2001 From: Maiklins Date: Sat, 5 Jan 2019 13:27:25 +0100 Subject: [PATCH 141/441] BAEL-2485 Permutations of an array in Java (#6027) --- .../algorithms/permutation/Permutation.java | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/permutation/Permutation.java diff --git a/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/permutation/Permutation.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/permutation/Permutation.java new file mode 100644 index 0000000000..7fedd78ffb --- /dev/null +++ b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/permutation/Permutation.java @@ -0,0 +1,123 @@ +package com.baeldung.algorithms.permutation; + +import java.util.Arrays; +import java.util.Collections; + +public class Permutation { + + public static void printAllRecursive(T[] elements, char delimiter) { + printAllRecursive(elements.length, elements, delimiter); + } + + public static void printAllRecursive(int n, T[] elements, char delimiter) { + + if(n == 1) { + printArray(elements, delimiter); + } else { + for(int i = 0; i < n-1; i++) { + printAllRecursive(n - 1, elements, delimiter); + if(n % 2 == 0) { + swap(elements, i, n-1); + } else { + swap(elements, 0, n-1); + } + } + printAllRecursive(n - 1, elements, delimiter); + } + } + + public static void printAllIterative(int n, T[] elements, char delimiter) { + + int[] indexes = new int[n]; + for (int i = 0; i < n; i++) { + indexes[i] = 0; + } + + printArray(elements, delimiter); + + int i = 0; + while (i < n) { + if (indexes[i] < i) { + swap(elements, i % 2 == 0 ? 0: indexes[i], i); + printArray(elements, delimiter); + indexes[i]++; + i = 0; + } + else { + indexes[i] = 0; + i++; + } + } + } + + public static > void printAllOrdered(T[] elements, char delimiter) { + + Arrays.sort(elements); + boolean hasNext = true; + + while(hasNext) { + printArray(elements, delimiter); + int k = 0, l = 0; + hasNext = false; + for (int i = elements.length - 1; i > 0; i--) { + if (elements[i].compareTo(elements[i - 1]) > 0) { + k = i - 1; + hasNext = true; + break; + } + } + + for (int i = elements.length - 1; i > k; i--) { + if (elements[i].compareTo(elements[k]) > 0) { + l = i; + break; + } + } + + swap(elements, k, l); + Collections.reverse(Arrays.asList(elements).subList(k + 1, elements.length)); + } + } + + public static void printRandom(T[] elements, char delimiter) { + + Collections.shuffle(Arrays.asList(elements)); + printArray(elements, delimiter); + } + + private static void swap(T[] elements, int a, int b) { + + T tmp = elements[a]; + elements[a] = elements[b]; + elements[b] = tmp; + } + + private static void printArray(T[] elements, char delimiter) { + + String delimiterSpace = delimiter + " "; + for(int i = 0; i < elements.length; i++) { + System.out.print(elements[i] + delimiterSpace); + } + System.out.print('\n'); + } + + public static void main(String[] argv) { + + Integer[] elements = {1,2,3,4}; + + System.out.println("Rec:"); + printAllRecursive(elements, ';'); + + System.out.println("Iter:"); + printAllIterative(elements.length, elements, ';'); + + System.out.println("Orderes:"); + printAllOrdered(elements, ';'); + + System.out.println("Random:"); + printRandom(elements, ';'); + + System.out.println("Random:"); + printRandom(elements, ';'); + } +} From cceb6a022e41bc84b7aa0ddd8a9cb8ea538d9019 Mon Sep 17 00:00:00 2001 From: pcoates33 Date: Sat, 5 Jan 2019 12:39:43 +0000 Subject: [PATCH 142/441] spring-boot ehcache example added (#6012) --- pom.xml | 3 + spring-ehcache/.gitignore | 13 +++ spring-ehcache/README.md | 7 ++ spring-ehcache/checkstyle.xml | 11 +++ spring-ehcache/pom.xml | 87 +++++++++++++++++++ .../com/baeldung/cachetest/Application.java | 13 +++ .../cachetest/config/CacheConfig.java | 57 ++++++++++++ .../cachetest/config/CacheEventLogger.java | 18 ++++ .../cachetest/rest/NumberController.java | 29 +++++++ .../cachetest/service/NumberService.java | 22 +++++ 10 files changed, 260 insertions(+) create mode 100644 spring-ehcache/.gitignore create mode 100644 spring-ehcache/README.md create mode 100644 spring-ehcache/checkstyle.xml create mode 100644 spring-ehcache/pom.xml create mode 100644 spring-ehcache/src/main/java/com/baeldung/cachetest/Application.java create mode 100644 spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java create mode 100644 spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java create mode 100644 spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java create mode 100644 spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java diff --git a/pom.xml b/pom.xml index e8ff86665c..4dba0da173 100644 --- a/pom.xml +++ b/pom.xml @@ -663,6 +663,7 @@ spring-dispatcher-servlet spring-drools + spring-ehcache spring-ejb spring-exceptions @@ -882,6 +883,7 @@ spring-data-rest spring-dispatcher-servlet spring-drools + spring-ehcache spring-freemarker persistence-modules/spring-hibernate-3 persistence-modules/spring-hibernate4 @@ -1370,6 +1372,7 @@ spring-dispatcher-servlet spring-drools + spring-ehcache spring-ejb spring-exceptions diff --git a/spring-ehcache/.gitignore b/spring-ehcache/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/spring-ehcache/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-ehcache/README.md b/spring-ehcache/README.md new file mode 100644 index 0000000000..749441375e --- /dev/null +++ b/spring-ehcache/README.md @@ -0,0 +1,7 @@ +## Spring Ehcache Example Project + +A simple example of using ehcache with spring-boot. + +### Relevant Articles: +- [Spring Boot Ehcache Example](http://www.baeldung.com/spring-ehcache) + diff --git a/spring-ehcache/checkstyle.xml b/spring-ehcache/checkstyle.xml new file mode 100644 index 0000000000..85063a7570 --- /dev/null +++ b/spring-ehcache/checkstyle.xml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/spring-ehcache/pom.xml b/spring-ehcache/pom.xml new file mode 100644 index 0000000000..b8378617c5 --- /dev/null +++ b/spring-ehcache/pom.xml @@ -0,0 +1,87 @@ + + 4.0.0 + spring-ehcache + 0.1-SNAPSHOT + spring-ehcache + jar + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-cache + + + javax.cache + cache-api + + + org.ehcache + ehcache + + + + + spring-ehcache + + + src/main/resources + true + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${checkstyle-maven-plugin.version} + + checkstyle.xml + + + + + check + + + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${checkstyle-maven-plugin.version} + + checkstyle.xml + + + + + + + + 3.0.0 + false + + + diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/Application.java b/spring-ehcache/src/main/java/com/baeldung/cachetest/Application.java new file mode 100644 index 0000000000..a1ce7a5317 --- /dev/null +++ b/spring-ehcache/src/main/java/com/baeldung/cachetest/Application.java @@ -0,0 +1,13 @@ +package com.baeldung.cachetest; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} \ No newline at end of file diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java b/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java new file mode 100644 index 0000000000..3cf2309cb9 --- /dev/null +++ b/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java @@ -0,0 +1,57 @@ +package com.baeldung.cachetest.config; + +import java.math.BigDecimal; +import java.time.Duration; + +import javax.cache.CacheManager; + +import org.ehcache.config.CacheConfiguration; +import org.ehcache.config.ResourcePools; +import org.ehcache.config.builders.CacheConfigurationBuilder; +import org.ehcache.config.builders.CacheEventListenerConfigurationBuilder; +import org.ehcache.config.builders.ExpiryPolicyBuilder; +import org.ehcache.config.builders.ResourcePoolsBuilder; +import org.ehcache.config.units.EntryUnit; +import org.ehcache.config.units.MemoryUnit; +import org.ehcache.event.EventType; +import org.ehcache.jsr107.Eh107Configuration; +import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableCaching +public class CacheConfig { + + private static final int ON_HEAP_CACHE_SIZE_ENTRIES = 2; + private static final int OFF_HEAP_CACHE_SIZE_MB = 10; + private static final int CACHE_EXPIRY_SECONDS = 30; + + @Bean + public JCacheManagerCustomizer jcacheManagerCustomizer() { + return new JCacheManagerCustomizer() { + + @Override + public void customize(CacheManager cacheManager) { + ResourcePools resourcePools = ResourcePoolsBuilder.newResourcePoolsBuilder() + .heap(ON_HEAP_CACHE_SIZE_ENTRIES, EntryUnit.ENTRIES) + .offheap(OFF_HEAP_CACHE_SIZE_MB, MemoryUnit.MB).build(); + + CacheEventListenerConfigurationBuilder eventLoggerConfig = CacheEventListenerConfigurationBuilder + .newEventListenerConfiguration(new CacheEventLogger(), EventType.CREATED, EventType.EXPIRED) + .unordered().asynchronous(); + + CacheConfiguration cacheConfiguration = CacheConfigurationBuilder + .newCacheConfigurationBuilder(Long.class, BigDecimal.class, resourcePools) + .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(CACHE_EXPIRY_SECONDS))) + .add(eventLoggerConfig).build(); + + cacheManager.createCache("squareCache", + Eh107Configuration.fromEhcacheCacheConfiguration(cacheConfiguration)); + + } + }; + } + +} diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java b/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java new file mode 100644 index 0000000000..c8ead85f1e --- /dev/null +++ b/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java @@ -0,0 +1,18 @@ +package com.baeldung.cachetest.config; + +import org.ehcache.event.CacheEvent; +import org.ehcache.event.CacheEventListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CacheEventLogger implements CacheEventListener { + + private static final Logger log = LoggerFactory.getLogger(CacheEventLogger.class); + + @Override + public void onEvent(CacheEvent cacheEvent) { + log.info("Cache event {} for item with key {}. Old value = {}, New value = {}", cacheEvent.getType(), + cacheEvent.getKey(), cacheEvent.getOldValue(), cacheEvent.getNewValue()); + } + +} diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java b/spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java new file mode 100644 index 0000000000..4115c34cc4 --- /dev/null +++ b/spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java @@ -0,0 +1,29 @@ +package com.baeldung.cachetest.rest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +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.cachetest.service.NumberService; + +@RestController +@RequestMapping(path = "/number", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) +public class NumberController { + + private final static Logger log = LoggerFactory.getLogger(NumberController.class); + + @Autowired + private NumberService numberService; + + @GetMapping(path = "/square/{number}") + public String getThing(@PathVariable Long number) { + log.info("call numberService to square {}", number); + return String.format("{\"square\": %s}", numberService.square(number)); + } + +} diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java b/spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java new file mode 100644 index 0000000000..bcd930f5e1 --- /dev/null +++ b/spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java @@ -0,0 +1,22 @@ +package com.baeldung.cachetest.service; + +import java.math.BigDecimal; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; + +@Service +public class NumberService { + + private final static Logger log = LoggerFactory.getLogger(NumberService.class); + + @Cacheable(value = "squareCache", key = "#number", condition = "#number>10") + public BigDecimal square(Long number) { + BigDecimal square = BigDecimal.valueOf(number).multiply(BigDecimal.valueOf(number)); + log.info("square of {} is {}", number, square); + return square; + } + +} From b5c29f0e1b556229ad9f29412cbecdcd62da7bb7 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sat, 5 Jan 2019 20:11:29 +0530 Subject: [PATCH 143/441] [BAEL-11403] - Moved DoubleToString and DoubleToStringUnitTest to java-numbers module --- .../src/main/java/com/baeldung/string/DoubleToString.java | 0 .../src/test/java/com/baeldung/string/DoubleToStringUnitTest.java | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {core-java => java-numbers}/src/main/java/com/baeldung/string/DoubleToString.java (100%) rename {core-java => java-numbers}/src/test/java/com/baeldung/string/DoubleToStringUnitTest.java (100%) diff --git a/core-java/src/main/java/com/baeldung/string/DoubleToString.java b/java-numbers/src/main/java/com/baeldung/string/DoubleToString.java similarity index 100% rename from core-java/src/main/java/com/baeldung/string/DoubleToString.java rename to java-numbers/src/main/java/com/baeldung/string/DoubleToString.java diff --git a/core-java/src/test/java/com/baeldung/string/DoubleToStringUnitTest.java b/java-numbers/src/test/java/com/baeldung/string/DoubleToStringUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/string/DoubleToStringUnitTest.java rename to java-numbers/src/test/java/com/baeldung/string/DoubleToStringUnitTest.java From bcc848f6a71688ead0c5d61d32abe3a53a984982 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 5 Jan 2019 18:35:47 +0200 Subject: [PATCH 144/441] Update DoubleToString.java --- .../src/main/java/com/baeldung/string/DoubleToString.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java-numbers/src/main/java/com/baeldung/string/DoubleToString.java b/java-numbers/src/main/java/com/baeldung/string/DoubleToString.java index d26d26f3df..dd55ba51ad 100644 --- a/java-numbers/src/main/java/com/baeldung/string/DoubleToString.java +++ b/java-numbers/src/main/java/com/baeldung/string/DoubleToString.java @@ -38,4 +38,5 @@ public class DoubleToString { return df.format(d); } + } From 9c45b7eda8e7f2eea9bc9ef8fd45d28fd9608db1 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 5 Jan 2019 18:44:33 +0200 Subject: [PATCH 145/441] Update README.MD --- spring-boot-testing/README.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-testing/README.MD b/spring-boot-testing/README.MD index a609b5bf09..144c3581f7 100644 --- a/spring-boot-testing/README.MD +++ b/spring-boot-testing/README.MD @@ -4,3 +4,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Testing with Spring and Spock](https://www.baeldung.com/spring-spock-testing) +- [Exclude Auto-Configuration Classes in Spring Boot Tests](https://www.baeldung.com/spring-boot-exclude-auto-configuration-test) From 994cb303a0595e96c0ec699a70e323391fe9366a Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 5 Jan 2019 19:03:14 +0100 Subject: [PATCH 146/441] [BAEL-2424] Added classes and tests --- .../com/baeldung/reflection/Employee.java | 7 + .../baeldung/reflection/MonthEmployee.java | 7 + .../java/com/baeldung/reflection/Person.java | 8 ++ .../PersonAndEmployeeReflectionTest.java | 128 ++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/reflection/Employee.java create mode 100644 core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java create mode 100644 core-java/src/main/java/com/baeldung/reflection/Person.java create mode 100644 core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionTest.java diff --git a/core-java/src/main/java/com/baeldung/reflection/Employee.java b/core-java/src/main/java/com/baeldung/reflection/Employee.java new file mode 100644 index 0000000000..833cf26b14 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/reflection/Employee.java @@ -0,0 +1,7 @@ +package com.baeldung.reflection; + +public class Employee extends Person { + + public int employeeId; + +} diff --git a/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java b/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java new file mode 100644 index 0000000000..697ecc1500 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java @@ -0,0 +1,7 @@ +package com.baeldung.reflection; + +public class MonthEmployee extends Employee { + + private double reward; + +} diff --git a/core-java/src/main/java/com/baeldung/reflection/Person.java b/core-java/src/main/java/com/baeldung/reflection/Person.java new file mode 100644 index 0000000000..23b312cdd9 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/reflection/Person.java @@ -0,0 +1,8 @@ +package com.baeldung.reflection; + +public class Person { + + public String lastName; + private String firstName; + +} diff --git a/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionTest.java b/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionTest.java new file mode 100644 index 0000000000..034e54ee93 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionTest.java @@ -0,0 +1,128 @@ +package com.baeldung.reflection; + +import org.junit.Test; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.junit.Assert.*; + +public class PersonAndEmployeeReflectionTest { + + // Fields names + private static final String LAST_NAME_FIELD = "lastName"; + private static final String FIRST_NAME_FIELD = "firstName"; + private static final String EMPLOYEE_ID_FIELD = "employeeId"; + private static final String MONTH_EMPLOYEE_REWARD_FIELD = "reward"; + + @Test + public void givenPersonClass_whenGetDeclaredFields_thenTwoFields() { + // When + Field[] allFields = Person.class.getDeclaredFields(); + + // Then + assertEquals(2, allFields.length); + + Field lastNameField = allFields[0]; + assertEquals(LAST_NAME_FIELD, lastNameField.getName()); + assertEquals(String.class, lastNameField.getType()); + + Field firstNameField = allFields[1]; + assertEquals(FIRST_NAME_FIELD, firstNameField.getName()); + assertEquals(String.class, firstNameField.getType()); + } + + @Test + public void givenEmployeeClass_whenSuperClassGetDeclaredFields_thenOneField() { + // When + Field[] allFields = Employee.class.getSuperclass().getDeclaredFields(); + + // Then + assertEquals(2, allFields.length); + + Field lastNameField = allFields[0]; + assertEquals(LAST_NAME_FIELD, lastNameField.getName()); + assertEquals(String.class, lastNameField.getType()); + + Field firstNameField = allFields[1]; + assertEquals(FIRST_NAME_FIELD, firstNameField.getName()); + assertEquals(String.class, firstNameField.getType()); + } + + @Test + public void givenEmployeeClass_whenGetDeclaredFields_thenOneField() { + // When + Field[] allFields = Employee.class.getDeclaredFields(); + + // Then + assertEquals(1, allFields.length); + + Field employeeIdField = allFields[0]; + assertEquals(EMPLOYEE_ID_FIELD, employeeIdField.getName()); + assertEquals(int.class, employeeIdField.getType()); + } + + @Test + public void givenEmployeeClass_whenGetDeclaredFieldsOnBothClasses_thenThreeFields() { + // When + Field[] personFields = Employee.class.getSuperclass().getDeclaredFields(); + Field[] employeeFields = Employee.class.getDeclaredFields(); + Field[] allFields = new Field[employeeFields.length + personFields.length]; + Arrays.setAll(allFields, i -> (i < personFields.length ? personFields[i] : employeeFields[i - personFields.length])); + + // Then + assertEquals(3, allFields.length); + + Field lastNameField = allFields[0]; + assertEquals(LAST_NAME_FIELD, lastNameField.getName()); + assertEquals(String.class, lastNameField.getType()); + + Field firstNameField = allFields[1]; + assertEquals(FIRST_NAME_FIELD, firstNameField.getName()); + assertEquals(String.class, firstNameField.getType()); + + Field employeeIdField = allFields[2]; + assertEquals(EMPLOYEE_ID_FIELD, employeeIdField.getName()); + assertEquals(int.class, employeeIdField.getType()); + } + + @Test + public void givenMonthEmployeeClass_whenGetAllFields_thenFourFields() { + // When + List allFields = getAllFields(MonthEmployee.class); + + // Then + assertEquals(4, allFields.size()); + + Field lastNameField = allFields.get(0); + assertEquals(LAST_NAME_FIELD, lastNameField.getName()); + assertEquals(String.class, lastNameField.getType()); + + Field firstNameField = allFields.get(1); + assertEquals(FIRST_NAME_FIELD, firstNameField.getName()); + assertEquals(String.class, firstNameField.getType()); + + Field employeeIdField = allFields.get(2); + assertEquals(EMPLOYEE_ID_FIELD, employeeIdField.getName()); + assertEquals(int.class, employeeIdField.getType()); + + Field monthEmployeeRewardField = allFields.get(3); + assertEquals(MONTH_EMPLOYEE_REWARD_FIELD, monthEmployeeRewardField.getName()); + assertEquals(double.class, monthEmployeeRewardField.getType()); + } + + public List getAllFields(Class clazz) { + if (clazz == null) { + return Collections.emptyList(); + } + + List result = new ArrayList<>(); + result.addAll(getAllFields(clazz.getSuperclass())); + result.addAll(Arrays.asList(clazz.getDeclaredFields())); + return result; + } + +} \ No newline at end of file From fe44881bb15a18497d1fb8f25c78db52dd4cf91d Mon Sep 17 00:00:00 2001 From: pandachris Date: Sun, 6 Jan 2019 01:21:28 +0700 Subject: [PATCH 147/441] BAEL-2565 (#6077) * BAEL-2565 * BAEL-2565 Test code consistency --- .../com/baeldung/enums/values/Element1.java | 17 ++++ .../com/baeldung/enums/values/Element2.java | 52 ++++++++++ .../com/baeldung/enums/values/Element3.java | 63 ++++++++++++ .../com/baeldung/enums/values/Element4.java | 95 +++++++++++++++++++ .../com/baeldung/enums/values/Labeled.java | 5 + .../enums/values/Element1UnitTest.java | 48 ++++++++++ .../enums/values/Element2UnitTest.java | 59 ++++++++++++ .../enums/values/Element3UnitTest.java | 57 +++++++++++ .../enums/values/Element4UnitTest.java | 71 ++++++++++++++ 9 files changed, 467 insertions(+) create mode 100644 core-java-8/src/main/java/com/baeldung/enums/values/Element1.java create mode 100644 core-java-8/src/main/java/com/baeldung/enums/values/Element2.java create mode 100644 core-java-8/src/main/java/com/baeldung/enums/values/Element3.java create mode 100644 core-java-8/src/main/java/com/baeldung/enums/values/Element4.java create mode 100644 core-java-8/src/main/java/com/baeldung/enums/values/Labeled.java create mode 100644 core-java-8/src/test/java/com/baeldung/enums/values/Element1UnitTest.java create mode 100644 core-java-8/src/test/java/com/baeldung/enums/values/Element2UnitTest.java create mode 100644 core-java-8/src/test/java/com/baeldung/enums/values/Element3UnitTest.java create mode 100644 core-java-8/src/test/java/com/baeldung/enums/values/Element4UnitTest.java diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Element1.java b/core-java-8/src/main/java/com/baeldung/enums/values/Element1.java new file mode 100644 index 0000000000..6c80adacb1 --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/enums/values/Element1.java @@ -0,0 +1,17 @@ +package com.baeldung.enums.values; + +/** + * This is a simple enum of periodic table elements + */ +public enum Element1 { + H, + HE, + LI, + BE, + B, + C, + N, + O, + F, + NE +} diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Element2.java b/core-java-8/src/main/java/com/baeldung/enums/values/Element2.java new file mode 100644 index 0000000000..28bf3a475a --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/enums/values/Element2.java @@ -0,0 +1,52 @@ +package com.baeldung.enums.values; + +/** + * The simple enum has been enhanced to add the name of the element. + */ +public enum Element2 { + H("Hydrogen"), + HE("Helium"), + LI("Lithium"), + BE("Beryllium"), + B("Boron"), + C("Carbon"), + N("Nitrogen"), + O("Oxygen"), + F("Flourine"), + NE("Neon"); + + /** a final variable to store the label, which can't be changed */ + public final String label; + + /** + * A private constructor that sets the label. + * @param label + */ + private Element2(String label) { + this.label = label; + } + + /** + * Look up Element2 instances by the label field. This implementation iterates through + * the values() list to find the label. + * @param label The label to look up + * @return The Element2 instance with the label, or null if not found. + */ + public static Element2 valueOfLabel(String label) { + for (Element2 e2 : values()) { + if (e2.label.equals(label)) { + return e2; + } + } + return null; + } + + /** + * Override the toString() method to return the label instead of the declared name. + * @return + */ + @Override + public String toString() { + return this.label; + } +} diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Element3.java b/core-java-8/src/main/java/com/baeldung/enums/values/Element3.java new file mode 100644 index 0000000000..cb98695de8 --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/enums/values/Element3.java @@ -0,0 +1,63 @@ +package com.baeldung.enums.values; + +import java.util.HashMap; +import java.util.Map; + +/** + * A Map has been added to cache labels for faster lookup. + */ +public enum Element3 { + H("Hydrogen"), + HE("Helium"), + LI("Lithium"), + BE("Beryllium"), + B("Boron"), + C("Carbon"), + N("Nitrogen"), + O("Oxygen"), + F("Flourine"), + NE("Neon"); + + /** + * A map to cache labels and their associated Element3 instances. + * Note that this only works if the labels are all unique! + */ + private static final Map BY_LABEL = new HashMap<>(); + + /** populate the BY_LABEL cache */ + static { + for (Element3 e3 : values()) { + BY_LABEL.put(e3.label, e3); + } + } + + /** a final variable to store the label, which can't be changed */ + public final String label; + + /** + * A private constructor that sets the label. + * @param label + */ + private Element3(String label) { + this.label = label; + } + + /** + * Look up Element2 instances by the label field. This implementation finds the + * label in the BY_LABEL cache. + * @param label The label to look up + * @return The Element3 instance with the label, or null if not found. + */ + public static Element3 valueOfLabel(String label) { + return BY_LABEL.get(label); + } + + /** + * Override the toString() method to return the label instead of the declared name. + * @return + */ + @Override + public String toString() { + return this.label; + } +} diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Element4.java b/core-java-8/src/main/java/com/baeldung/enums/values/Element4.java new file mode 100644 index 0000000000..89c45f9d1b --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/enums/values/Element4.java @@ -0,0 +1,95 @@ +package com.baeldung.enums.values; + +import java.util.HashMap; +import java.util.Map; + +/** + * Multiple fields have been added and the Labeled interface is implemented. + */ +public enum Element4 implements Labeled { + H("Hydrogen", 1, 1.008f), + HE("Helium", 2, 4.0026f), + LI("Lithium", 3, 6.94f), + BE("Beryllium", 4, 9.01722f), + B("Boron", 5, 10.81f), + C("Carbon", 6, 12.011f), + N("Nitrogen", 7, 14.007f), + O("Oxygen", 8, 15.999f), + F("Flourine", 9, 18.998f), + NE("Neon", 10, 20.180f); + /** + * Maps cache labels and their associated Element3 instances. + * Note that this only works if the values are all unique! + */ + private static final Map BY_LABEL = new HashMap<>(); + private static final Map BY_ATOMIC_NUMBER = new HashMap<>(); + private static final Map BY_ATOMIC_WEIGHT = new HashMap<>(); + + /** populate the caches */ + static { + for (Element4 e4 : values()) { + BY_LABEL.put(e4.label, e4); + BY_ATOMIC_NUMBER.put(e4.atomicNumber, e4); + BY_ATOMIC_WEIGHT.put(e4.atomicWeight, e4); + } + } + + /** final variables to store the values, which can't be changed */ + public final String label; + public final int atomicNumber; + public final float atomicWeight; + + private Element4(String label, int atomicNumber, float atomicWeight) { + this.label = label; + this.atomicNumber = atomicNumber; + this.atomicWeight = atomicWeight; + } + + /** + * Implement the Labeled interface. + * @return the label value + */ + @Override + public String label() { + return label; + } + + /** + * Look up Element2 instances by the label field. This implementation finds the + * label in the BY_LABEL cache. + * @param label The label to look up + * @return The Element4 instance with the label, or null if not found. + */ + public static Element4 valueOfLabel(String label) { + return BY_LABEL.get(label); + } + + /** + * Look up Element2 instances by the atomicNumber field. This implementation finds the + * atomicNUmber in the cache. + * @param number The atomicNumber to look up + * @return The Element4 instance with the label, or null if not found. + */ + public static Element4 valueOfAtomicNumber(int number) { + return BY_ATOMIC_NUMBER.get(number); + } + + /** + * Look up Element2 instances by the atomicWeight field. This implementation finds the + * atomic weight in the cache. + * @param weight the atomic weight to look up + * @return The Element4 instance with the label, or null if not found. + */ + public static Element4 valueOfAtomicWeight(float weight) { + return BY_ATOMIC_WEIGHT.get(weight); + } + + /** + * Override the toString() method to return the label instead of the declared name. + * @return + */ + @Override + public String toString() { + return this.label; + } +} diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Labeled.java b/core-java-8/src/main/java/com/baeldung/enums/values/Labeled.java new file mode 100644 index 0000000000..e41d6525f1 --- /dev/null +++ b/core-java-8/src/main/java/com/baeldung/enums/values/Labeled.java @@ -0,0 +1,5 @@ +package com.baeldung.enums.values; + +public interface Labeled { + String label(); +} diff --git a/core-java-8/src/test/java/com/baeldung/enums/values/Element1UnitTest.java b/core-java-8/src/test/java/com/baeldung/enums/values/Element1UnitTest.java new file mode 100644 index 0000000000..ab3e684230 --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/enums/values/Element1UnitTest.java @@ -0,0 +1,48 @@ +package com.baeldung.enums.values; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author chris + */ +public class Element1UnitTest { + + public Element1UnitTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + @Test + public void whenAccessingToString_thenItShouldEqualName() { + for (Element1 e1 : Element1.values()) { + assertEquals(e1.name(), e1.toString()); + } + } + + @Test + public void whenCallingValueOf_thenReturnTheCorrectEnum() { + for (Element1 e1 : Element1.values()) { + assertSame(e1, Element1.valueOf(e1.name())); + } + } +} diff --git a/core-java-8/src/test/java/com/baeldung/enums/values/Element2UnitTest.java b/core-java-8/src/test/java/com/baeldung/enums/values/Element2UnitTest.java new file mode 100644 index 0000000000..02995a2f41 --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/enums/values/Element2UnitTest.java @@ -0,0 +1,59 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.baeldung.enums.values; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author chris + */ +public class Element2UnitTest { + private static final Logger LOGGER = LoggerFactory.getLogger(Element2UnitTest.class); + + public Element2UnitTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + @Test + public void whenLocatebyLabel_thenReturnCorrectValue() { + for (Element2 e2 : Element2.values()) { + assertSame(e2, Element2.valueOfLabel(e2.label)); + } + } + + /** + * Test of toString method, of class Element2. + */ + @Test + public void whenCallingToString_thenReturnLabel() { + for (Element2 e2 : Element2.values()) { + assertEquals(e2.label, e2.toString()); + } + } +} diff --git a/core-java-8/src/test/java/com/baeldung/enums/values/Element3UnitTest.java b/core-java-8/src/test/java/com/baeldung/enums/values/Element3UnitTest.java new file mode 100644 index 0000000000..40c76a97b1 --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/enums/values/Element3UnitTest.java @@ -0,0 +1,57 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.baeldung.enums.values; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author chris + */ +public class Element3UnitTest { + + public Element3UnitTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + @Test + public void whenLocatebyLabel_thenReturnCorrectValue() { + for (Element3 e3 : Element3.values()) { + assertSame(e3, Element3.valueOfLabel(e3.label)); + } + } + + /** + * Test of toString method, of class Element3. + */ + @Test + public void whenCallingToString_thenReturnLabel() { + for (Element3 e3 : Element3.values()) { + assertEquals(e3.label, e3.toString()); + } + } + +} diff --git a/core-java-8/src/test/java/com/baeldung/enums/values/Element4UnitTest.java b/core-java-8/src/test/java/com/baeldung/enums/values/Element4UnitTest.java new file mode 100644 index 0000000000..d349dcef72 --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/enums/values/Element4UnitTest.java @@ -0,0 +1,71 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.baeldung.enums.values; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author chris + */ +public class Element4UnitTest { + + public Element4UnitTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + @Test + public void whenLocatebyLabel_thenReturnCorrectValue() { + for (Element4 e4 : Element4.values()) { + assertSame(e4, Element4.valueOfLabel(e4.label)); + } + } + + @Test + public void whenLocatebyAtmNum_thenReturnCorrectValue() { + for (Element4 e4 : Element4.values()) { + assertSame(e4, Element4.valueOfAtomicNumber(e4.atomicNumber)); + } + } + + @Test + public void whenLocatebyAtmWt_thenReturnCorrectValue() { + for (Element4 e4 : Element4.values()) { + assertSame(e4, Element4.valueOfAtomicWeight(e4.atomicWeight)); + } + } + + /** + * Test of toString method, of class Element4. + */ + @Test + public void whenCallingToString_thenReturnLabel() { + for (Element4 e4 : Element4.values()) { + assertEquals(e4.label, e4.toString()); + } + } + +} From 2d8ea6d287b2542ba7b4e5a13e3711d613b65ea8 Mon Sep 17 00:00:00 2001 From: kyleandari <44148335+kyleandari@users.noreply.github.com> Date: Sat, 5 Jan 2019 13:25:22 -0500 Subject: [PATCH 148/441] Bael 2431 (#6073) * Adding code to java core and deleting it from java-8 * removing failed unittest * removing space --- .../com/baeldung/interfaces/Electronic.java | 22 ---------------- .../com/baeldung/interfaces/Motorcycle.java | 10 ------- .../java/com/baeldung/interfaces/Truck.java | 8 ------ .../java/com/baeldung/interfaces/Vehicle.java | 6 ----- .../interfaces/multiinheritance/Vehicle.java | 13 ---------- .../interfaces/polymorphysim/Circle.java | 25 ------------------ .../polymorphysim/DisplayShape.java | 26 ------------------- .../polymorphysim/FunctionalMain.java | 23 ---------------- .../polymorphysim/MainPolymorphic.java | 15 ----------- .../interfaces/polymorphysim/Shape.java | 9 ------- .../interfaces/polymorphysim/Square.java | 25 ------------------ .../interfaces/PolymorphysimUnitTest.java | 26 ------------------- .../java/com/baeldung/interfaces/Box.java | 5 ++++ .../com/baeldung/interfaces/Employee.java | 1 - .../interfaces/EmployeeSalaryComparator.java | 7 +++-- .../com/baeldung/interfaces/HasColor.java | 3 +-- .../interfaces/multiinheritance/Car.java | 3 ++- .../interfaces/multiinheritance/Fly.java | 3 ++- .../multiinheritance/Transform.java | 0 .../interfaces/multiinheritance/Vehicle.java | 4 +++ .../interfaces/polymorphysim/Circle.java | 9 +++++++ .../polymorphysim/MainTestClass.java | 20 ++++++++++++++ .../interfaces/polymorphysim/Shape.java | 6 +++++ .../interfaces/polymorphysim/Square.java | 9 +++++++ 24 files changed, 61 insertions(+), 217 deletions(-) delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/Electronic.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/Motorcycle.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/Truck.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/Vehicle.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/DisplayShape.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/FunctionalMain.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/MainPolymorphic.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java delete mode 100644 core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java delete mode 100644 core-java-8/src/test/java/com/baeldung/interfaces/PolymorphysimUnitTest.java create mode 100644 core-java/src/main/java/com/baeldung/interfaces/Box.java rename {core-java-8 => core-java}/src/main/java/com/baeldung/interfaces/Employee.java (99%) rename {core-java-8 => core-java}/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java (67%) rename {core-java-8 => core-java}/src/main/java/com/baeldung/interfaces/HasColor.java (66%) rename {core-java-8 => core-java}/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java (84%) rename {core-java-8 => core-java}/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java (69%) rename {core-java-8 => core-java}/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java (100%) create mode 100644 core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java create mode 100644 core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java create mode 100644 core-java/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java create mode 100644 core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java create mode 100644 core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Electronic.java b/core-java-8/src/main/java/com/baeldung/interfaces/Electronic.java deleted file mode 100644 index bfbc381483..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/Electronic.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.interfaces; - -public interface Electronic { - //Constant variable - public static final String LED = "LED"; - - //Abstract method - public int getElectricityUse(); - - // Static method - public static boolean isEnergyEfficient(String electtronicType) { - if (electtronicType.equals(LED)) { - return true; - } - return false; - } - - //Default method - public default void printDescription() { - System.out.println("Electronic Description"); - } -} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Motorcycle.java b/core-java-8/src/main/java/com/baeldung/interfaces/Motorcycle.java deleted file mode 100644 index 6003f476a3..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/Motorcycle.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.interfaces; - -import com.baeldung.interfaces.multiinheritance.Transform; - -public class Motorcycle implements Transform { - @Override - public void transform() { - // Implementation - } -} \ No newline at end of file diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Truck.java b/core-java-8/src/main/java/com/baeldung/interfaces/Truck.java deleted file mode 100644 index d78de23371..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/Truck.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.interfaces; - -public class Truck extends Vehicle { - @Override - public void transform() { - // implementation - } -} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Vehicle.java b/core-java-8/src/main/java/com/baeldung/interfaces/Vehicle.java deleted file mode 100644 index 8b4662e1a3..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/Vehicle.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.baeldung.interfaces; - -import com.baeldung.interfaces.multiinheritance.Transform; - -public abstract class Vehicle implements Transform { -} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java b/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java deleted file mode 100644 index fb0d36e3e0..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.interfaces.multiinheritance; - -public class Vehicle implements Fly, Transform { - @Override - public void fly() { - System.out.println("I can Fly!!"); - } - - @Override - public void transform() { - System.out.println("I can Transform!!"); - } -} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java deleted file mode 100644 index afb3142d96..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.interfaces.polymorphysim; - -public class Circle implements Shape { - - private double radius; - - public Circle(double radius){ - this.radius = radius; - } - - @Override - public String name() { - return "Circle"; - } - - @Override - public double area() { - return Math.PI * (radius * radius); - } - - @Override - public String getColor() { - return "green"; - } -} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/DisplayShape.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/DisplayShape.java deleted file mode 100644 index d9c9dd107a..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/DisplayShape.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.interfaces.polymorphysim; - -import java.util.ArrayList; - -public class DisplayShape { - - private ArrayList shapes; - - public ArrayList getShapes() { - return shapes; - } - - public DisplayShape() { - shapes = new ArrayList<>(); - } - - public void add(Shape shape) { - shapes.add(shape); - } - - public void display() { - for (Shape shape : shapes) { - System.out.println(shape.name() + " area: " + shape.area()); - } - } -} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/FunctionalMain.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/FunctionalMain.java deleted file mode 100644 index 5316dd7db7..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/FunctionalMain.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.interfaces.polymorphysim; - -import java.util.function.Predicate; - -public class FunctionalMain { - -public static void main(String[] args) { - Shape circleShape = new Circle(2); - Shape squareShape = new Square(2); - - DisplayShape DisplayShape = new DisplayShape(); - DisplayShape.add(circleShape); - DisplayShape.add(squareShape); - - Predicate checkArea = (shape) -> shape.area() < 5; - - for (Shape shape : DisplayShape.getShapes()) { - if (checkArea.test(shape)) { - System.out.println(shape.name() + " " + shape.area()); - } - } -} -} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/MainPolymorphic.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/MainPolymorphic.java deleted file mode 100644 index cc43c1300b..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/MainPolymorphic.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.interfaces.polymorphysim; - -public class MainPolymorphic { - public static void main(String[] args){ - - Shape circleShape = new Circle(2); - Shape squareShape = new Square(2); - - DisplayShape displayShape = new DisplayShape(); - displayShape.add(circleShape); - displayShape.add(squareShape); - - displayShape.display(); - } -} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java deleted file mode 100644 index 560e07a80a..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.interfaces.polymorphysim; - -import com.baeldung.interfaces.HasColor; - -public interface Shape extends HasColor { - - public abstract String name(); - public abstract double area(); -} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java b/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java deleted file mode 100644 index 00b75ace20..0000000000 --- a/core-java-8/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.interfaces.polymorphysim; - -public class Square implements Shape { - - private double width; - - public Square(double width) { - this.width = width; - } - - @Override - public String name() { - return "Square"; - } - - @Override - public double area() { - return width * width; - } - - @Override - public String getColor() { - return "red"; - } -} diff --git a/core-java-8/src/test/java/com/baeldung/interfaces/PolymorphysimUnitTest.java b/core-java-8/src/test/java/com/baeldung/interfaces/PolymorphysimUnitTest.java deleted file mode 100644 index 7ded5e6621..0000000000 --- a/core-java-8/src/test/java/com/baeldung/interfaces/PolymorphysimUnitTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.interfaces; - -import com.baeldung.interfaces.polymorphysim.Circle; -import com.baeldung.interfaces.polymorphysim.Shape; -import com.baeldung.interfaces.polymorphysim.Square; -import org.assertj.core.api.Assertions; -import org.junit.Test; - -public class PolymorphysimUnitTest { - - @Test - public void whenInterfacePointsToCircle_CircleAreaMethodisBeingCalled(){ - double expectedArea = 12.566370614359172; - Shape circle = new Circle(2); - double actualArea = circle.area(); - Assertions.assertThat(actualArea).isEqualTo(expectedArea); - } - - @Test - public void whenInterfacePointsToSquare_SquareAreaMethodisBeingCalled(){ - double expectedArea = 4; - Shape square = new Square(2); - double actualArea = square.area(); - Assertions.assertThat(actualArea).isEqualTo(expectedArea); - } -} diff --git a/core-java/src/main/java/com/baeldung/interfaces/Box.java b/core-java/src/main/java/com/baeldung/interfaces/Box.java new file mode 100644 index 0000000000..0bb6560465 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/interfaces/Box.java @@ -0,0 +1,5 @@ +package com.baeldung.interfaces; + +public interface Box extends HasColor { + int getHeight(); +} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/Employee.java b/core-java/src/main/java/com/baeldung/interfaces/Employee.java similarity index 99% rename from core-java-8/src/main/java/com/baeldung/interfaces/Employee.java rename to core-java/src/main/java/com/baeldung/interfaces/Employee.java index 903bc81e6f..8c6bd3f7f3 100644 --- a/core-java-8/src/main/java/com/baeldung/interfaces/Employee.java +++ b/core-java/src/main/java/com/baeldung/interfaces/Employee.java @@ -11,5 +11,4 @@ public class Employee { public void setSalary(double salary) { this.salary = salary; } - } diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java b/core-java/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java similarity index 67% rename from core-java-8/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java rename to core-java/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java index cfa4226c1a..5c841b7c2b 100644 --- a/core-java-8/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java +++ b/core-java/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java @@ -6,12 +6,11 @@ public class EmployeeSalaryComparator implements Comparator { @Override public int compare(Employee employeeA, Employee employeeB) { - - if(employeeA.getSalary() < employeeB.getSalary()){ + if (employeeA.getSalary() < employeeB.getSalary()) { return -1; - }else if(employeeA.getSalary() > employeeB.getSalary()){ + } else if (employeeA.getSalary() > employeeB.getSalary()) { return 1; - }else{ + } else { return 0; } } diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/HasColor.java b/core-java/src/main/java/com/baeldung/interfaces/HasColor.java similarity index 66% rename from core-java-8/src/main/java/com/baeldung/interfaces/HasColor.java rename to core-java/src/main/java/com/baeldung/interfaces/HasColor.java index 6eface2d47..d9688ea866 100644 --- a/core-java-8/src/main/java/com/baeldung/interfaces/HasColor.java +++ b/core-java/src/main/java/com/baeldung/interfaces/HasColor.java @@ -1,5 +1,4 @@ package com.baeldung.interfaces; public interface HasColor { - public String getColor(); -} \ No newline at end of file +} diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java b/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java similarity index 84% rename from core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java rename to core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java index b951fc0273..d9b30a1e7b 100644 --- a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java +++ b/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java @@ -1,6 +1,7 @@ package com.baeldung.interfaces.multiinheritance; -public class Car implements Fly, Transform { +public class Car implements Fly,Transform { + @Override public void fly() { System.out.println("I can Fly!!"); diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java b/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java similarity index 69% rename from core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java rename to core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java index d84182aec6..611e51c67b 100644 --- a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java +++ b/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java @@ -1,5 +1,6 @@ package com.baeldung.interfaces.multiinheritance; -public abstract interface Fly{ +public interface Fly { + void fly(); } diff --git a/core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java b/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java rename to core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java b/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java new file mode 100644 index 0000000000..be25e112ee --- /dev/null +++ b/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java @@ -0,0 +1,4 @@ +package com.baeldung.interfaces.multiinheritance; + +public abstract class Vehicle implements Transform { +} diff --git a/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java b/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java new file mode 100644 index 0000000000..b4d97bd53a --- /dev/null +++ b/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java @@ -0,0 +1,9 @@ +package com.baeldung.interfaces.polymorphysim; + +public class Circle implements Shape { + + @Override + public String name() { + return "Circle"; + } +} diff --git a/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java b/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java new file mode 100644 index 0000000000..5cce3c3af0 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java @@ -0,0 +1,20 @@ +package com.baeldung.interfaces.polymorphysim; + +import java.util.ArrayList; +import java.util.List; + +public class MainTestClass { + + public static void main(String[] args) { + List shapes = new ArrayList<>(); + Shape circleShape = new Circle(); + Shape squareShape = new Square(); + + shapes.add(circleShape); + shapes.add(squareShape); + + for (Shape shape : shapes) { + System.out.println(shape.name()); + } + } +} diff --git a/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java b/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java new file mode 100644 index 0000000000..885dc73de2 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java @@ -0,0 +1,6 @@ +package com.baeldung.interfaces.polymorphysim; + +public interface Shape { + + String name(); +} diff --git a/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java b/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java new file mode 100644 index 0000000000..c17bdd902d --- /dev/null +++ b/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java @@ -0,0 +1,9 @@ +package com.baeldung.interfaces.polymorphysim; + +public class Square implements Shape { + + @Override + public String name() { + return "Square"; + } +} From 1d14de6b4b2a2fba456967a38a9e9623e925d5a2 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 5 Jan 2019 22:39:29 +0200 Subject: [PATCH 149/441] Update and rename PersonAndEmployeeReflectionTest.java to PersonAndEmployeeReflectionUnitTest.java --- ...tionTest.java => PersonAndEmployeeReflectionUnitTest.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename core-java/src/test/java/com/baeldung/reflection/{PersonAndEmployeeReflectionTest.java => PersonAndEmployeeReflectionUnitTest.java} (98%) diff --git a/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionTest.java b/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java similarity index 98% rename from core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionTest.java rename to core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java index 034e54ee93..c051f165f1 100644 --- a/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionTest.java +++ b/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java @@ -10,7 +10,7 @@ import java.util.List; import static org.junit.Assert.*; -public class PersonAndEmployeeReflectionTest { +public class PersonAndEmployeeReflectionUnitTest { // Fields names private static final String LAST_NAME_FIELD = "lastName"; @@ -125,4 +125,4 @@ public class PersonAndEmployeeReflectionTest { return result; } -} \ No newline at end of file +} From cd4be8ce9eba7905eecb78dd1195bc2ca7936ac5 Mon Sep 17 00:00:00 2001 From: kyleandari <44148335+kyleandari@users.noreply.github.com> Date: Sat, 5 Jan 2019 15:56:01 -0500 Subject: [PATCH 150/441] moving code from java-core to java-core-lang (#6084) --- .../src/main/java/com/baeldung/interfaces/Box.java | 0 .../src/main/java/com/baeldung/interfaces/Employee.java | 0 .../java/com/baeldung/interfaces/EmployeeSalaryComparator.java | 0 .../src/main/java/com/baeldung/interfaces/HasColor.java | 0 .../main/java/com/baeldung/interfaces/multiinheritance/Car.java | 0 .../main/java/com/baeldung/interfaces/multiinheritance/Fly.java | 0 .../java/com/baeldung/interfaces/multiinheritance/Transform.java | 0 .../java/com/baeldung/interfaces/multiinheritance/Vehicle.java | 0 .../main/java/com/baeldung/interfaces/polymorphysim/Circle.java | 0 .../java/com/baeldung/interfaces/polymorphysim/MainTestClass.java | 0 .../main/java/com/baeldung/interfaces/polymorphysim/Shape.java | 0 .../main/java/com/baeldung/interfaces/polymorphysim/Square.java | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/Box.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/Employee.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/HasColor.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java (100%) rename {core-java => core-java-lang}/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java (100%) diff --git a/core-java/src/main/java/com/baeldung/interfaces/Box.java b/core-java-lang/src/main/java/com/baeldung/interfaces/Box.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/Box.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/Box.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/Employee.java b/core-java-lang/src/main/java/com/baeldung/interfaces/Employee.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/Employee.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/Employee.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java b/core-java-lang/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/HasColor.java b/core-java-lang/src/main/java/com/baeldung/interfaces/HasColor.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/HasColor.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/HasColor.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java b/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java b/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java b/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java b/core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java b/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java b/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java b/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java diff --git a/core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java b/core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java similarity index 100% rename from core-java/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java rename to core-java-lang/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java From 20e8886165192cd55e5151120b07ff0029242e28 Mon Sep 17 00:00:00 2001 From: Kumar Chandrakant Date: Sun, 6 Jan 2019 19:26:21 +0530 Subject: [PATCH 151/441] Kafka spark cassandra (#6078) * Adding files for the tutorial BAEL-2301 * Incorporating review comments on the article. --- .../data/pipeline/WordCountingApp.java | 58 ++++------------ .../WordCountingAppWithCheckpoint.java | 66 +++++-------------- 2 files changed, 29 insertions(+), 95 deletions(-) diff --git a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java index 08695b3631..1155644e1e 100644 --- a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java +++ b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java @@ -6,7 +6,6 @@ import static com.datastax.spark.connector.japi.CassandraJavaUtil.mapToRow; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -35,7 +34,6 @@ import scala.Tuple2; public class WordCountingApp { - @SuppressWarnings("serial") public static void main(String[] args) throws InterruptedException { Logger.getLogger("org") .setLevel(Level.OFF); @@ -61,52 +59,24 @@ public class WordCountingApp { JavaInputDStream> messages = KafkaUtils.createDirectStream(streamingContext, LocationStrategies.PreferConsistent(), ConsumerStrategies. Subscribe(topics, kafkaParams)); - JavaPairDStream results = messages.mapToPair(new PairFunction, String, String>() { - @Override - public Tuple2 call(ConsumerRecord record) { - return new Tuple2<>(record.key(), record.value()); - } - }); + JavaPairDStream results = messages.mapToPair((PairFunction, String, String>) record -> new Tuple2<>(record.key(), record.value())); - JavaDStream lines = results.map(new Function, String>() { - @Override - public String call(Tuple2 tuple2) { - return tuple2._2(); - } - }); + JavaDStream lines = results.map((Function, String>) tuple2 -> tuple2._2()); - JavaDStream words = lines.flatMap(new FlatMapFunction() { - @Override - public Iterator call(String x) { - return Arrays.asList(x.split("\\s+")) - .iterator(); - } - }); + JavaDStream words = lines.flatMap((FlatMapFunction) x -> Arrays.asList(x.split("\\s+")) + .iterator()); - JavaPairDStream wordCounts = words.mapToPair(new PairFunction() { - @Override - public Tuple2 call(String s) { - return new Tuple2<>(s, 1); - } - }) - .reduceByKey(new Function2() { - @Override - public Integer call(Integer i1, Integer i2) { - return i1 + i2; - } - }); + JavaPairDStream wordCounts = words.mapToPair((PairFunction) s -> new Tuple2<>(s, 1)) + .reduceByKey((Function2) (i1, i2) -> i1 + i2); - wordCounts.foreachRDD(new VoidFunction>() { - @Override - public void call(JavaPairRDD javaRdd) throws Exception { - Map wordCountMap = javaRdd.collectAsMap(); - for (String key : wordCountMap.keySet()) { - List words = Arrays.asList(new Word(key, wordCountMap.get(key))); - JavaRDD rdd = streamingContext.sparkContext() - .parallelize(words); - javaFunctions(rdd).writerBuilder("vocabulary", "words", mapToRow(Word.class)) - .saveToCassandra(); - } + wordCounts.foreachRDD((VoidFunction>) javaRdd -> { + Map wordCountMap = javaRdd.collectAsMap(); + for (String key : wordCountMap.keySet()) { + List wordList = Arrays.asList(new Word(key, wordCountMap.get(key))); + JavaRDD rdd = streamingContext.sparkContext() + .parallelize(wordList); + javaFunctions(rdd).writerBuilder("vocabulary", "words", mapToRow(Word.class)) + .saveToCassandra(); } }); diff --git a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java index e20b910635..79e21f7209 100644 --- a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java +++ b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java @@ -6,7 +6,6 @@ import static com.datastax.spark.connector.japi.CassandraJavaUtil.mapToRow; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -15,7 +14,6 @@ import org.apache.kafka.common.serialization.StringDeserializer; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.spark.SparkConf; -import org.apache.spark.api.java.JavaPairRDD; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.api.java.Optional; @@ -43,7 +41,6 @@ public class WordCountingAppWithCheckpoint { public static JavaSparkContext sparkContext; - @SuppressWarnings("serial") public static void main(String[] args) throws InterruptedException { Logger.getLogger("org") @@ -74,63 +71,30 @@ public class WordCountingAppWithCheckpoint { JavaInputDStream> messages = KafkaUtils.createDirectStream(streamingContext, LocationStrategies.PreferConsistent(), ConsumerStrategies. Subscribe(topics, kafkaParams)); - JavaPairDStream results = messages.mapToPair(new PairFunction, String, String>() { - @Override - public Tuple2 call(ConsumerRecord record) { - return new Tuple2<>(record.key(), record.value()); - } - }); + JavaPairDStream results = messages.mapToPair((PairFunction, String, String>) record -> new Tuple2<>(record.key(), record.value())); - JavaDStream lines = results.map(new Function, String>() { - @Override - public String call(Tuple2 tuple2) { - return tuple2._2(); - } - }); + JavaDStream lines = results.map((Function, String>) tuple2 -> tuple2._2()); - JavaDStream words = lines.flatMap(new FlatMapFunction() { - @Override - public Iterator call(String x) { - return Arrays.asList(x.split("\\s+")) - .iterator(); - } - }); + JavaDStream words = lines.flatMap((FlatMapFunction) x -> Arrays.asList(x.split("\\s+")) + .iterator()); - JavaPairDStream wordCounts = words.mapToPair(new PairFunction() { - @Override - public Tuple2 call(String s) { - return new Tuple2<>(s, 1); - } - }) - .reduceByKey(new Function2() { - @Override - public Integer call(Integer i1, Integer i2) { - return i1 + i2; - } - }); + JavaPairDStream wordCounts = words.mapToPair((PairFunction) s -> new Tuple2<>(s, 1)) + .reduceByKey((Function2) (i1, i2) -> i1 + i2); - Function3, State, Tuple2> mappingFunc = (word, one, state) -> { + JavaMapWithStateDStream> cumulativeWordCounts = wordCounts.mapWithState(StateSpec.function((Function3, State, Tuple2>) (word, one, state) -> { int sum = one.orElse(0) + (state.exists() ? state.get() : 0); Tuple2 output = new Tuple2<>(word, sum); state.update(sum); return output; - }; + })); - JavaPairRDD initialRDD = JavaPairRDD.fromJavaRDD(sparkContext.emptyRDD()); - - JavaMapWithStateDStream> cumulativeWordCounts = wordCounts.mapWithState(StateSpec.function(mappingFunc) - .initialState(initialRDD)); - - cumulativeWordCounts.foreachRDD(new VoidFunction>>() { - @Override - public void call(JavaRDD> javaRdd) throws Exception { - List> wordCountList = javaRdd.collect(); - for (Tuple2 tuple : wordCountList) { - List words = Arrays.asList(new Word(tuple._1, tuple._2)); - JavaRDD rdd = sparkContext.parallelize(words); - javaFunctions(rdd).writerBuilder("vocabulary", "words", mapToRow(Word.class)) - .saveToCassandra(); - } + cumulativeWordCounts.foreachRDD((VoidFunction>>) javaRdd -> { + List> wordCountList = javaRdd.collect(); + for (Tuple2 tuple : wordCountList) { + List wordList = Arrays.asList(new Word(tuple._1, tuple._2)); + JavaRDD rdd = sparkContext.parallelize(wordList); + javaFunctions(rdd).writerBuilder("vocabulary", "words", mapToRow(Word.class)) + .saveToCassandra(); } }); From 731a3cd2298232d75ce41fd2ab194f091bca4e36 Mon Sep 17 00:00:00 2001 From: Corneil du Plessis Date: Sun, 6 Jan 2019 16:15:09 +0200 Subject: [PATCH 152/441] BAEL-2104: Spring Boot deployment to AWS Beanstalk (#5951) --- spring-boot-bootstrap/pom.xml | 21 +++++++++++++++++++ .../application-beanstalk.properties | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 spring-boot-bootstrap/src/main/resources/application-beanstalk.properties diff --git a/spring-boot-bootstrap/pom.xml b/spring-boot-bootstrap/pom.xml index 7cafc5aa24..0ffc1820b8 100644 --- a/spring-boot-bootstrap/pom.xml +++ b/spring-boot-bootstrap/pom.xml @@ -57,6 +57,27 @@ + + beanstalk + + ${project.name}-eb + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + **/cloud/config/*.java + + + + + + openshift diff --git a/spring-boot-bootstrap/src/main/resources/application-beanstalk.properties b/spring-boot-bootstrap/src/main/resources/application-beanstalk.properties new file mode 100644 index 0000000000..de03a3b5bb --- /dev/null +++ b/spring-boot-bootstrap/src/main/resources/application-beanstalk.properties @@ -0,0 +1,3 @@ +spring.datasource.url=jdbc:mysql://${rds.hostname}:${rds.port}/${rds.db.name} +spring.datasource.username=${rds.username} +spring.datasource.password=${rds.password} \ No newline at end of file From e89c0948d8b33be57cecf099b189748c2dc7cc29 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sat, 5 Jan 2019 19:58:09 +0530 Subject: [PATCH 153/441] [BAEL-11415] - Initial commit with sparing-kafka version and topic creation configuration onstatup --- spring-kafka/pom.xml | 2 +- .../spring/kafka/KafkaApplication.java | 18 +++++- .../spring/kafka/KafkaTopicConfig.java | 57 +++++++++++++++++++ .../org/baeldung/SpringContextLiveTest.java | 17 ++++++ 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaTopicConfig.java create mode 100644 spring-kafka/src/test/java/org/baeldung/SpringContextLiveTest.java diff --git a/spring-kafka/pom.xml b/spring-kafka/pom.xml index 5c370880b4..b76d4f10c0 100644 --- a/spring-kafka/pom.xml +++ b/spring-kafka/pom.xml @@ -33,7 +33,7 @@ - 1.1.3.RELEASE + 2.2.2.RELEASE 2.9.7 diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplication.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplication.java index 4ee7f40335..b313eafdb9 100644 --- a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplication.java +++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaApplication.java @@ -13,8 +13,11 @@ import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.annotation.TopicPartition; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.support.KafkaHeaders; +import org.springframework.kafka.support.SendResult; import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.handler.annotation.Payload; +import org.springframework.util.concurrent.ListenableFuture; +import org.springframework.util.concurrent.ListenableFutureCallback; @SpringBootApplication public class KafkaApplication { @@ -98,7 +101,20 @@ public class KafkaApplication { private String greetingTopicName; public void sendMessage(String message) { - kafkaTemplate.send(topicName, message); + + ListenableFuture> future = kafkaTemplate.send(topicName, message); + + future.addCallback(new ListenableFutureCallback>() { + + @Override + public void onSuccess(SendResult result) { + System.out.println("Sent message=[" + message + "] with offset=[" + result.getRecordMetadata().offset() + "]"); + } + @Override + public void onFailure(Throwable ex) { + System.out.println("Unable to send message=[" + message + "] due to : " + ex.getMessage()); + } + }); } public void sendMessageToPartion(String message, int partition) { diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaTopicConfig.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaTopicConfig.java new file mode 100644 index 0000000000..a3426e78a3 --- /dev/null +++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaTopicConfig.java @@ -0,0 +1,57 @@ +package com.baeldung.spring.kafka; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.kafka.clients.admin.AdminClientConfig; +import org.apache.kafka.clients.admin.NewTopic; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.kafka.core.KafkaAdmin; + +@Configuration +public class KafkaTopicConfig { + + @Value(value = "${kafka.bootstrapAddress}") + private String bootstrapAddress; + + @Value(value = "${message.topic.name}") + private String topicName; + + @Value(value = "${partitioned.topic.name}") + private String partionedTopicName; + + @Value(value = "${filtered.topic.name}") + private String filteredTopicName; + + @Value(value = "${greeting.topic.name}") + private String greetingTopicName; + + @Bean + public KafkaAdmin kafkaAdmin() { + Map configs = new HashMap<>(); + configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); + return new KafkaAdmin(configs); + } + + @Bean + public NewTopic topic1() { + return new NewTopic(topicName, 1, (short) 1); + } + + @Bean + public NewTopic topic2() { + return new NewTopic(partionedTopicName, 6, (short) 1); + } + + @Bean + public NewTopic topic3() { + return new NewTopic(filteredTopicName, 1, (short) 1); + } + + @Bean + public NewTopic topic4() { + return new NewTopic(greetingTopicName, 1, (short) 1); + } +} diff --git a/spring-kafka/src/test/java/org/baeldung/SpringContextLiveTest.java b/spring-kafka/src/test/java/org/baeldung/SpringContextLiveTest.java new file mode 100644 index 0000000000..d8fb3131f5 --- /dev/null +++ b/spring-kafka/src/test/java/org/baeldung/SpringContextLiveTest.java @@ -0,0 +1,17 @@ +package org.baeldung; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.spring.kafka.KafkaApplication; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = KafkaApplication.class) +public class SpringContextLiveTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} From 6f1e14b649b821cb1ab38c9ae3a3b3e24eb8d05d Mon Sep 17 00:00:00 2001 From: Andrey Shcherbakov Date: Sun, 6 Jan 2019 21:31:51 +0100 Subject: [PATCH 154/441] Code for article BAEL-2386 (#5958) * Add code for the article 'Java Primitives versus Objects' * Use JMH for benchmarking the primitive and wrapper classes * Uncomment the benchmarks and remove unused class * Add a binary search tree implementation * Add an example of how to use the binary tree class * Adjust the print statements * Add a code for article #BAEL-2386 --- .../flightrecorder/FlightRecorder.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java diff --git a/core-java/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java b/core-java/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java new file mode 100644 index 0000000000..02c3e96124 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java @@ -0,0 +1,32 @@ +package com.baeldung.flightrecorder; + +import java.util.ArrayList; +import java.util.List; + +/** + * Simple program that illustrates how to use Java Flight Recorder. + * + * This programs creates a list, inserts objects in it until + * an OutOfMemoryError is thrown. + * + */ +public class FlightRecorder { + + public static void main(String[] args) { + List items = new ArrayList<>(1); + try { + while (true) { + items.add(new Object()); + } + } catch (OutOfMemoryError e) { + System.out.println(e.getMessage()); + } + assert items.size() > 0; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + System.out.println(e.getMessage()); + } + } + +} From 65b9909fed4ab0a002cdb8554e0b86c91ae714a1 Mon Sep 17 00:00:00 2001 From: Rajesh Bhojwani Date: Mon, 7 Jan 2019 14:01:13 +0530 Subject: [PATCH 155/441] username:rajeshbhojwani "Java toString() method" (#6047) * Check in code for Java toString method * fix formatting issues * Fix formatting issues * Fix formatting issues * Fix formatting issues * Fix formatting issues * Fix formatting issues * replacing orders with order * Update formatting * Fix formatting * Fix formatting * Fix formatting * Fix formatting * Fix formatting --- .../baeldung/string/tostring/Customer.java | 19 ++++++++ .../tostring/CustomerArrayToString.java | 19 ++++++++ .../CustomerComplexObjectToString.java | 19 ++++++++ .../tostring/CustomerPrimitiveToString.java | 19 ++++++++ .../tostring/CustomerReflectionToString.java | 41 +++++++++++++++++ .../CustomerWrapperCollectionToString.java | 39 ++++++++++++++++ .../com/baeldung/string/tostring/Order.java | 46 +++++++++++++++++++ .../tostring/CustomerArrayToStringTest.java | 26 +++++++++++ .../CustomerComplexObjectToStringTest.java | 25 ++++++++++ .../CustomerPrimitiveToStringTest.java | 22 +++++++++ .../CustomerReflectionToStringTest.java | 32 +++++++++++++ ...CustomerWrapperCollectionToStringTest.java | 33 +++++++++++++ 12 files changed, 340 insertions(+) create mode 100644 java-strings/src/main/java/com/baeldung/string/tostring/Customer.java create mode 100644 java-strings/src/main/java/com/baeldung/string/tostring/CustomerArrayToString.java create mode 100644 java-strings/src/main/java/com/baeldung/string/tostring/CustomerComplexObjectToString.java create mode 100644 java-strings/src/main/java/com/baeldung/string/tostring/CustomerPrimitiveToString.java create mode 100644 java-strings/src/main/java/com/baeldung/string/tostring/CustomerReflectionToString.java create mode 100644 java-strings/src/main/java/com/baeldung/string/tostring/CustomerWrapperCollectionToString.java create mode 100644 java-strings/src/main/java/com/baeldung/string/tostring/Order.java create mode 100644 java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringTest.java create mode 100644 java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringTest.java diff --git a/java-strings/src/main/java/com/baeldung/string/tostring/Customer.java b/java-strings/src/main/java/com/baeldung/string/tostring/Customer.java new file mode 100644 index 0000000000..e914a83f0e --- /dev/null +++ b/java-strings/src/main/java/com/baeldung/string/tostring/Customer.java @@ -0,0 +1,19 @@ +package com.baeldung.string.tostring; + +public class Customer { + private String firstName; + private String lastName; + + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/java-strings/src/main/java/com/baeldung/string/tostring/CustomerArrayToString.java b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerArrayToString.java new file mode 100644 index 0000000000..1736657276 --- /dev/null +++ b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerArrayToString.java @@ -0,0 +1,19 @@ +package com.baeldung.string.tostring; + +import java.util.Arrays; + +public class CustomerArrayToString extends Customer { + private Order[] orders; + + public Order[] getOrders() { + return orders; + } + public void setOrders(Order[] orders) { + this.orders = orders; + } + @Override + public String toString() { + return "Customer [orders=" + Arrays.toString(orders) + ", getFirstName()=" + getFirstName() + + ", getLastName()=" + getLastName() + "]"; + } +} diff --git a/java-strings/src/main/java/com/baeldung/string/tostring/CustomerComplexObjectToString.java b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerComplexObjectToString.java new file mode 100644 index 0000000000..9bede1b3fc --- /dev/null +++ b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerComplexObjectToString.java @@ -0,0 +1,19 @@ +package com.baeldung.string.tostring; + +public class CustomerComplexObjectToString extends Customer { + private Order order; + + public Order getOrder() { + return order; + } + + public void setOrder(Order order) { + this.order = order; + } + + @Override + public String toString() { + return "Customer [order=" + order + ", getFirstName()=" + getFirstName() + + ", getLastName()=" + getLastName() + "]"; + } +} \ No newline at end of file diff --git a/java-strings/src/main/java/com/baeldung/string/tostring/CustomerPrimitiveToString.java b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerPrimitiveToString.java new file mode 100644 index 0000000000..86e08ca447 --- /dev/null +++ b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerPrimitiveToString.java @@ -0,0 +1,19 @@ +package com.baeldung.string.tostring; + +public class CustomerPrimitiveToString extends Customer { + private long balance; + + public long getBalance() { + return balance; + } + + public void setBalance(long balance) { + this.balance = balance; + } + + @Override + public String toString() { + return "Customer [balance=" + balance + ", getFirstName()=" + getFirstName() + + ", getLastName()=" + getLastName() + "]"; + } +} diff --git a/java-strings/src/main/java/com/baeldung/string/tostring/CustomerReflectionToString.java b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerReflectionToString.java new file mode 100644 index 0000000000..2da1163c63 --- /dev/null +++ b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerReflectionToString.java @@ -0,0 +1,41 @@ +package com.baeldung.string.tostring; + +import java.util.List; + +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; + +public class CustomerReflectionToString extends Customer{ + + private Integer score; + private List orders; + private StringBuffer fullname; + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + public List getOrders() { + return orders; + } + + public void setOrders(List orders) { + this.orders = orders; + } + + public StringBuffer getFullname() { + return fullname; + } + + public void setFullname(StringBuffer fullname) { + this.fullname = fullname; + } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } +} diff --git a/java-strings/src/main/java/com/baeldung/string/tostring/CustomerWrapperCollectionToString.java b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerWrapperCollectionToString.java new file mode 100644 index 0000000000..6c7b999045 --- /dev/null +++ b/java-strings/src/main/java/com/baeldung/string/tostring/CustomerWrapperCollectionToString.java @@ -0,0 +1,39 @@ +package com.baeldung.string.tostring; + +import java.util.List; + +public class CustomerWrapperCollectionToString extends Customer { + private Integer score; + private List orders; + private StringBuffer fullname; + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + public List getOrders() { + return orders; + } + + public void setOrders(List orders) { + this.orders = orders; + } + + public StringBuffer getFullname() { + return fullname; + } + + public void setFullname(StringBuffer fullname) { + this.fullname = fullname; + } + + @Override + public String toString() { + return "Customer [score=" + score + ", orders=" + orders + ", fullname=" + fullname + + ", getFirstName()=" + getFirstName() + ", getLastName()=" + getLastName() + "]"; + } +} diff --git a/java-strings/src/main/java/com/baeldung/string/tostring/Order.java b/java-strings/src/main/java/com/baeldung/string/tostring/Order.java new file mode 100644 index 0000000000..017e2d9bc8 --- /dev/null +++ b/java-strings/src/main/java/com/baeldung/string/tostring/Order.java @@ -0,0 +1,46 @@ +package com.baeldung.string.tostring; + +public class Order { + + private String orderId; + private String desc; + private long value; + private String status; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public long getValue() { + return value; + } + + public void setValue(long value) { + this.value = value; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + @Override + public String toString() { + return "Order [orderId=" + orderId + ", desc=" + desc + ", value=" + value + "]"; + } + +} diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringTest.java new file mode 100644 index 0000000000..31e268b4a3 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringTest.java @@ -0,0 +1,26 @@ +package com.baeldung.string.tostring; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class CustomerArrayToStringTest { + private static final String CUSTOMER_ARRAY_TO_STRING + = "Customer [orders=[Order [orderId=A1111, desc=Game, value=0]], getFirstName()=Rajesh, getLastName()=Bhojwani]"; + + @Test + public void givenArray_whenToString_thenCustomerDetails() { + CustomerArrayToString customer = new CustomerArrayToString(); + customer.setFirstName("Rajesh"); + customer.setLastName("Bhojwani"); + Order[] orders = new Order[1]; + orders[0] = new Order(); + orders[0].setOrderId("A1111"); + orders[0].setDesc("Game"); + orders[0].setStatus("In-Shiping"); + customer.setOrders(orders); + + assertEquals(CUSTOMER_ARRAY_TO_STRING, customer.toString()); + } + +} diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringTest.java new file mode 100644 index 0000000000..3c98394f85 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringTest.java @@ -0,0 +1,25 @@ +package com.baeldung.string.tostring; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class CustomerComplexObjectToStringTest { + private static final String CUSTOMER_COMPLEX_TO_STRING + = "Customer [order=Order [orderId=A1111, desc=Game, value=0], getFirstName()=Rajesh, getLastName()=Bhojwani]"; + + @Test + public void givenComplex_whenToString_thenCustomerDetails() { + CustomerComplexObjectToString customer = new CustomerComplexObjectToString(); + customer.setFirstName("Rajesh"); + customer.setLastName("Bhojwani"); + Order order = new Order(); + order.setOrderId("A1111"); + order.setDesc("Game"); + order.setStatus("In-Shiping"); + customer.setOrder(order); + + assertEquals(CUSTOMER_COMPLEX_TO_STRING, customer.toString()); + } + +} diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringTest.java new file mode 100644 index 0000000000..2a29cb93d8 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringTest.java @@ -0,0 +1,22 @@ +package com.baeldung.string.tostring; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class CustomerPrimitiveToStringTest { + + private static final String CUSTOMER_PRIMITIVE_TO_STRING + = "Customer [balance=110, getFirstName()=Rajesh, getLastName()=Bhojwani]"; + + @Test + public void givenPrimitive_whenToString_thenCustomerDetails() { + CustomerPrimitiveToString customer = new CustomerPrimitiveToString(); + customer.setFirstName("Rajesh"); + customer.setLastName("Bhojwani"); + customer.setBalance(110); + + assertEquals(CUSTOMER_PRIMITIVE_TO_STRING, customer.toString()); + } +} + diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringTest.java new file mode 100644 index 0000000000..290bef7133 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringTest.java @@ -0,0 +1,32 @@ +package com.baeldung.string.tostring; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Test; + +public class CustomerReflectionToStringTest { + private static final String CUSTOMER_REFLECTION_TO_STRING = "com.baeldung.string.tostring.CustomerReflectionToString"; + + @Test + public void givenWrapperCollectionStrBuffer_whenReflectionToString_thenCustomerDetails() { + CustomerReflectionToString customer = new CustomerReflectionToString(); + customer.setFirstName("Rajesh"); + customer.setLastName("Bhojwani"); + customer.setScore(8); + + List orders = new ArrayList(); + orders.add("Book"); + orders.add("Pen"); + customer.setOrders(orders); + + StringBuffer fullname = new StringBuffer(); + fullname.append(customer.getLastName()+", "+ customer.getFirstName()); + customer.setFullname(fullname); + + assertTrue(customer.toString().contains(CUSTOMER_REFLECTION_TO_STRING)); + } + +} diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringTest.java new file mode 100644 index 0000000000..c80969d453 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringTest.java @@ -0,0 +1,33 @@ +package com.baeldung.string.tostring; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Test; + +public class CustomerWrapperCollectionToStringTest { + private static final String CUSTOMER_WRAPPER_COLLECTION_TO_STRING + = "Customer [score=8, orders=[Book, Pen], fullname=Bhojwani, Rajesh, getFirstName()=Rajesh, getLastName()=Bhojwani]"; + + @Test + public void givenWrapperCollectionStrBuffer_whenToString_thenCustomerDetails() { + CustomerWrapperCollectionToString customer = new CustomerWrapperCollectionToString(); + customer.setFirstName("Rajesh"); + customer.setLastName("Bhojwani"); + customer.setScore(8); + + List orders = new ArrayList(); + orders.add("Book"); + orders.add("Pen"); + customer.setOrders(orders); + + StringBuffer fullname = new StringBuffer(); + fullname.append(customer.getLastName()+", "+ customer.getFirstName()); + customer.setFullname(fullname); + + assertEquals(CUSTOMER_WRAPPER_COLLECTION_TO_STRING, customer.toString()); + } + +} From 04743892db4547edada008b617ff6202da583da2 Mon Sep 17 00:00:00 2001 From: Alejandro Gervasio Date: Mon, 7 Jan 2019 08:17:52 -0300 Subject: [PATCH 156/441] What is thread-safety and how to achieve it Issue: BAEL-2416 --- .../threadsafety/application/Application.java | 86 +++++++++++++++++++ .../callables/AtomicCounterCallable.java | 19 ++++ .../callables/CounterCallable.java | 19 ++++ .../ExtrinsicLockCounterCallable.java | 19 ++++ .../callables/MessageServiceCallable.java | 19 ++++ .../ReentranReadWriteLockCounterCallable.java | 20 +++++ .../ReentrantLockCounterCallable.java | 19 ++++ .../threadsafety/mathutils/MathUtils.java | 14 +++ .../threadsafety/services/AtomicCounter.java | 18 ++++ .../threadsafety/services/Counter.java | 18 ++++ .../services/ExtrinsicLockCounter.java | 23 +++++ .../threadsafety/services/MessageService.java | 14 +++ .../services/ReentrantLockCounter.java | 26 ++++++ .../ReentrantReadWriteLockCounter.java | 34 ++++++++ .../threadsafety/services/StateHolder.java | 14 +++ .../threadsafety/tests/CounterTest.java | 23 +++++ .../tests/ExtrinsicLockCounterTest.java | 23 +++++ .../threadsafety/tests/MathUtilsTest.java | 13 +++ .../tests/MessageServiceTest.java | 23 +++++ .../tests/ReentrantLockCounterTest.java | 23 +++++ .../ReentrantReadWriteLockCounterTest.java | 24 ++++++ 21 files changed, 491 insertions(+) create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java create mode 100644 core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java create mode 100644 core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java create mode 100644 core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java create mode 100644 core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java create mode 100644 core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java create mode 100644 core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java create mode 100644 core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java new file mode 100644 index 0000000000..0c5caba8a0 --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java @@ -0,0 +1,86 @@ +package com.baeldung.concurrent.threadsafety.application; + +import com.baeldung.concurrent.threadsafety.callables.AtomicCounterCallable; +import com.baeldung.concurrent.threadsafety.mathutils.MathUtils; +import com.baeldung.concurrent.threadsafety.callables.CounterCallable; +import com.baeldung.concurrent.threadsafety.callables.ExtrinsicLockCounterCallable; +import com.baeldung.concurrent.threadsafety.callables.MessageServiceCallable; +import com.baeldung.concurrent.threadsafety.callables.ReentranReadWriteLockCounterCallable; +import com.baeldung.concurrent.threadsafety.callables.ReentrantLockCounterCallable; +import com.baeldung.concurrent.threadsafety.services.AtomicCounter; +import com.baeldung.concurrent.threadsafety.services.Counter; +import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; +import com.baeldung.concurrent.threadsafety.services.MessageService; +import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; +import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class Application { + + public static void main(String[] args) throws InterruptedException, ExecutionException { + + new Thread(() -> { + System.out.println(MathUtils.factorial(10)); + }).start(); + new Thread(() -> { + System.out.println(MathUtils.factorial(5)); + }).start(); + + ExecutorService executorService = Executors.newFixedThreadPool(10); + MessageService messageService = new MessageService("Welcome to Baeldung!"); + Future future1 = (Future) executorService.submit(new MessageServiceCallable(messageService)); + Future future2 = (Future) executorService.submit(new MessageServiceCallable(messageService)); + System.out.println(future1.get()); + System.out.println(future2.get()); + + Counter counter = new Counter(); + Future future3 = (Future) executorService.submit(new CounterCallable(counter)); + Future future4 = (Future) executorService.submit(new CounterCallable(counter)); + System.out.println(future3.get()); + System.out.println(future4.get()); + + ExtrinsicLockCounter extrinsicLockCounter = new ExtrinsicLockCounter(); + Future future5 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(extrinsicLockCounter)); + Future future6 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(extrinsicLockCounter)); + System.out.println(future5.get()); + System.out.println(future6.get()); + + ReentrantLockCounter reentrantLockCounter = new ReentrantLockCounter(); + Future future7 = (Future) executorService.submit(new ReentrantLockCounterCallable(reentrantLockCounter)); + Future future8 = (Future) executorService.submit(new ReentrantLockCounterCallable(reentrantLockCounter)); + System.out.println(future7.get()); + System.out.println(future8.get()); + + ReentrantReadWriteLockCounter reentrantReadWriteLockCounter = new ReentrantReadWriteLockCounter(); + Future future9 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(reentrantReadWriteLockCounter)); + Future future10 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(reentrantReadWriteLockCounter)); + System.out.println(future9.get()); + System.out.println(future10.get()); + + AtomicCounter atomicCounter = new AtomicCounter(); + Future future11 = (Future) executorService.submit(new AtomicCounterCallable(atomicCounter)); + Future future12 = (Future) executorService.submit(new AtomicCounterCallable(atomicCounter)); + System.out.println(future11.get()); + System.out.println(future12.get()); + + Collection syncCollection = Collections.synchronizedCollection(new ArrayList<>()); + Thread thread11 = new Thread(() -> syncCollection.addAll(Arrays.asList(1, 2, 3, 4, 5, 6))); + Thread thread12 = new Thread(() -> syncCollection.addAll(Arrays.asList(1, 2, 3, 4, 5, 6))); + thread11.start(); + thread12.start(); + + Map concurrentMap = new ConcurrentHashMap<>(); + concurrentMap.put("1", "one"); + concurrentMap.put("2", "two"); + concurrentMap.put("3", "three"); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java new file mode 100644 index 0000000000..d711299b5c --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/AtomicCounterCallable.java @@ -0,0 +1,19 @@ +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.AtomicCounter; +import java.util.concurrent.Callable; + +public class AtomicCounterCallable implements Callable { + + private final AtomicCounter counter; + + public AtomicCounterCallable(AtomicCounter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java new file mode 100644 index 0000000000..cdcd84a17b --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/CounterCallable.java @@ -0,0 +1,19 @@ +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.Counter; +import java.util.concurrent.Callable; + +public class CounterCallable implements Callable { + + private final Counter counter; + + public CounterCallable(Counter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java new file mode 100644 index 0000000000..29533e7630 --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java @@ -0,0 +1,19 @@ +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; +import java.util.concurrent.Callable; + +public class ExtrinsicLockCounterCallable implements Callable { + + private final ExtrinsicLockCounter counter; + + public ExtrinsicLockCounterCallable(ExtrinsicLockCounter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java new file mode 100644 index 0000000000..84e8c7bb51 --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/MessageServiceCallable.java @@ -0,0 +1,19 @@ +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.MessageService; +import java.util.concurrent.Callable; + +public class MessageServiceCallable implements Callable { + + private final MessageService messageService; + + public MessageServiceCallable(MessageService messageService) { + this.messageService = messageService; + + } + + @Override + public String call() { + return messageService.getMesssage(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java new file mode 100644 index 0000000000..e806460d50 --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentranReadWriteLockCounterCallable.java @@ -0,0 +1,20 @@ +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; +import java.util.concurrent.Callable; + +public class ReentranReadWriteLockCounterCallable implements Callable { + + private final ReentrantReadWriteLockCounter counter; + + public ReentranReadWriteLockCounterCallable(ReentrantReadWriteLockCounter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } + +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java new file mode 100644 index 0000000000..3511a98c60 --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ReentrantLockCounterCallable.java @@ -0,0 +1,19 @@ +package com.baeldung.concurrent.threadsafety.callables; + +import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; +import java.util.concurrent.Callable; + +public class ReentrantLockCounterCallable implements Callable { + + private final ReentrantLockCounter counter; + + public ReentrantLockCounterCallable(ReentrantLockCounter counter) { + this.counter = counter; + } + + @Override + public Integer call() throws Exception { + counter.incrementCounter(); + return counter.getCounter(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java new file mode 100644 index 0000000000..f560cd4281 --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/mathutils/MathUtils.java @@ -0,0 +1,14 @@ +package com.baeldung.concurrent.threadsafety.mathutils; + +import java.math.BigInteger; + +public class MathUtils { + + public static BigInteger factorial(int number) { + BigInteger f = new BigInteger("1"); + for (int i = 2; i <= number; i++) { + f = f.multiply(BigInteger.valueOf(i)); + } + return f; + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java new file mode 100644 index 0000000000..32a373495c --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/AtomicCounter.java @@ -0,0 +1,18 @@ +package com.baeldung.concurrent.threadsafety.services; + +import java.util.concurrent.atomic.AtomicInteger; + +public class AtomicCounter { + + private final AtomicInteger counter = new AtomicInteger(); + + public AtomicCounter() {} + + public void incrementCounter() { + counter.incrementAndGet(); + } + + public synchronized int getCounter() { + return counter.get(); + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java new file mode 100644 index 0000000000..f7dbc05639 --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/Counter.java @@ -0,0 +1,18 @@ +package com.baeldung.concurrent.threadsafety.services; + +public class Counter { + + private volatile int counter; + + public Counter() { + this.counter = 0; + } + + public synchronized void incrementCounter() { + counter += 1; + } + + public int getCounter() { + return counter; + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java new file mode 100644 index 0000000000..8ab431fbc3 --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java @@ -0,0 +1,23 @@ +package com.baeldung.concurrent.threadsafety.services; + +public class ExtrinsicLockCounter { + + private int counter; + private final Object lock = new Object(); + + public ExtrinsicLockCounter() { + this.counter = 0; + } + + public void incrementCounter() { + synchronized (lock) { + counter += 1; + } + } + + public int getCounter() { + synchronized (lock) { + return counter; + } + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java new file mode 100644 index 0000000000..33981381ea --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/MessageService.java @@ -0,0 +1,14 @@ +package com.baeldung.concurrent.threadsafety.services; + +public class MessageService { + + private final String message; + + public MessageService(String message) { + this.message = message; + } + + public String getMesssage() { + return message; + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java new file mode 100644 index 0000000000..717f0717af --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantLockCounter.java @@ -0,0 +1,26 @@ +package com.baeldung.concurrent.threadsafety.services; + +import java.util.concurrent.locks.ReentrantLock; + +public class ReentrantLockCounter { + + private int counter; + private final ReentrantLock reLock = new ReentrantLock(true); + + public ReentrantLockCounter() { + this.counter = 0; + } + + public void incrementCounter() { + reLock.lock(); + try { + counter += 1; + } finally { + reLock.unlock(); + } + } + + public int getCounter() { + return counter; + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java new file mode 100644 index 0000000000..f740c938b1 --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ReentrantReadWriteLockCounter.java @@ -0,0 +1,34 @@ +package com.baeldung.concurrent.threadsafety.services; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +public class ReentrantReadWriteLockCounter { + + private int counter; + private final ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); + private final Lock readLock = rwLock.readLock(); + private final Lock writeLock = rwLock.writeLock(); + + public ReentrantReadWriteLockCounter() { + this.counter = 0; + } + + public void incrementCounter() { + writeLock.lock(); + try { + counter += 1; + } finally { + writeLock.unlock(); + } + } + + public int getCounter() { + readLock.lock(); + try { + return counter; + } finally { + readLock.unlock(); + } + } +} diff --git a/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java new file mode 100644 index 0000000000..5bbff9f39c --- /dev/null +++ b/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/StateHolder.java @@ -0,0 +1,14 @@ +package com.baeldung.concurrent.threadsafety.services; + +public class StateHolder { + + private final String state; + + public StateHolder(String state) { + this.state = state; + } + + public String getState() { + return state; + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java new file mode 100644 index 0000000000..3abbb1bdad --- /dev/null +++ b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/CounterTest.java @@ -0,0 +1,23 @@ +package com.baeldung.concurrent.threadsafety.tests; + +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.baeldung.concurrent.threadsafety.callables.CounterCallable; +import com.baeldung.concurrent.threadsafety.services.Counter; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class CounterTest { + + @Test + public void whenCalledIncrementCounter_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + Counter counter = new Counter(); + Future future1 = (Future) executorService.submit(new CounterCallable(counter)); + Future future2 = (Future) executorService.submit(new CounterCallable(counter)); + + assertThat(future1.get()).isEqualTo(1); + assertThat(future2.get()).isEqualTo(2); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java new file mode 100644 index 0000000000..dba90f5b74 --- /dev/null +++ b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ExtrinsicLockCounterTest.java @@ -0,0 +1,23 @@ +package com.baeldung.concurrent.threadsafety.tests; + +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.baeldung.concurrent.threadsafety.callables.ExtrinsicLockCounterCallable; +import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class ExtrinsicLockCounterTest { + + @Test + public void whenCalledIncrementCounter_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + ExtrinsicLockCounter counter = new ExtrinsicLockCounter(); + Future future1 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(counter)); + Future future2 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(counter)); + + assertThat(future1.get()).isEqualTo(1); + assertThat(future2.get()).isEqualTo(2); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java new file mode 100644 index 0000000000..8f3f574b03 --- /dev/null +++ b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MathUtilsTest.java @@ -0,0 +1,13 @@ +package com.baeldung.concurrent.threadsafety.tests; + +import com.baeldung.concurrent.threadsafety.mathutils.MathUtils; +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class MathUtilsTest { + + @Test + public void whenCalledFactorialMethod_thenCorrect() { + assertThat(MathUtils.factorial(2)).isEqualTo(2); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java new file mode 100644 index 0000000000..8f1f1a8754 --- /dev/null +++ b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/MessageServiceTest.java @@ -0,0 +1,23 @@ +package com.baeldung.concurrent.threadsafety.tests; + +import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; +import com.baeldung.concurrent.threadsafety.callables.MessageServiceCallable; +import com.baeldung.concurrent.threadsafety.services.MessageService; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class MessageServiceTest { + + @Test + public void whenCalledgetMessage_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + MessageService messageService = new MessageService("Welcome to Baeldung!"); + Future future1 = (Future) executorService.submit(new MessageServiceCallable(messageService)); + Future future2 = (Future) executorService.submit(new MessageServiceCallable(messageService)); + + assertThat(future1.get()).isEqualTo("Welcome to Baeldung!"); + assertThat(future2.get()).isEqualTo("Welcome to Baeldung!"); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java new file mode 100644 index 0000000000..05c721ab26 --- /dev/null +++ b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantLockCounterTest.java @@ -0,0 +1,23 @@ +package com.baeldung.concurrent.threadsafety.tests; + +import com.baeldung.concurrent.threadsafety.callables.ReentrantLockCounterCallable; +import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class ReentrantLockCounterTest { + + @Test + public void whenCalledIncrementCounter_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + ReentrantLockCounter counter = new ReentrantLockCounter(); + Future future1 = (Future) executorService.submit(new ReentrantLockCounterCallable(counter)); + Future future2 = (Future) executorService.submit(new ReentrantLockCounterCallable(counter)); + + assertThat(future1.get()).isEqualTo(1); + assertThat(future2.get()).isEqualTo(2); + } +} diff --git a/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java new file mode 100644 index 0000000000..c56137ce04 --- /dev/null +++ b/core-java-concurrency-basic/src/test/com/baeldung/concurrent/threadsafety/tests/ReentrantReadWriteLockCounterTest.java @@ -0,0 +1,24 @@ +package com.baeldung.concurrent.threadsafety.tests; + +import com.baeldung.concurrent.threadsafety.callables.ReentranReadWriteLockCounterCallable; +import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class ReentrantReadWriteLockCounterTest { + + @Test + public void whenCalledIncrementCounter_thenCorrect() throws Exception { + ExecutorService executorService = Executors.newFixedThreadPool(2); + ReentrantReadWriteLockCounter counter = new ReentrantReadWriteLockCounter(); + Future future1 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(counter)); + Future future2 = (Future) executorService.submit(new ReentranReadWriteLockCounterCallable(counter)); + + assertThat(future1.get()).isEqualTo(1); + assertThat(future2.get()).isEqualTo(2); + } + +} From 0e69cd5ab47d61ac4c18cac73e9d516e1c7ca8db Mon Sep 17 00:00:00 2001 From: Surapaneni Venkata Kiran Date: Mon, 7 Jan 2019 09:02:58 -0500 Subject: [PATCH 157/441] Changes to enable TLSv1.2 on Java 7 Issue: BAEL-2500 --- .../java/com/baeldung/ssl/EnableTLSv12.java | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 core-java-security/src/main/java/com/baeldung/ssl/EnableTLSv12.java diff --git a/core-java-security/src/main/java/com/baeldung/ssl/EnableTLSv12.java b/core-java-security/src/main/java/com/baeldung/ssl/EnableTLSv12.java new file mode 100644 index 0000000000..aa70b11584 --- /dev/null +++ b/core-java-security/src/main/java/com/baeldung/ssl/EnableTLSv12.java @@ -0,0 +1,115 @@ +package com.baeldung.ssl; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.net.URL; +import java.net.UnknownHostException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EnableTLSv12 { + + private final Logger logger = LoggerFactory.getLogger(EnableTLSv12.class); + + public String url = ""; + public Integer port = null; + + public EnableTLSv12() { + } + + public static void main(String[] args) throws IOException, KeyManagementException, NoSuchAlgorithmException { + EnableTLSv12 enableTLSv12 = new EnableTLSv12(); + if (args.length != 2) { + System.out.println("Provide the server url and the secure port:"); + System.exit(-1); + } + enableTLSv12.setHost(args); + enableTLSv12.setPort(args); + enableTLSv12.enableTLSv12UsingHttpConnection(); + enableTLSv12.enableTLSv12UsingProtocol(); + enableTLSv12.enableTLSv12UsingSSLContext(); + enableTLSv12.enableTLSv12UsingSSLParameters(); + } + + private void setPort(String[] args) { + url = args[0]; + } + + private void setHost(String[] args) { + String portNumber = args[1]; + port = Integer.parseInt(portNumber); + } + + private void handleCommunication(SSLSocket socket, String usedTLSProcess) throws IOException { + logger.debug("Enabled TLS v1.2 on " + usedTLSProcess); + try (PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()))); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) { + out.println("GET / HTTP/1.0"); + out.println(); + out.flush(); + if (out.checkError()) { + logger.error("SSLSocketClient: java.io.PrintWriter error"); + return; + } + + String inputLine; + while ((inputLine = in.readLine()) != null) + logger.info(inputLine); + } + } + + public void enableTLSv12UsingSSLParameters() throws UnknownHostException, IOException { + SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); + SSLSocket sslSocket = (SSLSocket) socketFactory.createSocket(url.trim(), port); + SSLParameters params = new SSLParameters(); + params.setProtocols(new String[] { "TLSv1.2" }); + sslSocket.setSSLParameters(params); + sslSocket.startHandshake(); + handleCommunication(sslSocket, "SSLSocketFactory-SSLParameters"); + } + + public void enableTLSv12UsingProtocol() throws IOException { + SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); + SSLSocket sslSocket = (SSLSocket) socketFactory.createSocket(url, port); + sslSocket.setEnabledProtocols(new String[] { "TLSv1.2" }); + sslSocket.startHandshake(); + handleCommunication(sslSocket, "SSLSocketFactory-EnabledProtocols"); + } + + public void enableTLSv12UsingHttpConnection() throws IOException, NoSuchAlgorithmException, KeyManagementException { + URL urls = new URL("https://" + url + ":" + port); + SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); + sslContext.init(null, null, new SecureRandom()); + HttpsURLConnection connection = (HttpsURLConnection) urls.openConnection(); + connection.setSSLSocketFactory(sslContext.getSocketFactory()); + try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + String input; + while ((input = br.readLine()) != null) { + logger.info(input); + } + } + logger.debug("Created TLSv1.2 connection on HttpsURLConnection"); + } + + public void enableTLSv12UsingSSLContext() throws NoSuchAlgorithmException, KeyManagementException, UnknownHostException, IOException { + SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); + sslContext.init(null, null, new SecureRandom()); + SSLSocketFactory socketFactory = sslContext.getSocketFactory(); + SSLSocket socket = (SSLSocket) socketFactory.createSocket(url, port); + handleCommunication(socket, "SSLContext"); + } + +} From 115a52a124ce455bbe1c844a6cea93ed3d56cae8 Mon Sep 17 00:00:00 2001 From: Urvy Agrawal Date: Mon, 7 Jan 2019 22:03:52 +0530 Subject: [PATCH 158/441] Adding files for BAEL-2543 --- .../java/com/baeldung/keyword/Circle.java | 4 ++ .../main/java/com/baeldung/keyword/Ring.java | 4 ++ .../main/java/com/baeldung/keyword/Round.java | 4 ++ .../main/java/com/baeldung/keyword/Shape.java | 4 ++ .../java/com/baeldung/keyword/Triangle.java | 4 ++ .../keyword/test/InstanceOfUnitTest.java | 49 +++++++++++++++++++ 6 files changed, 69 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/keyword/Circle.java create mode 100644 core-java/src/main/java/com/baeldung/keyword/Ring.java create mode 100644 core-java/src/main/java/com/baeldung/keyword/Round.java create mode 100644 core-java/src/main/java/com/baeldung/keyword/Shape.java create mode 100644 core-java/src/main/java/com/baeldung/keyword/Triangle.java create mode 100644 core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java diff --git a/core-java/src/main/java/com/baeldung/keyword/Circle.java b/core-java/src/main/java/com/baeldung/keyword/Circle.java new file mode 100644 index 0000000000..4ec91d1b8a --- /dev/null +++ b/core-java/src/main/java/com/baeldung/keyword/Circle.java @@ -0,0 +1,4 @@ +package com.baeldung.keyword; + +public class Circle extends Round implements Shape { +} diff --git a/core-java/src/main/java/com/baeldung/keyword/Ring.java b/core-java/src/main/java/com/baeldung/keyword/Ring.java new file mode 100644 index 0000000000..99873f9640 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/keyword/Ring.java @@ -0,0 +1,4 @@ +package com.baeldung.keyword; + +public class Ring extends Round { +} diff --git a/core-java/src/main/java/com/baeldung/keyword/Round.java b/core-java/src/main/java/com/baeldung/keyword/Round.java new file mode 100644 index 0000000000..0e2cc2c8c7 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/keyword/Round.java @@ -0,0 +1,4 @@ +package com.baeldung.keyword; + +public class Round { +} diff --git a/core-java/src/main/java/com/baeldung/keyword/Shape.java b/core-java/src/main/java/com/baeldung/keyword/Shape.java new file mode 100644 index 0000000000..8d00c165a3 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/keyword/Shape.java @@ -0,0 +1,4 @@ +package com.baeldung.keyword; + +public interface Shape { +} diff --git a/core-java/src/main/java/com/baeldung/keyword/Triangle.java b/core-java/src/main/java/com/baeldung/keyword/Triangle.java new file mode 100644 index 0000000000..406b8f23e5 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/keyword/Triangle.java @@ -0,0 +1,4 @@ +package com.baeldung.keyword; + +public class Triangle implements Shape { +} diff --git a/core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java b/core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java new file mode 100644 index 0000000000..fbeec3a077 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java @@ -0,0 +1,49 @@ +package com.baeldung.keyword.test; + +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +import com.baeldung.keyword.Circle; +import com.baeldung.keyword.Ring; +import com.baeldung.keyword.Round; +import com.baeldung.keyword.Shape; +import com.baeldung.keyword.Triangle; + +public class InstanceOfUnitTest { + + @Test + public void giveWhenInstanceIsCorrect_thenReturnTrue() { + Ring ring = new Ring(); + Assert.assertTrue("ring is instance of Round ", ring instanceof Round); + } + + @Test + public void giveWhenObjectIsInstanceOfType_thenReturnTrue() { + Circle circle = new Circle(); + Assert.assertTrue("circle is instance of Circle ", circle instanceof Circle); + } + + + @Test + public void giveWhenInstanceIsOfSubtype_thenReturnTrue() { + Circle circle = new Circle(); + Assert.assertTrue("circle is instance of Round", circle instanceof Round); + } + + @Test + public void giveWhenTypeIsInterface_thenReturnTrue() { + Circle circle = new Circle(); + Assert.assertTrue("circle is instance of Shape", circle instanceof Shape); + } + + @Test + public void giveWhenInstanceValueIsNull_thenReturnFalse() { + Circle circle = null; + Assert.assertFalse("circle is instance of Round", circle instanceof Round); + } + + @Test + public void giveWhenComparingClassInDiffHierarchy_thenCompilationError() { + // Assert.assertFalse("circle is instance of Triangle", circle instanceof Triangle); + } +} From 43b0770e134802ad328b6282c86af8ac2a729954 Mon Sep 17 00:00:00 2001 From: Emily Cheyne Date: Mon, 7 Jan 2019 18:36:15 -0700 Subject: [PATCH 159/441] Update readme (#6095) --- algorithms-miscellaneous-1/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/algorithms-miscellaneous-1/README.md b/algorithms-miscellaneous-1/README.md index 59765588b0..6f18396005 100644 --- a/algorithms-miscellaneous-1/README.md +++ b/algorithms-miscellaneous-1/README.md @@ -14,3 +14,4 @@ - [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial) - [Find Substrings That Are Palindromes in Java](https://www.baeldung.com/java-palindrome-substrings) - [Find the Longest Substring without Repeating Characters](https://www.baeldung.com/java-longest-substring-without-repeated-characters) +- [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique) From ea1a4678929221680fcf15005ff9c1cfad775bae Mon Sep 17 00:00:00 2001 From: eric-martin Date: Mon, 7 Jan 2019 20:32:55 -0600 Subject: [PATCH 160/441] BAEL-2386: Moved FlightRecorder from core-java to core-java-perf --- .../src/main/java/com/baeldung/flightrecorder/FlightRecorder.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {core-java => core-java-perf}/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java (100%) diff --git a/core-java/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java b/core-java-perf/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java similarity index 100% rename from core-java/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java rename to core-java-perf/src/main/java/com/baeldung/flightrecorder/FlightRecorder.java From 59fa72d45bdbed9936cd5e9e669f1c88bb5229a8 Mon Sep 17 00:00:00 2001 From: eric-martin Date: Mon, 7 Jan 2019 21:51:47 -0600 Subject: [PATCH 161/441] Fix PMD violations in java-strings *ToStringTest --- ...rrayToStringTest.java => CustomerArrayToStringUnitTest.java} | 2 +- ...ringTest.java => CustomerComplexObjectToStringUnitTest.java} | 2 +- ...ToStringTest.java => CustomerPrimitiveToStringUnitTest.java} | 2 +- ...oStringTest.java => CustomerReflectionToStringUnitTest.java} | 2 +- ...Test.java => CustomerWrapperCollectionToStringUnitTest.java} | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename java-strings/src/test/java/com/baeldung/string/tostring/{CustomerArrayToStringTest.java => CustomerArrayToStringUnitTest.java} (94%) rename java-strings/src/test/java/com/baeldung/string/tostring/{CustomerComplexObjectToStringTest.java => CustomerComplexObjectToStringUnitTest.java} (94%) rename java-strings/src/test/java/com/baeldung/string/tostring/{CustomerPrimitiveToStringTest.java => CustomerPrimitiveToStringUnitTest.java} (92%) rename java-strings/src/test/java/com/baeldung/string/tostring/{CustomerReflectionToStringTest.java => CustomerReflectionToStringUnitTest.java} (95%) rename java-strings/src/test/java/com/baeldung/string/tostring/{CustomerWrapperCollectionToStringTest.java => CustomerWrapperCollectionToStringUnitTest.java} (94%) diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringUnitTest.java similarity index 94% rename from java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringTest.java rename to java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringUnitTest.java index 31e268b4a3..9a88416179 100644 --- a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringTest.java +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerArrayToStringUnitTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -public class CustomerArrayToStringTest { +public class CustomerArrayToStringUnitTest { private static final String CUSTOMER_ARRAY_TO_STRING = "Customer [orders=[Order [orderId=A1111, desc=Game, value=0]], getFirstName()=Rajesh, getLastName()=Bhojwani]"; diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringUnitTest.java similarity index 94% rename from java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringTest.java rename to java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringUnitTest.java index 3c98394f85..5ffb0d0e58 100644 --- a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringTest.java +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerComplexObjectToStringUnitTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -public class CustomerComplexObjectToStringTest { +public class CustomerComplexObjectToStringUnitTest { private static final String CUSTOMER_COMPLEX_TO_STRING = "Customer [order=Order [orderId=A1111, desc=Game, value=0], getFirstName()=Rajesh, getLastName()=Bhojwani]"; diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringUnitTest.java similarity index 92% rename from java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringTest.java rename to java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringUnitTest.java index 2a29cb93d8..d43733bc60 100644 --- a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringTest.java +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerPrimitiveToStringUnitTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -public class CustomerPrimitiveToStringTest { +public class CustomerPrimitiveToStringUnitTest { private static final String CUSTOMER_PRIMITIVE_TO_STRING = "Customer [balance=110, getFirstName()=Rajesh, getLastName()=Bhojwani]"; diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringUnitTest.java similarity index 95% rename from java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringTest.java rename to java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringUnitTest.java index 290bef7133..77dcab52e6 100644 --- a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringTest.java +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringUnitTest.java @@ -7,7 +7,7 @@ import java.util.List; import org.junit.jupiter.api.Test; -public class CustomerReflectionToStringTest { +public class CustomerReflectionToStringUnitTest { private static final String CUSTOMER_REFLECTION_TO_STRING = "com.baeldung.string.tostring.CustomerReflectionToString"; @Test diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringUnitTest.java similarity index 94% rename from java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringTest.java rename to java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringUnitTest.java index c80969d453..e04512ff75 100644 --- a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringTest.java +++ b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerWrapperCollectionToStringUnitTest.java @@ -7,7 +7,7 @@ import java.util.List; import org.junit.jupiter.api.Test; -public class CustomerWrapperCollectionToStringTest { +public class CustomerWrapperCollectionToStringUnitTest { private static final String CUSTOMER_WRAPPER_COLLECTION_TO_STRING = "Customer [score=8, orders=[Book, Pen], fullname=Bhojwani, Rajesh, getFirstName()=Rajesh, getLastName()=Bhojwani]"; From ffcb8f586625f20ada94658ebeba6cd92e965b80 Mon Sep 17 00:00:00 2001 From: Graham Cox Date: Tue, 8 Jan 2019 10:44:18 +0000 Subject: [PATCH 162/441] Kovert (#6092) * Kovert examples * Moved the Kovert examples to kotlin-libraries --- kotlin-libraries/pom.xml | 19 ++++- .../com/baeldung/kovert/AnnotatedServer.kt | 73 ++++++++++++++++++ .../kotlin/com/baeldung/kovert/ErrorServer.kt | 75 ++++++++++++++++++ .../kotlin/com/baeldung/kovert/JsonServer.kt | 76 +++++++++++++++++++ .../kotlin/com/baeldung/kovert/NoopServer.kt | 57 ++++++++++++++ .../com/baeldung/kovert/SecuredServer.kt | 68 +++++++++++++++++ .../com/baeldung/kovert/SimpleServer.kt | 65 ++++++++++++++++ .../src/main/resources/kovert.conf | 15 ++++ 8 files changed, 447 insertions(+), 1 deletion(-) create mode 100644 kotlin-libraries/src/main/kotlin/com/baeldung/kovert/AnnotatedServer.kt create mode 100644 kotlin-libraries/src/main/kotlin/com/baeldung/kovert/ErrorServer.kt create mode 100644 kotlin-libraries/src/main/kotlin/com/baeldung/kovert/JsonServer.kt create mode 100644 kotlin-libraries/src/main/kotlin/com/baeldung/kovert/NoopServer.kt create mode 100644 kotlin-libraries/src/main/kotlin/com/baeldung/kovert/SecuredServer.kt create mode 100644 kotlin-libraries/src/main/kotlin/com/baeldung/kovert/SimpleServer.kt create mode 100644 kotlin-libraries/src/main/resources/kovert.conf diff --git a/kotlin-libraries/pom.xml b/kotlin-libraries/pom.xml index ae77a9aa2d..507e5820d4 100644 --- a/kotlin-libraries/pom.xml +++ b/kotlin-libraries/pom.xml @@ -95,6 +95,23 @@ 0.7.3 + + uy.kohesive.kovert + kovert-vertx + [1.5.0,1.6.0) + + + nl.komponents.kovenant + kovenant + + + + + nl.komponents.kovenant + kovenant + 3.3.0 + pom + @@ -110,4 +127,4 @@ 0.10.4 - \ No newline at end of file + diff --git a/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/AnnotatedServer.kt b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/AnnotatedServer.kt new file mode 100644 index 0000000000..da2bbe4208 --- /dev/null +++ b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/AnnotatedServer.kt @@ -0,0 +1,73 @@ +package com.baeldung.kovert + +import io.vertx.ext.web.Router +import io.vertx.ext.web.RoutingContext +import nl.komponents.kovenant.functional.bind +import org.kodein.di.Kodein +import org.kodein.di.conf.global +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import uy.klutter.config.typesafe.ClassResourceConfig +import uy.klutter.config.typesafe.ReferenceConfig +import uy.klutter.config.typesafe.kodein.importConfig +import uy.klutter.config.typesafe.loadConfig +import uy.klutter.vertx.kodein.KodeinVertx +import uy.kohesive.kovert.core.HttpVerb +import uy.kohesive.kovert.core.Location +import uy.kohesive.kovert.core.Verb +import uy.kohesive.kovert.core.VerbAlias +import uy.kohesive.kovert.vertx.bindController +import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx +import uy.kohesive.kovert.vertx.boot.KovertVerticle +import uy.kohesive.kovert.vertx.boot.KovertVerticleModule +import uy.kohesive.kovert.vertx.boot.KovertVertx + + +class AnnotatedServer { + companion object { + private val LOG: Logger = LoggerFactory.getLogger(AnnotatedServer::class.java) + + @JvmStatic + fun main(args: Array) { + AnnotatedServer().start() + } + } + + @VerbAlias("show", HttpVerb.GET) + class AnnotatedController { + fun RoutingContext.showStringById(id: String) = id + + @Verb(HttpVerb.GET) + @Location("/ping/:id") + fun RoutingContext.ping(id: String) = id + } + + fun start() { + Kodein.global.addImport(Kodein.Module { + importConfig(loadConfig(ClassResourceConfig("/kovert.conf", AnnotatedServer::class.java), ReferenceConfig())) { + import("kovert.vertx", KodeinKovertVertx.configModule) + import("kovert.server", KovertVerticleModule.configModule) + } + + // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j + import(KodeinVertx.moduleWithLoggingToSlf4j) + // Kovert boot + import(KodeinKovertVertx.module) + import(KovertVerticleModule.module) + }) + + val initControllers = fun Router.() { + bindController(AnnotatedController(), "api") + } + + // startup asynchronously... + KovertVertx.start() bind { vertx -> + KovertVerticle.deploy(vertx, routerInit = initControllers) + } success { deploymentId -> + LOG.warn("Deployment complete.") + } fail { error -> + LOG.error("Deployment failed!", error) + } + + } +} diff --git a/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/ErrorServer.kt b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/ErrorServer.kt new file mode 100644 index 0000000000..a596391ed8 --- /dev/null +++ b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/ErrorServer.kt @@ -0,0 +1,75 @@ +package com.baeldung.kovert + +import io.vertx.ext.web.Router +import io.vertx.ext.web.RoutingContext +import nl.komponents.kovenant.functional.bind +import org.kodein.di.Kodein +import org.kodein.di.conf.global +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import uy.klutter.config.typesafe.ClassResourceConfig +import uy.klutter.config.typesafe.ReferenceConfig +import uy.klutter.config.typesafe.kodein.importConfig +import uy.klutter.config.typesafe.loadConfig +import uy.klutter.vertx.kodein.KodeinVertx +import uy.kohesive.kovert.core.HttpErrorCode +import uy.kohesive.kovert.core.HttpErrorCodeWithBody +import uy.kohesive.kovert.core.HttpErrorForbidden +import uy.kohesive.kovert.vertx.bindController +import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx +import uy.kohesive.kovert.vertx.boot.KovertVerticle +import uy.kohesive.kovert.vertx.boot.KovertVerticleModule +import uy.kohesive.kovert.vertx.boot.KovertVertx + + +class ErrorServer { + companion object { + private val LOG: Logger = LoggerFactory.getLogger(ErrorServer::class.java) + + @JvmStatic + fun main(args: Array) { + ErrorServer().start() + } + } + + class ErrorController { + fun RoutingContext.getForbidden() { + throw HttpErrorForbidden() + } + fun RoutingContext.getError() { + throw HttpErrorCode("Something went wrong", 590) + } + fun RoutingContext.getErrorbody() { + throw HttpErrorCodeWithBody("Something went wrong", 591, "Body here") + } + } + + fun start() { + Kodein.global.addImport(Kodein.Module { + importConfig(loadConfig(ClassResourceConfig("/kovert.conf", ErrorServer::class.java), ReferenceConfig())) { + import("kovert.vertx", KodeinKovertVertx.configModule) + import("kovert.server", KovertVerticleModule.configModule) + } + + // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j + import(KodeinVertx.moduleWithLoggingToSlf4j) + // Kovert boot + import(KodeinKovertVertx.module) + import(KovertVerticleModule.module) + }) + + val initControllers = fun Router.() { + bindController(ErrorController(), "api") + } + + // startup asynchronously... + KovertVertx.start() bind { vertx -> + KovertVerticle.deploy(vertx, routerInit = initControllers) + } success { deploymentId -> + LOG.warn("Deployment complete.") + } fail { error -> + LOG.error("Deployment failed!", error) + } + + } +} diff --git a/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/JsonServer.kt b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/JsonServer.kt new file mode 100644 index 0000000000..310fe2a7a0 --- /dev/null +++ b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/JsonServer.kt @@ -0,0 +1,76 @@ +package com.baeldung.kovert + +import com.fasterxml.jackson.annotation.JsonProperty +import io.vertx.ext.web.Router +import io.vertx.ext.web.RoutingContext +import nl.komponents.kovenant.functional.bind +import org.kodein.di.Kodein +import org.kodein.di.conf.global +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import uy.klutter.config.typesafe.ClassResourceConfig +import uy.klutter.config.typesafe.ReferenceConfig +import uy.klutter.config.typesafe.kodein.importConfig +import uy.klutter.config.typesafe.loadConfig +import uy.klutter.vertx.kodein.KodeinVertx +import uy.kohesive.kovert.vertx.bindController +import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx +import uy.kohesive.kovert.vertx.boot.KovertVerticle +import uy.kohesive.kovert.vertx.boot.KovertVerticleModule +import uy.kohesive.kovert.vertx.boot.KovertVertx + +class JsonServer { + companion object { + private val LOG: Logger = LoggerFactory.getLogger(JsonServer::class.java) + + @JvmStatic + fun main(args: Array) { + JsonServer().start() + } + } + + data class Person( + @JsonProperty("_id") + val id: String, + val name: String, + val job: String + ) + + class JsonController { + fun RoutingContext.getPersonById(id: String) = Person( + id = id, + name = "Tony Stark", + job = "Iron Man" + ) + fun RoutingContext.putPersonById(id: String, person: Person) = person + } + + fun start() { + Kodein.global.addImport(Kodein.Module { + importConfig(loadConfig(ClassResourceConfig("/kovert.conf", JsonServer::class.java), ReferenceConfig())) { + import("kovert.vertx", KodeinKovertVertx.configModule) + import("kovert.server", KovertVerticleModule.configModule) + } + + // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j + import(KodeinVertx.moduleWithLoggingToSlf4j) + // Kovert boot + import(KodeinKovertVertx.module) + import(KovertVerticleModule.module) + }) + + val initControllers = fun Router.() { + bindController(JsonController(), "api") + } + + // startup asynchronously... + KovertVertx.start() bind { vertx -> + KovertVerticle.deploy(vertx, routerInit = initControllers) + } success { deploymentId -> + LOG.warn("Deployment complete.") + } fail { error -> + LOG.error("Deployment failed!", error) + } + + } +} diff --git a/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/NoopServer.kt b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/NoopServer.kt new file mode 100644 index 0000000000..98ce775e66 --- /dev/null +++ b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/NoopServer.kt @@ -0,0 +1,57 @@ +package com.baeldung.kovert + +import io.vertx.ext.web.Router +import nl.komponents.kovenant.functional.bind +import org.kodein.di.Kodein +import org.kodein.di.conf.global +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import uy.klutter.config.typesafe.ClassResourceConfig +import uy.klutter.config.typesafe.ReferenceConfig +import uy.klutter.config.typesafe.kodein.importConfig +import uy.klutter.config.typesafe.loadConfig +import uy.klutter.vertx.kodein.KodeinVertx +import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx +import uy.kohesive.kovert.vertx.boot.KovertVerticle +import uy.kohesive.kovert.vertx.boot.KovertVerticleModule +import uy.kohesive.kovert.vertx.boot.KovertVertx + +class NoopServer { + companion object { + private val LOG: Logger = LoggerFactory.getLogger(NoopServer::class.java) + + @JvmStatic + fun main(args: Array) { + NoopServer().start() + } + } + + + fun start() { + Kodein.global.addImport(Kodein.Module { + importConfig(loadConfig(ClassResourceConfig("/kovert.conf", NoopServer::class.java), ReferenceConfig())) { + import("kovert.vertx", KodeinKovertVertx.configModule) + import("kovert.server", KovertVerticleModule.configModule) + } + + // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j + import(KodeinVertx.moduleWithLoggingToSlf4j) + // Kovert boot + import(KodeinKovertVertx.module) + import(KovertVerticleModule.module) + }) + + val initControllers = fun Router.() { + } + + // startup asynchronously... + KovertVertx.start() bind { vertx -> + KovertVerticle.deploy(vertx, routerInit = initControllers) + } success { deploymentId -> + LOG.warn("Deployment complete.") + } fail { error -> + LOG.error("Deployment failed!", error) + } + + } +} diff --git a/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/SecuredServer.kt b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/SecuredServer.kt new file mode 100644 index 0000000000..86ca482808 --- /dev/null +++ b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/SecuredServer.kt @@ -0,0 +1,68 @@ +package com.baeldung.kovert + +import io.vertx.ext.web.Router +import io.vertx.ext.web.RoutingContext +import nl.komponents.kovenant.functional.bind +import org.kodein.di.Kodein +import org.kodein.di.conf.global +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import uy.klutter.config.typesafe.ClassResourceConfig +import uy.klutter.config.typesafe.ReferenceConfig +import uy.klutter.config.typesafe.kodein.importConfig +import uy.klutter.config.typesafe.loadConfig +import uy.klutter.vertx.kodein.KodeinVertx +import uy.kohesive.kovert.vertx.bindController +import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx +import uy.kohesive.kovert.vertx.boot.KovertVerticle +import uy.kohesive.kovert.vertx.boot.KovertVerticleModule +import uy.kohesive.kovert.vertx.boot.KovertVertx + + +class SecuredServer { + companion object { + private val LOG: Logger = LoggerFactory.getLogger(SecuredServer::class.java) + + @JvmStatic + fun main(args: Array) { + SecuredServer().start() + } + } + + class SecuredContext(private val routingContext: RoutingContext) { + val authenticated = routingContext.request().getHeader("Authorization") == "Secure" + } + + class SecuredController { + fun SecuredContext.getSecured() = this.authenticated + } + + fun start() { + Kodein.global.addImport(Kodein.Module { + importConfig(loadConfig(ClassResourceConfig("/kovert.conf", SecuredServer::class.java), ReferenceConfig())) { + import("kovert.vertx", KodeinKovertVertx.configModule) + import("kovert.server", KovertVerticleModule.configModule) + } + + // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j + import(KodeinVertx.moduleWithLoggingToSlf4j) + // Kovert boot + import(KodeinKovertVertx.module) + import(KovertVerticleModule.module) + }) + + val initControllers = fun Router.() { + bindController(SecuredController(), "api") + } + + // startup asynchronously... + KovertVertx.start() bind { vertx -> + KovertVerticle.deploy(vertx, routerInit = initControllers) + } success { deploymentId -> + LOG.warn("Deployment complete.") + } fail { error -> + LOG.error("Deployment failed!", error) + } + + } +} diff --git a/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/SimpleServer.kt b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/SimpleServer.kt new file mode 100644 index 0000000000..172469ab46 --- /dev/null +++ b/kotlin-libraries/src/main/kotlin/com/baeldung/kovert/SimpleServer.kt @@ -0,0 +1,65 @@ +package com.baeldung.kovert + +import io.vertx.ext.web.Router +import io.vertx.ext.web.RoutingContext +import nl.komponents.kovenant.functional.bind +import org.kodein.di.Kodein +import org.kodein.di.conf.global +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import uy.klutter.config.typesafe.ClassResourceConfig +import uy.klutter.config.typesafe.ReferenceConfig +import uy.klutter.config.typesafe.kodein.importConfig +import uy.klutter.config.typesafe.loadConfig +import uy.klutter.vertx.kodein.KodeinVertx +import uy.kohesive.kovert.vertx.bindController +import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx +import uy.kohesive.kovert.vertx.boot.KovertVerticle +import uy.kohesive.kovert.vertx.boot.KovertVerticleModule +import uy.kohesive.kovert.vertx.boot.KovertVertx + + +class SimpleServer { + companion object { + private val LOG: Logger = LoggerFactory.getLogger(SimpleServer::class.java) + + @JvmStatic + fun main(args: Array) { + SimpleServer().start() + } + } + + class SimpleController { + fun RoutingContext.getStringById(id: String) = id + fun RoutingContext.get_truncatedString_by_id(id: String, length: Int = 1) = id.subSequence(0, length) + } + + fun start() { + Kodein.global.addImport(Kodein.Module { + importConfig(loadConfig(ClassResourceConfig("/kovert.conf", SimpleServer::class.java), ReferenceConfig())) { + import("kovert.vertx", KodeinKovertVertx.configModule) + import("kovert.server", KovertVerticleModule.configModule) + } + + // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j + import(KodeinVertx.moduleWithLoggingToSlf4j) + // Kovert boot + import(KodeinKovertVertx.module) + import(KovertVerticleModule.module) + }) + + val initControllers = fun Router.() { + bindController(SimpleController(), "api") + } + + // startup asynchronously... + KovertVertx.start() bind { vertx -> + KovertVerticle.deploy(vertx, routerInit = initControllers) + } success { deploymentId -> + LOG.warn("Deployment complete.") + } fail { error -> + LOG.error("Deployment failed!", error) + } + + } +} diff --git a/kotlin-libraries/src/main/resources/kovert.conf b/kotlin-libraries/src/main/resources/kovert.conf new file mode 100644 index 0000000000..3b08641693 --- /dev/null +++ b/kotlin-libraries/src/main/resources/kovert.conf @@ -0,0 +1,15 @@ +{ + kovert: { + vertx: { + clustered: false + } + server: { + listeners: [ + { + host: "0.0.0.0" + port: "8000" + } + ] + } + } +} From 802e2b0398f46f9939308416066fe9bfe0bf3c6c Mon Sep 17 00:00:00 2001 From: Graham Cox Date: Tue, 8 Jan 2019 14:06:25 +0000 Subject: [PATCH 163/441] Removed Kovert from core-kotlin now it's in kotlin-libraries instead (#6101) --- core-kotlin/pom.xml | 11 --- .../com/baeldung/kovert/AnnotatedServer.kt | 73 ------------------ .../kotlin/com/baeldung/kovert/ErrorServer.kt | 75 ------------------ .../kotlin/com/baeldung/kovert/JsonServer.kt | 76 ------------------- .../kotlin/com/baeldung/kovert/NoopServer.kt | 57 -------------- .../com/baeldung/kovert/SecuredServer.kt | 68 ----------------- .../com/baeldung/kovert/SimpleServer.kt | 65 ---------------- core-kotlin/src/main/resources/kovert.conf | 15 ---- 8 files changed, 440 deletions(-) delete mode 100644 core-kotlin/src/main/kotlin/com/baeldung/kovert/AnnotatedServer.kt delete mode 100644 core-kotlin/src/main/kotlin/com/baeldung/kovert/ErrorServer.kt delete mode 100644 core-kotlin/src/main/kotlin/com/baeldung/kovert/JsonServer.kt delete mode 100644 core-kotlin/src/main/kotlin/com/baeldung/kovert/NoopServer.kt delete mode 100644 core-kotlin/src/main/kotlin/com/baeldung/kovert/SecuredServer.kt delete mode 100644 core-kotlin/src/main/kotlin/com/baeldung/kovert/SimpleServer.kt delete mode 100644 core-kotlin/src/main/resources/kovert.conf diff --git a/core-kotlin/pom.xml b/core-kotlin/pom.xml index 8b871f28ee..ed79ebc01b 100644 --- a/core-kotlin/pom.xml +++ b/core-kotlin/pom.xml @@ -72,17 +72,6 @@ injekt-core 1.16.1 - - uy.kohesive.kovert - kovert-vertx - [1.5.0,1.6.0) - - - nl.komponents.kovenant - kovenant - - - diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kovert/AnnotatedServer.kt b/core-kotlin/src/main/kotlin/com/baeldung/kovert/AnnotatedServer.kt deleted file mode 100644 index da2bbe4208..0000000000 --- a/core-kotlin/src/main/kotlin/com/baeldung/kovert/AnnotatedServer.kt +++ /dev/null @@ -1,73 +0,0 @@ -package com.baeldung.kovert - -import io.vertx.ext.web.Router -import io.vertx.ext.web.RoutingContext -import nl.komponents.kovenant.functional.bind -import org.kodein.di.Kodein -import org.kodein.di.conf.global -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import uy.klutter.config.typesafe.ClassResourceConfig -import uy.klutter.config.typesafe.ReferenceConfig -import uy.klutter.config.typesafe.kodein.importConfig -import uy.klutter.config.typesafe.loadConfig -import uy.klutter.vertx.kodein.KodeinVertx -import uy.kohesive.kovert.core.HttpVerb -import uy.kohesive.kovert.core.Location -import uy.kohesive.kovert.core.Verb -import uy.kohesive.kovert.core.VerbAlias -import uy.kohesive.kovert.vertx.bindController -import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx -import uy.kohesive.kovert.vertx.boot.KovertVerticle -import uy.kohesive.kovert.vertx.boot.KovertVerticleModule -import uy.kohesive.kovert.vertx.boot.KovertVertx - - -class AnnotatedServer { - companion object { - private val LOG: Logger = LoggerFactory.getLogger(AnnotatedServer::class.java) - - @JvmStatic - fun main(args: Array) { - AnnotatedServer().start() - } - } - - @VerbAlias("show", HttpVerb.GET) - class AnnotatedController { - fun RoutingContext.showStringById(id: String) = id - - @Verb(HttpVerb.GET) - @Location("/ping/:id") - fun RoutingContext.ping(id: String) = id - } - - fun start() { - Kodein.global.addImport(Kodein.Module { - importConfig(loadConfig(ClassResourceConfig("/kovert.conf", AnnotatedServer::class.java), ReferenceConfig())) { - import("kovert.vertx", KodeinKovertVertx.configModule) - import("kovert.server", KovertVerticleModule.configModule) - } - - // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j - import(KodeinVertx.moduleWithLoggingToSlf4j) - // Kovert boot - import(KodeinKovertVertx.module) - import(KovertVerticleModule.module) - }) - - val initControllers = fun Router.() { - bindController(AnnotatedController(), "api") - } - - // startup asynchronously... - KovertVertx.start() bind { vertx -> - KovertVerticle.deploy(vertx, routerInit = initControllers) - } success { deploymentId -> - LOG.warn("Deployment complete.") - } fail { error -> - LOG.error("Deployment failed!", error) - } - - } -} diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kovert/ErrorServer.kt b/core-kotlin/src/main/kotlin/com/baeldung/kovert/ErrorServer.kt deleted file mode 100644 index a596391ed8..0000000000 --- a/core-kotlin/src/main/kotlin/com/baeldung/kovert/ErrorServer.kt +++ /dev/null @@ -1,75 +0,0 @@ -package com.baeldung.kovert - -import io.vertx.ext.web.Router -import io.vertx.ext.web.RoutingContext -import nl.komponents.kovenant.functional.bind -import org.kodein.di.Kodein -import org.kodein.di.conf.global -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import uy.klutter.config.typesafe.ClassResourceConfig -import uy.klutter.config.typesafe.ReferenceConfig -import uy.klutter.config.typesafe.kodein.importConfig -import uy.klutter.config.typesafe.loadConfig -import uy.klutter.vertx.kodein.KodeinVertx -import uy.kohesive.kovert.core.HttpErrorCode -import uy.kohesive.kovert.core.HttpErrorCodeWithBody -import uy.kohesive.kovert.core.HttpErrorForbidden -import uy.kohesive.kovert.vertx.bindController -import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx -import uy.kohesive.kovert.vertx.boot.KovertVerticle -import uy.kohesive.kovert.vertx.boot.KovertVerticleModule -import uy.kohesive.kovert.vertx.boot.KovertVertx - - -class ErrorServer { - companion object { - private val LOG: Logger = LoggerFactory.getLogger(ErrorServer::class.java) - - @JvmStatic - fun main(args: Array) { - ErrorServer().start() - } - } - - class ErrorController { - fun RoutingContext.getForbidden() { - throw HttpErrorForbidden() - } - fun RoutingContext.getError() { - throw HttpErrorCode("Something went wrong", 590) - } - fun RoutingContext.getErrorbody() { - throw HttpErrorCodeWithBody("Something went wrong", 591, "Body here") - } - } - - fun start() { - Kodein.global.addImport(Kodein.Module { - importConfig(loadConfig(ClassResourceConfig("/kovert.conf", ErrorServer::class.java), ReferenceConfig())) { - import("kovert.vertx", KodeinKovertVertx.configModule) - import("kovert.server", KovertVerticleModule.configModule) - } - - // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j - import(KodeinVertx.moduleWithLoggingToSlf4j) - // Kovert boot - import(KodeinKovertVertx.module) - import(KovertVerticleModule.module) - }) - - val initControllers = fun Router.() { - bindController(ErrorController(), "api") - } - - // startup asynchronously... - KovertVertx.start() bind { vertx -> - KovertVerticle.deploy(vertx, routerInit = initControllers) - } success { deploymentId -> - LOG.warn("Deployment complete.") - } fail { error -> - LOG.error("Deployment failed!", error) - } - - } -} diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kovert/JsonServer.kt b/core-kotlin/src/main/kotlin/com/baeldung/kovert/JsonServer.kt deleted file mode 100644 index 310fe2a7a0..0000000000 --- a/core-kotlin/src/main/kotlin/com/baeldung/kovert/JsonServer.kt +++ /dev/null @@ -1,76 +0,0 @@ -package com.baeldung.kovert - -import com.fasterxml.jackson.annotation.JsonProperty -import io.vertx.ext.web.Router -import io.vertx.ext.web.RoutingContext -import nl.komponents.kovenant.functional.bind -import org.kodein.di.Kodein -import org.kodein.di.conf.global -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import uy.klutter.config.typesafe.ClassResourceConfig -import uy.klutter.config.typesafe.ReferenceConfig -import uy.klutter.config.typesafe.kodein.importConfig -import uy.klutter.config.typesafe.loadConfig -import uy.klutter.vertx.kodein.KodeinVertx -import uy.kohesive.kovert.vertx.bindController -import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx -import uy.kohesive.kovert.vertx.boot.KovertVerticle -import uy.kohesive.kovert.vertx.boot.KovertVerticleModule -import uy.kohesive.kovert.vertx.boot.KovertVertx - -class JsonServer { - companion object { - private val LOG: Logger = LoggerFactory.getLogger(JsonServer::class.java) - - @JvmStatic - fun main(args: Array) { - JsonServer().start() - } - } - - data class Person( - @JsonProperty("_id") - val id: String, - val name: String, - val job: String - ) - - class JsonController { - fun RoutingContext.getPersonById(id: String) = Person( - id = id, - name = "Tony Stark", - job = "Iron Man" - ) - fun RoutingContext.putPersonById(id: String, person: Person) = person - } - - fun start() { - Kodein.global.addImport(Kodein.Module { - importConfig(loadConfig(ClassResourceConfig("/kovert.conf", JsonServer::class.java), ReferenceConfig())) { - import("kovert.vertx", KodeinKovertVertx.configModule) - import("kovert.server", KovertVerticleModule.configModule) - } - - // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j - import(KodeinVertx.moduleWithLoggingToSlf4j) - // Kovert boot - import(KodeinKovertVertx.module) - import(KovertVerticleModule.module) - }) - - val initControllers = fun Router.() { - bindController(JsonController(), "api") - } - - // startup asynchronously... - KovertVertx.start() bind { vertx -> - KovertVerticle.deploy(vertx, routerInit = initControllers) - } success { deploymentId -> - LOG.warn("Deployment complete.") - } fail { error -> - LOG.error("Deployment failed!", error) - } - - } -} diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kovert/NoopServer.kt b/core-kotlin/src/main/kotlin/com/baeldung/kovert/NoopServer.kt deleted file mode 100644 index 98ce775e66..0000000000 --- a/core-kotlin/src/main/kotlin/com/baeldung/kovert/NoopServer.kt +++ /dev/null @@ -1,57 +0,0 @@ -package com.baeldung.kovert - -import io.vertx.ext.web.Router -import nl.komponents.kovenant.functional.bind -import org.kodein.di.Kodein -import org.kodein.di.conf.global -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import uy.klutter.config.typesafe.ClassResourceConfig -import uy.klutter.config.typesafe.ReferenceConfig -import uy.klutter.config.typesafe.kodein.importConfig -import uy.klutter.config.typesafe.loadConfig -import uy.klutter.vertx.kodein.KodeinVertx -import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx -import uy.kohesive.kovert.vertx.boot.KovertVerticle -import uy.kohesive.kovert.vertx.boot.KovertVerticleModule -import uy.kohesive.kovert.vertx.boot.KovertVertx - -class NoopServer { - companion object { - private val LOG: Logger = LoggerFactory.getLogger(NoopServer::class.java) - - @JvmStatic - fun main(args: Array) { - NoopServer().start() - } - } - - - fun start() { - Kodein.global.addImport(Kodein.Module { - importConfig(loadConfig(ClassResourceConfig("/kovert.conf", NoopServer::class.java), ReferenceConfig())) { - import("kovert.vertx", KodeinKovertVertx.configModule) - import("kovert.server", KovertVerticleModule.configModule) - } - - // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j - import(KodeinVertx.moduleWithLoggingToSlf4j) - // Kovert boot - import(KodeinKovertVertx.module) - import(KovertVerticleModule.module) - }) - - val initControllers = fun Router.() { - } - - // startup asynchronously... - KovertVertx.start() bind { vertx -> - KovertVerticle.deploy(vertx, routerInit = initControllers) - } success { deploymentId -> - LOG.warn("Deployment complete.") - } fail { error -> - LOG.error("Deployment failed!", error) - } - - } -} diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kovert/SecuredServer.kt b/core-kotlin/src/main/kotlin/com/baeldung/kovert/SecuredServer.kt deleted file mode 100644 index 86ca482808..0000000000 --- a/core-kotlin/src/main/kotlin/com/baeldung/kovert/SecuredServer.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.baeldung.kovert - -import io.vertx.ext.web.Router -import io.vertx.ext.web.RoutingContext -import nl.komponents.kovenant.functional.bind -import org.kodein.di.Kodein -import org.kodein.di.conf.global -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import uy.klutter.config.typesafe.ClassResourceConfig -import uy.klutter.config.typesafe.ReferenceConfig -import uy.klutter.config.typesafe.kodein.importConfig -import uy.klutter.config.typesafe.loadConfig -import uy.klutter.vertx.kodein.KodeinVertx -import uy.kohesive.kovert.vertx.bindController -import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx -import uy.kohesive.kovert.vertx.boot.KovertVerticle -import uy.kohesive.kovert.vertx.boot.KovertVerticleModule -import uy.kohesive.kovert.vertx.boot.KovertVertx - - -class SecuredServer { - companion object { - private val LOG: Logger = LoggerFactory.getLogger(SecuredServer::class.java) - - @JvmStatic - fun main(args: Array) { - SecuredServer().start() - } - } - - class SecuredContext(private val routingContext: RoutingContext) { - val authenticated = routingContext.request().getHeader("Authorization") == "Secure" - } - - class SecuredController { - fun SecuredContext.getSecured() = this.authenticated - } - - fun start() { - Kodein.global.addImport(Kodein.Module { - importConfig(loadConfig(ClassResourceConfig("/kovert.conf", SecuredServer::class.java), ReferenceConfig())) { - import("kovert.vertx", KodeinKovertVertx.configModule) - import("kovert.server", KovertVerticleModule.configModule) - } - - // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j - import(KodeinVertx.moduleWithLoggingToSlf4j) - // Kovert boot - import(KodeinKovertVertx.module) - import(KovertVerticleModule.module) - }) - - val initControllers = fun Router.() { - bindController(SecuredController(), "api") - } - - // startup asynchronously... - KovertVertx.start() bind { vertx -> - KovertVerticle.deploy(vertx, routerInit = initControllers) - } success { deploymentId -> - LOG.warn("Deployment complete.") - } fail { error -> - LOG.error("Deployment failed!", error) - } - - } -} diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kovert/SimpleServer.kt b/core-kotlin/src/main/kotlin/com/baeldung/kovert/SimpleServer.kt deleted file mode 100644 index 172469ab46..0000000000 --- a/core-kotlin/src/main/kotlin/com/baeldung/kovert/SimpleServer.kt +++ /dev/null @@ -1,65 +0,0 @@ -package com.baeldung.kovert - -import io.vertx.ext.web.Router -import io.vertx.ext.web.RoutingContext -import nl.komponents.kovenant.functional.bind -import org.kodein.di.Kodein -import org.kodein.di.conf.global -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import uy.klutter.config.typesafe.ClassResourceConfig -import uy.klutter.config.typesafe.ReferenceConfig -import uy.klutter.config.typesafe.kodein.importConfig -import uy.klutter.config.typesafe.loadConfig -import uy.klutter.vertx.kodein.KodeinVertx -import uy.kohesive.kovert.vertx.bindController -import uy.kohesive.kovert.vertx.boot.KodeinKovertVertx -import uy.kohesive.kovert.vertx.boot.KovertVerticle -import uy.kohesive.kovert.vertx.boot.KovertVerticleModule -import uy.kohesive.kovert.vertx.boot.KovertVertx - - -class SimpleServer { - companion object { - private val LOG: Logger = LoggerFactory.getLogger(SimpleServer::class.java) - - @JvmStatic - fun main(args: Array) { - SimpleServer().start() - } - } - - class SimpleController { - fun RoutingContext.getStringById(id: String) = id - fun RoutingContext.get_truncatedString_by_id(id: String, length: Int = 1) = id.subSequence(0, length) - } - - fun start() { - Kodein.global.addImport(Kodein.Module { - importConfig(loadConfig(ClassResourceConfig("/kovert.conf", SimpleServer::class.java), ReferenceConfig())) { - import("kovert.vertx", KodeinKovertVertx.configModule) - import("kovert.server", KovertVerticleModule.configModule) - } - - // includes jackson ObjectMapper to match compatibility with Vertx, app logging via Vertx facade to Slf4j - import(KodeinVertx.moduleWithLoggingToSlf4j) - // Kovert boot - import(KodeinKovertVertx.module) - import(KovertVerticleModule.module) - }) - - val initControllers = fun Router.() { - bindController(SimpleController(), "api") - } - - // startup asynchronously... - KovertVertx.start() bind { vertx -> - KovertVerticle.deploy(vertx, routerInit = initControllers) - } success { deploymentId -> - LOG.warn("Deployment complete.") - } fail { error -> - LOG.error("Deployment failed!", error) - } - - } -} diff --git a/core-kotlin/src/main/resources/kovert.conf b/core-kotlin/src/main/resources/kovert.conf deleted file mode 100644 index 3b08641693..0000000000 --- a/core-kotlin/src/main/resources/kovert.conf +++ /dev/null @@ -1,15 +0,0 @@ -{ - kovert: { - vertx: { - clustered: false - } - server: { - listeners: [ - { - host: "0.0.0.0" - port: "8000" - } - ] - } - } -} From 5faa406cb062ae194f84a19ab029eb5176ecbcb4 Mon Sep 17 00:00:00 2001 From: myluckagain Date: Tue, 8 Jan 2019 19:36:42 +0500 Subject: [PATCH 164/441] BAEL-2474 (#5997) * BAEL-2474 * rename UserRepositoryImpl.java into UserRepositoryCustomImpl.java --- .../dao/repositories/user/UserRepository.java | 3 +- .../user/UserRepositoryCustom.java | 10 ++++ .../user/UserRepositoryCustomImpl.java | 43 +++++++++++++++ .../UserRepositoryIntegrationTest.java | 55 +++++++++++++------ 4 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepositoryCustom.java create mode 100644 persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepositoryCustomImpl.java diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepository.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepository.java index 5bb0232e4a..7f54254832 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepository.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepository.java @@ -1,6 +1,7 @@ package com.baeldung.dao.repositories.user; import com.baeldung.domain.user.User; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -13,7 +14,7 @@ import java.util.Collection; import java.util.List; import java.util.stream.Stream; -public interface UserRepository extends JpaRepository { +public interface UserRepository extends JpaRepository , UserRepositoryCustom{ Stream findAllByName(String name); diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepositoryCustom.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepositoryCustom.java new file mode 100644 index 0000000000..72c1fd5d00 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepositoryCustom.java @@ -0,0 +1,10 @@ +package com.baeldung.dao.repositories.user; + +import java.util.List; +import java.util.Set; + +import com.baeldung.domain.user.User; + +public interface UserRepositoryCustom { + List findUserByEmails(Set emails); +} diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepositoryCustomImpl.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepositoryCustomImpl.java new file mode 100644 index 0000000000..9f841caf68 --- /dev/null +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/user/UserRepositoryCustomImpl.java @@ -0,0 +1,43 @@ +package com.baeldung.dao.repositories.user; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Path; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +import com.baeldung.domain.user.User; + +public class UserRepositoryCustomImpl implements UserRepositoryCustom { + + @PersistenceContext + private EntityManager entityManager; + + @Override + public List findUserByEmails(Set emails) { + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery query = cb.createQuery(User.class); + Root user = query.from(User.class); + + Path emailPath = user.get("email"); + + List predicates = new ArrayList<>(); + for (String email : emails) { + + predicates.add(cb.like(emailPath, email)); + + } + query.select(user) + .where(cb.or(predicates.toArray(new Predicate[predicates.size()]))); + + return entityManager.createQuery(query) + .getResultList(); + } + +} diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/UserRepositoryIntegrationTest.java index e29161394b..b05086d00e 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/UserRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/dao/repositories/UserRepositoryIntegrationTest.java @@ -18,7 +18,9 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -274,9 +276,8 @@ public class UserRepositoryIntegrationTest { List usersSortByName = userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); - assertThat(usersSortByName - .get(0) - .getName()).isEqualTo(USER_NAME_ADAM); + assertThat(usersSortByName.get(0) + .getName()).isEqualTo(USER_NAME_ADAM); } @Test(expected = PropertyReferenceException.class) @@ -289,9 +290,8 @@ public class UserRepositoryIntegrationTest { List usersSortByNameLength = userRepository.findAll(new Sort("LENGTH(name)")); - assertThat(usersSortByNameLength - .get(0) - .getName()).isEqualTo(USER_NAME_ADAM); + assertThat(usersSortByNameLength.get(0) + .getName()).isEqualTo(USER_NAME_ADAM); } @Test @@ -304,9 +304,8 @@ public class UserRepositoryIntegrationTest { List usersSortByNameLength = userRepository.findAllUsers(JpaSort.unsafe("LENGTH(name)")); - assertThat(usersSortByNameLength - .get(0) - .getName()).isEqualTo(USER_NAME_ADAM); + assertThat(usersSortByNameLength.get(0) + .getName()).isEqualTo(USER_NAME_ADAM); } @Test @@ -320,10 +319,9 @@ public class UserRepositoryIntegrationTest { Page usersPage = userRepository.findAllUsersWithPagination(new PageRequest(1, 3)); - assertThat(usersPage - .getContent() - .get(0) - .getName()).isEqualTo("SAMPLE1"); + assertThat(usersPage.getContent() + .get(0) + .getName()).isEqualTo("SAMPLE1"); } @Test @@ -337,10 +335,9 @@ public class UserRepositoryIntegrationTest { Page usersSortByNameLength = userRepository.findAllUsersWithPaginationNative(new PageRequest(1, 3)); - assertThat(usersSortByNameLength - .getContent() - .get(0) - .getName()).isEqualTo("SAMPLE1"); + assertThat(usersSortByNameLength.getContent() + .get(0) + .getName()).isEqualTo("SAMPLE1"); } @Test @@ -370,6 +367,30 @@ public class UserRepositoryIntegrationTest { assertThat(updatedUsersSize).isEqualTo(2); } + @Test + public void givenUsersInDBWhenFindByEmailsWithDynamicQueryThenReturnCollection() { + + User user1 = new User(); + user1.setEmail(USER_EMAIL); + userRepository.save(user1); + + User user2 = new User(); + user2.setEmail(USER_EMAIL2); + userRepository.save(user2); + + User user3 = new User(); + user3.setEmail(USER_EMAIL3); + userRepository.save(user3); + + Set emails = new HashSet<>(); + emails.add(USER_EMAIL2); + emails.add(USER_EMAIL3); + + Collection usersWithEmails = userRepository.findUserByEmails(emails); + + assertThat(usersWithEmails.size()).isEqualTo(2); + } + @After public void cleanUp() { userRepository.deleteAll(); From 26101769311c7de0285f23e34f00c90187e53f64 Mon Sep 17 00:00:00 2001 From: Urvy Agrawal Date: Tue, 8 Jan 2019 20:09:51 +0530 Subject: [PATCH 165/441] Review comments added --- .../java/com/baeldung/keyword/test/InstanceOfUnitTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java b/core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java index fbeec3a077..4c010e3a16 100644 --- a/core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java +++ b/core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java @@ -35,6 +35,12 @@ public class InstanceOfUnitTest { Circle circle = new Circle(); Assert.assertTrue("circle is instance of Shape", circle instanceof Shape); } + + @Test + public void giveWhenTypeIsOfObjectType_thenReturnTrue() { + Thread thread = new Thread(); + Assert.assertTrue("thread is instance of Object", thread instanceof Object); + } @Test public void giveWhenInstanceValueIsNull_thenReturnFalse() { From f1fa9c8253a9db826ad4de40dd71be2ec2ac7527 Mon Sep 17 00:00:00 2001 From: pandachris Date: Tue, 8 Jan 2019 22:18:47 +0700 Subject: [PATCH 166/441] BAEL-2565 move code to different project (#6099) * BAEL-2565 * BAEL-2565 Test code consistency * BAEL-2565 Move code to different project --- .../src/main/java/com/baeldung/enums/values/Element1.java | 0 .../src/main/java/com/baeldung/enums/values/Element2.java | 0 .../src/main/java/com/baeldung/enums/values/Element3.java | 0 .../src/main/java/com/baeldung/enums/values/Element4.java | 0 .../src/main/java/com/baeldung/enums/values/Labeled.java | 0 .../src/test/java/com/baeldung/enums/values/Element1UnitTest.java | 0 .../src/test/java/com/baeldung/enums/values/Element2UnitTest.java | 0 .../src/test/java/com/baeldung/enums/values/Element3UnitTest.java | 0 .../src/test/java/com/baeldung/enums/values/Element4UnitTest.java | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename {core-java-8 => core-java-lang}/src/main/java/com/baeldung/enums/values/Element1.java (100%) rename {core-java-8 => core-java-lang}/src/main/java/com/baeldung/enums/values/Element2.java (100%) rename {core-java-8 => core-java-lang}/src/main/java/com/baeldung/enums/values/Element3.java (100%) rename {core-java-8 => core-java-lang}/src/main/java/com/baeldung/enums/values/Element4.java (100%) rename {core-java-8 => core-java-lang}/src/main/java/com/baeldung/enums/values/Labeled.java (100%) rename {core-java-8 => core-java-lang}/src/test/java/com/baeldung/enums/values/Element1UnitTest.java (100%) rename {core-java-8 => core-java-lang}/src/test/java/com/baeldung/enums/values/Element2UnitTest.java (100%) rename {core-java-8 => core-java-lang}/src/test/java/com/baeldung/enums/values/Element3UnitTest.java (100%) rename {core-java-8 => core-java-lang}/src/test/java/com/baeldung/enums/values/Element4UnitTest.java (100%) diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Element1.java b/core-java-lang/src/main/java/com/baeldung/enums/values/Element1.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/enums/values/Element1.java rename to core-java-lang/src/main/java/com/baeldung/enums/values/Element1.java diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Element2.java b/core-java-lang/src/main/java/com/baeldung/enums/values/Element2.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/enums/values/Element2.java rename to core-java-lang/src/main/java/com/baeldung/enums/values/Element2.java diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Element3.java b/core-java-lang/src/main/java/com/baeldung/enums/values/Element3.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/enums/values/Element3.java rename to core-java-lang/src/main/java/com/baeldung/enums/values/Element3.java diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Element4.java b/core-java-lang/src/main/java/com/baeldung/enums/values/Element4.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/enums/values/Element4.java rename to core-java-lang/src/main/java/com/baeldung/enums/values/Element4.java diff --git a/core-java-8/src/main/java/com/baeldung/enums/values/Labeled.java b/core-java-lang/src/main/java/com/baeldung/enums/values/Labeled.java similarity index 100% rename from core-java-8/src/main/java/com/baeldung/enums/values/Labeled.java rename to core-java-lang/src/main/java/com/baeldung/enums/values/Labeled.java diff --git a/core-java-8/src/test/java/com/baeldung/enums/values/Element1UnitTest.java b/core-java-lang/src/test/java/com/baeldung/enums/values/Element1UnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/enums/values/Element1UnitTest.java rename to core-java-lang/src/test/java/com/baeldung/enums/values/Element1UnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/enums/values/Element2UnitTest.java b/core-java-lang/src/test/java/com/baeldung/enums/values/Element2UnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/enums/values/Element2UnitTest.java rename to core-java-lang/src/test/java/com/baeldung/enums/values/Element2UnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/enums/values/Element3UnitTest.java b/core-java-lang/src/test/java/com/baeldung/enums/values/Element3UnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/enums/values/Element3UnitTest.java rename to core-java-lang/src/test/java/com/baeldung/enums/values/Element3UnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/enums/values/Element4UnitTest.java b/core-java-lang/src/test/java/com/baeldung/enums/values/Element4UnitTest.java similarity index 100% rename from core-java-8/src/test/java/com/baeldung/enums/values/Element4UnitTest.java rename to core-java-lang/src/test/java/com/baeldung/enums/values/Element4UnitTest.java From 91f8c421c9941997165d0e7ac1e8c3e81836432d Mon Sep 17 00:00:00 2001 From: amdegregorio Date: Tue, 8 Jan 2019 10:31:20 -0500 Subject: [PATCH 167/441] example code for Article How to Write to a CSV File in Java --- .../com/baeldung/csv/WriteCsvFileExample.java | 29 ++++++ .../csv/WriteCsvFileExampleUnitTest.java | 90 +++++++++++++++++++ .../src/test/resources/exampleOutput.csv | 2 + 3 files changed, 121 insertions(+) create mode 100644 core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java create mode 100644 core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java create mode 100644 core-java-io/src/test/resources/exampleOutput.csv diff --git a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java new file mode 100644 index 0000000000..fd3678d2c5 --- /dev/null +++ b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java @@ -0,0 +1,29 @@ +package com.baeldung.csv; + +import java.io.BufferedWriter; +import java.io.IOException; + +public class WriteCsvFileExample { + + public void writeLine(BufferedWriter writer, String[] data) throws IOException { + StringBuilder csvLine = new StringBuilder(); + + for (int i = 0; i < data.length; i++) { + if (i > 0) { + csvLine.append(","); + } + csvLine.append(escapeSpecialCharacters(data[i])); + } + + writer.write(csvLine.toString()); + } + + public String escapeSpecialCharacters(String data) { + String escapedData = data.replaceAll("\\R", " "); + if (data.contains(",") || data.contains("\"") || data.contains("'")) { + data = data.replace("\"", "\"\""); + escapedData = "\"" + data + "\""; + } + return escapedData; + } +} diff --git a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java new file mode 100644 index 0000000000..4ac84f939d --- /dev/null +++ b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java @@ -0,0 +1,90 @@ +package com.baeldung.csv; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WriteCsvFileExampleUnitTest { + private static final Logger LOG = LoggerFactory.getLogger(WriteCsvFileExampleUnitTest.class); + + private static final String CSV_FILE_NAME = "src/test/resources/exampleOutput.csv"; + private WriteCsvFileExample csvExample; + + @Before + public void setupClass() { + csvExample = new WriteCsvFileExample(); + } + + @Test + public void givenCommaContainingData_whenEscapeSpecialCharacters_stringReturnedInQuotes() { + String data = "three,two,one"; + String escapedData = csvExample.escapeSpecialCharacters(data); + + String expectedData = "\"three,two,one\""; + assertEquals(expectedData, escapedData); + } + + @Test + public void givenQuoteContainingData_whenEscapeSpecialCharacters_stringReturnedFormatted() { + String data = "She said \"Hello\""; + String escapedData = csvExample.escapeSpecialCharacters(data); + + String expectedData = "\"She said \"\"Hello\"\"\""; + assertEquals(expectedData, escapedData); + } + + @Test + public void givenNewlineContainingData_whenEscapeSpecialCharacters_stringReturnedInQuotes() { + String dataNewline = "This contains\na newline"; + String dataCarriageReturn = "This contains\r\na newline and carriage return"; + String escapedDataNl = csvExample.escapeSpecialCharacters(dataNewline); + String escapedDataCr = csvExample.escapeSpecialCharacters(dataCarriageReturn); + + String expectedData = "This contains a newline"; + assertEquals(expectedData, escapedDataNl); + String expectedDataCr = "This contains a newline and carriage return"; + assertEquals(expectedDataCr, escapedDataCr); + } + + @Test + public void givenNonSpecialData_whenEscapeSpecialCharacters_stringReturnedUnchanged() { + String data = "This is nothing special"; + String returnedData = csvExample.escapeSpecialCharacters(data); + + assertEquals(data, returnedData); + } + + @Test + public void givenBufferedWriter_whenWriteLine_thenOutputCreated() { + List dataLines = new ArrayList(); + dataLines.add(new String[] { "John", "Doe", "38", "Comment Data\nAnother line of comment data" }); + dataLines.add(new String[] { "Jane", "Doe, Jr.", "19", "She said \"I'm being quoted\"" }); + + File csvOutputFile = new File(CSV_FILE_NAME); + try (BufferedWriter writer = new BufferedWriter(new FileWriter(csvOutputFile))) { + for (Iterator dataIterator = dataLines.iterator(); dataIterator.hasNext();) { + csvExample.writeLine(writer, dataIterator.next()); + if (dataIterator.hasNext()) { + writer.newLine(); + } + } + writer.flush(); + } catch (IOException e) { + LOG.error("IOException " + e.getMessage()); + } + + assertTrue(csvOutputFile.exists()); + } +} diff --git a/core-java-io/src/test/resources/exampleOutput.csv b/core-java-io/src/test/resources/exampleOutput.csv new file mode 100644 index 0000000000..45c37f3a3b --- /dev/null +++ b/core-java-io/src/test/resources/exampleOutput.csv @@ -0,0 +1,2 @@ +John,Doe,38,Comment Data Another line of comment data +Jane,"Doe, Jr.",19,"She said ""I'm being quoted""" \ No newline at end of file From c0e36d5b10ca8716390ac1954218b037e9775b83 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Wed, 9 Jan 2019 00:30:54 +0530 Subject: [PATCH 168/441] BAEL-10925 New module spring-boot-rest --- pom.xml | 6 ++- spring-boot-rest/pom.xml | 43 +++++++++++++++++++ .../web/SpringBootRestApplication.java | 13 ++++++ .../com/baeldung/web/config/WebConfig.java | 8 ++++ .../src/main/resources/application.properties | 0 .../SpringBootRestApplicationUnitTest.java | 16 +++++++ 6 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 spring-boot-rest/pom.xml create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/config/WebConfig.java create mode 100644 spring-boot-rest/src/main/resources/application.properties create mode 100644 spring-boot-rest/src/test/java/com/baeldung/web/SpringBootRestApplicationUnitTest.java diff --git a/pom.xml b/pom.xml index 4dba0da173..cf7eb1f394 100644 --- a/pom.xml +++ b/pom.xml @@ -645,6 +645,7 @@ spring-boot-mvc spring-boot-ops spring-boot-property-exp + spring-boot-rest spring-boot-security spring-boot-testing spring-boot-vue @@ -1356,8 +1357,11 @@ spring-boot-mvc spring-boot-ops spring-boot-property-exp + spring-boot-rest spring-boot-security + spring-boot-testing spring-boot-vue + spring-boot-libraries spring-cloud spring-cloud-bus @@ -1372,7 +1376,7 @@ spring-dispatcher-servlet spring-drools - spring-ehcache + spring-ehcache spring-ejb spring-exceptions diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml new file mode 100644 index 0000000000..baf9d35a09 --- /dev/null +++ b/spring-boot-rest/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + com.baeldung.web + spring-boot-rest + spring-boot-rest + Spring Boot Rest Module + war + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + com.baeldung.SpringBootRestApplication + + diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java b/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java new file mode 100644 index 0000000000..62aae7619d --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java @@ -0,0 +1,13 @@ +package com.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootRestApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootRestApplication.class, args); + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/config/WebConfig.java b/spring-boot-rest/src/main/java/com/baeldung/web/config/WebConfig.java new file mode 100644 index 0000000000..808e946218 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/config/WebConfig.java @@ -0,0 +1,8 @@ +package com.baeldung.web.config; + +import org.springframework.context.annotation.Configuration; + +@Configuration +public class WebConfig { + +} \ No newline at end of file diff --git a/spring-boot-rest/src/main/resources/application.properties b/spring-boot-rest/src/main/resources/application.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/SpringBootRestApplicationUnitTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/SpringBootRestApplicationUnitTest.java new file mode 100644 index 0000000000..747e08f6f8 --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/web/SpringBootRestApplicationUnitTest.java @@ -0,0 +1,16 @@ +package com.baeldung.spring.boot.rest; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringBootRestApplicationUnitTest { + + @Test + public void contextLoads() { + } + +} From 842d8573af8bef74a34b3b65d3f7bae59ffa5742 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Wed, 9 Jan 2019 00:38:14 +0530 Subject: [PATCH 169/441] Revert parent pom.xml --- pom.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index cf7eb1f394..4dba0da173 100644 --- a/pom.xml +++ b/pom.xml @@ -645,7 +645,6 @@ spring-boot-mvc spring-boot-ops spring-boot-property-exp - spring-boot-rest spring-boot-security spring-boot-testing spring-boot-vue @@ -1357,11 +1356,8 @@ spring-boot-mvc spring-boot-ops spring-boot-property-exp - spring-boot-rest spring-boot-security - spring-boot-testing spring-boot-vue - spring-boot-libraries spring-cloud spring-cloud-bus @@ -1376,7 +1372,7 @@ spring-dispatcher-servlet spring-drools - spring-ehcache + spring-ehcache spring-ejb spring-exceptions From 6cd561d91a1ef1d8b5fc52f2d10ceff16e4bcf1f Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Wed, 9 Jan 2019 00:41:57 +0530 Subject: [PATCH 170/441] Fixed pom.xml --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 4dba0da173..324f6129db 100644 --- a/pom.xml +++ b/pom.xml @@ -644,6 +644,7 @@ spring-boot-logging-log4j2 spring-boot-mvc spring-boot-ops + spring-boot-rest spring-boot-property-exp spring-boot-security spring-boot-testing @@ -1355,6 +1356,7 @@ spring-boot-logging-log4j2 spring-boot-mvc spring-boot-ops + spring-boot-rest spring-boot-property-exp spring-boot-security spring-boot-vue From e6f28c61a3484d5cd488c1160981ac36c35e8b05 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 9 Jan 2019 00:09:02 +0200 Subject: [PATCH 171/441] Create README.md --- spring-boot-rest/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-boot-rest/README.md diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md new file mode 100644 index 0000000000..0a8d13cf76 --- /dev/null +++ b/spring-boot-rest/README.md @@ -0,0 +1,3 @@ +Module for the articles that 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) From 58ed9e47b204652bae2ced49cb0b541840272f8f Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 9 Jan 2019 00:12:40 +0200 Subject: [PATCH 172/441] Update and rename SpringBootRestApplicationUnitTest.java to SpringContextIntegrationTest.java --- ...plicationUnitTest.java => SpringContextIntegrationTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spring-boot-rest/src/test/java/com/baeldung/web/{SpringBootRestApplicationUnitTest.java => SpringContextIntegrationTest.java} (86%) diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/SpringBootRestApplicationUnitTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java similarity index 86% rename from spring-boot-rest/src/test/java/com/baeldung/web/SpringBootRestApplicationUnitTest.java rename to spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java index 747e08f6f8..0c1fdf372b 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/web/SpringBootRestApplicationUnitTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java @@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest -public class SpringBootRestApplicationUnitTest { +public class SpringContextIntegrationTest { @Test public void contextLoads() { From 065a6e2519d5b52093381a388f9075c5580d8f7f Mon Sep 17 00:00:00 2001 From: jose Date: Tue, 8 Jan 2019 23:55:48 -0300 Subject: [PATCH 173/441] BAEL-2472 code examples --- .../com/baeldung/scope/ClassScopeExample.java | 15 +++++++++++++++ .../com/baeldung/scope/LoopScopeExample.java | 18 ++++++++++++++++++ .../com/baeldung/scope/MethodScopeExample.java | 16 ++++++++++++++++ .../baeldung/scope/NestedScopesExample.java | 13 +++++++++++++ .../com/baeldung/scope/OutOfScopeExample.java | 14 ++++++++++++++ 5 files changed, 76 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java create mode 100644 core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java create mode 100644 core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java create mode 100644 core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java create mode 100644 core-java/src/main/java/com/baeldung/scope/OutOfScopeExample.java diff --git a/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java b/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java new file mode 100644 index 0000000000..17ca1e01eb --- /dev/null +++ b/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java @@ -0,0 +1,15 @@ +package org.baeldung.variable.scope.examples; + +public class ClassScopeExample { + + Integer amount = 0; + + public void exampleMethod() { + amount++; + } + + public void anotherExampleMethod() { + amount--; + } + +} diff --git a/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java b/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java new file mode 100644 index 0000000000..2dd3be3333 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java @@ -0,0 +1,18 @@ +package org.baeldung.variable.scope.examples; + +import java.util.Arrays; +import java.util.List; + +public class LoopScopeExample { + + List listOfNames = Arrays.asList("Joe", "Susan", "Pattrick"); + + public void iterationOfNames() { + String allNames = ""; + for (String name : listOfNames) { + allNames = allNames + " " + name; + } + + } + +} diff --git a/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java b/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java new file mode 100644 index 0000000000..122d12e2fc --- /dev/null +++ b/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java @@ -0,0 +1,16 @@ +package org.baeldung.variable.scope.examples; + +public class MethodScopeExample { + + Integer size = 2; + + public void methodA() { + Integer area = 2; + area = area + size; + } + + public void methodB() { + size = size + 5; + } + +} diff --git a/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java b/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java new file mode 100644 index 0000000000..9bd2268e52 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java @@ -0,0 +1,13 @@ +package org.baeldung.variable.scope.examples; + +public class NestedScopesExample { + + String title = "Baeldung"; + + public void printTitle() { + System.out.println(title); + String title = "John Doe"; + System.out.println(title); + } + +} diff --git a/core-java/src/main/java/com/baeldung/scope/OutOfScopeExample.java b/core-java/src/main/java/com/baeldung/scope/OutOfScopeExample.java new file mode 100644 index 0000000000..774095228c --- /dev/null +++ b/core-java/src/main/java/com/baeldung/scope/OutOfScopeExample.java @@ -0,0 +1,14 @@ +package org.baeldung.variable.scope.examples; + +public class OutOfScopeExample { + + public void methodWithAVariableDeclaredInside() { + String name = "John Doe"; + System.out.println(name); + } + + public void methodWithoutVariables() { + System.out.println("Pattrick"); + } + +} From f1e3ceaea75f6b5e6efcd2517523baa48b8ccfa8 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Wed, 9 Jan 2019 12:21:43 +0400 Subject: [PATCH 174/441] text searching Aho-Corasick algorithm --- java-strings/pom.xml | 6 +++ .../java/com/baeldung/string/MatchWords.java | 48 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 java-strings/src/main/java/com/baeldung/string/MatchWords.java diff --git a/java-strings/pom.xml b/java-strings/pom.xml index f4fb1c0865..9f89ed6d76 100755 --- a/java-strings/pom.xml +++ b/java-strings/pom.xml @@ -95,6 +95,12 @@ 1.4 + + org.ahocorasick + ahocorasick + 0.4.0 + + diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java new file mode 100644 index 0000000000..ec926d99c4 --- /dev/null +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -0,0 +1,48 @@ +package com.baeldung.string; + +import org.ahocorasick.trie.Emit; +import org.ahocorasick.trie.Trie; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.regex.Pattern; + +public class MatchWords { + + // *778*1# *778*00# + public static void main(String[] args) { + String[] items = {"hello", "Baeldung"}; + String inputString = "hello there, Baeldung"; + + boolean isMatch = java8(inputString, new ArrayList<>(Arrays.asList(items))); + + System.out.println(isMatch); + + System.out.println(patternMatch(inputString)); + + ahoCorasick(); + } + + private static void ahoCorasick() { + Trie trie = Trie.builder() + .onlyWholeWords() + .addKeyword("hello") + .addKeyword("Baeldung") + .build(); + Collection emits = trie.parseText("hello there, Baeldung"); + emits.forEach(System.out::println); + } + + private static boolean patternMatch(String inputString) { + Pattern pattern = Pattern.compile("(?=.*hello)(?=.*Baeldung)"); + if (pattern.matcher(inputString).find()) { + return true; + } + return false; + } + + private static boolean java8(String inputString, ArrayList items) { + return Arrays.stream(inputString.split(" ")).allMatch(items::contains); + } +} From 1861e9b94ccadeaed1dd796c5e55bddfbe28607f Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Wed, 9 Jan 2019 16:16:48 +0400 Subject: [PATCH 175/441] match words --- .../java/com/baeldung/string/MatchWords.java | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index ec926d99c4..0cdb4cde6a 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -10,18 +10,28 @@ import java.util.regex.Pattern; public class MatchWords { - // *778*1# *778*00# public static void main(String[] args) { String[] items = {"hello", "Baeldung"}; String inputString = "hello there, Baeldung"; - boolean isMatch = java8(inputString, new ArrayList<>(Arrays.asList(items))); + //System.out.println(containsWords(inputString, items)); - System.out.println(isMatch); + System.out.println(java8(new ArrayList<>(Arrays.asList(inputString.split(" "))), new ArrayList<>(Arrays.asList(items)))); - System.out.println(patternMatch(inputString)); + //System.out.println(patternMatch(inputString)); - ahoCorasick(); + //ahoCorasick(); + } + + private static boolean containsWords(String inputString, String[] items) { + boolean found = true; + for (String item : items) { + if (!inputString.contains(item)) { + found = false; + break; + } + } + return found; } private static void ahoCorasick() { @@ -42,7 +52,12 @@ public class MatchWords { return false; } - private static boolean java8(String inputString, ArrayList items) { - return Arrays.stream(inputString.split(" ")).allMatch(items::contains); + private static boolean java8(ArrayList inputString, ArrayList items) { + return items.stream().allMatch(inputString::contains); } + + private static boolean array(ArrayList inputString, ArrayList items) { + return inputString.containsAll(items); + } + } From d413ec768f99a2967075f2dff2d6e456dd7b629c Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Wed, 9 Jan 2019 16:18:32 +0400 Subject: [PATCH 176/441] match words final --- .../src/main/java/com/baeldung/string/MatchWords.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index 0cdb4cde6a..6e6acb24cf 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -14,13 +14,13 @@ public class MatchWords { String[] items = {"hello", "Baeldung"}; String inputString = "hello there, Baeldung"; - //System.out.println(containsWords(inputString, items)); + System.out.println(containsWords(inputString, items)); System.out.println(java8(new ArrayList<>(Arrays.asList(inputString.split(" "))), new ArrayList<>(Arrays.asList(items)))); - //System.out.println(patternMatch(inputString)); + System.out.println(patternMatch(inputString)); - //ahoCorasick(); + ahoCorasick(); } private static boolean containsWords(String inputString, String[] items) { From 9e9458ea5f000131a76c9105666b77f0c3454fc7 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Wed, 9 Jan 2019 17:17:35 +0400 Subject: [PATCH 177/441] indexOf example --- .../java/com/baeldung/string/MatchWords.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index 6e6acb24cf..c0f89b635d 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -3,9 +3,7 @@ package com.baeldung.string; import org.ahocorasick.trie.Emit; import org.ahocorasick.trie.Trie; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; +import java.util.*; import java.util.regex.Pattern; public class MatchWords { @@ -21,6 +19,25 @@ public class MatchWords { System.out.println(patternMatch(inputString)); ahoCorasick(); + + wordIndices(inputString); + } + + private static void wordIndices(String inputString) { + Map wordIndices = new TreeMap<>(); + List words = new ArrayList<>(); + words.add("hello"); + words.add("Baeldung"); + + for (String word : words) { + int index = inputString.indexOf(word); + + if (index != -1) { + wordIndices.put(index, word); + } + } + + wordIndices.keySet().forEach(System.out::println); } private static boolean containsWords(String inputString, String[] items) { From a094e49a6292aaad494f6d66194066c69a81c43f Mon Sep 17 00:00:00 2001 From: Mikhail Chugunov Date: Wed, 9 Jan 2019 19:53:12 +0300 Subject: [PATCH 178/441] BAEL-2475: Changes after first review --- .../deserialization/immutable/Employee.java | 24 ++++++++ .../immutable/MaritalAwarePerson.java | 58 ------------------- .../deserialization/immutable/Person.java | 32 ++++++++-- ...mmutableObjectDeserializationUnitTest.java | 22 ++++--- 4 files changed, 60 insertions(+), 76 deletions(-) create mode 100644 jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Employee.java delete mode 100644 jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/MaritalAwarePerson.java diff --git a/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Employee.java b/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Employee.java new file mode 100644 index 0000000000..44b10ee39b --- /dev/null +++ b/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Employee.java @@ -0,0 +1,24 @@ +package com.baeldung.jackson.deserialization.immutable; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Employee { + + private final long id; + private final String name; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + public Employee(@JsonProperty("id") long id, @JsonProperty("name") String name) { + this.id = id; + this.name = name; + } + + public long getId() { + return id; + } + + public String getName() { + return name; + } +} diff --git a/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/MaritalAwarePerson.java b/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/MaritalAwarePerson.java deleted file mode 100644 index cb593b3bb7..0000000000 --- a/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/MaritalAwarePerson.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.baeldung.jackson.deserialization.immutable; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; - -@JsonDeserialize(builder = MaritalAwarePerson.Builder.class) -public class MaritalAwarePerson { - - private final String name; - private final int age; - private final Boolean married; - - private MaritalAwarePerson(String name, int age, Boolean married) { - this.name = name; - this.age = age; - this.married = married; - } - - public String getName() { - return name; - } - - public int getAge() { - return age; - } - - public Boolean getMarried() { - return married; - } - - @JsonPOJOBuilder - static class Builder { - String name; - int age; - Boolean married; - - Builder withName(String name) { - this.name = name; - return this; - } - - Builder withAge(int age) { - this.age = age; - return this; - } - - Builder withMarried(boolean married) { - this.married = married; - return this; - } - - public MaritalAwarePerson build() { - return new MaritalAwarePerson(name, age, married); - } - - - } -} diff --git a/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Person.java b/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Person.java index 0214f93ca9..d9041720b6 100644 --- a/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Person.java +++ b/jackson/src/main/java/com/baeldung/jackson/deserialization/immutable/Person.java @@ -1,15 +1,15 @@ package com.baeldung.jackson.deserialization.immutable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +@JsonDeserialize(builder = Person.Builder.class) public class Person { private final String name; - private final int age; + private final Integer age; - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - public Person(@JsonProperty("name") String name, @JsonProperty("age") int age) { + private Person(String name, Integer age) { this.name = name; this.age = age; } @@ -18,7 +18,27 @@ public class Person { return name; } - public int getAge() { + public Integer getAge() { return age; } + + @JsonPOJOBuilder + static class Builder { + String name; + Integer age; + + Builder withName(String name) { + this.name = name; + return this; + } + + Builder withAge(Integer age) { + this.age = age; + return this; + } + + Person build() { + return new Person(name, age); + } + } } diff --git a/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java b/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java index 5c33a2da26..1252179e3a 100644 --- a/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java +++ b/jackson/src/test/java/com/baeldung/jackson/deserialization/immutable/ImmutableObjectDeserializationUnitTest.java @@ -11,30 +11,28 @@ public class ImmutableObjectDeserializationUnitTest { @Test public void whenPublicConstructorIsUsed_thenObjectIsDeserialized() throws IOException { - final String json = "{\"name\":\"Frank\",\"age\":50}"; - Person person = new ObjectMapper().readValue(json, Person.class); + final String json = "{\"name\":\"Frank\",\"id\":5000}"; + Employee employee = new ObjectMapper().readValue(json, Employee.class); - assertEquals("Frank", person.getName()); - assertEquals(50, person.getAge()); + assertEquals("Frank", employee.getName()); + assertEquals(5000, employee.getId()); } @Test public void whenBuilderIsUsedAndFieldIsNull_thenObjectIsDeserialized() throws IOException { - final String json = "{\"name\":\"Frank\",\"age\":50}"; - MaritalAwarePerson person = new ObjectMapper().readValue(json, MaritalAwarePerson.class); + final String json = "{\"name\":\"Frank\"}"; + Person person = new ObjectMapper().readValue(json, Person.class); assertEquals("Frank", person.getName()); - assertEquals(50, person.getAge()); - assertNull(person.getMarried()); + assertNull(person.getAge()); } @Test public void whenBuilderIsUsedAndAllFieldsPresent_thenObjectIsDeserialized() throws IOException { - final String json = "{\"name\":\"Frank\",\"age\":50,\"married\":true}"; - MaritalAwarePerson person = new ObjectMapper().readValue(json, MaritalAwarePerson.class); + final String json = "{\"name\":\"Frank\",\"age\":50}"; + Person person = new ObjectMapper().readValue(json, Person.class); assertEquals("Frank", person.getName()); - assertEquals(50, person.getAge()); - assertTrue(person.getMarried()); + assertEquals(50, (int) person.getAge()); } } From 44490a052ff0760b5115ba5764e53553c41ccf44 Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Wed, 9 Jan 2019 18:06:47 +0000 Subject: [PATCH 179/441] BAEL2526 queue interface code (#6115) * BAEL2526 queue interface code * renamed test class to end with 'UnitTest', removed camel case from package name --- .../queueInterface/CustomBaeldungQueue.java | 48 +++++++++++++++++ .../queueInterface/PriorityQueueUnitTest.java | 53 +++++++++++++++++++ .../CustomBaeldungQueueUnitTest.java | 30 +++++++++++ 3 files changed, 131 insertions(+) create mode 100644 core-java-collections/src/main/java/com/baeldung/queueInterface/CustomBaeldungQueue.java create mode 100644 core-java-collections/src/test/java/com/baeldung/queueInterface/PriorityQueueUnitTest.java create mode 100644 core-java-collections/src/test/java/com/baeldung/queueinterface/CustomBaeldungQueueUnitTest.java diff --git a/core-java-collections/src/main/java/com/baeldung/queueInterface/CustomBaeldungQueue.java b/core-java-collections/src/main/java/com/baeldung/queueInterface/CustomBaeldungQueue.java new file mode 100644 index 0000000000..6b088a5079 --- /dev/null +++ b/core-java-collections/src/main/java/com/baeldung/queueInterface/CustomBaeldungQueue.java @@ -0,0 +1,48 @@ +package com.baeldung.queueinterface; + +import java.util.AbstractQueue; +import java.util.Iterator; +import java.util.LinkedList; + +public class CustomBaeldungQueue extends AbstractQueue { + + private LinkedList elements; + + public CustomBaeldungQueue() { + this.elements = new LinkedList(); + } + + @Override + public Iterator iterator() { + return elements.iterator(); + } + + @Override + public int size() { + return elements.size(); + } + + @Override + public boolean offer(T t) { + if(t == null) return false; + elements.add(t); + return true; + } + + @Override + public T poll() { + + Iterator iter = elements.iterator(); + T t = iter.next(); + if(t != null){ + iter.remove(); + return t; + } + return null; + } + + @Override + public T peek() { + return elements.getFirst(); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/queueInterface/PriorityQueueUnitTest.java b/core-java-collections/src/test/java/com/baeldung/queueInterface/PriorityQueueUnitTest.java new file mode 100644 index 0000000000..c5b564b55b --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/queueInterface/PriorityQueueUnitTest.java @@ -0,0 +1,53 @@ +package com.baeldung.queueinterface; + +import org.junit.Before; +import org.junit.Test; + +import java.util.PriorityQueue; + +import static org.junit.Assert.assertEquals; + +public class PriorityQueueUnitTest { + + + + @Test + public void givenIntegerQueue_whenIntegersOutOfOrder_checkRetrievalOrderIsNatural() { + + PriorityQueue integerQueue = new PriorityQueue<>(); + + integerQueue.add(9); + integerQueue.add(2); + integerQueue.add(4); + + int first = integerQueue.poll(); + int second = integerQueue.poll(); + int third = integerQueue.poll(); + + assertEquals(2, first); + assertEquals(4, second); + assertEquals(9, third); + + + } + + @Test + public void givenStringQueue_whenStringsAddedOutOfNaturalOrder_checkRetrievalOrderNatural() { + + PriorityQueue stringQueue = new PriorityQueue<>(); + + stringQueue.add("banana"); + stringQueue.add("apple"); + stringQueue.add("cherry"); + + String first = stringQueue.poll(); + String second = stringQueue.poll(); + String third = stringQueue.poll(); + + assertEquals("apple", first); + assertEquals("banana", second); + assertEquals("cherry", third); + + + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/queueinterface/CustomBaeldungQueueUnitTest.java b/core-java-collections/src/test/java/com/baeldung/queueinterface/CustomBaeldungQueueUnitTest.java new file mode 100644 index 0000000000..6dec768542 --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/queueinterface/CustomBaeldungQueueUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.queueinterface; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class CustomBaeldungQueueUnitTest { + + private CustomBaeldungQueue customQueue; + + @Before + public void setUp() throws Exception { + customQueue = new CustomBaeldungQueue<>(); + } + + @Test + public void givenQueueWithTwoElements_whenElementsRetrieved_checkRetrievalCorrect() { + + customQueue.add(7); + customQueue.add(5); + + int first = customQueue.poll(); + int second = customQueue.poll(); + + assertEquals(7, first); + assertEquals(5, second); + + } +} From 128817cfebe533b21c4248f6d14099579108a52d Mon Sep 17 00:00:00 2001 From: Amy DeGregorio Date: Wed, 9 Jan 2019 15:20:47 -0500 Subject: [PATCH 180/441] example code for Article How to Write to a CSV File in Java (#6102) --- .../com/baeldung/csv/WriteCsvFileExample.java | 29 ++++++ .../csv/WriteCsvFileExampleUnitTest.java | 90 +++++++++++++++++++ .../src/test/resources/exampleOutput.csv | 2 + 3 files changed, 121 insertions(+) create mode 100644 core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java create mode 100644 core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java create mode 100644 core-java-io/src/test/resources/exampleOutput.csv diff --git a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java new file mode 100644 index 0000000000..fd3678d2c5 --- /dev/null +++ b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java @@ -0,0 +1,29 @@ +package com.baeldung.csv; + +import java.io.BufferedWriter; +import java.io.IOException; + +public class WriteCsvFileExample { + + public void writeLine(BufferedWriter writer, String[] data) throws IOException { + StringBuilder csvLine = new StringBuilder(); + + for (int i = 0; i < data.length; i++) { + if (i > 0) { + csvLine.append(","); + } + csvLine.append(escapeSpecialCharacters(data[i])); + } + + writer.write(csvLine.toString()); + } + + public String escapeSpecialCharacters(String data) { + String escapedData = data.replaceAll("\\R", " "); + if (data.contains(",") || data.contains("\"") || data.contains("'")) { + data = data.replace("\"", "\"\""); + escapedData = "\"" + data + "\""; + } + return escapedData; + } +} diff --git a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java new file mode 100644 index 0000000000..4ac84f939d --- /dev/null +++ b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java @@ -0,0 +1,90 @@ +package com.baeldung.csv; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WriteCsvFileExampleUnitTest { + private static final Logger LOG = LoggerFactory.getLogger(WriteCsvFileExampleUnitTest.class); + + private static final String CSV_FILE_NAME = "src/test/resources/exampleOutput.csv"; + private WriteCsvFileExample csvExample; + + @Before + public void setupClass() { + csvExample = new WriteCsvFileExample(); + } + + @Test + public void givenCommaContainingData_whenEscapeSpecialCharacters_stringReturnedInQuotes() { + String data = "three,two,one"; + String escapedData = csvExample.escapeSpecialCharacters(data); + + String expectedData = "\"three,two,one\""; + assertEquals(expectedData, escapedData); + } + + @Test + public void givenQuoteContainingData_whenEscapeSpecialCharacters_stringReturnedFormatted() { + String data = "She said \"Hello\""; + String escapedData = csvExample.escapeSpecialCharacters(data); + + String expectedData = "\"She said \"\"Hello\"\"\""; + assertEquals(expectedData, escapedData); + } + + @Test + public void givenNewlineContainingData_whenEscapeSpecialCharacters_stringReturnedInQuotes() { + String dataNewline = "This contains\na newline"; + String dataCarriageReturn = "This contains\r\na newline and carriage return"; + String escapedDataNl = csvExample.escapeSpecialCharacters(dataNewline); + String escapedDataCr = csvExample.escapeSpecialCharacters(dataCarriageReturn); + + String expectedData = "This contains a newline"; + assertEquals(expectedData, escapedDataNl); + String expectedDataCr = "This contains a newline and carriage return"; + assertEquals(expectedDataCr, escapedDataCr); + } + + @Test + public void givenNonSpecialData_whenEscapeSpecialCharacters_stringReturnedUnchanged() { + String data = "This is nothing special"; + String returnedData = csvExample.escapeSpecialCharacters(data); + + assertEquals(data, returnedData); + } + + @Test + public void givenBufferedWriter_whenWriteLine_thenOutputCreated() { + List dataLines = new ArrayList(); + dataLines.add(new String[] { "John", "Doe", "38", "Comment Data\nAnother line of comment data" }); + dataLines.add(new String[] { "Jane", "Doe, Jr.", "19", "She said \"I'm being quoted\"" }); + + File csvOutputFile = new File(CSV_FILE_NAME); + try (BufferedWriter writer = new BufferedWriter(new FileWriter(csvOutputFile))) { + for (Iterator dataIterator = dataLines.iterator(); dataIterator.hasNext();) { + csvExample.writeLine(writer, dataIterator.next()); + if (dataIterator.hasNext()) { + writer.newLine(); + } + } + writer.flush(); + } catch (IOException e) { + LOG.error("IOException " + e.getMessage()); + } + + assertTrue(csvOutputFile.exists()); + } +} diff --git a/core-java-io/src/test/resources/exampleOutput.csv b/core-java-io/src/test/resources/exampleOutput.csv new file mode 100644 index 0000000000..45c37f3a3b --- /dev/null +++ b/core-java-io/src/test/resources/exampleOutput.csv @@ -0,0 +1,2 @@ +John,Doe,38,Comment Data Another line of comment data +Jane,"Doe, Jr.",19,"She said ""I'm being quoted""" \ No newline at end of file From 70a7aaa4fc25ad2d40e314d3f1c3ae8d8b760101 Mon Sep 17 00:00:00 2001 From: Kumar Chandrakant Date: Thu, 10 Jan 2019 02:20:46 +0530 Subject: [PATCH 181/441] Kafka spark cassandra (#6089) * Adding files for the tutorial BAEL-2301 * Incorporating review comments on the article. * Incorporated additional review comments on the article. --- .../data/pipeline/WordCountingApp.java | 18 ++++++------------ .../WordCountingAppWithCheckpoint.java | 19 ++++++------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java index 1155644e1e..db2a73b411 100644 --- a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java +++ b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingApp.java @@ -14,13 +14,7 @@ import org.apache.kafka.common.serialization.StringDeserializer; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.spark.SparkConf; -import org.apache.spark.api.java.JavaPairRDD; import org.apache.spark.api.java.JavaRDD; -import org.apache.spark.api.java.function.FlatMapFunction; -import org.apache.spark.api.java.function.Function; -import org.apache.spark.api.java.function.Function2; -import org.apache.spark.api.java.function.PairFunction; -import org.apache.spark.api.java.function.VoidFunction; import org.apache.spark.streaming.Durations; import org.apache.spark.streaming.api.java.JavaDStream; import org.apache.spark.streaming.api.java.JavaInputDStream; @@ -59,17 +53,17 @@ public class WordCountingApp { JavaInputDStream> messages = KafkaUtils.createDirectStream(streamingContext, LocationStrategies.PreferConsistent(), ConsumerStrategies. Subscribe(topics, kafkaParams)); - JavaPairDStream results = messages.mapToPair((PairFunction, String, String>) record -> new Tuple2<>(record.key(), record.value())); + JavaPairDStream results = messages.mapToPair(record -> new Tuple2<>(record.key(), record.value())); - JavaDStream lines = results.map((Function, String>) tuple2 -> tuple2._2()); + JavaDStream lines = results.map(tuple2 -> tuple2._2()); - JavaDStream words = lines.flatMap((FlatMapFunction) x -> Arrays.asList(x.split("\\s+")) + JavaDStream words = lines.flatMap(x -> Arrays.asList(x.split("\\s+")) .iterator()); - JavaPairDStream wordCounts = words.mapToPair((PairFunction) s -> new Tuple2<>(s, 1)) - .reduceByKey((Function2) (i1, i2) -> i1 + i2); + JavaPairDStream wordCounts = words.mapToPair(s -> new Tuple2<>(s, 1)) + .reduceByKey((i1, i2) -> i1 + i2); - wordCounts.foreachRDD((VoidFunction>) javaRdd -> { + wordCounts.foreachRDD(javaRdd -> { Map wordCountMap = javaRdd.collectAsMap(); for (String key : wordCountMap.keySet()) { List wordList = Arrays.asList(new Word(key, wordCountMap.get(key))); diff --git a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java index 79e21f7209..efbe5f3851 100644 --- a/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java +++ b/apache-spark/src/main/java/com/baeldung/data/pipeline/WordCountingAppWithCheckpoint.java @@ -16,15 +16,8 @@ import org.apache.log4j.Logger; import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; -import org.apache.spark.api.java.Optional; -import org.apache.spark.api.java.function.FlatMapFunction; -import org.apache.spark.api.java.function.Function; import org.apache.spark.api.java.function.Function2; -import org.apache.spark.api.java.function.Function3; -import org.apache.spark.api.java.function.PairFunction; -import org.apache.spark.api.java.function.VoidFunction; import org.apache.spark.streaming.Durations; -import org.apache.spark.streaming.State; import org.apache.spark.streaming.StateSpec; import org.apache.spark.streaming.api.java.JavaDStream; import org.apache.spark.streaming.api.java.JavaInputDStream; @@ -71,24 +64,24 @@ public class WordCountingAppWithCheckpoint { JavaInputDStream> messages = KafkaUtils.createDirectStream(streamingContext, LocationStrategies.PreferConsistent(), ConsumerStrategies. Subscribe(topics, kafkaParams)); - JavaPairDStream results = messages.mapToPair((PairFunction, String, String>) record -> new Tuple2<>(record.key(), record.value())); + JavaPairDStream results = messages.mapToPair(record -> new Tuple2<>(record.key(), record.value())); - JavaDStream lines = results.map((Function, String>) tuple2 -> tuple2._2()); + JavaDStream lines = results.map(tuple2 -> tuple2._2()); - JavaDStream words = lines.flatMap((FlatMapFunction) x -> Arrays.asList(x.split("\\s+")) + JavaDStream words = lines.flatMap(x -> Arrays.asList(x.split("\\s+")) .iterator()); - JavaPairDStream wordCounts = words.mapToPair((PairFunction) s -> new Tuple2<>(s, 1)) + JavaPairDStream wordCounts = words.mapToPair(s -> new Tuple2<>(s, 1)) .reduceByKey((Function2) (i1, i2) -> i1 + i2); - JavaMapWithStateDStream> cumulativeWordCounts = wordCounts.mapWithState(StateSpec.function((Function3, State, Tuple2>) (word, one, state) -> { + JavaMapWithStateDStream> cumulativeWordCounts = wordCounts.mapWithState(StateSpec.function((word, one, state) -> { int sum = one.orElse(0) + (state.exists() ? state.get() : 0); Tuple2 output = new Tuple2<>(word, sum); state.update(sum); return output; })); - cumulativeWordCounts.foreachRDD((VoidFunction>>) javaRdd -> { + cumulativeWordCounts.foreachRDD(javaRdd -> { List> wordCountList = javaRdd.collect(); for (Tuple2 tuple : wordCountList) { List wordList = Arrays.asList(new Word(tuple._1, tuple._2)); From 288fc3db8af02097cd1cb7bca13aa5a2569af9de Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 10 Jan 2019 01:04:16 +0200 Subject: [PATCH 182/441] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 324f6129db..07e90cca94 100644 --- a/pom.xml +++ b/pom.xml @@ -436,7 +436,7 @@ java-collections-conversions java-collections-maps - java-ee-8-security-api + java-lite java-numbers java-rmi From c7ba38ffcd805b088e9e44d7145eb393ef162025 Mon Sep 17 00:00:00 2001 From: geroza Date: Tue, 8 Jan 2019 16:16:51 -0200 Subject: [PATCH 183/441] migrated the following modules using parent-spring-5 to spring 5.1: spring-mvc-simple spring-security-mvc-custom spring-security-mvc-login spring-security-rest spring-security-rest-basic-auth spring-static-resources spring-thymeleaf --- ethereum/pom.xml | 4 +- parent-spring-5-1/README.md | 1 + parent-spring-5-1/pom.xml | 39 +++++++++++++++++++ parent-spring-5/pom.xml | 4 +- .../spring-data-elasticsearch/pom.xml | 4 +- .../spring-data-mongodb/pom.xml | 5 +-- pom.xml | 6 +++ spring-dispatcher-servlet/pom.xml | 4 +- spring-mvc-forms-jsp/pom.xml | 4 +- spring-mvc-java/pom.xml | 4 +- spring-mvc-simple/pom.xml | 19 --------- .../java/com/baeldung/spring/MvcConfig.java | 1 - .../baeldung/client/RestTemplateFactory.java | 4 +- .../java/org/baeldung/spring/WebConfig.java | 1 - .../SpringContextIntegrationTest.java | 2 +- .../java/org/baeldung/web/FooLiveTest.java | 2 +- 16 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 parent-spring-5-1/README.md create mode 100644 parent-spring-5-1/pom.xml diff --git a/ethereum/pom.xml b/ethereum/pom.xml index 85cb260670..334840edaf 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -7,10 +7,10 @@ ethereum - parent-spring-5 + parent-spring-5-1 com.baeldung 0.0.1-SNAPSHOT - ../parent-spring-5 + ../parent-spring-5-1 diff --git a/parent-spring-5-1/README.md b/parent-spring-5-1/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/parent-spring-5-1/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/parent-spring-5-1/pom.xml b/parent-spring-5-1/pom.xml new file mode 100644 index 0000000000..983e5e63eb --- /dev/null +++ b/parent-spring-5-1/pom.xml @@ -0,0 +1,39 @@ + + 4.0.0 + com.baeldung + parent-spring-5-1 + 0.0.1-SNAPSHOT + pom + parent-spring-5-1 + Parent for all spring 5 core modules + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.springframework + spring-core + ${spring.version} + + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + test + + + + + 5.0.6.RELEASE + 5.0.2 + 2.9.6 + 2.9.6 + 5.0.6.RELEASE + + + diff --git a/parent-spring-5/pom.xml b/parent-spring-5/pom.xml index 6a15f38884..51a2c1fd1f 100644 --- a/parent-spring-5/pom.xml +++ b/parent-spring-5/pom.xml @@ -29,11 +29,11 @@ - 5.0.6.RELEASE + 5.1.2.RELEASE 5.0.2 2.9.6 2.9.6 - 5.0.6.RELEASE + 5.1.2.RELEASE \ No newline at end of file diff --git a/persistence-modules/spring-data-elasticsearch/pom.xml b/persistence-modules/spring-data-elasticsearch/pom.xml index ee9e71a1cb..c5ad9b64f9 100644 --- a/persistence-modules/spring-data-elasticsearch/pom.xml +++ b/persistence-modules/spring-data-elasticsearch/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-spring-5 + parent-spring-5-1 0.0.1-SNAPSHOT - ../../parent-spring-5 + ../../parent-spring-5-1 diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index 63b9c3c1b0..4da0526ca6 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -6,9 +6,9 @@ com.baeldung - parent-spring-5 + parent-spring-5-1 0.0.1-SNAPSHOT - ../../parent-spring-5 + ../../parent-spring-5-1 @@ -99,7 +99,6 @@ 2.1.2.RELEASE 4.1.4 1.1.3 - 5.1.0.RELEASE 1.9.2 3.2.0.RELEASE diff --git a/pom.xml b/pom.xml index 324f6129db..13b866b968 100644 --- a/pom.xml +++ b/pom.xml @@ -329,6 +329,7 @@ parent-boot-2 parent-spring-4 parent-spring-5 + parent-spring-5-1 parent-java parent-kotlin @@ -600,6 +601,7 @@ parent-boot-2 parent-spring-4 parent-spring-5 + parent-spring-5-1 parent-java parent-kotlin @@ -993,6 +995,7 @@ parent-boot-2 parent-spring-4 parent-spring-5 + parent-spring-5-1 parent-java parent-kotlin @@ -1045,6 +1048,7 @@ parent-boot-2 parent-spring-4 parent-spring-5 + parent-spring-5-1 parent-java parent-kotlin @@ -1312,6 +1316,7 @@ parent-boot-2 parent-spring-4 parent-spring-5 + parent-spring-5-1 parent-java parent-kotlin @@ -1544,6 +1549,7 @@ parent-boot-2 parent-spring-4 parent-spring-5 + parent-spring-5-1 parent-java parent-kotlin diff --git a/spring-dispatcher-servlet/pom.xml b/spring-dispatcher-servlet/pom.xml index 7ac291740e..ea5eb8845e 100644 --- a/spring-dispatcher-servlet/pom.xml +++ b/spring-dispatcher-servlet/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-spring-5 + parent-spring-5-1 0.0.1-SNAPSHOT - ../parent-spring-5 + ../parent-spring-5-1 diff --git a/spring-mvc-forms-jsp/pom.xml b/spring-mvc-forms-jsp/pom.xml index 5536314086..80818f4e88 100644 --- a/spring-mvc-forms-jsp/pom.xml +++ b/spring-mvc-forms-jsp/pom.xml @@ -11,9 +11,9 @@ com.baeldung - parent-spring-5 + parent-spring-5-1 0.0.1-SNAPSHOT - ../parent-spring-5 + ../parent-spring-5-1 diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 9d3e0ca1b2..b0b187ee84 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -8,10 +8,10 @@ war - parent-spring-5 + parent-spring-5-1 com.baeldung 0.0.1-SNAPSHOT - ../parent-spring-5 + ../parent-spring-5-1 diff --git a/spring-mvc-simple/pom.xml b/spring-mvc-simple/pom.xml index 65fa4339d6..087ffea46d 100644 --- a/spring-mvc-simple/pom.xml +++ b/spring-mvc-simple/pom.xml @@ -154,25 +154,6 @@ ${deploy-path} - - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - default-test - - true - - - - - - org.junit.platform - junit-platform-surefire-provider - ${junit.platform.version} - - - spring-mvc-simple diff --git a/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java b/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java index a9c7e0cf15..082477c98c 100644 --- a/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java +++ b/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java @@ -1,7 +1,6 @@ package com.baeldung.spring; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; diff --git a/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java index 5e15648e9b..3ed0bc82b7 100644 --- a/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java +++ b/spring-security-rest-basic-auth/src/main/java/org/baeldung/client/RestTemplateFactory.java @@ -4,7 +4,7 @@ import org.apache.http.HttpHost; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.support.BasicAuthorizationInterceptor; +import org.springframework.http.client.support.BasicAuthenticationInterceptor; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; @@ -38,7 +38,7 @@ public class RestTemplateFactory implements FactoryBean, Initializ HttpHost host = new HttpHost("localhost", 8082, "http"); final ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactoryBasicAuth(host); restTemplate = new RestTemplate(requestFactory); - restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor("user1", "user1Pass")); + restTemplate.getInterceptors().add(new BasicAuthenticationInterceptor("user1", "user1Pass")); } } \ No newline at end of file diff --git a/spring-security-rest-basic-auth/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-basic-auth/src/main/java/org/baeldung/spring/WebConfig.java index 2305a7b6c2..5876e1307b 100644 --- a/spring-security-rest-basic-auth/src/main/java/org/baeldung/spring/WebConfig.java +++ b/spring-security-rest-basic-auth/src/main/java/org/baeldung/spring/WebConfig.java @@ -8,7 +8,6 @@ import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration @EnableWebMvc diff --git a/spring-security-rest-basic-auth/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-security-rest-basic-auth/src/test/java/org/baeldung/SpringContextIntegrationTest.java index 6cf624c179..31b3f2be87 100644 --- a/spring-security-rest-basic-auth/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-security-rest-basic-auth/src/test/java/org/baeldung/SpringContextIntegrationTest.java @@ -6,7 +6,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration({ "/WebSecurityConfig.xml" }) +@ContextConfiguration({ "/webSecurityConfig.xml" }) public class SpringContextIntegrationTest { @Test diff --git a/spring-security-rest/src/test/java/org/baeldung/web/FooLiveTest.java b/spring-security-rest/src/test/java/org/baeldung/web/FooLiveTest.java index 0a53da674a..86beeb46a9 100644 --- a/spring-security-rest/src/test/java/org/baeldung/web/FooLiveTest.java +++ b/spring-security-rest/src/test/java/org/baeldung/web/FooLiveTest.java @@ -29,7 +29,7 @@ public class FooLiveTest { // } // return RestAssured.given().cookie("JSESSIONID", cookie); return RestAssured.given() - .auth() + .auth().preemptive() .basic("user", "userPass"); } From cde1d1c7ad72c3d3608b97aa45c933b4ded0b86b Mon Sep 17 00:00:00 2001 From: geroza Date: Tue, 8 Jan 2019 17:17:28 -0200 Subject: [PATCH 184/441] Fixed usage of deprecated GzipResourceResolver in spring-static-resources added back spring-version modification in module that hasnt been worked yet cleaned unused classes --- persistence-modules/spring-data-mongodb/pom.xml | 1 + .../src/main/java/com/baeldung/spring/MvcConfig.java | 1 - .../src/main/java/org/baeldung/spring/MvcConfig.java | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index 4da0526ca6..86e4b275e7 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -96,6 +96,7 @@ + 5.1.0.RELEASE 2.1.2.RELEASE 4.1.4 1.1.3 diff --git a/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java b/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java index 082477c98c..629e203b56 100644 --- a/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java +++ b/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java @@ -1,7 +1,6 @@ package com.baeldung.spring; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; diff --git a/spring-static-resources/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-static-resources/src/main/java/org/baeldung/spring/MvcConfig.java index dbc548e028..7bd03617be 100644 --- a/spring-static-resources/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-static-resources/src/main/java/org/baeldung/spring/MvcConfig.java @@ -18,7 +18,7 @@ import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.i18n.CookieLocaleResolver; import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; -import org.springframework.web.servlet.resource.GzipResourceResolver; +import org.springframework.web.servlet.resource.EncodedResourceResolver; import org.springframework.web.servlet.resource.PathResourceResolver; import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter; import org.springframework.web.servlet.view.InternalResourceViewResolver; @@ -57,10 +57,10 @@ public class MvcConfig implements WebMvcConfigurer { public void addResourceHandlers(ResourceHandlerRegistry registry) { // For examples using Spring 4.1.0 if ((env.getProperty("resource.handler.conf")).equals("4.1.0")) { - registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver()).addResolver(new PathResourceResolver()); + registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(3600).resourceChain(true).addResolver(new EncodedResourceResolver()).addResolver(new PathResourceResolver()); registry.addResourceHandler("/resources/**").addResourceLocations("/resources/", "classpath:/other-resources/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver()); registry.addResourceHandler("/files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver()); - registry.addResourceHandler("/other-files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver()); + registry.addResourceHandler("/other-files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new EncodedResourceResolver()); } // For examples using Spring 4.0.7 else if ((env.getProperty("resource.handler.conf")).equals("4.0.7")) { From 74df0da304af2152a45ecf60a5f65ae77e0bc474 Mon Sep 17 00:00:00 2001 From: geroza Date: Wed, 9 Jan 2019 12:28:21 -0200 Subject: [PATCH 185/441] fixed removed import by mistake --- .../src/main/java/com/baeldung/spring/MvcConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java b/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java index 629e203b56..082477c98c 100644 --- a/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java +++ b/spring-security-mvc-login/src/main/java/com/baeldung/spring/MvcConfig.java @@ -1,6 +1,7 @@ package com.baeldung.spring; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; From 63258737ceb25dd435d3437920b2e8d8fff709aa Mon Sep 17 00:00:00 2001 From: geroza Date: Wed, 9 Jan 2019 13:33:39 -0200 Subject: [PATCH 186/441] modified readme file to kick off travis build --- ethereum/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ethereum/README.md b/ethereum/README.md index d06ca09636..0c7ae3d4d2 100644 --- a/ethereum/README.md +++ b/ethereum/README.md @@ -4,3 +4,4 @@ - [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) + From 04a4c339b767267739690c633901f911a621b46f Mon Sep 17 00:00:00 2001 From: geroza Date: Wed, 9 Jan 2019 14:53:44 -0200 Subject: [PATCH 187/441] change to kick off build --- ethereum/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/ethereum/README.md b/ethereum/README.md index 0c7ae3d4d2..d06ca09636 100644 --- a/ethereum/README.md +++ b/ethereum/README.md @@ -4,4 +4,3 @@ - [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) - From 39bfa04d11d34b8b3fe98deb43936854eaea9fcf Mon Sep 17 00:00:00 2001 From: geroza Date: Wed, 9 Jan 2019 23:51:39 -0200 Subject: [PATCH 188/441] change to kick off build --- ethereum/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ethereum/README.md b/ethereum/README.md index d06ca09636..7accb4cd53 100644 --- a/ethereum/README.md +++ b/ethereum/README.md @@ -4,3 +4,4 @@ - [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) + \ No newline at end of file From 57228dfc6b9ec1af0658f9b616056708c070bb28 Mon Sep 17 00:00:00 2001 From: Rodolfo Felipe Date: Wed, 9 Jan 2019 22:29:44 -0400 Subject: [PATCH 189/441] BAEL-2446 Unit tests for new added examples. --- .../StringReplaceAndRemoveUnitTest.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java b/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java index d952d2383b..d54bf09b35 100644 --- a/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java +++ b/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java @@ -1,15 +1,16 @@ package com.baeldung.string; - import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.RegExUtils; import org.junit.Test; +import com.sun.source.tree.AssertTree; + import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class StringReplaceAndRemoveUnitTest { - @Test public void givenTestStrings_whenReplace_thenProcessedString() { @@ -26,7 +27,7 @@ public class StringReplaceAndRemoveUnitTest { public void givenTestStrings_whenReplaceAll_thenProcessedString() { String master2 = "Welcome to Baeldung, Hello World Baeldung"; - String regexTarget= "(Baeldung)$"; + String regexTarget = "(Baeldung)$"; String replacement = "Java"; String processed2 = master2.replaceAll(regexTarget, replacement); assertTrue(processed2.endsWith("Java")); @@ -45,18 +46,16 @@ public class StringReplaceAndRemoveUnitTest { StringBuilder builder = new StringBuilder(master); - builder.delete(startIndex, stopIndex); - assertFalse(builder.toString().contains(target)); - + assertFalse(builder.toString() + .contains(target)); builder.replace(startIndex, stopIndex, replacement); - assertTrue(builder.toString().contains(replacement)); - + assertTrue(builder.toString() + .contains(replacement)); } - @Test public void givenTestStrings_whenStringUtilsMethods_thenProcessedStrings() { @@ -74,10 +73,20 @@ public class StringReplaceAndRemoveUnitTest { } + @Test + public void givenTestStrings_whenReplaceExactWord_thenProcessedString() { + String sentence = "A car is not the same as a carriage, and some planes can carry cars inside them!"; + String regexTarget = "\\bcar\\b"; + String exactWordReplaced = sentence.replaceAll(regexTarget, "truck"); + assertTrue("A truck is not the same as a carriage, and some planes can carry cars inside them!".equals(exactWordReplaced)); + } - - - - + @Test + public void givenTestStrings_whenReplaceExactWordUsingRegExUtilsMethod_thenProcessedString() { + String sentence = "A car is not the same as a carriage, and some planes can carry cars inside them!"; + String regexTarget = "\\bcar\\b"; + String exactWordReplaced = RegExUtils.replaceAll(sentence, regexTarget, "truck"); + assertTrue("A truck is not the same as a carriage, and some planes can carry cars inside them!".equals(exactWordReplaced)); + } } From 44a796b9e66aa8ff28fa464ecaca486bdbcf0277 Mon Sep 17 00:00:00 2001 From: Rodolfo Felipe Date: Wed, 9 Jan 2019 23:16:44 -0400 Subject: [PATCH 190/441] Deleting invalid package Package added by eclipse. Nonexistent. --- .../com/baeldung/string/StringReplaceAndRemoveUnitTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java b/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java index d54bf09b35..4d2b54241b 100644 --- a/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java +++ b/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java @@ -4,8 +4,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.RegExUtils; import org.junit.Test; -import com.sun.source.tree.AssertTree; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; From bb966c8e1461083cc6d3617242bc7cf9ac7c0fac Mon Sep 17 00:00:00 2001 From: dupirefr Date: Thu, 10 Jan 2019 08:51:53 +0100 Subject: [PATCH 191/441] [BAEL-2531] Directories creation tests --- .../directories/NewDirectoryUnitTest.java | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java diff --git a/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java b/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java new file mode 100644 index 0000000000..e0111c2702 --- /dev/null +++ b/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java @@ -0,0 +1,100 @@ +package com.baeldung.directories; + +import org.junit.Before; +import org.junit.Test; + +import java.io.File; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class NewDirectoryUnitTest { + + private static final File TEMP_DIRECTORY = new File(System.getProperty("java.io.tmpdir")); + + @Before + public void beforeEach() { + File newDirectory = new File(TEMP_DIRECTORY, "new_directory"); + File nestedInNewDirectory = new File(newDirectory, "nested_directory"); + File existingDirectory = new File(TEMP_DIRECTORY, "existing_directory"); + File existingNestedDirectory = new File(existingDirectory, "existing_nested_directory"); + File nestedInExistingDirectory = new File(existingDirectory, "nested_directory"); + + nestedInNewDirectory.delete(); + newDirectory.delete(); + nestedInExistingDirectory.delete(); + existingDirectory.mkdir(); + existingNestedDirectory.mkdir(); + } + + @Test + public void givenUnexistingDirectory_whenMkdir_thenTrue() { + File newDirectory = new File(TEMP_DIRECTORY, "new_directory"); + assertFalse(newDirectory.exists()); + + boolean directoryCreated = newDirectory.mkdir(); + + assertTrue(directoryCreated); + } + + @Test + public void givenExistingDirectory_whenMkdir_thenFalse() { + File newDirectory = new File(TEMP_DIRECTORY, "new_directory"); + newDirectory.mkdir(); + assertTrue(newDirectory.exists()); + + boolean directoryCreated = newDirectory.mkdir(); + + assertFalse(directoryCreated); + } + + @Test + public void givenUnexistingNestedDirectories_whenMkdir_thenFalse() { + File newDirectory = new File(TEMP_DIRECTORY, "new_directory"); + File nestedDirectory = new File(newDirectory, "nested_directory"); + assertFalse(newDirectory.exists()); + assertFalse(nestedDirectory.exists()); + + boolean directoriesCreated = nestedDirectory.mkdir(); + + assertFalse(directoriesCreated); + } + + @Test + public void givenUnexistingNestedDirectories_whenMkdirs_thenTrue() { + File newDirectory = new File(TEMP_DIRECTORY, "new_directory"); + File nestedDirectory = new File(newDirectory, "nested_directory"); + assertFalse(newDirectory.exists()); + assertFalse(nestedDirectory.exists()); + + boolean directoriesCreated = nestedDirectory.mkdirs(); + + assertTrue(directoriesCreated); + } + + @Test + public void givenExistingParentDirectories_whenMkdirs_thenTrue() { + File newDirectory = new File(TEMP_DIRECTORY, "existing_directory"); + newDirectory.mkdir(); + File nestedDirectory = new File(newDirectory, "nested_directory"); + assertTrue(newDirectory.exists()); + assertFalse(nestedDirectory.exists()); + + boolean directoriesCreated = nestedDirectory.mkdirs(); + + assertTrue(directoriesCreated); + } + + @Test + public void givenExistingNestedDirectories_whenMkdirs_thenFalse() { + File existingDirectory = new File(TEMP_DIRECTORY, "existing_directory"); + File existingNestedDirectory = new File(existingDirectory, "existing_nested_directory"); + assertTrue(existingDirectory.exists()); + assertTrue(existingNestedDirectory.exists()); + + boolean directoriesCreated = existingNestedDirectory.mkdirs(); + + assertFalse(directoriesCreated); + } + +} From 9b550e6554f0432f9e93a1f20273398909f17369 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Thu, 10 Jan 2019 15:00:38 +0400 Subject: [PATCH 192/441] localdate converter --- .../com/baeldung/util/LocalDateConverter.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java new file mode 100644 index 0000000000..341492d1fd --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java @@ -0,0 +1,25 @@ +package com.baeldung.util; + +import javax.persistence.AttributeConverter; +import javax.persistence.Converter; +import java.sql.Date; +import java.time.LocalDate; +import java.util.Optional; + +@Converter(autoApply = true) +public class LocalDateConverter implements AttributeConverter { + + @Override + public Date convertToDatabaseColumn(LocalDate localDateTime) { + return Optional.ofNullable(localDateTime) + .map(Date::valueOf) + .orElse(null); + } + + @Override + public LocalDate convertToEntityAttribute(Date timestamp) { + return Optional.ofNullable(timestamp) + .map(Date::toLocalDate) + .orElse(null); + } +} \ No newline at end of file From 6202b7caab30ba5db67e992925efa60c21c2a881 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Thu, 10 Jan 2019 15:18:21 +0400 Subject: [PATCH 193/441] localdate converter --- .../main/java/com/baeldung/util/LocalDateConverter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java index 341492d1fd..00fd378b05 100644 --- a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java @@ -10,15 +10,15 @@ import java.util.Optional; public class LocalDateConverter implements AttributeConverter { @Override - public Date convertToDatabaseColumn(LocalDate localDateTime) { - return Optional.ofNullable(localDateTime) + public Date convertToDatabaseColumn(LocalDate localDate) { + return Optional.ofNullable(localDate) .map(Date::valueOf) .orElse(null); } @Override - public LocalDate convertToEntityAttribute(Date timestamp) { - return Optional.ofNullable(timestamp) + public LocalDate convertToEntityAttribute(Date date) { + return Optional.ofNullable(date) .map(Date::toLocalDate) .orElse(null); } From 1ca15e59190955a5bb53c1466d7aac68a8d79859 Mon Sep 17 00:00:00 2001 From: geroza Date: Wed, 9 Jan 2019 12:23:10 -0200 Subject: [PATCH 194/441] Migrated modules using parent-spring-5: ethereum persistence-modules/spring-data-elasticsearch persistence-modules/spring-data-mongodb spring-dispatcher-servlet spring-mvc-forms-jsp spring-mvc-java --- ethereum/pom.xml | 15 ++--- .../spring-data-elasticsearch/pom.xml | 4 +- .../ElasticSearchManualTest.java | 7 ++ ...ionTest.java => GeoQueriesManualTest.java} | 10 ++- ...Test.java => ElasticSearchManualTest.java} | 9 ++- ...java => ElasticSearchQueryManualTest.java} | 9 ++- ...Test.java => SpringContextManualTest.java} | 8 ++- .../spring-data-mongodb/pom.xml | 5 +- .../aggregation/ZipsAggregationLiveTest.java | 6 ++ .../com/baeldung/gridfs/GridFSLiveTest.java | 6 ++ .../mongotemplate/DocumentQueryLiveTest.java | 6 ++ .../MongoTemplateProjectionLiveTest.java | 6 ++ .../MongoTemplateQueryLiveTest.java | 6 ++ .../repository/ActionRepositoryLiveTest.java | 6 ++ .../repository/BaseQueryLiveTest.java | 6 ++ .../baeldung/repository/DSLQueryLiveTest.java | 8 ++- .../repository/JSONQueryLiveTest.java | 6 ++ .../repository/QueryMethodsLiveTest.java | 6 ++ .../repository/UserRepositoryLiveTest.java | 6 ++ .../UserRepositoryProjectionLiveTest.java | 6 ++ .../MongoTransactionReactiveLiveTest.java | 6 ++ .../MongoTransactionTemplateLiveTest.java | 6 ++ .../MongoTransactionalLiveTest.java | 6 ++ spring-4/README.md | 1 + spring-4/pom.xml | 16 +++++ .../com/baeldung/flips/ApplicationConfig.java | 8 ++- .../com/baeldung/jsonp/JsonPApplication.java | 27 ++++++++ .../com/baeldung/jsonp/model/Company.java | 38 +++++++++++ .../web/controller/CompanyController.java | 27 ++++++++ .../jsonp/web/controller/IndexController.java | 13 ++++ .../advice/JsonpControllerAdvice.java | 5 +- .../src/main/resources/application.properties | 2 +- .../resources/jsonp-application.properties | 2 + .../src/main/webapp/WEB-INF/jsp/index.jsp | 66 +++++++++++++++++++ spring-dispatcher-servlet/pom.xml | 4 +- spring-mvc-forms-jsp/pom.xml | 4 +- spring-mvc-java/README.md | 1 - spring-mvc-java/pom.xml | 20 +++++- .../web/controller/CompanyController.java | 13 ---- .../config/HandlerMappingDefaultConfig.java | 9 +-- .../com/baeldung/htmlunit/TestConfig.java | 1 - .../ClassValidationMvcIntegrationTest.java | 1 - .../GreetControllerIntegrationTest.java | 1 - 43 files changed, 366 insertions(+), 52 deletions(-) rename persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/{GeoQueriesIntegrationTest.java => GeoQueriesManualTest.java} (97%) rename persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/{ElasticSearchIntegrationTest.java => ElasticSearchManualTest.java} (97%) rename persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/{ElasticSearchQueryIntegrationTest.java => ElasticSearchQueryManualTest.java} (98%) rename persistence-modules/spring-data-elasticsearch/src/test/java/org/baeldung/{SpringContextIntegrationTest.java => SpringContextManualTest.java} (77%) create mode 100644 spring-4/src/main/java/com/baeldung/jsonp/JsonPApplication.java create mode 100644 spring-4/src/main/java/com/baeldung/jsonp/model/Company.java create mode 100644 spring-4/src/main/java/com/baeldung/jsonp/web/controller/CompanyController.java create mode 100644 spring-4/src/main/java/com/baeldung/jsonp/web/controller/IndexController.java rename {spring-mvc-java/src/main/java/com/baeldung => spring-4/src/main/java/com/baeldung/jsonp}/web/controller/advice/JsonpControllerAdvice.java (53%) create mode 100644 spring-4/src/main/resources/jsonp-application.properties create mode 100644 spring-4/src/main/webapp/WEB-INF/jsp/index.jsp diff --git a/ethereum/pom.xml b/ethereum/pom.xml index 334840edaf..c7f82eaf22 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -7,10 +7,10 @@ ethereum - parent-spring-5-1 + parent-spring-5 com.baeldung 0.0.1-SNAPSHOT - ../parent-spring-5-1 + ../parent-spring-5 @@ -37,17 +37,17 @@ org.springframework spring-core - ${springframework.version} + ${spring.version} org.springframework spring-web - ${springframework.version} + ${spring.version} org.springframework spring-webmvc - ${springframework.version} + ${spring.version} @@ -123,12 +123,12 @@ org.springframework spring-context - ${springframework.version} + ${spring.version} org.springframework spring-test - ${springframework.version} + ${spring.version} test @@ -212,7 +212,6 @@ 8.5.4 1.5.0-RELEASE 3.3.1 - 5.0.5.RELEASE 1.5.6.RELEASE 2.21.0 2.9.7 diff --git a/persistence-modules/spring-data-elasticsearch/pom.xml b/persistence-modules/spring-data-elasticsearch/pom.xml index c5ad9b64f9..ee9e71a1cb 100644 --- a/persistence-modules/spring-data-elasticsearch/pom.xml +++ b/persistence-modules/spring-data-elasticsearch/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-spring-5-1 + parent-spring-5 0.0.1-SNAPSHOT - ../../parent-spring-5-1 + ../../parent-spring-5 diff --git a/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchManualTest.java b/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchManualTest.java index fbf4e5ab99..e43dcdf43e 100644 --- a/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchManualTest.java +++ b/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/ElasticSearchManualTest.java @@ -30,6 +30,13 @@ import org.junit.Test; import com.alibaba.fastjson.JSON; +/** + * + * This Manual test requires: + * * Elasticsearch instance running on host + * * with cluster name = elasticsearch + * + */ public class ElasticSearchManualTest { private List listOfPersons = new ArrayList<>(); private Client client = null; diff --git a/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/GeoQueriesIntegrationTest.java b/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/GeoQueriesManualTest.java similarity index 97% rename from persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/GeoQueriesIntegrationTest.java rename to persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/GeoQueriesManualTest.java index 1f55379418..f9a42050b6 100644 --- a/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/GeoQueriesIntegrationTest.java +++ b/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/elasticsearch/GeoQueriesManualTest.java @@ -31,9 +31,17 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.baeldung.spring.data.es.config.Config; import com.vividsolutions.jts.geom.Coordinate; +/** + * + * This Manual test requires: + * * Elasticsearch instance running on host + * * with cluster name = elasticsearch + * * and further configurations + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = Config.class) -public class GeoQueriesIntegrationTest { +public class GeoQueriesManualTest { private static final String WONDERS_OF_WORLD = "wonders-of-world"; private static final String WONDERS = "Wonders"; diff --git a/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchIntegrationTest.java b/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchManualTest.java similarity index 97% rename from persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchIntegrationTest.java rename to persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchManualTest.java index 6ecb11cdbe..bed2e2ff25 100644 --- a/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchIntegrationTest.java +++ b/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchManualTest.java @@ -27,9 +27,16 @@ import com.baeldung.spring.data.es.model.Article; import com.baeldung.spring.data.es.model.Author; import com.baeldung.spring.data.es.service.ArticleService; +/** + * + * This Manual test requires: + * * Elasticsearch instance running on host + * * with cluster name = elasticsearch + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = Config.class) -public class ElasticSearchIntegrationTest { +public class ElasticSearchManualTest { @Autowired private ElasticsearchTemplate elasticsearchTemplate; diff --git a/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchQueryIntegrationTest.java b/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchQueryManualTest.java similarity index 98% rename from persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchQueryIntegrationTest.java rename to persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchQueryManualTest.java index 2348c49830..5e24d8398c 100644 --- a/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchQueryIntegrationTest.java +++ b/persistence-modules/spring-data-elasticsearch/src/test/java/com/baeldung/spring/data/es/ElasticSearchQueryManualTest.java @@ -41,9 +41,16 @@ import com.baeldung.spring.data.es.model.Article; import com.baeldung.spring.data.es.model.Author; import com.baeldung.spring.data.es.service.ArticleService; +/** + * + * This Manual test requires: + * * Elasticsearch instance running on host + * * with cluster name = elasticsearch + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = Config.class) -public class ElasticSearchQueryIntegrationTest { +public class ElasticSearchQueryManualTest { @Autowired private ElasticsearchTemplate elasticsearchTemplate; diff --git a/persistence-modules/spring-data-elasticsearch/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/persistence-modules/spring-data-elasticsearch/src/test/java/org/baeldung/SpringContextManualTest.java similarity index 77% rename from persistence-modules/spring-data-elasticsearch/src/test/java/org/baeldung/SpringContextIntegrationTest.java rename to persistence-modules/spring-data-elasticsearch/src/test/java/org/baeldung/SpringContextManualTest.java index 6f45039c96..c6f095eae9 100644 --- a/persistence-modules/spring-data-elasticsearch/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/persistence-modules/spring-data-elasticsearch/src/test/java/org/baeldung/SpringContextManualTest.java @@ -7,9 +7,15 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.baeldung.spring.data.es.config.Config; +/** + * + * This Manual test requires: + * * Elasticsearch instance running on host + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = Config.class) -public class SpringContextIntegrationTest { +public class SpringContextManualTest { @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index 86e4b275e7..c1faf72103 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -6,9 +6,9 @@ com.baeldung - parent-spring-5-1 + parent-spring-5 0.0.1-SNAPSHOT - ../../parent-spring-5-1 + ../../parent-spring-5 @@ -96,7 +96,6 @@ - 5.1.0.RELEASE 2.1.2.RELEASE 4.1.4 1.1.3 diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/aggregation/ZipsAggregationLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/aggregation/ZipsAggregationLiveTest.java index 1da50d7cb4..1002dc79eb 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/aggregation/ZipsAggregationLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/aggregation/ZipsAggregationLiveTest.java @@ -44,6 +44,12 @@ import com.mongodb.MongoClient; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class ZipsAggregationLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java index 3a88a1e654..d25b9ece4f 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java @@ -31,6 +31,12 @@ import com.mongodb.BasicDBObject; import com.mongodb.DBObject; import com.mongodb.client.gridfs.model.GridFSFile; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @ContextConfiguration("file:src/main/resources/mongoConfig.xml") @RunWith(SpringJUnit4ClassRunner.class) public class GridFSLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/DocumentQueryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/DocumentQueryLiveTest.java index d05bde0f1b..e5e4a188ec 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/DocumentQueryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/DocumentQueryLiveTest.java @@ -24,6 +24,12 @@ import com.baeldung.config.MongoConfig; import com.baeldung.model.EmailAddress; import com.baeldung.model.User; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class DocumentQueryLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateProjectionLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateProjectionLiveTest.java index 309f14e995..9e12997c67 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateProjectionLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateProjectionLiveTest.java @@ -16,6 +16,12 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = SimpleMongoConfig.class) public class MongoTemplateProjectionLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java index fc78921b75..4f62f0d7a7 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java @@ -27,6 +27,12 @@ import com.baeldung.config.MongoConfig; import com.baeldung.model.EmailAddress; import com.baeldung.model.User; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class MongoTemplateQueryLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/ActionRepositoryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/ActionRepositoryLiveTest.java index 096015ca0a..79648f1a20 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/ActionRepositoryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/ActionRepositoryLiveTest.java @@ -15,6 +15,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.time.ZoneOffset; import java.time.ZonedDateTime; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class ActionRepositoryLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/BaseQueryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/BaseQueryLiveTest.java index e4849181e5..c94bb2ae4c 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/BaseQueryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/BaseQueryLiveTest.java @@ -7,6 +7,12 @@ import org.junit.Before; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoOperations; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ public class BaseQueryLiveTest { @Autowired diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/DSLQueryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/DSLQueryLiveTest.java index f87ca5cbb5..0ccf677b3e 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/DSLQueryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/DSLQueryLiveTest.java @@ -15,8 +15,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.querydsl.core.types.Predicate; - - +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class DSLQueryLiveTest extends BaseQueryLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/JSONQueryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/JSONQueryLiveTest.java index 4e99c0b140..3a99407350 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/JSONQueryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/JSONQueryLiveTest.java @@ -12,6 +12,12 @@ import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class JSONQueryLiveTest extends BaseQueryLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/QueryMethodsLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/QueryMethodsLiveTest.java index 47e67a6b4c..ef8ce10dd1 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/QueryMethodsLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/QueryMethodsLiveTest.java @@ -12,6 +12,12 @@ import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class QueryMethodsLiveTest extends BaseQueryLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryLiveTest.java index 901610e42d..dd7215af7e 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryLiveTest.java @@ -23,6 +23,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.baeldung.config.MongoConfig; import com.baeldung.model.User; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class UserRepositoryLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryProjectionLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryProjectionLiveTest.java index 80f4275794..8972246041 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryProjectionLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/UserRepositoryProjectionLiveTest.java @@ -13,6 +13,12 @@ import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class UserRepositoryProjectionLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionReactiveLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionReactiveLiveTest.java index 70908552fe..3fc8dcf977 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionReactiveLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionReactiveLiveTest.java @@ -12,6 +12,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.baeldung.config.MongoReactiveConfig; import com.baeldung.model.User; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoReactiveConfig.class) public class MongoTransactionReactiveLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionTemplateLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionTemplateLiveTest.java index 20ac6974bc..53b2c7a0e7 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionTemplateLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionTemplateLiveTest.java @@ -24,6 +24,12 @@ import org.springframework.transaction.support.TransactionTemplate; import com.baeldung.config.MongoConfig; import com.baeldung.model.User; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class MongoTransactionTemplateLiveTest { diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java index 0cf86aa43e..bafcd770ec 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java @@ -24,6 +24,12 @@ import com.baeldung.model.User; import com.baeldung.repository.UserRepository; import com.mongodb.MongoCommandException; +/** + * + * This test requires: + * * mongodb instance running on the environment + * + */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) diff --git a/spring-4/README.md b/spring-4/README.md index 402557eb41..57cb8c3eeb 100644 --- a/spring-4/README.md +++ b/spring-4/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [A Guide to Flips for Spring](http://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) diff --git a/spring-4/pom.xml b/spring-4/pom.xml index 78939bba95..60f1555d8f 100644 --- a/spring-4/pom.xml +++ b/spring-4/pom.xml @@ -52,6 +52,21 @@ provided + + javax.servlet + jstl + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.apache.tomcat.embed + tomcat-embed-jasper + provided + @@ -71,6 +86,7 @@ + com.baeldung.flips.ApplicationConfig 1.0.1 1.16.18 1.4.197 diff --git a/spring-4/src/main/java/com/baeldung/flips/ApplicationConfig.java b/spring-4/src/main/java/com/baeldung/flips/ApplicationConfig.java index 7001aeb991..1bd6ffa336 100644 --- a/spring-4/src/main/java/com/baeldung/flips/ApplicationConfig.java +++ b/spring-4/src/main/java/com/baeldung/flips/ApplicationConfig.java @@ -3,9 +3,15 @@ package com.baeldung.flips; import org.flips.describe.config.FlipWebContextConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; +import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.context.annotation.Import; -@SpringBootApplication +@SpringBootApplication(exclude = { + DataSourceAutoConfiguration.class, + DataSourceTransactionManagerAutoConfiguration.class, + HibernateJpaAutoConfiguration.class }) @Import(FlipWebContextConfiguration.class) public class ApplicationConfig { diff --git a/spring-4/src/main/java/com/baeldung/jsonp/JsonPApplication.java b/spring-4/src/main/java/com/baeldung/jsonp/JsonPApplication.java new file mode 100644 index 0000000000..a8f3c0e102 --- /dev/null +++ b/spring-4/src/main/java/com/baeldung/jsonp/JsonPApplication.java @@ -0,0 +1,27 @@ +package com.baeldung.jsonp; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; +import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.context.annotation.PropertySource; + +@SpringBootApplication(exclude = { + DataSourceAutoConfiguration.class, + DataSourceTransactionManagerAutoConfiguration.class, + HibernateJpaAutoConfiguration.class }) +@PropertySource("classpath:jsonp-application.properties") +public class JsonPApplication extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(JsonPApplication.class); + } + + public static void main(String[] args) throws Exception { + SpringApplication.run(JsonPApplication.class, args); + } +} diff --git a/spring-4/src/main/java/com/baeldung/jsonp/model/Company.java b/spring-4/src/main/java/com/baeldung/jsonp/model/Company.java new file mode 100644 index 0000000000..b11a216e52 --- /dev/null +++ b/spring-4/src/main/java/com/baeldung/jsonp/model/Company.java @@ -0,0 +1,38 @@ +package com.baeldung.jsonp.model; + +public class Company { + + private long id; + private String name; + + public Company() { + super(); + } + + public Company(final long id, final String name) { + this.id = id; + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + @Override + public String toString() { + return "Company [id=" + id + ", name=" + name + "]"; + } + +} diff --git a/spring-4/src/main/java/com/baeldung/jsonp/web/controller/CompanyController.java b/spring-4/src/main/java/com/baeldung/jsonp/web/controller/CompanyController.java new file mode 100644 index 0000000000..8710359365 --- /dev/null +++ b/spring-4/src/main/java/com/baeldung/jsonp/web/controller/CompanyController.java @@ -0,0 +1,27 @@ +package com.baeldung.jsonp.web.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.baeldung.jsonp.model.Company; + +@Controller +public class CompanyController { + + @RequestMapping(value = "/companyResponseBody", produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public Company getCompanyResponseBody() { + final Company company = new Company(2, "ABC"); + return company; + } + + @RequestMapping(value = "/companyResponseEntity", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity getCompanyResponseEntity() { + final Company company = new Company(3, "123"); + return new ResponseEntity(company, HttpStatus.OK); + } +} diff --git a/spring-4/src/main/java/com/baeldung/jsonp/web/controller/IndexController.java b/spring-4/src/main/java/com/baeldung/jsonp/web/controller/IndexController.java new file mode 100644 index 0000000000..8469e19458 --- /dev/null +++ b/spring-4/src/main/java/com/baeldung/jsonp/web/controller/IndexController.java @@ -0,0 +1,13 @@ +package com.baeldung.jsonp.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +public class IndexController { + + @RequestMapping() + public String retrieveIndex() { + return "index"; + } +} diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/advice/JsonpControllerAdvice.java b/spring-4/src/main/java/com/baeldung/jsonp/web/controller/advice/JsonpControllerAdvice.java similarity index 53% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/advice/JsonpControllerAdvice.java rename to spring-4/src/main/java/com/baeldung/jsonp/web/controller/advice/JsonpControllerAdvice.java index 7b2c6870df..be7c65cb1e 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/advice/JsonpControllerAdvice.java +++ b/spring-4/src/main/java/com/baeldung/jsonp/web/controller/advice/JsonpControllerAdvice.java @@ -1,8 +1,11 @@ -package com.baeldung.web.controller.advice; +package com.baeldung.jsonp.web.controller.advice; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice; +// AbstractJsonpResponseBodyAdvice was deprecated in favor of configuring CORS properly +// We still want to cover the usage of JSON-P in our articles, therefore we don't care that it was deprecated. +@SuppressWarnings("deprecation") @ControllerAdvice public class JsonpControllerAdvice extends AbstractJsonpResponseBodyAdvice { diff --git a/spring-4/src/main/resources/application.properties b/spring-4/src/main/resources/application.properties index 274896be15..e67700b7be 100644 --- a/spring-4/src/main/resources/application.properties +++ b/spring-4/src/main/resources/application.properties @@ -2,4 +2,4 @@ feature.foo.by.id=Y feature.new.foo=Y last.active.after=2018-03-14T00:00:00Z first.active.after=2999-03-15T00:00:00Z -logging.level.org.flips=info \ No newline at end of file +logging.level.org.flips=info diff --git a/spring-4/src/main/resources/jsonp-application.properties b/spring-4/src/main/resources/jsonp-application.properties new file mode 100644 index 0000000000..94e7fcc026 --- /dev/null +++ b/spring-4/src/main/resources/jsonp-application.properties @@ -0,0 +1,2 @@ +spring.mvc.view.prefix=/WEB-INF/jsp/ +spring.mvc.view.suffix=.jsp diff --git a/spring-4/src/main/webapp/WEB-INF/jsp/index.jsp b/spring-4/src/main/webapp/WEB-INF/jsp/index.jsp new file mode 100644 index 0000000000..fa5498c966 --- /dev/null +++ b/spring-4/src/main/webapp/WEB-INF/jsp/index.jsp @@ -0,0 +1,66 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1" %> + + + + + Company Data + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/spring-dispatcher-servlet/pom.xml b/spring-dispatcher-servlet/pom.xml index ea5eb8845e..7ac291740e 100644 --- a/spring-dispatcher-servlet/pom.xml +++ b/spring-dispatcher-servlet/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-spring-5-1 + parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-5-1 + ../parent-spring-5 diff --git a/spring-mvc-forms-jsp/pom.xml b/spring-mvc-forms-jsp/pom.xml index 80818f4e88..5536314086 100644 --- a/spring-mvc-forms-jsp/pom.xml +++ b/spring-mvc-forms-jsp/pom.xml @@ -11,9 +11,9 @@ com.baeldung - parent-spring-5-1 + parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-5-1 + ../parent-spring-5 diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index c7fcbd400b..851a3689ab 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -11,7 +11,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Introduction to Advice Types in Spring](http://www.baeldung.com/spring-aop-advice-tutorial) - [A Guide to the ViewResolver in Spring MVC](http://www.baeldung.com/spring-mvc-view-resolver-tutorial) - [Integration Testing in Spring](http://www.baeldung.com/integration-testing-in-spring) -- [Spring JSON-P with Jackson](http://www.baeldung.com/spring-jackson-jsonp) - [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) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index b0b187ee84..562df30318 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -8,10 +8,10 @@ war - parent-spring-5-1 + parent-spring-5 com.baeldung 0.0.1-SNAPSHOT - ../parent-spring-5-1 + ../parent-spring-5 @@ -60,6 +60,12 @@ commons-fileupload commons-fileupload ${commons-fileupload.version} + + + commons-io + commons-io + + net.sourceforge.htmlunit @@ -70,8 +76,17 @@ commons-logging commons-logging + + commons-io + commons-io + + + commons-io + commons-io + ${commons-io.version} + @@ -255,6 +270,7 @@ 19.0 3.5 1.3.2 + 2.5 2.2.0 diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java b/spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java index e92abfdc47..af1e729c13 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java +++ b/spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java @@ -60,17 +60,4 @@ public class CompanyController { result.put("name", name); return new ResponseEntity<>(result, HttpStatus.OK); } - - @RequestMapping(value = "/companyResponseBody", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public Company getCompanyResponseBody() { - final Company company = new Company(2, "ABC"); - return company; - } - - @RequestMapping(value = "/companyResponseEntity", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity getCompanyResponseEntity() { - final Company company = new Company(3, "123"); - return new ResponseEntity(company, HttpStatus.OK); - } } diff --git a/spring-mvc-java/src/test/java/com/baeldung/config/HandlerMappingDefaultConfig.java b/spring-mvc-java/src/test/java/com/baeldung/config/HandlerMappingDefaultConfig.java index 9190d07d6b..d3a329a387 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/config/HandlerMappingDefaultConfig.java +++ b/spring-mvc-java/src/test/java/com/baeldung/config/HandlerMappingDefaultConfig.java @@ -1,15 +1,10 @@ package com.baeldung.config; -import com.baeldung.web.controller.handlermapping.BeanNameHandlerMappingController; -import com.baeldung.web.controller.handlermapping.SimpleUrlMappingController; -import com.baeldung.web.controller.handlermapping.WelcomeController; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping; -import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; -import java.util.HashMap; -import java.util.Map; +import com.baeldung.web.controller.handlermapping.BeanNameHandlerMappingController; +import com.baeldung.web.controller.handlermapping.WelcomeController; @Configuration diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/TestConfig.java b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/TestConfig.java index 5b86b59095..529879fada 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/TestConfig.java +++ b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/TestConfig.java @@ -9,7 +9,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.view.ThymeleafViewResolver; import org.thymeleaf.templateresolver.ServletContextTemplateResolver; diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/ClassValidationMvcIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/web/controller/ClassValidationMvcIntegrationTest.java index a86f71011c..2cd225a775 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/ClassValidationMvcIntegrationTest.java +++ b/spring-mvc-java/src/test/java/com/baeldung/web/controller/ClassValidationMvcIntegrationTest.java @@ -1,6 +1,5 @@ package com.baeldung.web.controller; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java index 384bd85ec6..bce5ab0a8c 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java +++ b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java @@ -20,7 +20,6 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import com.baeldung.spring.web.config.WebConfig; import com.baeldung.spring.web.config.WebConfig; @RunWith(SpringJUnit4ClassRunner.class) From 8c34b3e93ba35f8d06cbda55d9e46f048997abe4 Mon Sep 17 00:00:00 2001 From: geroza Date: Wed, 9 Jan 2019 12:43:11 -0200 Subject: [PATCH 195/441] * removed temporary parent module parent-spring-5 --- parent-spring-5-1/README.md | 1 - parent-spring-5-1/pom.xml | 39 ------------------------------------- pom.xml | 6 ------ 3 files changed, 46 deletions(-) delete mode 100644 parent-spring-5-1/README.md delete mode 100644 parent-spring-5-1/pom.xml diff --git a/parent-spring-5-1/README.md b/parent-spring-5-1/README.md deleted file mode 100644 index ff12555376..0000000000 --- a/parent-spring-5-1/README.md +++ /dev/null @@ -1 +0,0 @@ -## Relevant articles: diff --git a/parent-spring-5-1/pom.xml b/parent-spring-5-1/pom.xml deleted file mode 100644 index 983e5e63eb..0000000000 --- a/parent-spring-5-1/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - 4.0.0 - com.baeldung - parent-spring-5-1 - 0.0.1-SNAPSHOT - pom - parent-spring-5-1 - Parent for all spring 5 core modules - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - - org.springframework - spring-core - ${spring.version} - - - org.junit.jupiter - junit-jupiter-engine - ${junit.jupiter.version} - test - - - - - 5.0.6.RELEASE - 5.0.2 - 2.9.6 - 2.9.6 - 5.0.6.RELEASE - - - diff --git a/pom.xml b/pom.xml index 13b866b968..324f6129db 100644 --- a/pom.xml +++ b/pom.xml @@ -329,7 +329,6 @@ parent-boot-2 parent-spring-4 parent-spring-5 - parent-spring-5-1 parent-java parent-kotlin @@ -601,7 +600,6 @@ parent-boot-2 parent-spring-4 parent-spring-5 - parent-spring-5-1 parent-java parent-kotlin @@ -995,7 +993,6 @@ parent-boot-2 parent-spring-4 parent-spring-5 - parent-spring-5-1 parent-java parent-kotlin @@ -1048,7 +1045,6 @@ parent-boot-2 parent-spring-4 parent-spring-5 - parent-spring-5-1 parent-java parent-kotlin @@ -1316,7 +1312,6 @@ parent-boot-2 parent-spring-4 parent-spring-5 - parent-spring-5-1 parent-java parent-kotlin @@ -1549,7 +1544,6 @@ parent-boot-2 parent-spring-4 parent-spring-5 - parent-spring-5-1 parent-java parent-kotlin From 2432527980d6adcd5fe77cf11857a45945b27a03 Mon Sep 17 00:00:00 2001 From: eelhazati Date: Thu, 10 Jan 2019 16:22:07 +0100 Subject: [PATCH 196/441] jpa 2.2 support for java 8 date and time types. --- persistence-modules/java-jpa/pom.xml | 31 ++- .../datetime/DateTimeEntityRepository.java | 68 +++++++ .../jpa/datetime/JPA22DateTimeEntity.java | 176 ++++++++++++++++++ .../com/baeldung/jpa/datetime/MainApp.java | 18 ++ .../main/resources/META-INF/persistence.xml | 22 ++- 5 files changed, 310 insertions(+), 5 deletions(-) create mode 100644 persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/DateTimeEntityRepository.java create mode 100644 persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/JPA22DateTimeEntity.java create mode 100644 persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/MainApp.java diff --git a/persistence-modules/java-jpa/pom.xml b/persistence-modules/java-jpa/pom.xml index ddab51a2e2..7e9c7b83f1 100644 --- a/persistence-modules/java-jpa/pom.xml +++ b/persistence-modules/java-jpa/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 java-jpa - java-jpa - + java-jpa + parent-modules com.baeldung @@ -24,10 +24,35 @@ h2 ${h2.version} + + + + javax.persistence + javax.persistence-api + 2.2 + + + + + org.eclipse.persistence + eclipselink + ${eclipselink.version} + runtime + + + org.postgresql + postgresql + ${postgres.version} + runtime + bundle + - 5.3.1.Final + 5.4.0.Final 1.4.197 + 2.7.4-RC1 + 42.2.5 + \ No newline at end of file diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/DateTimeEntityRepository.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/DateTimeEntityRepository.java new file mode 100644 index 0000000000..0bd04da221 --- /dev/null +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/DateTimeEntityRepository.java @@ -0,0 +1,68 @@ +package com.baeldung.jpa.datetime; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.time.*; +import java.util.Calendar; + +public class DateTimeEntityRepository { + private EntityManagerFactory emf = null; + + public DateTimeEntityRepository() { + emf = Persistence.createEntityManagerFactory("java8-datetime-postgresql"); + } + + public JPA22DateTimeEntity find(Long id) { + EntityManager entityManager = emf.createEntityManager(); + + JPA22DateTimeEntity dateTimeTypes = entityManager.find(JPA22DateTimeEntity.class, id); + + entityManager.close(); + return dateTimeTypes; + } + + public void save(Long id) { + JPA22DateTimeEntity dateTimeTypes = new JPA22DateTimeEntity(); + dateTimeTypes.setId(id); + + //java.sql types: date/time + dateTimeTypes.setSqlTime(Time.valueOf(LocalTime.now())); + dateTimeTypes.setSqlDate(Date.valueOf(LocalDate.now())); + dateTimeTypes.setSqlTimestamp(Timestamp.valueOf(LocalDateTime.now())); + + //java.util types: date/calendar + java.util.Date date = new java.util.Date(); + dateTimeTypes.setUtilTime(date); + dateTimeTypes.setUtilDate(date); + dateTimeTypes.setUtilTimestamp(date); + + //Calendar + Calendar calendar = Calendar.getInstance(); + dateTimeTypes.setCalendarTime(calendar); + dateTimeTypes.setCalendarDate(calendar); + dateTimeTypes.setCalendarTimestamp(calendar); + + //java.time types + dateTimeTypes.setLocalTime(LocalTime.now()); + dateTimeTypes.setLocalDate(LocalDate.now()); + dateTimeTypes.setLocalDateTime(LocalDateTime.now()); + + //java.time types with offset + dateTimeTypes.setOffsetTime(OffsetTime.now()); + dateTimeTypes.setOffsetDateTime(OffsetDateTime.now()); + + EntityManager entityManager = emf.createEntityManager(); + entityManager.getTransaction().begin(); + entityManager.persist(dateTimeTypes); + entityManager.getTransaction().commit(); + entityManager.close(); + } + + public void clean() { + emf.close(); + } +} diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/JPA22DateTimeEntity.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/JPA22DateTimeEntity.java new file mode 100644 index 0000000000..065385bd86 --- /dev/null +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/JPA22DateTimeEntity.java @@ -0,0 +1,176 @@ +package com.baeldung.jpa.datetime; + +import javax.persistence.*; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.time.*; +import java.util.Calendar; + +@Entity +public class JPA22DateTimeEntity { + + @Id + private Long id; + + //java.sql types + private Time sqlTime; + private Date sqlDate; + private Timestamp sqlTimestamp; + + //java.util types + @Temporal(TemporalType.TIME) + private java.util.Date utilTime; + + @Temporal(TemporalType.DATE) + private java.util.Date utilDate; + + @Temporal(TemporalType.TIMESTAMP) + private java.util.Date utilTimestamp; + + //Calendar + @Temporal(TemporalType.TIME) + private Calendar calendarTime; + + @Temporal(TemporalType.DATE) + private Calendar calendarDate; + + @Temporal(TemporalType.TIMESTAMP) + private Calendar calendarTimestamp; + + // java.time types + @Column(name = "local_time", columnDefinition = "TIME") + private LocalTime localTime; + + @Column(name = "local_date", columnDefinition = "DATE") + private LocalDate localDate; + + @Column(name = "local_date_time", columnDefinition = "TIMESTAMP") + private LocalDateTime localDateTime; + + @Column(name = "offset_time", columnDefinition = "TIME WITH TIME ZONE") + private OffsetTime offsetTime; + + @Column(name = "offset_date_time", columnDefinition = "TIMESTAMP WITH TIME ZONE") + private OffsetDateTime offsetDateTime; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Time getSqlTime() { + return sqlTime; + } + + public void setSqlTime(Time sqlTime) { + this.sqlTime = sqlTime; + } + + public Date getSqlDate() { + return sqlDate; + } + + public void setSqlDate(Date sqlDate) { + this.sqlDate = sqlDate; + } + + public Timestamp getSqlTimestamp() { + return sqlTimestamp; + } + + public void setSqlTimestamp(Timestamp sqlTimestamp) { + this.sqlTimestamp = sqlTimestamp; + } + + public java.util.Date getUtilTime() { + return utilTime; + } + + public void setUtilTime(java.util.Date utilTime) { + this.utilTime = utilTime; + } + + public java.util.Date getUtilDate() { + return utilDate; + } + + public void setUtilDate(java.util.Date utilDate) { + this.utilDate = utilDate; + } + + public java.util.Date getUtilTimestamp() { + return utilTimestamp; + } + + public void setUtilTimestamp(java.util.Date utilTimestamp) { + this.utilTimestamp = utilTimestamp; + } + + public Calendar getCalendarTime() { + return calendarTime; + } + + public void setCalendarTime(Calendar calendarTime) { + this.calendarTime = calendarTime; + } + + public Calendar getCalendarDate() { + return calendarDate; + } + + public void setCalendarDate(Calendar calendarDate) { + this.calendarDate = calendarDate; + } + + public Calendar getCalendarTimestamp() { + return calendarTimestamp; + } + + public void setCalendarTimestamp(Calendar calendarTimestamp) { + this.calendarTimestamp = calendarTimestamp; + } + + public LocalTime getLocalTime() { + return localTime; + } + + public void setLocalTime(LocalTime localTime) { + this.localTime = localTime; + } + + public LocalDate getLocalDate() { + return localDate; + } + + public void setLocalDate(LocalDate localDate) { + this.localDate = localDate; + } + + public LocalDateTime getLocalDateTime() { + return localDateTime; + } + + public void setLocalDateTime(LocalDateTime localDateTime) { + this.localDateTime = localDateTime; + } + + public OffsetTime getOffsetTime() { + return offsetTime; + } + + public void setOffsetTime(OffsetTime offsetTime) { + this.offsetTime = offsetTime; + } + + public OffsetDateTime getOffsetDateTime() { + return offsetDateTime; + } + + public void setOffsetDateTime(OffsetDateTime offsetDateTime) { + this.offsetDateTime = offsetDateTime; + } +} diff --git a/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/MainApp.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/MainApp.java new file mode 100644 index 0000000000..7f23f44254 --- /dev/null +++ b/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/datetime/MainApp.java @@ -0,0 +1,18 @@ +package com.baeldung.jpa.datetime; + +public class MainApp { + + public static void main(String... args) { + + DateTimeEntityRepository dateTimeEntityRepository = new DateTimeEntityRepository(); + + //Persist + dateTimeEntityRepository.save(100L); + + //Find + JPA22DateTimeEntity dateTimeEntity = dateTimeEntityRepository.find(100L); + + dateTimeEntityRepository.clean(); + } + +} \ No newline at end of file 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 433d456cc9..9e4f4bf4c9 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 @@ -2,8 +2,8 @@ + http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd" + version="2.2"> org.hibernate.jpa.HibernatePersistenceProvider @@ -66,4 +66,22 @@
+ + org.eclipse.persistence.jpa.PersistenceProvider + com.baeldung.jpa.datetime.JPA22DateTimeEntity + true + + + + + + + + + + + + + + \ No newline at end of file From 3907f624b57bf9314ec8a9bf73d354685ff50a80 Mon Sep 17 00:00:00 2001 From: eelhazati Date: Thu, 10 Jan 2019 16:36:52 +0100 Subject: [PATCH 197/441] jpa 2.2 support for java 8 date and time types. --- persistence-modules/java-jpa/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/persistence-modules/java-jpa/pom.xml b/persistence-modules/java-jpa/pom.xml index 7e9c7b83f1..fa47d6bd9c 100644 --- a/persistence-modules/java-jpa/pom.xml +++ b/persistence-modules/java-jpa/pom.xml @@ -44,7 +44,6 @@ postgresql ${postgres.version} runtime - bundle
From 81e2750ee0011d4badb355b87c112177a0e0d333 Mon Sep 17 00:00:00 2001 From: amdegregorio Date: Thu, 10 Jan 2019 10:50:03 -0500 Subject: [PATCH 198/441] Updated to use a Stream --- .../com/baeldung/csv/WriteCsvFileExample.java | 7 ++----- .../csv/WriteCsvFileExampleUnitTest.java | 20 +++++++------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java index fd3678d2c5..e1237481b1 100644 --- a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java +++ b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java @@ -1,11 +1,8 @@ package com.baeldung.csv; -import java.io.BufferedWriter; -import java.io.IOException; - public class WriteCsvFileExample { - public void writeLine(BufferedWriter writer, String[] data) throws IOException { + public String convertToCSV(String[] data) { StringBuilder csvLine = new StringBuilder(); for (int i = 0; i < data.length; i++) { @@ -15,7 +12,7 @@ public class WriteCsvFileExample { csvLine.append(escapeSpecialCharacters(data[i])); } - writer.write(csvLine.toString()); + return csvLine.toString(); } public String escapeSpecialCharacters(String data) { diff --git a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java index 4ac84f939d..e30ec0818c 100644 --- a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java @@ -3,12 +3,10 @@ package com.baeldung.csv; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; -import java.io.IOException; +import java.io.FileNotFoundException; +import java.io.PrintWriter; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.junit.Before; @@ -73,15 +71,11 @@ public class WriteCsvFileExampleUnitTest { dataLines.add(new String[] { "Jane", "Doe, Jr.", "19", "She said \"I'm being quoted\"" }); File csvOutputFile = new File(CSV_FILE_NAME); - try (BufferedWriter writer = new BufferedWriter(new FileWriter(csvOutputFile))) { - for (Iterator dataIterator = dataLines.iterator(); dataIterator.hasNext();) { - csvExample.writeLine(writer, dataIterator.next()); - if (dataIterator.hasNext()) { - writer.newLine(); - } - } - writer.flush(); - } catch (IOException e) { + try (PrintWriter pw = new PrintWriter(csvOutputFile)) { + dataLines.stream() + .map(csvExample::convertToCSV) + .forEach(pw::println); + } catch (FileNotFoundException e) { LOG.error("IOException " + e.getMessage()); } From 1c6dba97187e598e25219291408b87be6dd8e793 Mon Sep 17 00:00:00 2001 From: eelhazati Date: Thu, 10 Jan 2019 16:50:29 +0100 Subject: [PATCH 199/441] excludes jpa entities. --- .../java-jpa/src/main/resources/META-INF/persistence.xml | 2 ++ 1 file changed, 2 insertions(+) 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 9e4f4bf4c9..f7258e3109 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 @@ -8,6 +8,8 @@ org.hibernate.jpa.HibernatePersistenceProvider com.baeldung.sqlresultsetmapping.ScheduledDay + com.baeldung.sqlresultsetmapping.Employee + true Date: Thu, 10 Jan 2019 17:08:47 +0100 Subject: [PATCH 200/441] exludes jpa entities. --- .../java-jpa/src/main/resources/META-INF/persistence.xml | 2 ++ 1 file changed, 2 insertions(+) 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 f7258e3109..8592fce533 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 @@ -26,6 +26,7 @@ org.hibernate.jpa.HibernatePersistenceProvider com.baeldung.jpa.stringcast.Message + true @@ -41,6 +42,7 @@ org.hibernate.jpa.HibernatePersistenceProvider com.baeldung.jpa.model.Car + true From 94c146e245c78b2ddaf941f0f6e43fb1eff3a1b4 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Thu, 10 Jan 2019 14:21:27 -0200 Subject: [PATCH 201/441] just to trigger the Travis build --- ethereum/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/README.md b/ethereum/README.md index 7accb4cd53..0c7ae3d4d2 100644 --- a/ethereum/README.md +++ b/ethereum/README.md @@ -4,4 +4,4 @@ - [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) - \ No newline at end of file + From 4fb05ab3a27bc4267db4d344a3987e875d55537d Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 10 Jan 2019 21:22:46 +0200 Subject: [PATCH 202/441] Update pom.xml --- java-numbers/pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/java-numbers/pom.xml b/java-numbers/pom.xml index bb63c8cfe1..0f5140ea5e 100644 --- a/java-numbers/pom.xml +++ b/java-numbers/pom.xml @@ -72,16 +72,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*IntegrationTest.java - - true - - org.apache.maven.plugins From dfbff7aa19384117e758e12ae1eab870d183f097 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 10 Jan 2019 21:32:08 +0200 Subject: [PATCH 203/441] Update pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 07e90cca94..a9b4b3f119 100644 --- a/pom.xml +++ b/pom.xml @@ -232,6 +232,7 @@ ${maven-war-plugin.version} + com.vackosar.gitflowincrementalbuilder From a15045f8a7f46a72268a088e4d0c7943cd17b456 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Thu, 10 Jan 2019 18:17:59 -0200 Subject: [PATCH 204/441] edit readme to trigger travis build --- ethereum/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/ethereum/README.md b/ethereum/README.md index 0c7ae3d4d2..d06ca09636 100644 --- a/ethereum/README.md +++ b/ethereum/README.md @@ -4,4 +4,3 @@ - [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) - From 7f501f169f7f7d22362e7e28cdb1331ad020ef55 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 10 Jan 2019 22:32:12 +0200 Subject: [PATCH 205/441] Update Circle.java --- core-java/src/main/java/com/baeldung/keyword/Circle.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/src/main/java/com/baeldung/keyword/Circle.java b/core-java/src/main/java/com/baeldung/keyword/Circle.java index 4ec91d1b8a..231b2f5a59 100644 --- a/core-java/src/main/java/com/baeldung/keyword/Circle.java +++ b/core-java/src/main/java/com/baeldung/keyword/Circle.java @@ -1,4 +1,5 @@ package com.baeldung.keyword; public class Circle extends Round implements Shape { + } From b8dbc9d053a6f56eb2884baa7c811b713ce7a2ae Mon Sep 17 00:00:00 2001 From: Laurentiu Delcea Date: Thu, 10 Jan 2019 23:21:06 +0200 Subject: [PATCH 206/441] BAEL-2480 Java Map to String conversion (#6075) * BAEL-2480 Java Map to String conversion * BAEL-2480 Java Map to String conversion * BAEL-2480 Java Map to String conversion * BAEL-2480 Java Map to String conversion --- .../com/baeldung/convert/MapToString.java | 34 +++++++++++++ .../com/baeldung/convert/StringToMap.java | 21 ++++++++ .../baeldung/convert/MapToStringUnitTest.java | 48 +++++++++++++++++++ .../baeldung/convert/StringToMapUnitTest.java | 23 +++++++++ 4 files changed, 126 insertions(+) create mode 100644 java-collections-maps/src/main/java/com/baeldung/convert/MapToString.java create mode 100644 java-collections-maps/src/main/java/com/baeldung/convert/StringToMap.java create mode 100644 java-collections-maps/src/test/java/com/baeldung/convert/MapToStringUnitTest.java create mode 100644 java-collections-maps/src/test/java/com/baeldung/convert/StringToMapUnitTest.java diff --git a/java-collections-maps/src/main/java/com/baeldung/convert/MapToString.java b/java-collections-maps/src/main/java/com/baeldung/convert/MapToString.java new file mode 100644 index 0000000000..aca0d05ef1 --- /dev/null +++ b/java-collections-maps/src/main/java/com/baeldung/convert/MapToString.java @@ -0,0 +1,34 @@ +package com.baeldung.convert; + +import com.google.common.base.Joiner; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; +import java.util.stream.Collectors; + +public class MapToString { + + public static String convertWithIteration(Map map) { + StringBuilder mapAsString = new StringBuilder("{"); + for (Integer key : map.keySet()) { + mapAsString.append(key + "=" + map.get(key) + ", "); + } + mapAsString.delete(mapAsString.length()-2, mapAsString.length()).append("}"); + return mapAsString.toString(); + } + + public static String convertWithStream(Map map) { + String mapAsString = map.keySet().stream() + .map(key -> key + "=" + map.get(key)) + .collect(Collectors.joining(", ", "{", "}")); + return mapAsString; + } + + public static String convertWithGuava(Map map) { + return Joiner.on(",").withKeyValueSeparator("=").join(map); + } + + public static String convertWithApache(Map map) { + return StringUtils.join(map); + } +} diff --git a/java-collections-maps/src/main/java/com/baeldung/convert/StringToMap.java b/java-collections-maps/src/main/java/com/baeldung/convert/StringToMap.java new file mode 100644 index 0000000000..caabca4a09 --- /dev/null +++ b/java-collections-maps/src/main/java/com/baeldung/convert/StringToMap.java @@ -0,0 +1,21 @@ +package com.baeldung.convert; + +import com.google.common.base.Splitter; + +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; + +public class StringToMap { + + public static Map convertWithStream(String mapAsString) { + Map map = Arrays.stream(mapAsString.split(",")) + .map(entry -> entry.split("=")) + .collect(Collectors.toMap(entry -> entry[0], entry -> entry[1])); + return map; + } + + public static Map convertWithGuava(String mapAsString) { + return Splitter.on(',').withKeyValueSeparator('=').split(mapAsString); + } +} diff --git a/java-collections-maps/src/test/java/com/baeldung/convert/MapToStringUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/convert/MapToStringUnitTest.java new file mode 100644 index 0000000000..d9923e74a0 --- /dev/null +++ b/java-collections-maps/src/test/java/com/baeldung/convert/MapToStringUnitTest.java @@ -0,0 +1,48 @@ +package com.baeldung.convert; + +import org.apache.commons.collections4.MapUtils; +import org.junit.Assert; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.Map; + +public class MapToStringUnitTest { + + private Map wordsByKey = new HashMap<>(); + + @BeforeEach + public void setup() { + wordsByKey.clear(); + wordsByKey.put(1, "one"); + wordsByKey.put(2, "two"); + wordsByKey.put(3, "three"); + wordsByKey.put(4, "four"); + } + + @Test + public void givenMap_WhenUsingIteration_ThenResultingMapIsCorrect() { + String mapAsString = MapToString.convertWithIteration(wordsByKey); + Assert.assertEquals("{1=one, 2=two, 3=three, 4=four}", mapAsString); + } + + @Test + public void givenMap_WhenUsingStream_ThenResultingMapIsCorrect() { + String mapAsString = MapToString.convertWithStream(wordsByKey); + Assert.assertEquals("{1=one, 2=two, 3=three, 4=four}", mapAsString); + } + + @Test + public void givenMap_WhenUsingGuava_ThenResultingMapIsCorrect() { + String mapAsString = MapToString.convertWithGuava(wordsByKey); + Assert.assertEquals("1=one,2=two,3=three,4=four", mapAsString); + } + + @Test + public void givenMap_WhenUsingApache_ThenResultingMapIsCorrect() { + String mapAsString = MapToString.convertWithApache(wordsByKey); + Assert.assertEquals("{1=one, 2=two, 3=three, 4=four}", mapAsString); + MapUtils.debugPrint(System.out, "Map as String", wordsByKey); + } +} \ No newline at end of file diff --git a/java-collections-maps/src/test/java/com/baeldung/convert/StringToMapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/convert/StringToMapUnitTest.java new file mode 100644 index 0000000000..8fb906efd0 --- /dev/null +++ b/java-collections-maps/src/test/java/com/baeldung/convert/StringToMapUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.convert; + +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +public class StringToMapUnitTest { + + @Test + public void givenString_WhenUsingStream_ThenResultingStringIsCorrect() { + Map wordsByKey = StringToMap.convertWithStream("1=one,2=two,3=three,4=four"); + Assert.assertEquals(4, wordsByKey.size()); + Assert.assertEquals("one", wordsByKey.get("1")); + } + + @Test + void givenString_WhenUsingGuava_ThenResultingStringIsCorrect() { + Map wordsByKey = StringToMap.convertWithGuava("1=one,2=two,3=three,4=four"); + Assert.assertEquals(4, wordsByKey.size()); + Assert.assertEquals("one", wordsByKey.get("1")); + } +} \ No newline at end of file From c65180c74f75f2cbb0d21b787d12b9098865a703 Mon Sep 17 00:00:00 2001 From: Emily Cheyne Date: Thu, 10 Jan 2019 15:05:00 -0700 Subject: [PATCH 207/441] BAEL-2535 Remove CustomerReflectionToStringUnitTest --- .../CustomerReflectionToStringUnitTest.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringUnitTest.java diff --git a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringUnitTest.java b/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringUnitTest.java deleted file mode 100644 index 77dcab52e6..0000000000 --- a/java-strings/src/test/java/com/baeldung/string/tostring/CustomerReflectionToStringUnitTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.string.tostring; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.Test; - -public class CustomerReflectionToStringUnitTest { - private static final String CUSTOMER_REFLECTION_TO_STRING = "com.baeldung.string.tostring.CustomerReflectionToString"; - - @Test - public void givenWrapperCollectionStrBuffer_whenReflectionToString_thenCustomerDetails() { - CustomerReflectionToString customer = new CustomerReflectionToString(); - customer.setFirstName("Rajesh"); - customer.setLastName("Bhojwani"); - customer.setScore(8); - - List orders = new ArrayList(); - orders.add("Book"); - orders.add("Pen"); - customer.setOrders(orders); - - StringBuffer fullname = new StringBuffer(); - fullname.append(customer.getLastName()+", "+ customer.getFirstName()); - customer.setFullname(fullname); - - assertTrue(customer.toString().contains(CUSTOMER_REFLECTION_TO_STRING)); - } - -} From c5415eecac1322a79f30e6ecf9bcd946d231233d Mon Sep 17 00:00:00 2001 From: "Erick Audet M.Sc" Date: Thu, 10 Jan 2019 17:16:53 -0500 Subject: [PATCH 208/441] BAEL-2059 * New section in InputStream to byte array article and recreating branch. * Minor typo * Code reformat using intellij formatter. * Code reformat using intellij formatter. * guava implementation to be completed * guava implementation * Added assert to guava test * Fix formatting --- .../io/InputStreamToByteBufferUnitTest.java | 60 ++++++++++++++++++ .../resources/frontenac-2257154_960_720.jpg | Bin 0 -> 194684 bytes parent-java/pom.xml | 4 +- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java create mode 100644 core-java-io/src/test/resources/frontenac-2257154_960_720.jpg diff --git a/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java b/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java new file mode 100644 index 0000000000..fedadde04b --- /dev/null +++ b/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java @@ -0,0 +1,60 @@ +package org.baeldung.java.io; + + +import com.google.common.io.ByteStreams; +import org.apache.commons.io.IOUtils; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.ReadableByteChannel; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class InputStreamToByteBufferUnitTest { + + @Test + public void givenUsingCoreClasses_whenWritingAFileIntoAByteBuffer_thenBytesLengthMustMatch() throws IOException { + File inputFile = getFile(); + ByteBuffer bufferByte = ByteBuffer.allocate((int) inputFile.length()); + FileInputStream in = new FileInputStream(inputFile); + in.getChannel().read(bufferByte); + + assertEquals(bufferByte.position(), inputFile.length()); + } + + @Test + public void givenUsingCommonsIo_whenWritingAFileIntoAByteBuffer_thenBytesLengthMustMatch() throws IOException { + File inputFile = getFile(); + ByteBuffer bufferByte = ByteBuffer.allocateDirect((int) inputFile.length()); + ReadableByteChannel readableByteChannel = new FileInputStream(inputFile).getChannel(); + IOUtils.readFully(readableByteChannel, bufferByte); + + assertEquals(bufferByte.position(), inputFile.length()); + } + + @Test + public void givenUsingGuava_whenWritingAFileIntoAByteBuffer_thenBytesLengthMustMatch() throws IOException { + File inputFile = getFile(); + FileInputStream in = new FileInputStream(inputFile); + byte[] targetArray = ByteStreams.toByteArray(in); + ByteBuffer bufferByte = ByteBuffer.wrap(targetArray); + bufferByte.rewind(); + while (bufferByte.hasRemaining()) { + bufferByte.get(); + } + + assertEquals(bufferByte.position(), inputFile.length()); + } + + private File getFile() { + ClassLoader classLoader = new InputStreamToByteBufferUnitTest().getClass().getClassLoader(); + + String fileName = "frontenac-2257154_960_720.jpg"; + + return new File(classLoader.getResource(fileName).getFile()); + } + +} diff --git a/core-java-io/src/test/resources/frontenac-2257154_960_720.jpg b/core-java-io/src/test/resources/frontenac-2257154_960_720.jpg new file mode 100644 index 0000000000000000000000000000000000000000..77c459b0e39604cbac6d0bd59e6ef3fceb22061b GIT binary patch literal 194684 zcmb4qXHZk$7i}Pc0MZc!qy!SBic}3?=q(^kdJ%!3bfinKQVoQTh2DEFigc7v6r_cw zfChem0V4>Z24DUk-pu>@PG&N9?z#8wd*+_A_g-tS^KbFrI)GJA8>tPTq5=S@C_liz z6@Uf+Nd3R|zkeX5foMVhYjm`?|3=H&i^z;mjEQ}0Sn6J>&GqEu-v#_$Vu`)2S zbFi~=P>xyu_YkW8-3bKIQEp_tLVtyF_W!f}8vwA;QQrU#0I7rk)NE8hHmZLg0eqDA z1Ofl|y8pLPYt#;Lf zPR7xf6B?7DUea<+_TeD?b(n^e-}H|^H}|>ZOk*`s{&7Q@S!MFht!=}U2l7$@s43?D zAA{6D${SEj(ouSq*(k?UKx!bEijHysqI6L%X9KYdO4F!u2$|4cr5KCJDB*;vw+vEj zJOp2p-G|-OaEkTIEd93(U<6XGX9KbUQ~(apBq~+JA^0Ca<&nq0y&6pODc4M&?L7!$ zaHOaCM-rKy?}BjjsA=N2P_LezCij@|oDwYRFR?+7_SiEpI^s|dVh(Bak2NCHD_-N8 zR2+l_7Ln!EMs5BWz{~*-#m9wxXNS>^R8ZlSrU;R%9J9?M^a2O}00>mvHIXYEtJ5( z0<@)nYj;?+F1>2rj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Qbsq7isU;CXa%+4OQPbODgjWG9>e8WjnLs6#l!gUJ$XpOX z$OMf(Qtumus%S1VR$RqpxV*Nym8;_=KOv7_AXv6YyOA&Usy4gNEiC?8%TG2X zhCs}y!J}YQf}ji$@vdw0Cc$Yi*8acI6Go!Gky`2Iuc4)^meo;DB+)CF~k|C~qb<%h5*tkO}<2{q^W0$_`+03iPTHTX>2;HX3ww z1M^0`jQ*qc)qB5u8MAK6I+-q|DoHP)xYFAncf z$o2as%3Lr3;-g4g^JCsH54NLwhrL=I6fe`)ke9%?*dGG5ACAX$+mD* z35@K%eeQjoy*B>Uxow@pB`rynB&Vl(NaHcgLh(Yf5E*iC8A%Q9Fv>7!3RDdke0&3j zAEv&Ac!_qn*{wCAlBCG00`aQ?sYuHEiGu^~ef7f|!rMb^+}AsOzL_AVhN!G@C*?&T z90Bk1#Yp zYhgyX`BdoMX%0G3kXew9!yk}6!9P0c{{X=~mdCm)Zg$$ByJJY{{lS>UnO)PRZlJFrY$B;M(M@Q^?1LITsq+;AH=|;~UY9x?9HfKj!5ml9m zEUW~MG6*~t^`q44kVLobFC_(ulM+0VDq2w`a&=`WtK zM^q}~^@G89ze6#PNXK~2tsS#dJ<``=70>1ht0J`O09BEi;ZVhhTmo{dgYGfbHD$|e zqN?0cLp&v;TBCx_13$>5;8=s;i7K)ll2-O;bm3fK3>gDj~pC9AzVtjzklKfu`>o{B%pk=ehV6 zyFn;v_MO<#Qq{+CGV_L-DI-84XvQ*xe~jY;-#UH#VBBt2>$iuGL2|68F>VT|ltobL zI2ofHNCyOCuJug#m2# - 22.0 + 23.0 - \ No newline at end of file + From c4edb95d4ef6733a1e520249861950743c0fa54c Mon Sep 17 00:00:00 2001 From: Olaniyi Anjola Date: Thu, 10 Jan 2019 18:51:30 -0500 Subject: [PATCH 209/441] BAEL-2452: Using curl from Java (#6113) * Renamed from Unit Test to Live Test * Update JavaCurlExamplesLiveTest.java --- ...est.java => JavaCurlExamplesLiveTest.java} | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) rename core-java/src/test/java/com/baeldung/curltojava/{JavaCurlExamplesUnitTest.java => JavaCurlExamplesLiveTest.java} (56%) diff --git a/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesUnitTest.java b/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesLiveTest.java similarity index 56% rename from core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesUnitTest.java rename to core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesLiveTest.java index 4e82059f2b..2ec62cbbf9 100644 --- a/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesUnitTest.java +++ b/core-java/src/test/java/com/baeldung/curltojava/JavaCurlExamplesLiveTest.java @@ -3,19 +3,16 @@ package com.baeldung.curltojava; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; import org.junit.Assert; import org.junit.Test; -public class JavaCurlExamplesUnitTest { - +public class JavaCurlExamplesLiveTest { @Test public void givenCommand_whenCalled_thenProduceZeroExitCode() throws IOException { - String command = "curl --location --request GET \"https://postman-echo.com/get?foo1=bar1&foo2=bar2\""; - ProcessBuilder processBuilder = new ProcessBuilder(command.replaceAll("\"", "").split(" ")); + String command = "curl -X GET https://postman-echo.com/get?foo1=bar1&foo2=bar2"; + ProcessBuilder processBuilder = new ProcessBuilder(command.split(" ")); processBuilder.directory(new File("/home/")); Process process = processBuilder.start(); InputStream inputStream = process.getInputStream(); @@ -28,8 +25,8 @@ public class JavaCurlExamplesUnitTest { @Test public void givenNewCommands_whenCalled_thenCheckIfIsAlive() throws IOException { - String command = "curl --location --request GET \"https://postman-echo.com/get?foo1=bar1&foo2=bar2\""; - ProcessBuilder processBuilder = new ProcessBuilder(command.replaceAll("\"", "").split(" ")); + String command = "curl -X GET https://postman-echo.com/get?foo1=bar1&foo2=bar2"; + ProcessBuilder processBuilder = new ProcessBuilder(command.split(" ")); processBuilder.directory(new File("/home/")); Process process = processBuilder.start(); @@ -40,16 +37,14 @@ public class JavaCurlExamplesUnitTest { } @Test - public void whenRequestGet_thenReturnSuccessResponseCode() throws IOException { - String url = "https://postman-echo.com/get?foo1=bar1&foo2=bar2"; - URL urlObj = new URL(url); - HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection(); - connection.setDoOutput(true); - connection.setInstanceFollowRedirects(false); - connection.setRequestMethod("GET"); - connection.connect(); + public void whenRequestPost_thenCheckIfReturnContent() throws IOException { + String command = "curl -X POST https://postman-echo.com/post --data foo1=bar1&foo2=bar2"; + Process process = Runtime.getRuntime().exec(command); - Assert.assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode()); + // Get the POST result + String content = JavaCurlExamples.inputStreamToString(process.getInputStream()); + + Assert.assertTrue(null != content && !content.isEmpty()); } } From ea5039f1a197156e9cb4686f6bd42e9659044e56 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Fri, 11 Jan 2019 15:05:34 +0400 Subject: [PATCH 210/441] indexOf changed example --- .../java/com/baeldung/string/MatchWords.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index c0f89b635d..f0b64c19cf 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -20,24 +20,19 @@ public class MatchWords { ahoCorasick(); - wordIndices(inputString); + indexOfWords(inputString, items); } - private static void wordIndices(String inputString) { - Map wordIndices = new TreeMap<>(); - List words = new ArrayList<>(); - words.add("hello"); - words.add("Baeldung"); - + private static boolean indexOfWords(String inputString, String[] words) { + boolean found = true; for (String word : words) { int index = inputString.indexOf(word); - - if (index != -1) { - wordIndices.put(index, word); + if (index == -1) { + found = false; + break; } } - - wordIndices.keySet().forEach(System.out::println); + return found; } private static boolean containsWords(String inputString, String[] items) { From 36e48924468b9030ec382bf537084635785fc5e1 Mon Sep 17 00:00:00 2001 From: Upendra Chintala Date: Fri, 11 Jan 2019 18:13:27 +0530 Subject: [PATCH 211/441] Check if a year/date is a leap year in Java (#6086) * Hexagonal architecture implementation in Java - upendra.chintala@gmail.com * An example program to find a leap year using java 8 java.time.Year API * Changed to add assertions * Remvoed evaluation article code * Added unit test suite for leap year testing using java.time.Year and java.util.GregorianCalendar * Update LeapYearUnitTest.java * Update LeapYearUnitTest.java --- .../baeldung/leapyear/LeapYearUnitTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java diff --git a/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java b/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java new file mode 100644 index 0000000000..9fb3d03838 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java @@ -0,0 +1,39 @@ +package com.baeldung.leapyear; + +import java.time.Year; +import java.util.GregorianCalendar; + +import org.junit.Assert; +import org.junit.Test; + +public class LeapYearUnitTest { + + //Before Java8 + @Test + public void testLeapYearUsingGregorianCalendar () { + Assert.assertFalse(new GregorianCalendar().isLeapYear(2018)); + } + + //Java 8 and above + @Test + public void testLeapYearUsingJavaTimeYear () { + Assert.assertTrue(Year.isLeap(2012)); + } + + @Test + public void testBCYearUsingJavaTimeYear () { + Assert.assertTrue(Year.isLeap(-4)); + } + + @Test + public void testWrongLeapYearUsingJavaTimeYear () { + Assert.assertFalse(Year.isLeap(2018)); + } + + @Test + public void testLeapYearInDateUsingJavaTimeYear () { + LocalDate date = LocalDate.parse("2020-01-05", DateTimeFormatter.ISO_LOCAL_DATE); + Assert.assertTrue(Year.from(date).isLeap()); + } + +} From 583969b59d09e3a975e3da06823270a217103e41 Mon Sep 17 00:00:00 2001 From: Amy DeGregorio Date: Fri, 11 Jan 2019 13:28:10 -0500 Subject: [PATCH 212/441] BAEL-2499 Write to CSV in Java - Updated PR (#6122) * example code for Article How to Write to a CSV File in Java * Updated to use a Stream --- .../com/baeldung/csv/WriteCsvFileExample.java | 7 ++----- .../csv/WriteCsvFileExampleUnitTest.java | 20 +++++++------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java index fd3678d2c5..e1237481b1 100644 --- a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java +++ b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java @@ -1,11 +1,8 @@ package com.baeldung.csv; -import java.io.BufferedWriter; -import java.io.IOException; - public class WriteCsvFileExample { - public void writeLine(BufferedWriter writer, String[] data) throws IOException { + public String convertToCSV(String[] data) { StringBuilder csvLine = new StringBuilder(); for (int i = 0; i < data.length; i++) { @@ -15,7 +12,7 @@ public class WriteCsvFileExample { csvLine.append(escapeSpecialCharacters(data[i])); } - writer.write(csvLine.toString()); + return csvLine.toString(); } public String escapeSpecialCharacters(String data) { diff --git a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java index 4ac84f939d..e30ec0818c 100644 --- a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java @@ -3,12 +3,10 @@ package com.baeldung.csv; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; -import java.io.IOException; +import java.io.FileNotFoundException; +import java.io.PrintWriter; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.junit.Before; @@ -73,15 +71,11 @@ public class WriteCsvFileExampleUnitTest { dataLines.add(new String[] { "Jane", "Doe, Jr.", "19", "She said \"I'm being quoted\"" }); File csvOutputFile = new File(CSV_FILE_NAME); - try (BufferedWriter writer = new BufferedWriter(new FileWriter(csvOutputFile))) { - for (Iterator dataIterator = dataLines.iterator(); dataIterator.hasNext();) { - csvExample.writeLine(writer, dataIterator.next()); - if (dataIterator.hasNext()) { - writer.newLine(); - } - } - writer.flush(); - } catch (IOException e) { + try (PrintWriter pw = new PrintWriter(csvOutputFile)) { + dataLines.stream() + .map(csvExample::convertToCSV) + .forEach(pw::println); + } catch (FileNotFoundException e) { LOG.error("IOException " + e.getMessage()); } From 39f2baab28db45f97309b7cb01e76dcf52227d60 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Fri, 11 Jan 2019 21:25:58 +0200 Subject: [PATCH 213/441] Update LoopScopeExample.java --- core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java b/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java index 2dd3be3333..04414067ad 100644 --- a/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java +++ b/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java @@ -12,7 +12,6 @@ public class LoopScopeExample { for (String name : listOfNames) { allNames = allNames + " " + name; } - } } From 4b47306e913180c1c4da86f6f507a3d1724b28f5 Mon Sep 17 00:00:00 2001 From: Emily Cheyne Date: Fri, 11 Jan 2019 12:48:28 -0700 Subject: [PATCH 214/441] BAEL-2535 --- java-strings/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-strings/README.md b/java-strings/README.md index 08fbec35ab..b72a378d06 100644 --- a/java-strings/README.md +++ b/java-strings/README.md @@ -49,3 +49,4 @@ - [Add a Character to a String at a Given Position](https://www.baeldung.com/java-add-character-to-string) - [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 toString() Method](https://www.baeldung.com/java-tostring) From 2cb4faddb0edf2f05edb8d2cc77560e6205396fc Mon Sep 17 00:00:00 2001 From: Loredana Date: Fri, 11 Jan 2019 23:03:38 +0200 Subject: [PATCH 215/441] fix core-java test and back to build --- core-java/pom.xml | 1 + .../src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java | 2 ++ pom.xml | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index 6c58653d5a..d21c624997 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -13,6 +13,7 @@ ../parent-java + commons-io diff --git a/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java b/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java index 9fb3d03838..e710eecc66 100644 --- a/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java +++ b/core-java/src/test/java/com/baeldung/leapyear/LeapYearUnitTest.java @@ -1,6 +1,8 @@ package com.baeldung.leapyear; +import java.time.LocalDate; import java.time.Year; +import java.time.format.DateTimeFormatter; import java.util.GregorianCalendar; import org.junit.Assert; diff --git a/pom.xml b/pom.xml index a9b4b3f119..1c0738cafb 100644 --- a/pom.xml +++ b/pom.xml @@ -391,6 +391,7 @@ core-java-networking core-java-perf core-java-sun + core-java core-scala couchbase custom-pmd @@ -996,8 +997,7 @@ parent-spring-5 parent-java parent-kotlin - - core-java + core-java-concurrency-advanced core-kotlin From 469e36f07a93156664dd05dfb7efee58a7689c6b Mon Sep 17 00:00:00 2001 From: Juan Moreno Date: Sat, 12 Jan 2019 15:59:25 -0300 Subject: [PATCH 216/441] BAEL-2444 Extra examples (#6087) --- .../com/baeldung/time/InstantUnitTest.java | 42 +++++++++++++++++ .../time/InstantWithJMockUnitTest.java | 47 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 core-java-8/src/test/java/com/baeldung/time/InstantUnitTest.java create mode 100644 core-java-8/src/test/java/com/baeldung/time/InstantWithJMockUnitTest.java diff --git a/core-java-8/src/test/java/com/baeldung/time/InstantUnitTest.java b/core-java-8/src/test/java/com/baeldung/time/InstantUnitTest.java new file mode 100644 index 0000000000..8400748710 --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/time/InstantUnitTest.java @@ -0,0 +1,42 @@ +package com.baeldung.time; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.time.Clock; +import java.time.Instant; +import java.time.ZoneId; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; +import static org.powermock.api.mockito.PowerMockito.mockStatic; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ Instant.class }) +public class InstantUnitTest { + + @Test + public void givenInstantMock_whenNow_thenGetFixedInstant() { + String instantExpected = "2014-12-22T10:15:30Z"; + Clock clock = Clock.fixed(Instant.parse(instantExpected), ZoneId.of("UTC")); + Instant instant = Instant.now(clock); + mockStatic(Instant.class); + when(Instant.now()).thenReturn(instant); + + Instant now = Instant.now(); + + assertThat(now.toString()).isEqualTo(instantExpected); + } + + @Test + public void givenFixedClock_whenNow_thenGetFixedInstant() { + String instantExpected = "2014-12-22T10:15:30Z"; + Clock clock = Clock.fixed(Instant.parse(instantExpected), ZoneId.of("UTC")); + + Instant instant = Instant.now(clock); + + assertThat(instant.toString()).isEqualTo(instantExpected); + } +} diff --git a/core-java-8/src/test/java/com/baeldung/time/InstantWithJMockUnitTest.java b/core-java-8/src/test/java/com/baeldung/time/InstantWithJMockUnitTest.java new file mode 100644 index 0000000000..8f83b91101 --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/time/InstantWithJMockUnitTest.java @@ -0,0 +1,47 @@ +package com.baeldung.time; + +import mockit.Expectations; +import mockit.Mock; +import mockit.MockUp; +import org.junit.jupiter.api.Test; + +import java.time.Clock; +import java.time.Instant; +import java.time.ZoneId; + +import static org.assertj.core.api.Assertions.assertThat; + +public class InstantWithJMockUnitTest { + + @Test + public void givenInstantWithJMock_whenNow_thenGetFixedInstant() { + String instantExpected = "2014-12-21T10:15:30Z"; + Clock clock = Clock.fixed(Instant.parse(instantExpected), ZoneId.of("UTC")); + new MockUp() { + @Mock + public Instant now() { + return Instant.now(clock); + } + }; + + Instant now = Instant.now(); + + assertThat(now.toString()).isEqualTo(instantExpected); + } + + @Test + public void givenInstantWithExpectations_whenNow_thenGetFixedInstant() { + Clock clock = Clock.fixed(Instant.parse("2014-12-23T10:15:30.00Z"), ZoneId.of("UTC")); + Instant instantExpected = Instant.now(clock); + new Expectations(Instant.class) { + { + Instant.now(); + result = instantExpected; + } + }; + + Instant now = Instant.now(); + + assertThat(now).isEqualTo(instantExpected); + } +} From b395dc1d418f5077ffe76c17d7d59fda9328c2ac Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Sat, 12 Jan 2019 18:57:19 -0200 Subject: [PATCH 217/441] Now using Auth and Resource servers from Baeldung/spring-security-oauth (#6128) --- .../OauthClientApplication.java | 4 +-- .../web/ClientRestController.java | 2 +- ....java => OauthClientLoginApplication.java} | 8 ++--- .../web/ClientRestController.java | 2 +- .../ClientCredentialsOauthApplication.java | 4 +-- .../service/WebClientChonJob.java | 6 ++-- .../ManualRequestApplication.java | 5 ++-- .../web/ManualOauthRequestController.java | 20 ++++++++----- ...nt-auth-code-client-application.properties | 8 ++--- ...ent-auth-code-login-application.properties | 12 ++++---- ...t-credentials-oauth-application.properties | 6 ++-- ...anual-request-oauth-application.properties | 3 ++ .../OAuth2ClientCredentialsLiveTest.java | 6 ++-- .../OAuth2ManualRequestLiveTest.java | 5 ++-- .../AuthorizationServerApplication.java | 17 ----------- .../configuration/WebSecurityConfig.java | 26 ----------------- .../ResourceServerApplication.java | 17 ----------- .../configuration/AuthorizationConfigs.java | 29 ------------------- .../web/ResourceRestController.java | 23 --------------- ...lient-authorization-application.properties | 13 --------- ...webclient-resources-application.properties | 6 ---- 21 files changed, 48 insertions(+), 174 deletions(-) rename spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/{OauthClientApplication.java => OauthClientLoginApplication.java} (62%) create mode 100644 spring-5-reactive-oauth/src/main/resources/webclient-manual-request-oauth-application.properties delete mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/AuthorizationServerApplication.java delete mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/configuration/WebSecurityConfig.java delete mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/ResourceServerApplication.java delete mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/configuration/AuthorizationConfigs.java delete mode 100644 spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/web/ResourceRestController.java delete mode 100644 spring-5-security-oauth/src/main/resources/webclient-authorization-application.properties delete mode 100644 spring-5-security-oauth/src/main/resources/webclient-resources-application.properties diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java index 7bae78bb14..843d3f251f 100644 --- a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java @@ -6,9 +6,9 @@ import org.springframework.context.annotation.PropertySource; /** * - * Note: This app is configured to use the authorization service and the resource service located in module spring-5-security-oauth + * Note: This app is configured to use the authorization service and the resource service located in Baeldung/spring-security-oauth repo * - * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using user credentials (bael-user/bael-password) and client configurations (bael-client-id/bael-secret) handled by the auth server + * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using user credentials (john/123) and client configurations handled by the auth server * * @author rozagerardo * diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java index c36b7d1dea..9994a1255a 100644 --- a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java @@ -15,7 +15,7 @@ import reactor.core.publisher.Mono; @RestController public class ClientRestController { - private static final String RESOURCE_URI = "http://localhost:8084/retrieve-resource"; + private static final String RESOURCE_URI = "http://localhost:8082/spring-security-oauth-resource/foos/1"; @Autowired WebClient webClient; diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientApplication.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientLoginApplication.java similarity index 62% rename from spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientApplication.java rename to spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientLoginApplication.java index 9dd6dd1bde..e71e549ea4 100644 --- a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientApplication.java +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientLoginApplication.java @@ -6,19 +6,19 @@ import org.springframework.context.annotation.PropertySource; /** * - * Note: This app is configured to use the authorization service and the resource service located in module spring-5-security-oauth + * Note: This app is configured to use the authorization service and the resource service located in Baeldung/spring-security-oauth repo * - * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using user credentials (bael-user/bael-password) and client configurations (bael-client-id/bael-secret) handled by the auth server + * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using user credentials (john/123) and client configurations handled by the auth server * * @author rozagerardo * */ @PropertySource("classpath:webclient-auth-code-login-application.properties") @SpringBootApplication -public class OauthClientApplication { +public class OauthClientLoginApplication { public static void main(String[] args) { - SpringApplication.run(OauthClientApplication.class, args); + SpringApplication.run(OauthClientLoginApplication.class, args); } } diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java index 55e0096525..24e5377f36 100644 --- a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java @@ -16,7 +16,7 @@ import reactor.core.publisher.Mono; @RestController public class ClientRestController { - private static final String RESOURCE_URI = "http://localhost:8084/retrieve-resource"; + private static final String RESOURCE_URI = "http://localhost:8082/spring-security-oauth-resource/foos/1"; @Autowired WebClient webClient; diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java index d1b9f7f744..4356581819 100644 --- a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java @@ -7,9 +7,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; /** * - * Note: This app is configured to use the authorization service and the resource service located in module spring-5-security-oauth - * - * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using credentials handled by the auth server (bael-user/bael-password) + * Note: This app is configured to use the authorization service and the resource service located in Baeldung/spring-security-oauth repo * * @author rozagerardo * diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java index dc38ce3f9e..ef39222933 100644 --- a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java @@ -4,8 +4,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; -import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; @@ -14,12 +12,12 @@ public class WebClientChonJob { Logger logger = LoggerFactory.getLogger(WebClientChonJob.class); - private static final String RESOURCE_URI = "http://localhost:8084/retrieve-resource"; + private static final String RESOURCE_URI = "localhost:8082/spring-security-oauth-resource/foos/1"; @Autowired private WebClient webClient; - @Scheduled(fixedRate = 1000) + @Scheduled(fixedRate = 5000) public void logResourceServiceResponse() { webClient.get() diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java index c2762ad559..59a63355f7 100644 --- a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java @@ -6,13 +6,12 @@ import org.springframework.context.annotation.PropertySource; /** * - * Note: This app is configured to use the authorization service and the resource service located in module spring-5-security-oauth - * - * As we usually do with other well-known auth providers (github/facebook/...) we have to log-in using user credentials (bael-user/bael-password) and client configurations (bael-client-id/bael-secret) handled by the auth server + * Note: This app is configured to use the authorization service and the resource service located in Baeldung/spring-security-oauth repo * * @author rozagerardo * */ +@PropertySource("classpath:webclient-manual-request-oauth-application.properties") @SpringBootApplication public class ManualRequestApplication { diff --git a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java index 9f9d6d3167..d54d811032 100644 --- a/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java +++ b/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java @@ -3,8 +3,8 @@ package com.baeldung.webclient.manualrequest.web; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames; import org.springframework.util.Base64Utils; import org.springframework.web.bind.annotation.GetMapping; @@ -22,10 +22,16 @@ public class ManualOauthRequestController { private static Logger logger = LoggerFactory.getLogger(ManualOauthRequestController.class); - private static final String TOKEN_ENDPOINT = "localhost:8085/oauth/token"; - private static final String RESOURCE_ENDPOINT = "localhost:8084/retrieve-resource"; - private static final String CLIENT_ID = "bael-client-id"; - private static final String CLIENT_SECRET = "bael-secret"; + private static final String RESOURCE_ENDPOINT = "localhost:8082/spring-security-oauth-resource/foos/1"; + + @Value("${the.authorization.client-id}") + private String clientId; + + @Value("${the.authorization.client-secret}") + private String clientSecret; + + @Value("${the.authorization.token-uri}") + private String tokenUri; @Autowired WebClient client; @@ -34,8 +40,8 @@ public class ManualOauthRequestController { public Mono obtainSecuredResource() { logger.info("Creating web client..."); Mono resource = client.post() - .uri(TOKEN_ENDPOINT) - .header(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils.encodeToString((CLIENT_ID + ":" + CLIENT_SECRET).getBytes())) + .uri(tokenUri) + .header(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils.encodeToString((clientId + ":" + clientSecret).getBytes())) .body(BodyInserters.fromFormData(OAuth2ParameterNames.GRANT_TYPE, GrantType.CLIENT_CREDENTIALS.getValue())) .retrieve() .bodyToMono(JsonNode.class) diff --git a/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties b/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties index 612777a06d..ac96aae6d6 100644 --- a/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties +++ b/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties @@ -1,10 +1,10 @@ spring.security.oauth2.client.registration.bael.client-name=bael -spring.security.oauth2.client.registration.bael.client-id=bael-client-id -spring.security.oauth2.client.registration.bael.client-secret=bael-secret +spring.security.oauth2.client.registration.bael.client-id=fooClientIdPassword +spring.security.oauth2.client.registration.bael.client-secret=secret spring.security.oauth2.client.registration.bael.authorization-grant-type=authorization_code spring.security.oauth2.client.registration.bael.redirect-uri=http://localhost:8080/authorize/oauth2/code/bael -spring.security.oauth2.client.provider.bael.token-uri=http://localhost:8085/oauth/token -spring.security.oauth2.client.provider.bael.authorization-uri=http://localhost:8085/oauth/authorize +spring.security.oauth2.client.provider.bael.token-uri=http://localhost:8081/spring-security-oauth-server/oauth/token +spring.security.oauth2.client.provider.bael.authorization-uri=http://localhost:8081/spring-security-oauth-server/oauth/authorize spring.security.user.password=pass diff --git a/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties b/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties index edd5b80b13..e4dd0a532d 100644 --- a/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties +++ b/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties @@ -1,10 +1,10 @@ spring.security.oauth2.client.registration.bael.client-name=bael -spring.security.oauth2.client.registration.bael.client-id=bael-client-id -spring.security.oauth2.client.registration.bael.client-secret=bael-secret +spring.security.oauth2.client.registration.bael.client-id=fooClientIdPassword +spring.security.oauth2.client.registration.bael.client-secret=secret spring.security.oauth2.client.registration.bael.authorization-grant-type=authorization_code spring.security.oauth2.client.registration.bael.redirect-uri=http://localhost:8080/login/oauth2/code/bael -spring.security.oauth2.client.provider.bael.token-uri=http://localhost:8085/oauth/token -spring.security.oauth2.client.provider.bael.authorization-uri=http://localhost:8085/oauth/authorize -spring.security.oauth2.client.provider.bael.user-info-uri=http://localhost:8084/user -spring.security.oauth2.client.provider.bael.user-name-attribute=name +spring.security.oauth2.client.provider.bael.token-uri=http://localhost:8081/spring-security-oauth-server/oauth/token +spring.security.oauth2.client.provider.bael.authorization-uri=http://localhost:8081/spring-security-oauth-server/oauth/authorize +spring.security.oauth2.client.provider.bael.user-info-uri=http://localhost:8082/spring-security-oauth-resource/users/extra +spring.security.oauth2.client.provider.bael.user-name-attribute=user_name diff --git a/spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties b/spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties index f82f74ec48..14c5b97605 100644 --- a/spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties +++ b/spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties @@ -1,4 +1,4 @@ spring.security.oauth2.client.registration.bael.authorization-grant-type=client_credentials -spring.security.oauth2.client.registration.bael.client-id=bael-client-id -spring.security.oauth2.client.registration.bael.client-secret=bael-secret -spring.security.oauth2.client.provider.bael.token-uri=http://localhost:8085/oauth/token +spring.security.oauth2.client.registration.bael.client-id=fooClientIdPassword +spring.security.oauth2.client.registration.bael.client-secret=secret +spring.security.oauth2.client.provider.bael.token-uri=http://localhost:8081/spring-security-oauth-server/oauth/token diff --git a/spring-5-reactive-oauth/src/main/resources/webclient-manual-request-oauth-application.properties b/spring-5-reactive-oauth/src/main/resources/webclient-manual-request-oauth-application.properties new file mode 100644 index 0000000000..36ec3defd1 --- /dev/null +++ b/spring-5-reactive-oauth/src/main/resources/webclient-manual-request-oauth-application.properties @@ -0,0 +1,3 @@ +the.authorization.client-id=fooClientIdPassword +the.authorization.client-secret=secret +the.authorization.token-uri=http://localhost:8081/spring-security-oauth-server/oauth/token diff --git a/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java index e31815c3f8..ef913ba055 100644 --- a/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java +++ b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java @@ -19,9 +19,9 @@ import ch.qos.logback.classic.spi.ILoggingEvent; /** * - * Note: this Live test requires the Authorization Service and the Resource service located in the spring-5-security-oauth module + * Note: this Live test requires the Authorization Service and the Resource service located in the Baeldung/spring-security-oauth repo * - * @author ger + * @author rozagerardo * */ @RunWith(SpringRunner.class) @@ -46,7 +46,7 @@ public class OAuth2ClientCredentialsLiveTest { .stream() .map(ILoggingEvent::getFormattedMessage) .collect(Collectors.toList()); - assertThat(allLoggedEntries).anyMatch(entry -> entry.contains("We retrieved the following resource using Client Credentials Grant Type: This is the resource!")); + assertThat(allLoggedEntries).anyMatch(entry -> entry.contains("We retrieved the following resource using Client Credentials Grant Type: {\"id\"")); } } diff --git a/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java index 94aa580f0a..2381264926 100644 --- a/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java +++ b/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java @@ -1,5 +1,6 @@ package com.baeldung.webclient.manualrequest; +import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; import org.springframework.test.web.reactive.server.WebTestClient; @@ -8,7 +9,7 @@ import org.springframework.test.web.reactive.server.WebTestClient.ResponseSpec; /** * * Note: this Live test requires not only the corresponding application running, - * but also the Authorization Service and the Resource service located in the spring-5-security-oauth module. + * but also the Authorization Service and the Resource service located in the Baeldung/spring-security-oauth repo * * * @author ger @@ -37,7 +38,7 @@ public class OAuth2ManualRequestLiveTest { response.expectStatus() .isOk() .expectBody(String.class) - .isEqualTo("Retrieved the resource using a manual approach: This is the resource!"); + .value(Matchers.containsString("Retrieved the resource using a manual approach: {\"id\"")); } } diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/AuthorizationServerApplication.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/AuthorizationServerApplication.java deleted file mode 100644 index d72704386c..0000000000 --- a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/AuthorizationServerApplication.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.webclient.authorizationserver; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.PropertySource; -import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; - -@EnableAuthorizationServer -@PropertySource("classpath:webclient-authorization-application.properties") -@SpringBootApplication -public class AuthorizationServerApplication { - - public static void main(String[] args) { - SpringApplication.run(AuthorizationServerApplication.class, args); - } - -} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/configuration/WebSecurityConfig.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/configuration/WebSecurityConfig.java deleted file mode 100644 index 5dd15f1b8c..0000000000 --- a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/authorizationserver/configuration/WebSecurityConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.webclient.authorizationserver.configuration; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -@EnableWebSecurity -@Configuration -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests() - .antMatchers("/login", "/user") - .permitAll() - .and() - .authorizeRequests() - .anyRequest() - .authenticated() - .and() - .formLogin() - .and() - .httpBasic(); - } -} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/ResourceServerApplication.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/ResourceServerApplication.java deleted file mode 100644 index 50ad293ef8..0000000000 --- a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/ResourceServerApplication.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.webclient.resourceserver; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.PropertySource; -import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; - -@EnableResourceServer -@PropertySource("webclient-resources-application.properties") -@SpringBootApplication -public class ResourceServerApplication { - - public static void main(String[] args) { - SpringApplication.run(ResourceServerApplication.class, args); - } - -} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/configuration/AuthorizationConfigs.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/configuration/AuthorizationConfigs.java deleted file mode 100644 index 5aea1983db..0000000000 --- a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/configuration/AuthorizationConfigs.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.webclient.resourceserver.configuration; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.oauth2.provider.token.RemoteTokenServices; -import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices; - -@Configuration -public class AuthorizationConfigs { - - @Value("${oauth.authserver.client-id}") - String clientId; - - @Value("${oauth.authserver.client-secret}") - String clientSecret; - - @Value("${oauth.authserver.check-token-endpoint}") - String checkTokenEndpoint; - - @Bean - public ResourceServerTokenServices tokenSvc() { - RemoteTokenServices remoteService = new RemoteTokenServices(); - remoteService.setCheckTokenEndpointUrl(checkTokenEndpoint); - remoteService.setClientId(clientId); - remoteService.setClientSecret(clientSecret); - return remoteService; - } -} diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/web/ResourceRestController.java b/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/web/ResourceRestController.java deleted file mode 100644 index aef0fb4d7d..0000000000 --- a/spring-5-security-oauth/src/main/java/com/baeldung/webclient/resourceserver/web/ResourceRestController.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.webclient.resourceserver.web; - -import java.security.Principal; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class ResourceRestController { - - @GetMapping("/retrieve-resource") - public String retrieveResource() { - return "This is the resource!"; - } - - @GetMapping("/user") - @ResponseBody - public Principal user(Principal user) { - return user; - } - -} diff --git a/spring-5-security-oauth/src/main/resources/webclient-authorization-application.properties b/spring-5-security-oauth/src/main/resources/webclient-authorization-application.properties deleted file mode 100644 index 9531045359..0000000000 --- a/spring-5-security-oauth/src/main/resources/webclient-authorization-application.properties +++ /dev/null @@ -1,13 +0,0 @@ -server.port=8085 - -security.oauth2.client.client-id=bael-client-id -security.oauth2.client.client-secret=bael-secret -security.oauth2.client.scope=read,write - -security.oauth2.authorization.check-token-access=isAuthenticated() - -spring.security.user.name=bael-user -spring.security.user.password=bael-password - -security.oauth2.client.registered-redirect-uri=http://localhost:8080/login/oauth2/code/bael, http://localhost:8080/authorize/oauth2/code/bael -security.oauth2.client.use-current-uri=false \ No newline at end of file diff --git a/spring-5-security-oauth/src/main/resources/webclient-resources-application.properties b/spring-5-security-oauth/src/main/resources/webclient-resources-application.properties deleted file mode 100644 index 1cfb9ca12d..0000000000 --- a/spring-5-security-oauth/src/main/resources/webclient-resources-application.properties +++ /dev/null @@ -1,6 +0,0 @@ -server.port=8084 - -#spring.security.oauth2.resourceserver.jwt.issuer-uri=localhost:8085 -oauth.authserver.client-id=bael-client-id -oauth.authserver.client-secret=bael-secret -oauth.authserver.check-token-endpoint=http://localhost:8085/oauth/check_token From dcc1cd3850cdb3dbbfa6df343604ac4b720cd424 Mon Sep 17 00:00:00 2001 From: chandra Date: Sat, 12 Jan 2019 16:52:52 -0500 Subject: [PATCH 218/441] BAEL-2088 Common Hibernate Exceptions Commin Hibernate Exceptions unit tests --- .../hibernate/exception/EntityWithNoId.java | 16 + .../hibernate/exception/HibernateUtil.java | 63 +++ .../baeldung/hibernate/exception/Product.java | 40 ++ .../exception/HibernateExceptionUnitTest.java | 425 ++++++++++++++++++ .../resources/hibernate-exception.properties | 16 + 5 files changed, 560 insertions(+) create mode 100644 persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/EntityWithNoId.java create mode 100644 persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/HibernateUtil.java create mode 100644 persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/Product.java create mode 100644 persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/exception/HibernateExceptionUnitTest.java create mode 100644 persistence-modules/hibernate5/src/test/resources/hibernate-exception.properties diff --git a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/EntityWithNoId.java b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/EntityWithNoId.java new file mode 100644 index 0000000000..989fa1281a --- /dev/null +++ b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/EntityWithNoId.java @@ -0,0 +1,16 @@ +package com.baeldung.hibernate.exception; + +import javax.persistence.Entity; + +@Entity +public class EntityWithNoId { + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/HibernateUtil.java b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/HibernateUtil.java new file mode 100644 index 0000000000..ae5174ac9c --- /dev/null +++ b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/HibernateUtil.java @@ -0,0 +1,63 @@ +package com.baeldung.hibernate.exception; + +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URL; +import java.util.Properties; + +import org.apache.commons.lang3.StringUtils; +import org.hibernate.SessionFactory; +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.service.ServiceRegistry; + +public class HibernateUtil { + private static SessionFactory sessionFactory; + private static String PROPERTY_FILE_NAME; + + public static SessionFactory getSessionFactory() throws IOException { + return getSessionFactory(null); + } + + public static SessionFactory getSessionFactory(String propertyFileName) + throws IOException { + PROPERTY_FILE_NAME = propertyFileName; + if (sessionFactory == null) { + ServiceRegistry serviceRegistry = configureServiceRegistry(); + sessionFactory = makeSessionFactory(serviceRegistry); + } + return sessionFactory; + } + + private static SessionFactory makeSessionFactory( + ServiceRegistry serviceRegistry) { + MetadataSources metadataSources = new MetadataSources(serviceRegistry); + metadataSources.addAnnotatedClass(Product.class); + Metadata metadata = metadataSources.getMetadataBuilder() + .build(); + return metadata.getSessionFactoryBuilder() + .build(); + + } + + private static ServiceRegistry configureServiceRegistry() + throws IOException { + Properties properties = getProperties(); + return new StandardServiceRegistryBuilder().applySettings(properties) + .build(); + } + + private static Properties getProperties() throws IOException { + Properties properties = new Properties(); + URL propertiesURL = Thread.currentThread() + .getContextClassLoader() + .getResource(StringUtils.defaultString(PROPERTY_FILE_NAME, + "hibernate-exception.properties")); + try (FileInputStream inputStream = new FileInputStream( + propertiesURL.getFile())) { + properties.load(inputStream); + } + return properties; + } +} \ No newline at end of file diff --git a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/Product.java b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/Product.java new file mode 100644 index 0000000000..031fa38de0 --- /dev/null +++ b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/exception/Product.java @@ -0,0 +1,40 @@ +package com.baeldung.hibernate.exception; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class Product { + + private int id; + + private String name; + private String description; + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + @Column(nullable=false) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/exception/HibernateExceptionUnitTest.java b/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/exception/HibernateExceptionUnitTest.java new file mode 100644 index 0000000000..3581c81daa --- /dev/null +++ b/persistence-modules/hibernate5/src/test/java/com/baeldung/hibernate/exception/HibernateExceptionUnitTest.java @@ -0,0 +1,425 @@ +package com.baeldung.hibernate.exception; + +import static org.hamcrest.CoreMatchers.isA; +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.util.List; + +import javax.persistence.OptimisticLockException; +import javax.persistence.PersistenceException; + +import org.hibernate.AnnotationException; +import org.hibernate.HibernateException; +import org.hibernate.MappingException; +import org.hibernate.NonUniqueObjectException; +import org.hibernate.PropertyValueException; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.StaleObjectStateException; +import org.hibernate.StaleStateException; +import org.hibernate.Transaction; +import org.hibernate.TransactionException; +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.cfg.Configuration; +import org.hibernate.exception.ConstraintViolationException; +import org.hibernate.exception.DataException; +import org.hibernate.exception.SQLGrammarException; +import org.hibernate.query.NativeQuery; +import org.hibernate.tool.schema.spi.CommandAcceptanceException; +import org.hibernate.tool.schema.spi.SchemaManagementException; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class HibernateExceptionUnitTest { + + private static final Logger logger = LoggerFactory + .getLogger(HibernateExceptionUnitTest.class); + private SessionFactory sessionFactory; + + @Before + public void setUp() throws IOException { + sessionFactory = HibernateUtil.getSessionFactory(); + } + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private Configuration getConfiguration() { + Configuration cfg = new Configuration(); + cfg.setProperty(AvailableSettings.DIALECT, + "org.hibernate.dialect.H2Dialect"); + cfg.setProperty(AvailableSettings.HBM2DDL_AUTO, "none"); + cfg.setProperty(AvailableSettings.DRIVER, "org.h2.Driver"); + cfg.setProperty(AvailableSettings.URL, + "jdbc:h2:mem:myexceptiondb2;DB_CLOSE_DELAY=-1"); + cfg.setProperty(AvailableSettings.USER, "sa"); + cfg.setProperty(AvailableSettings.PASS, ""); + return cfg; + } + + @Test + public void whenQueryExecutedWithUnmappedEntity_thenMappingException() { + thrown.expectCause(isA(MappingException.class)); + thrown.expectMessage("Unknown entity: java.lang.String"); + + Session session = sessionFactory.openSession(); + NativeQuery query = session + .createNativeQuery("select name from PRODUCT", String.class); + query.getResultList(); + } + + @Test + @SuppressWarnings("rawtypes") + public void whenQueryExecuted_thenOK() { + Session session = sessionFactory.openSession(); + NativeQuery query = session + .createNativeQuery("select name from PRODUCT"); + List results = query.getResultList(); + assertNotNull(results); + } + + @Test + public void givenEntityWithoutId_whenSessionFactoryCreated_thenAnnotationException() { + thrown.expect(AnnotationException.class); + thrown.expectMessage("No identifier specified for entity"); + + Configuration cfg = getConfiguration(); + cfg.addAnnotatedClass(EntityWithNoId.class); + cfg.buildSessionFactory(); + } + + @Test + public void givenMissingTable_whenSchemaValidated_thenSchemaManagementException() { + thrown.expect(SchemaManagementException.class); + thrown.expectMessage("Schema-validation: missing table"); + + Configuration cfg = getConfiguration(); + cfg.setProperty(AvailableSettings.HBM2DDL_AUTO, "validate"); + cfg.addAnnotatedClass(Product.class); + cfg.buildSessionFactory(); + } + + @Test + public void whenWrongDialectSpecified_thenCommandAcceptanceException() { + thrown.expect(SchemaManagementException.class); + thrown.expectCause(isA(CommandAcceptanceException.class)); + thrown.expectMessage("Halting on error : Error executing DDL"); + + Configuration cfg = getConfiguration(); + cfg.setProperty(AvailableSettings.DIALECT, + "org.hibernate.dialect.MySQLDialect"); + cfg.setProperty(AvailableSettings.HBM2DDL_AUTO, "update"); + + // This does not work due to hibernate bug + // cfg.setProperty(AvailableSettings.HBM2DDL_HALT_ON_ERROR,"true"); + cfg.getProperties() + .put(AvailableSettings.HBM2DDL_HALT_ON_ERROR, true); + + cfg.addAnnotatedClass(Product.class); + cfg.buildSessionFactory(); + } + + @Test + public void givenMissingTable_whenEntitySaved_thenSQLGrammarException() { + thrown.expect(isA(PersistenceException.class)); + thrown.expectCause(isA(SQLGrammarException.class)); + thrown + .expectMessage("SQLGrammarException: could not prepare statement"); + + Configuration cfg = getConfiguration(); + cfg.addAnnotatedClass(Product.class); + + SessionFactory sessionFactory = cfg.buildSessionFactory(); + Session session = null; + Transaction transaction = null; + try { + + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + Product product = new Product(); + product.setId(1); + product.setName("Product 1"); + session.save(product); + transaction.commit(); + } catch (Exception e) { + rollbackTransactionQuietly(transaction); + throw (e); + } finally { + closeSessionQuietly(session); + closeSessionFactoryQuietly(sessionFactory); + } + } + + @Test + public void givenMissingTable_whenQueryExecuted_thenSQLGrammarException() { + thrown.expect(isA(PersistenceException.class)); + thrown.expectCause(isA(SQLGrammarException.class)); + thrown + .expectMessage("SQLGrammarException: could not prepare statement"); + + Session session = sessionFactory.openSession(); + NativeQuery query = session.createNativeQuery( + "select * from NON_EXISTING_TABLE", Product.class); + query.getResultList(); + } + + @Test + public void whenDuplicateIdSaved_thenConstraintViolationException() { + thrown.expect(isA(PersistenceException.class)); + thrown.expectCause(isA(ConstraintViolationException.class)); + thrown.expectMessage( + "ConstraintViolationException: could not execute statement"); + + Session session = null; + Transaction transaction = null; + + for (int i = 1; i <= 2; i++) { + try { + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + Product product = new Product(); + product.setId(1); + product.setName("Product " + i); + session.save(product); + transaction.commit(); + } catch (Exception e) { + rollbackTransactionQuietly(transaction); + throw (e); + } finally { + closeSessionQuietly(session); + } + } + } + + @Test + public void givenNotNullPropertyNotSet_whenEntityIdSaved_thenPropertyValueException() { + thrown.expect(isA(PropertyValueException.class)); + thrown.expectMessage( + "not-null property references a null or transient value"); + + Session session = null; + Transaction transaction = null; + + try { + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + + Product product = new Product(); + product.setId(1); + session.save(product); + transaction.commit(); + } catch (Exception e) { + rollbackTransactionQuietly(transaction); + throw (e); + } finally { + closeSessionQuietly(session); + } + + } + + @Test + public void givenQueryWithDataTypeMismatch_WhenQueryExecuted_thenDataException() { + thrown.expectCause(isA(DataException.class)); + thrown.expectMessage( + "org.hibernate.exception.DataException: could not prepare statement"); + + Session session = sessionFactory.openSession(); + NativeQuery query = session.createNativeQuery( + "select * from PRODUCT where id='wrongTypeId'", Product.class); + query.getResultList(); + } + + @Test + public void givenSessionContainingAnId_whenIdAssociatedAgain_thenNonUniqueObjectException() { + thrown.expect(isA(NonUniqueObjectException.class)); + thrown.expectMessage( + "A different object with the same identifier value was already associated with the session"); + + Session session = null; + Transaction transaction = null; + + try { + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + + Product product1 = new Product(); + product1.setId(1); + product1.setName("Product 1"); + session.save(product1); + + Product product2 = new Product(); + product2.setId(1); + product2.setName("Product 2"); + session.save(product2); + + transaction.commit(); + } catch (Exception e) { + rollbackTransactionQuietly(transaction); + throw (e); + } finally { + closeSessionQuietly(session); + } + } + + @Test + public void whenDeletingADeletedObject_thenOptimisticLockException() { + thrown.expect(isA(OptimisticLockException.class)); + thrown.expectMessage( + "Batch update returned unexpected row count from update"); + thrown.expectCause(isA(StaleStateException.class)); + + Session session = null; + Transaction transaction = null; + + try { + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + + Product product1 = new Product(); + product1.setId(12); + product1.setName("Product 12"); + session.save(product1); + transaction.commit(); + session.close(); + + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + Product product2 = session.get(Product.class, 12); + session.createNativeQuery("delete from Product where id=12") + .executeUpdate(); + // We need to refresh to fix the error. + // session.refresh(product2); + session.delete(product2); + transaction.commit(); + } catch (Exception e) { + rollbackTransactionQuietly(transaction); + throw (e); + } finally { + closeSessionQuietly(session); + } + } + + @Test + public void whenUpdatingNonExistingObject_thenStaleStateException() { + thrown.expect(isA(OptimisticLockException.class)); + thrown + .expectMessage("Row was updated or deleted by another transaction"); + thrown.expectCause(isA(StaleObjectStateException.class)); + + Session session = null; + Transaction transaction = null; + + try { + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + + Product product1 = new Product(); + product1.setId(15); + product1.setName("Product1"); + session.update(product1); + transaction.commit(); + } catch (Exception e) { + rollbackTransactionQuietly(transaction); + throw (e); + } finally { + closeSessionQuietly(session); + } + } + + @Test + public void givenTxnMarkedRollbackOnly_whenCommitted_thenTransactionException() { + thrown.expect(isA(TransactionException.class)); + + Session session = null; + Transaction transaction = null; + try { + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + + Product product1 = new Product(); + product1.setId(15); + product1.setName("Product1"); + session.save(product1); + transaction.setRollbackOnly(); + + transaction.commit(); + } catch (Exception e) { + rollbackTransactionQuietly(transaction); + throw (e); + } finally { + closeSessionQuietly(session); + } + } + + private void rollbackTransactionQuietly(Transaction transaction) { + if (transaction != null && transaction.isActive()) { + try { + transaction.rollback(); + } catch (Exception e) { + logger.error("Exception while rolling back transaction", e); + } + } + } + + private void closeSessionQuietly(Session session) { + if (session != null) { + try { + session.close(); + } catch (Exception e) { + logger.error("Exception while closing session", e); + } + } + } + + private void closeSessionFactoryQuietly(SessionFactory sessionFactory) { + if (sessionFactory != null) { + try { + sessionFactory.close(); + } catch (Exception e) { + logger.error("Exception while closing sessionFactory", e); + } + } + } + + @Test + public void givenExistingEntity_whenIdUpdated_thenHibernateException() { + thrown.expect(isA(PersistenceException.class)); + thrown.expectCause(isA(HibernateException.class)); + thrown.expectMessage( + "identifier of an instance of com.baeldung.hibernate.exception.Product was altered"); + + Session session = null; + Transaction transaction = null; + + try { + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + + Product product1 = new Product(); + product1.setId(222); + product1.setName("Product 222"); + session.save(product1); + transaction.commit(); + closeSessionQuietly(session); + + session = sessionFactory.openSession(); + transaction = session.beginTransaction(); + + Product product2 = session.get(Product.class, 222); + product2.setId(333); + session.save(product2); + + transaction.commit(); + } catch (Exception e) { + rollbackTransactionQuietly(transaction); + throw (e); + } finally { + closeSessionQuietly(session); + } + } +} diff --git a/persistence-modules/hibernate5/src/test/resources/hibernate-exception.properties b/persistence-modules/hibernate5/src/test/resources/hibernate-exception.properties new file mode 100644 index 0000000000..e08a23166d --- /dev/null +++ b/persistence-modules/hibernate5/src/test/resources/hibernate-exception.properties @@ -0,0 +1,16 @@ +hibernate.connection.driver_class=org.h2.Driver +hibernate.connection.url=jdbc:h2:mem:myexceptiondb1;DB_CLOSE_DELAY=-1 +hibernate.connection.username=sa +hibernate.connection.autocommit=true +jdbc.password= + +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=true +hibernate.hbm2ddl.auto=create-drop + +hibernate.c3p0.min_size=5 +hibernate.c3p0.max_size=20 +hibernate.c3p0.acquire_increment=5 +hibernate.c3p0.timeout=1800 + +hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory From 16bed6f64b2a55fa36568119a92c3593345b00d1 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Sun, 13 Jan 2019 10:42:18 +0400 Subject: [PATCH 219/441] match words refactoring --- .../java/com/baeldung/string/MatchWords.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index f0b64c19cf..f4a52ae308 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -9,21 +9,21 @@ import java.util.regex.Pattern; public class MatchWords { public static void main(String[] args) { - String[] items = {"hello", "Baeldung"}; + String[] words = {"hello", "Baeldung"}; String inputString = "hello there, Baeldung"; - System.out.println(containsWords(inputString, items)); + containsWords(inputString, words); - System.out.println(java8(new ArrayList<>(Arrays.asList(inputString.split(" "))), new ArrayList<>(Arrays.asList(items)))); + containsWordsJava8(new ArrayList<>(Arrays.asList(inputString.split(" "))), new ArrayList<>(Arrays.asList(words))); - System.out.println(patternMatch(inputString)); + containsWordsPatternMatch(inputString, words); - ahoCorasick(); + containsWordsAhoCorasick(inputString, words); - indexOfWords(inputString, items); + containsWordsIndexOf(inputString, words); } - private static boolean indexOfWords(String inputString, String[] words) { + private static boolean containsWordsIndexOf(String inputString, String[] words) { boolean found = true; for (String word : words) { int index = inputString.indexOf(word); @@ -46,30 +46,31 @@ public class MatchWords { return found; } - private static void ahoCorasick() { + private static boolean containsWordsAhoCorasick(String inputString, String[] words) { Trie trie = Trie.builder() .onlyWholeWords() - .addKeyword("hello") - .addKeyword("Baeldung") + .addKeyword(words[0]) + .addKeyword(words[1]) .build(); - Collection emits = trie.parseText("hello there, Baeldung"); - emits.forEach(System.out::println); + Collection emits = trie.parseText(inputString); + + return emits.size() == words.length; } - private static boolean patternMatch(String inputString) { - Pattern pattern = Pattern.compile("(?=.*hello)(?=.*Baeldung)"); + private static boolean containsWordsPatternMatch(String inputString, String[] words) { + Pattern pattern = Pattern.compile("(?=.*words[0])(?=.*words[1])"); if (pattern.matcher(inputString).find()) { return true; } return false; } - private static boolean java8(ArrayList inputString, ArrayList items) { - return items.stream().allMatch(inputString::contains); + private static boolean containsWordsJava8(ArrayList inputString, ArrayList words) { + return words.stream().allMatch(inputString::contains); } - private static boolean array(ArrayList inputString, ArrayList items) { - return inputString.containsAll(items); + private static boolean containsWordsArray(ArrayList inputString, ArrayList words) { + return inputString.containsAll(words); } } From 06ffe3b5e42581d28e582d68ebf35f2403789954 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Sun, 13 Jan 2019 11:04:42 +0400 Subject: [PATCH 220/441] match words final refactor --- .../main/java/com/baeldung/string/MatchWords.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index f4a52ae308..675f4577c3 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -4,7 +4,10 @@ import org.ahocorasick.trie.Emit; import org.ahocorasick.trie.Trie; import java.util.*; +import java.util.function.Function; import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class MatchWords { @@ -51,14 +54,17 @@ public class MatchWords { .onlyWholeWords() .addKeyword(words[0]) .addKeyword(words[1]) + .ignoreOverlaps() .build(); - Collection emits = trie.parseText(inputString); - + Collection emits = trie.parseText(inputString) + .stream() + .filter(e -> !Objects.equals(e.getKeyword(), e.getKeyword())) + .collect(Collectors.toList()); return emits.size() == words.length; } private static boolean containsWordsPatternMatch(String inputString, String[] words) { - Pattern pattern = Pattern.compile("(?=.*words[0])(?=.*words[1])"); + Pattern pattern = Pattern.compile("(?=.*hello)(?=.*Baeldung)"); if (pattern.matcher(inputString).find()) { return true; } From 04c6cd1215be367f43652a6e771f4bf8eba0032e Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Sun, 13 Jan 2019 11:35:54 +0400 Subject: [PATCH 221/441] replace hardcoded strings --- .../src/main/java/com/baeldung/string/MatchWords.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index 675f4577c3..0b803da0ae 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -56,15 +56,20 @@ public class MatchWords { .addKeyword(words[1]) .ignoreOverlaps() .build(); + Collection emits = trie.parseText(inputString) .stream() .filter(e -> !Objects.equals(e.getKeyword(), e.getKeyword())) .collect(Collectors.toList()); + + emits.forEach(System.out::println); + return emits.size() == words.length; } private static boolean containsWordsPatternMatch(String inputString, String[] words) { - Pattern pattern = Pattern.compile("(?=.*hello)(?=.*Baeldung)"); + + Pattern pattern = Pattern.compile("(?=.*" + words[0] + ")(?=.*" + words[1] + ")"); if (pattern.matcher(inputString).find()) { return true; } From 4f103eeb278324ad943e8b5ad17542fc04902ea5 Mon Sep 17 00:00:00 2001 From: Loredana Date: Sun, 13 Jan 2019 10:32:02 +0200 Subject: [PATCH 222/441] move instanceof code --- .../src/main/java/com/baeldung/keyword/Circle.java | 0 .../src/main/java/com/baeldung/keyword/Ring.java | 0 .../src/main/java/com/baeldung/keyword/Round.java | 0 .../src/main/java/com/baeldung/keyword/Shape.java | 0 .../src/main/java/com/baeldung/keyword/Triangle.java | 0 .../test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {core-java => core-java-lang-syntax}/src/main/java/com/baeldung/keyword/Circle.java (100%) rename {core-java => core-java-lang-syntax}/src/main/java/com/baeldung/keyword/Ring.java (100%) rename {core-java => core-java-lang-syntax}/src/main/java/com/baeldung/keyword/Round.java (100%) rename {core-java => core-java-lang-syntax}/src/main/java/com/baeldung/keyword/Shape.java (100%) rename {core-java => core-java-lang-syntax}/src/main/java/com/baeldung/keyword/Triangle.java (100%) rename {core-java => core-java-lang-syntax}/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java (100%) diff --git a/core-java/src/main/java/com/baeldung/keyword/Circle.java b/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Circle.java similarity index 100% rename from core-java/src/main/java/com/baeldung/keyword/Circle.java rename to core-java-lang-syntax/src/main/java/com/baeldung/keyword/Circle.java diff --git a/core-java/src/main/java/com/baeldung/keyword/Ring.java b/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Ring.java similarity index 100% rename from core-java/src/main/java/com/baeldung/keyword/Ring.java rename to core-java-lang-syntax/src/main/java/com/baeldung/keyword/Ring.java diff --git a/core-java/src/main/java/com/baeldung/keyword/Round.java b/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Round.java similarity index 100% rename from core-java/src/main/java/com/baeldung/keyword/Round.java rename to core-java-lang-syntax/src/main/java/com/baeldung/keyword/Round.java diff --git a/core-java/src/main/java/com/baeldung/keyword/Shape.java b/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Shape.java similarity index 100% rename from core-java/src/main/java/com/baeldung/keyword/Shape.java rename to core-java-lang-syntax/src/main/java/com/baeldung/keyword/Shape.java diff --git a/core-java/src/main/java/com/baeldung/keyword/Triangle.java b/core-java-lang-syntax/src/main/java/com/baeldung/keyword/Triangle.java similarity index 100% rename from core-java/src/main/java/com/baeldung/keyword/Triangle.java rename to core-java-lang-syntax/src/main/java/com/baeldung/keyword/Triangle.java diff --git a/core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java b/core-java-lang-syntax/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java similarity index 100% rename from core-java/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java rename to core-java-lang-syntax/src/test/java/com/baeldung/keyword/test/InstanceOfUnitTest.java From 9c0363e221aba40d44323fd57eecf4e78edd3243 Mon Sep 17 00:00:00 2001 From: jose Date: Sun, 13 Jan 2019 15:12:40 -0300 Subject: [PATCH 223/441] BAEL-2472 changes after editor-review --- .../com/baeldung/scope/BracketScopeExample.java | 14 ++++++++++++++ .../java/com/baeldung/scope/ClassScopeExample.java | 5 ++--- .../java/com/baeldung/scope/LoopScopeExample.java | 6 +++--- .../com/baeldung/scope/MethodScopeExample.java | 9 +++------ .../com/baeldung/scope/NestedScopesExample.java | 3 +-- .../java/com/baeldung/scope/OutOfScopeExample.java | 14 -------------- 6 files changed, 23 insertions(+), 28 deletions(-) create mode 100644 core-java/src/main/java/com/baeldung/scope/BracketScopeExample.java delete mode 100644 core-java/src/main/java/com/baeldung/scope/OutOfScopeExample.java diff --git a/core-java/src/main/java/com/baeldung/scope/BracketScopeExample.java b/core-java/src/main/java/com/baeldung/scope/BracketScopeExample.java new file mode 100644 index 0000000000..37ae211dcb --- /dev/null +++ b/core-java/src/main/java/com/baeldung/scope/BracketScopeExample.java @@ -0,0 +1,14 @@ +package org.baeldung.variable.scope.examples; + +public class BracketScopeExample { + + public void mathOperationExample() { + Integer sum = 0; + { + Integer number = 2; + sum = sum + number; + } + // compiler error, number cannot be solved as a variable + // number++; + } +} \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java b/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java index 17ca1e01eb..241c6b466e 100644 --- a/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java +++ b/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java @@ -9,7 +9,6 @@ public class ClassScopeExample { } public void anotherExampleMethod() { - amount--; + Integer anotherAmount = amount + 4; } - -} +} \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java b/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java index 2dd3be3333..8049a49c4d 100644 --- a/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java +++ b/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java @@ -12,7 +12,7 @@ public class LoopScopeExample { for (String name : listOfNames) { allNames = allNames + " " + name; } - + // compiler error, name cannot be resolved to a variable + // String lastNameUsed = name; } - -} +} \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java b/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java index 122d12e2fc..e62c6a2a1c 100644 --- a/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java +++ b/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java @@ -2,15 +2,12 @@ package org.baeldung.variable.scope.examples; public class MethodScopeExample { - Integer size = 2; - public void methodA() { Integer area = 2; - area = area + size; } public void methodB() { - size = size + 5; + // compiler error, area cannot be resolved to a variable + // area = area + 2; } - -} +} \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java b/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java index 9bd2268e52..fcd23e5ae0 100644 --- a/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java +++ b/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java @@ -9,5 +9,4 @@ public class NestedScopesExample { String title = "John Doe"; System.out.println(title); } - -} +} \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/scope/OutOfScopeExample.java b/core-java/src/main/java/com/baeldung/scope/OutOfScopeExample.java deleted file mode 100644 index 774095228c..0000000000 --- a/core-java/src/main/java/com/baeldung/scope/OutOfScopeExample.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.variable.scope.examples; - -public class OutOfScopeExample { - - public void methodWithAVariableDeclaredInside() { - String name = "John Doe"; - System.out.println(name); - } - - public void methodWithoutVariables() { - System.out.println("Pattrick"); - } - -} From d16167ea63a6cbef5e665248e94f20decbea4027 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Mon, 14 Jan 2019 00:37:51 +0530 Subject: [PATCH 224/441] [BAEL-10781] - Added code for spring data rest pagination --- .../java/com/baeldung/config/DbConfig.java | 8 ++-- .../java/com/baeldung/models/Subject.java | 37 +++++++++++++++++++ .../repositories/SubjectRepository.java | 15 ++++++++ 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 spring-data-rest/src/main/java/com/baeldung/models/Subject.java create mode 100644 spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java diff --git a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java b/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java index 26d882d6a0..05fa27bbff 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java +++ b/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java @@ -64,22 +64,22 @@ public class DbConfig { @Configuration @Profile("h2") -@PropertySource("persistence-h2.properties") +@PropertySource("classpath:persistence-h2.properties") class H2Config {} @Configuration @Profile("hsqldb") -@PropertySource("persistence-hsqldb.properties") +@PropertySource("classpath:persistence-hsqldb.properties") class HsqldbConfig {} @Configuration @Profile("derby") -@PropertySource("persistence-derby.properties") +@PropertySource("classpath:persistence-derby.properties") class DerbyConfig {} @Configuration @Profile("sqlite") -@PropertySource("persistence-sqlite.properties") +@PropertySource("classpath:persistence-sqlite.properties") class SqliteConfig {} diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Subject.java b/spring-data-rest/src/main/java/com/baeldung/models/Subject.java new file mode 100644 index 0000000000..b3b9a5b0a0 --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/models/Subject.java @@ -0,0 +1,37 @@ +package com.baeldung.models; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Subject { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private long id; + + @Column(nullable = false) + private String name; + + public Subject() { + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java b/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java new file mode 100644 index 0000000000..a91ae2d505 --- /dev/null +++ b/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java @@ -0,0 +1,15 @@ +package com.baeldung.repositories; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RestResource; +import com.baeldung.models.Subject; + +public interface SubjectRepository extends PagingAndSortingRepository { + + @RestResource(path = "nameContains") + public Page findByNameContaining(@Param("name") String name, Pageable p); + +} \ No newline at end of file From e7412182a9e7f8d5e5ab13760b23580aad940d24 Mon Sep 17 00:00:00 2001 From: fanatixan Date: Sun, 13 Jan 2019 22:27:07 +0100 Subject: [PATCH 225/441] bael-2508 - Stream.peek() examples (#6132) * bael-2508 - Stream.peek() examples * beal-2508 additional example * bael-2508 moving examples --- .../com/baeldung/stream/PeekUnitTest.java | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 java-streams/src/test/java/com/baeldung/stream/PeekUnitTest.java diff --git a/java-streams/src/test/java/com/baeldung/stream/PeekUnitTest.java b/java-streams/src/test/java/com/baeldung/stream/PeekUnitTest.java new file mode 100644 index 0000000000..a3a2816e9c --- /dev/null +++ b/java-streams/src/test/java/com/baeldung/stream/PeekUnitTest.java @@ -0,0 +1,118 @@ +package com.baeldung.stream; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.StringWriter; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PeekUnitTest { + + private StringWriter out; + + @BeforeEach + void setup() { + out = new StringWriter(); + } + + @Test + void givenStringStream_whenCallingPeekOnly_thenNoElementProcessed() { + // given + Stream nameStream = Stream.of("Alice", "Bob", "Chuck"); + + // when + nameStream.peek(out::append); + + // then + assertThat(out.toString()).isEmpty(); + } + + @Test + void givenStringStream_whenCallingForEachOnly_thenElementsProcessed() { + // given + Stream nameStream = Stream.of("Alice", "Bob", "Chuck"); + + // when + nameStream.forEach(out::append); + + // then + assertThat(out.toString()).isEqualTo("AliceBobChuck"); + } + + @Test + void givenStringStream_whenCallingPeekAndNoopForEach_thenElementsProcessed() { + // given + Stream nameStream = Stream.of("Alice", "Bob", "Chuck"); + + // when + nameStream.peek(out::append) + .forEach(this::noop); + + // then + assertThat(out.toString()).isEqualTo("AliceBobChuck"); + } + + @Test + void givenStringStream_whenCallingPeekAndCollect_thenElementsProcessed() { + // given + Stream nameStream = Stream.of("Alice", "Bob", "Chuck"); + + // when + nameStream.peek(out::append) + .collect(Collectors.toList()); + + // then + assertThat(out.toString()).isEqualTo("AliceBobChuck"); + } + + @Test + void givenStringStream_whenCallingPeekAndForEach_thenElementsProcessedTwice() { + // given + Stream nameStream = Stream.of("Alice", "Bob", "Chuck"); + + // when + nameStream.peek(out::append) + .forEach(out::append); + + // then + assertThat(out.toString()).isEqualTo("AliceAliceBobBobChuckChuck"); + } + + @Test + void givenStringStream_whenCallingPeek_thenElementsProcessedTwice() { + // given + Stream userStream = Stream.of(new User("Alice"), new User("Bob"), new User("Chuck")); + + // when + userStream.peek(u -> u.setName(u.getName().toLowerCase())) + .map(User::getName) + .forEach(out::append); + + // then + assertThat(out.toString()).isEqualTo("alicebobchuck"); + } + + private static class User { + private String name; + + public User(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + } + + private void noop(String s) { + } + +} From c9275edf90db9fc2c8d22ce7dd6f1f7780401605 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Mon, 14 Jan 2019 11:53:53 +0400 Subject: [PATCH 226/441] matching for all keywords --- .../java/com/baeldung/string/MatchWords.java | 51 +++++++++++++------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index 0b803da0ae..9374ef84a2 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -1,6 +1,7 @@ package com.baeldung.string; import org.ahocorasick.trie.Emit; +import org.ahocorasick.trie.Token; import org.ahocorasick.trie.Trie; import java.util.*; @@ -17,7 +18,7 @@ public class MatchWords { containsWords(inputString, words); - containsWordsJava8(new ArrayList<>(Arrays.asList(inputString.split(" "))), new ArrayList<>(Arrays.asList(words))); + containsWordsJava8(inputString, words); containsWordsPatternMatch(inputString, words); @@ -52,36 +53,56 @@ public class MatchWords { private static boolean containsWordsAhoCorasick(String inputString, String[] words) { Trie trie = Trie.builder() .onlyWholeWords() - .addKeyword(words[0]) - .addKeyword(words[1]) - .ignoreOverlaps() + .addKeywords(words) .build(); - Collection emits = trie.parseText(inputString) - .stream() - .filter(e -> !Objects.equals(e.getKeyword(), e.getKeyword())) - .collect(Collectors.toList()); - + Collection emits = trie.parseText(inputString); emits.forEach(System.out::println); - return emits.size() == words.length; + boolean found = true; + for(String word : words) { + boolean contains = Arrays.toString(emits.toArray()).contains(word); + if (!contains) { + found = false; + break; + } + } + + return found; } private static boolean containsWordsPatternMatch(String inputString, String[] words) { - Pattern pattern = Pattern.compile("(?=.*" + words[0] + ")(?=.*" + words[1] + ")"); + StringBuilder regexp = new StringBuilder(); + for (String word : words) { + regexp.append("(?=.*").append(word).append(")"); + } + Pattern pattern = Pattern.compile(regexp.toString()); if (pattern.matcher(inputString).find()) { return true; } return false; } - private static boolean containsWordsJava8(ArrayList inputString, ArrayList words) { - return words.stream().allMatch(inputString::contains); + private static boolean containsWordsJava8(String inputString, String[] words) { + ArrayList inputStringList = new ArrayList<>(Arrays.asList(inputString.split(" "))); + ArrayList wordsList = new ArrayList<>(Arrays.asList(words)); + + return wordsList.stream().allMatch(inputStringList::contains); } - private static boolean containsWordsArray(ArrayList inputString, ArrayList words) { - return inputString.containsAll(words); + private static boolean containsWordsArray(String inputString, String[] words) { + ArrayList inputStringList = new ArrayList<>(Arrays.asList(inputString.split(" "))); + ArrayList wordsList = new ArrayList<>(Arrays.asList(words)); + + return inputStringList.containsAll(wordsList); + } + + private static boolean containsAnyWord(String inputString, String[] words) { + ArrayList inputStringList = new ArrayList<>(Arrays.asList(inputString.split(" "))); + ArrayList wordsList = new ArrayList<>(Arrays.asList(words)); + + return inputStringList.contains(wordsList); } } From aa125c6c6b4820fd5c2e058071ab169e345e533e Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Mon, 14 Jan 2019 11:58:31 +0400 Subject: [PATCH 227/441] remove unnecessary method --- .../src/main/java/com/baeldung/string/MatchWords.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index 9374ef84a2..647b60af9a 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -77,6 +77,7 @@ public class MatchWords { for (String word : words) { regexp.append("(?=.*").append(word).append(")"); } + Pattern pattern = Pattern.compile(regexp.toString()); if (pattern.matcher(inputString).find()) { return true; @@ -97,12 +98,4 @@ public class MatchWords { return inputStringList.containsAll(wordsList); } - - private static boolean containsAnyWord(String inputString, String[] words) { - ArrayList inputStringList = new ArrayList<>(Arrays.asList(inputString.split(" "))); - ArrayList wordsList = new ArrayList<>(Arrays.asList(words)); - - return inputStringList.contains(wordsList); - } - } From 2db589c5b47ee20cbc7b3e82d857bd261938dd0d Mon Sep 17 00:00:00 2001 From: amdegregorio Date: Mon, 14 Jan 2019 13:35:07 -0500 Subject: [PATCH 228/441] Updated to use Streams in convertToCSV for BAEL-2499 --- .../com/baeldung/csv/WriteCsvFileExample.java | 16 ++++++---------- .../csv/WriteCsvFileExampleUnitTest.java | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java index e1237481b1..f409d05b06 100644 --- a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java +++ b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java @@ -1,18 +1,14 @@ package com.baeldung.csv; +import java.util.stream.Collectors; +import java.util.stream.Stream; + public class WriteCsvFileExample { public String convertToCSV(String[] data) { - StringBuilder csvLine = new StringBuilder(); - - for (int i = 0; i < data.length; i++) { - if (i > 0) { - csvLine.append(","); - } - csvLine.append(escapeSpecialCharacters(data[i])); - } - - return csvLine.toString(); + return Stream.of(data) + .map(this::escapeSpecialCharacters) + .collect(Collectors.joining(",")); } public String escapeSpecialCharacters(String data) { diff --git a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java index e30ec0818c..0658ec6101 100644 --- a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java @@ -65,7 +65,7 @@ public class WriteCsvFileExampleUnitTest { } @Test - public void givenBufferedWriter_whenWriteLine_thenOutputCreated() { + public void givenDataArray_whenConvertToCSV_thenOutputCreated() { List dataLines = new ArrayList(); dataLines.add(new String[] { "John", "Doe", "38", "Comment Data\nAnother line of comment data" }); dataLines.add(new String[] { "Jane", "Doe, Jr.", "19", "She said \"I'm being quoted\"" }); From a480f7b8d326b794e8003d54b0543380da2c4a64 Mon Sep 17 00:00:00 2001 From: Tom Hombergs Date: Mon, 14 Jan 2019 20:48:58 +0100 Subject: [PATCH 229/441] added link --- core-java-concurrency-basic/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-java-concurrency-basic/README.md b/core-java-concurrency-basic/README.md index 1c43149d03..ad3de4a758 100644 --- a/core-java-concurrency-basic/README.md +++ b/core-java-concurrency-basic/README.md @@ -14,4 +14,5 @@ - [ExecutorService - Waiting for Threads to Finish](http://www.baeldung.com/java-executor-wait-for-threads) - [wait and notify() Methods in Java](http://www.baeldung.com/java-wait-notify) - [Life Cycle of a Thread in Java](http://www.baeldung.com/java-thread-lifecycle) -- [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable) \ No newline at end of file +- [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable) +- [What is Thread-Safety and How to Achieve it](https://www.baeldung.com/java-thread-safety) From d7bfa764629815684c6588ade9dc32eca58280f3 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Mon, 14 Jan 2019 22:21:27 +0200 Subject: [PATCH 230/441] Update README.md --- libraries-data/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries-data/README.md b/libraries-data/README.md index 69856af66b..077961f887 100644 --- a/libraries-data/README.md +++ b/libraries-data/README.md @@ -15,3 +15,4 @@ - [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) From 18e1a3067d660556d3c6e1b78debc64f525266d8 Mon Sep 17 00:00:00 2001 From: freddyaott Date: Tue, 15 Jan 2019 04:04:54 +0100 Subject: [PATCH 231/441] [BAEL-2270] Guide to XMPP Smack Client (#5959) Smack Library - Simple chat client --- libraries/log4j.properties | 4 + libraries/pom.xml | 25 ++++++ .../java/com/baeldung/smack/StanzaThread.java | 40 +++++++++ .../baeldung/smack/SmackIntegrationTest.java | 85 +++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 libraries/src/main/java/com/baeldung/smack/StanzaThread.java create mode 100644 libraries/src/test/java/com/baeldung/smack/SmackIntegrationTest.java diff --git a/libraries/log4j.properties b/libraries/log4j.properties index 2173c5d96f..ed367509d1 100644 --- a/libraries/log4j.properties +++ b/libraries/log4j.properties @@ -1 +1,5 @@ log4j.rootLogger=INFO, stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/libraries/pom.xml b/libraries/pom.xml index c7ef64bc59..301fa86c8d 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -675,6 +675,30 @@ ${mockftpserver.version} test + + + org.igniterealtime.smack + smack-tcp + ${smack.version} + + + + org.igniterealtime.smack + smack-im + ${smack.version} + + + + org.igniterealtime.smack + smack-extensions + ${smack.version} + + + + org.igniterealtime.smack + smack-java7 + ${smack.version} + @@ -896,6 +920,7 @@ 1.1.0 2.7.1 3.6 + 4.3.1 diff --git a/libraries/src/main/java/com/baeldung/smack/StanzaThread.java b/libraries/src/main/java/com/baeldung/smack/StanzaThread.java new file mode 100644 index 0000000000..72db258164 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/smack/StanzaThread.java @@ -0,0 +1,40 @@ +package com.baeldung.smack; + +import org.jivesoftware.smack.AbstractXMPPConnection; +import org.jivesoftware.smack.chat2.Chat; +import org.jivesoftware.smack.chat2.ChatManager; +import org.jivesoftware.smack.tcp.XMPPTCPConnection; +import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; +import org.jxmpp.jid.impl.JidCreate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class StanzaThread implements Runnable { + + private Logger logger = LoggerFactory.getLogger(StanzaThread.class); + + @Override + public void run() { + XMPPTCPConnectionConfiguration config = null; + try { + config = XMPPTCPConnectionConfiguration.builder() + .setUsernameAndPassword("baeldung2","baeldung2") + .setXmppDomain("jabb3r.org") + .setHost("jabb3r.org") + .build(); + + AbstractXMPPConnection connection = new XMPPTCPConnection(config); + connection.connect(); + connection.login(); + + ChatManager chatManager = ChatManager.getInstanceFor(connection); + + Chat chat = chatManager.chatWith(JidCreate.from("baeldung@jabb3r.org").asEntityBareJidOrThrow()); + + chat.send("Hello!"); + + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } +} diff --git a/libraries/src/test/java/com/baeldung/smack/SmackIntegrationTest.java b/libraries/src/test/java/com/baeldung/smack/SmackIntegrationTest.java new file mode 100644 index 0000000000..1e5e36ce24 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/smack/SmackIntegrationTest.java @@ -0,0 +1,85 @@ +package com.baeldung.smack; + +import org.jivesoftware.smack.AbstractXMPPConnection; +import org.jivesoftware.smack.SmackException; +import org.jivesoftware.smack.XMPPException; +import org.jivesoftware.smack.chat2.ChatManager; +import org.jivesoftware.smack.filter.StanzaTypeFilter; +import org.jivesoftware.smack.packet.Message; +import org.jivesoftware.smack.tcp.XMPPTCPConnection; +import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.jxmpp.stringprep.XmppStringprepException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.concurrent.CountDownLatch; + +public class SmackIntegrationTest { + + private static AbstractXMPPConnection connection; + private Logger logger = LoggerFactory.getLogger(SmackIntegrationTest.class); + + @BeforeClass + public static void setup() throws IOException, InterruptedException, XMPPException, SmackException { + + XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder() + .setUsernameAndPassword("baeldung","baeldung") + .setXmppDomain("jabb3r.org") + .setHost("jabb3r.org") + .build(); + + XMPPTCPConnectionConfiguration config2 = XMPPTCPConnectionConfiguration.builder() + .setUsernameAndPassword("baeldung2","baeldung2") + .setXmppDomain("jabb3r.org") + .setHost("jabb3r.org") + .build(); + + connection = new XMPPTCPConnection(config); + connection.connect(); + connection.login(); + + } + + @Test + public void whenSendMessageWithChat_thenReceiveMessage() throws XmppStringprepException, InterruptedException { + + CountDownLatch latch = new CountDownLatch(1); + ChatManager chatManager = ChatManager.getInstanceFor(connection); + final String[] expected = {null}; + + new StanzaThread().run(); + + chatManager.addIncomingListener((entityBareJid, message, chat) -> { + logger.info("Message arrived: " + message.getBody()); + expected[0] = message.getBody(); + latch.countDown(); + }); + + latch.await(); + Assert.assertEquals("Hello!", expected[0]); + } + + @Test + public void whenSendMessage_thenReceiveMessageWithFilter() throws XmppStringprepException, InterruptedException { + + CountDownLatch latch = new CountDownLatch(1); + final String[] expected = {null}; + + new StanzaThread().run(); + + connection.addAsyncStanzaListener(stanza -> { + if (stanza instanceof Message) { + Message message = (Message) stanza; + expected[0] = message.getBody(); + latch.countDown(); + } + }, StanzaTypeFilter.MESSAGE); + + latch.await(); + Assert.assertEquals("Hello!", expected[0]); + } +} From 2e2f3bc4a95f83b91188b5ea7ee75e7913d3fe03 Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Tue, 15 Jan 2019 17:14:03 +0530 Subject: [PATCH 232/441] BAEL-2408 Java Project Loom --- .../java/com/baeldung/loom/AsyncThreads.java | 22 +++++++++++++ .../com/baeldung/loom/BlockingThreads.java | 33 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 libraries/src/main/java/com/baeldung/loom/AsyncThreads.java create mode 100644 libraries/src/main/java/com/baeldung/loom/BlockingThreads.java diff --git a/libraries/src/main/java/com/baeldung/loom/AsyncThreads.java b/libraries/src/main/java/com/baeldung/loom/AsyncThreads.java new file mode 100644 index 0000000000..1ec448be69 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/loom/AsyncThreads.java @@ -0,0 +1,22 @@ +package com.baeldung.loom; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +public class AsyncThreads { + + public static void main(String[] args) throws ExecutionException, InterruptedException { + + CompletableFuture cf = CompletableFuture.runAsync(() -> { + + System.out.println("Hello " + Thread.currentThread().getName()); + }); + + cf.thenRun(() -> { + + System.out.println("World " + Thread.currentThread().getName()); + }); + + cf.get(); + } +} diff --git a/libraries/src/main/java/com/baeldung/loom/BlockingThreads.java b/libraries/src/main/java/com/baeldung/loom/BlockingThreads.java new file mode 100644 index 0000000000..de11529753 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/loom/BlockingThreads.java @@ -0,0 +1,33 @@ +package com.baeldung.loom; + +public class BlockingThreads { + + private static final Object LOCK = new Object(); + + public static void main(String[] args) throws InterruptedException { + + Thread thread1 = new Thread(() -> { + synchronized (LOCK) { + System.out.println("Hello " + Thread.currentThread().getName()); + LOCK.notify(); + } + }); + + + Thread thread2 = new Thread(() -> { + synchronized (LOCK) { + try { + System.out.println("Will wait for thread1 now..."); + LOCK.wait(); + System.out.println("World " + Thread.currentThread().getName()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + thread2.start(); + thread1.start(); + + } +} From e7301029c346147df75c1b256a7ee8b50fc273b3 Mon Sep 17 00:00:00 2001 From: soufiane-cheouati <46105138+soufiane-cheouati@users.noreply.github.com> Date: Tue, 15 Jan 2019 16:37:38 +0000 Subject: [PATCH 233/441] Adding new methods for calculating the sum (#6088) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Creating new module Creating new module for Hexagonal Architecture * Adding Java classes Adding Java classes used in the example * Adding the pom.xml file Adding the pom.xml file. * Update the pom.xml file Update the pom.xml file * BAEL-2498: Creating new folder Creating new folder for Java 8 sum with Streams examples * BAEL-2498: Uploading java Classes Adding the Java classes containing examples of different methods to calculate the sum using Java 8 Streams * BAEL-2498: Creating new folder Creating new folder for sum unit tests * BAEL-2498: Adding the unit tests Adding the unit tests for the methods that calculate the sum using the Java Streams * Add files via Upload - Adding a method for calculating the sum of a map´s values - Adding a method for calculating the sum of numbers within a String object * Add files via upload - Adding a method for calculating the sum of a map´s values - Adding a method for calculating the sum of numbers within a String object * Delete . ... * Delete pom.xml * Delete User.java * Delete UserControler.java * Delete UserDataBaseAdapter.java * Delete UserInterfaceAdapter.java * Delete UserDataBasePort.java * Delete UserInterfacePort.java * Delete UserService.java --- .../main/java/com/baeldung/stream/sum/. .. | 1 + .../baeldung/stream/sum/ArithmeticUtils.java | 8 ++ .../java/com/baeldung/stream/sum/Item.java | 31 ++++ .../stream/sum/StreamSumCalculator.java | 59 ++++++++ .../sum/StreamSumCalculatorWithObject.java | 38 +++++ .../test/java/com/baeldung/stream/sum/. .. | 1 + .../stream/sum/StreamSumUnitTest.java | 136 ++++++++++++++++++ 7 files changed, 274 insertions(+) create mode 100644 java-streams/src/main/java/com/baeldung/stream/sum/. .. create mode 100644 java-streams/src/main/java/com/baeldung/stream/sum/ArithmeticUtils.java create mode 100644 java-streams/src/main/java/com/baeldung/stream/sum/Item.java create mode 100644 java-streams/src/main/java/com/baeldung/stream/sum/StreamSumCalculator.java create mode 100644 java-streams/src/main/java/com/baeldung/stream/sum/StreamSumCalculatorWithObject.java create mode 100644 java-streams/src/test/java/com/baeldung/stream/sum/. .. create mode 100644 java-streams/src/test/java/com/baeldung/stream/sum/StreamSumUnitTest.java diff --git a/java-streams/src/main/java/com/baeldung/stream/sum/. .. b/java-streams/src/main/java/com/baeldung/stream/sum/. .. new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/java-streams/src/main/java/com/baeldung/stream/sum/. .. @@ -0,0 +1 @@ + diff --git a/java-streams/src/main/java/com/baeldung/stream/sum/ArithmeticUtils.java b/java-streams/src/main/java/com/baeldung/stream/sum/ArithmeticUtils.java new file mode 100644 index 0000000000..3170b1fb31 --- /dev/null +++ b/java-streams/src/main/java/com/baeldung/stream/sum/ArithmeticUtils.java @@ -0,0 +1,8 @@ +package com.baeldung.stream.sum; + +public class ArithmeticUtils { + + public static int add(int a, int b) { + return a + b; + } +} diff --git a/java-streams/src/main/java/com/baeldung/stream/sum/Item.java b/java-streams/src/main/java/com/baeldung/stream/sum/Item.java new file mode 100644 index 0000000000..2f162d6eda --- /dev/null +++ b/java-streams/src/main/java/com/baeldung/stream/sum/Item.java @@ -0,0 +1,31 @@ +package com.baeldung.stream.sum; + +public class Item { + + private int id; + private Integer price; + + public Item(int id, Integer price) { + super(); + this.id = id; + this.price = price; + } + + // Standard getters and setters + public long getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } + +} diff --git a/java-streams/src/main/java/com/baeldung/stream/sum/StreamSumCalculator.java b/java-streams/src/main/java/com/baeldung/stream/sum/StreamSumCalculator.java new file mode 100644 index 0000000000..2f63cf8629 --- /dev/null +++ b/java-streams/src/main/java/com/baeldung/stream/sum/StreamSumCalculator.java @@ -0,0 +1,59 @@ +package com.baeldung.stream.sum; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class StreamSumCalculator { + + public static Integer getSumUsingCustomizedAccumulator(List integers) { + return integers.stream() + .reduce(0, ArithmeticUtils::add); + + } + + public static Integer getSumUsingJavaAccumulator(List integers) { + return integers.stream() + .reduce(0, Integer::sum); + + } + + public static Integer getSumUsingReduce(List integers) { + return integers.stream() + .reduce(0, (a, b) -> a + b); + + } + + public static Integer getSumUsingCollect(List integers) { + + return integers.stream() + .collect(Collectors.summingInt(Integer::intValue)); + + } + + public static Integer getSumUsingSum(List integers) { + + return integers.stream() + .mapToInt(Integer::intValue) + .sum(); + } + + public static Integer getSumOfMapValues(Map map) { + + return map.values() + .stream() + .mapToInt(Integer::valueOf) + .sum(); + } + + public static Integer getSumIntegersFromString(String str) { + + Integer sum = Arrays.stream(str.split(" ")) + .filter((s) -> s.matches("\\d+")) + .mapToInt(Integer::valueOf) + .sum(); + + return sum; + } +} diff --git a/java-streams/src/main/java/com/baeldung/stream/sum/StreamSumCalculatorWithObject.java b/java-streams/src/main/java/com/baeldung/stream/sum/StreamSumCalculatorWithObject.java new file mode 100644 index 0000000000..b83616928e --- /dev/null +++ b/java-streams/src/main/java/com/baeldung/stream/sum/StreamSumCalculatorWithObject.java @@ -0,0 +1,38 @@ +package com.baeldung.stream.sum; + +import java.util.List; +import java.util.stream.Collectors; + +public class StreamSumCalculatorWithObject { + + public static Integer getSumUsingCustomizedAccumulator(List items) { + return items.stream() + .map(x -> x.getPrice()) + .reduce(0, ArithmeticUtils::add); + } + + public static Integer getSumUsingJavaAccumulator(List items) { + return items.stream() + .map(x -> x.getPrice()) + .reduce(0, Integer::sum); + } + + public static Integer getSumUsingReduce(List items) { + return items.stream() + .map(item -> item.getPrice()) + .reduce(0, (a, b) -> a + b); + } + + public static Integer getSumUsingCollect(List items) { + return items.stream() + .map(x -> x.getPrice()) + .collect(Collectors.summingInt(Integer::intValue)); + } + + public static Integer getSumUsingSum(List items) { + return items.stream() + .mapToInt(x -> x.getPrice()) + .sum(); + } + +} diff --git a/java-streams/src/test/java/com/baeldung/stream/sum/. .. b/java-streams/src/test/java/com/baeldung/stream/sum/. .. new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/java-streams/src/test/java/com/baeldung/stream/sum/. .. @@ -0,0 +1 @@ + diff --git a/java-streams/src/test/java/com/baeldung/stream/sum/StreamSumUnitTest.java b/java-streams/src/test/java/com/baeldung/stream/sum/StreamSumUnitTest.java new file mode 100644 index 0000000000..46e1af9a4a --- /dev/null +++ b/java-streams/src/test/java/com/baeldung/stream/sum/StreamSumUnitTest.java @@ -0,0 +1,136 @@ +package com.baeldung.stream.sum; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +public class StreamSumUnitTest { + + @Test + public void givenListOfIntegersWhenSummingUsingCustomizedAccumulatorThenCorrectValueReturned() { + List integers = Arrays.asList(1, 2, 3, 4, 5); + Integer sum = StreamSumCalculator.getSumUsingCustomizedAccumulator(integers); + assertEquals(15, sum.intValue()); + + } + + @Test + public void givenListOfIntegersWhenSummingUsingJavaAccumulatorThenCorrectValueReturned() { + List integers = Arrays.asList(1, 2, 3, 4, 5); + Integer sum = StreamSumCalculator.getSumUsingJavaAccumulator(integers); + assertEquals(15, sum.intValue()); + } + + @Test + public void givenListOfIntegersWhenSummingUsingReduceThenCorrectValueReturned() { + List integers = Arrays.asList(1, 2, 3, 4, 5); + Integer sum = StreamSumCalculator.getSumUsingReduce(integers); + assertEquals(15, sum.intValue()); + } + + @Test + public void givenListOfIntegersWhenSummingUsingCollectThenCorrectValueReturned() { + List integers = Arrays.asList(1, 2, 3, 4, 5); + Integer sum = StreamSumCalculator.getSumUsingCollect(integers); + assertEquals(15, sum.intValue()); + } + + @Test + public void givenListOfIntegersWhenSummingUsingSumThenCorrectValueReturned() { + List integers = Arrays.asList(1, 2, 3, 4, 5); + Integer sum = StreamSumCalculator.getSumUsingSum(integers); + assertEquals(15, sum.intValue()); + } + + @Test + public void givenListOfItemsWhenSummingUsingCustomizedAccumulatorThenCorrectValueReturned() { + Item item1 = new Item(1, 10); + Item item2 = new Item(2, 15); + Item item3 = new Item(3, 25); + Item item4 = new Item(4, 40); + + List items = Arrays.asList(item1, item2, item3, item4); + + Integer sum = StreamSumCalculatorWithObject.getSumUsingCustomizedAccumulator(items); + assertEquals(90, sum.intValue()); + + } + + @Test + public void givenListOfItemsWhenSummingUsingJavaAccumulatorThenCorrectValueReturned() { + Item item1 = new Item(1, 10); + Item item2 = new Item(2, 15); + Item item3 = new Item(3, 25); + Item item4 = new Item(4, 40); + + List items = Arrays.asList(item1, item2, item3, item4); + + Integer sum = StreamSumCalculatorWithObject.getSumUsingJavaAccumulator(items); + assertEquals(90, sum.intValue()); + } + + @Test + public void givenListOfItemsWhenSummingUsingReduceThenCorrectValueReturned() { + Item item1 = new Item(1, 10); + Item item2 = new Item(2, 15); + Item item3 = new Item(3, 25); + Item item4 = new Item(4, 40); + + List items = Arrays.asList(item1, item2, item3, item4); + + Integer sum = StreamSumCalculatorWithObject.getSumUsingReduce(items); + assertEquals(90, sum.intValue()); + } + + @Test + public void givenListOfItemsWhenSummingUsingCollectThenCorrectValueReturned() { + Item item1 = new Item(1, 10); + Item item2 = new Item(2, 15); + Item item3 = new Item(3, 25); + Item item4 = new Item(4, 40); + + List items = Arrays.asList(item1, item2, item3, item4); + + Integer sum = StreamSumCalculatorWithObject.getSumUsingCollect(items); + assertEquals(90, sum.intValue()); + } + + @Test + public void givenListOfItemsWhenSummingUsingSumThenCorrectValueReturned() { + Item item1 = new Item(1, 10); + Item item2 = new Item(2, 15); + Item item3 = new Item(3, 25); + Item item4 = new Item(4, 40); + + List items = Arrays.asList(item1, item2, item3, item4); + + Integer sum = StreamSumCalculatorWithObject.getSumUsingSum(items); + assertEquals(90, sum.intValue()); + } + + @Test + public void givenMapWhenSummingThenCorrectValueReturned() { + Map map = new HashMap(); + map.put(1, 10); + map.put(2, 15); + map.put(3, 25); + map.put(4, 40); + + Integer sum = StreamSumCalculator.getSumOfMapValues(map); + assertEquals(90, sum.intValue()); + } + + @Test + public void givenStringWhenSummingThenCorrectValueReturned() { + String string = "Item1 10 Item2 25 Item3 30 Item4 45"; + + Integer sum = StreamSumCalculator.getSumIntegersFromString(string); + assertEquals(110, sum.intValue()); + } + +} From 0bfa50825bad3bd4bdb98712c7ff6e419f95d9dd Mon Sep 17 00:00:00 2001 From: Amy DeGregorio Date: Tue, 15 Jan 2019 15:31:37 -0500 Subject: [PATCH 234/441] BAEL-2499 Write to CSV in Java - updated (#6135) * example code for Article How to Write to a CSV File in Java * Updated to use a Stream * Updated to use Streams in convertToCSV for BAEL-2499 --- .../com/baeldung/csv/WriteCsvFileExample.java | 16 ++++++---------- .../csv/WriteCsvFileExampleUnitTest.java | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java index e1237481b1..f409d05b06 100644 --- a/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java +++ b/core-java-io/src/main/java/com/baeldung/csv/WriteCsvFileExample.java @@ -1,18 +1,14 @@ package com.baeldung.csv; +import java.util.stream.Collectors; +import java.util.stream.Stream; + public class WriteCsvFileExample { public String convertToCSV(String[] data) { - StringBuilder csvLine = new StringBuilder(); - - for (int i = 0; i < data.length; i++) { - if (i > 0) { - csvLine.append(","); - } - csvLine.append(escapeSpecialCharacters(data[i])); - } - - return csvLine.toString(); + return Stream.of(data) + .map(this::escapeSpecialCharacters) + .collect(Collectors.joining(",")); } public String escapeSpecialCharacters(String data) { diff --git a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java index e30ec0818c..0658ec6101 100644 --- a/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/csv/WriteCsvFileExampleUnitTest.java @@ -65,7 +65,7 @@ public class WriteCsvFileExampleUnitTest { } @Test - public void givenBufferedWriter_whenWriteLine_thenOutputCreated() { + public void givenDataArray_whenConvertToCSV_thenOutputCreated() { List dataLines = new ArrayList(); dataLines.add(new String[] { "John", "Doe", "38", "Comment Data\nAnother line of comment data" }); dataLines.add(new String[] { "Jane", "Doe, Jr.", "19", "She said \"I'm being quoted\"" }); From 4c9ea991cc5edacd714fc566ce572a417181ce0c Mon Sep 17 00:00:00 2001 From: PRIFTI Date: Tue, 15 Jan 2019 21:38:40 +0100 Subject: [PATCH 235/441] BAEL-2441: Providing example for Implementing simple State Machine with Java Enums. --- .../enumstatemachine/LeaveRequestState.java | 46 +++++++++++++++++++ .../LeaveRequestStateTest.java | 41 +++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestState.java create mode 100644 algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java diff --git a/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestState.java b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestState.java new file mode 100644 index 0000000000..5153c2e18e --- /dev/null +++ b/algorithms-miscellaneous-1/src/main/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestState.java @@ -0,0 +1,46 @@ +package com.baeldung.algorithms.enumstatemachine; + +public enum LeaveRequestState { + + Submitted { + @Override + public LeaveRequestState nextState() { + System.out.println("Starting the Leave Request and sending to Team Leader for approval."); + return Escalated; + } + + @Override + public String responsiblePerson() { + return "Employee"; + } + }, + Escalated { + @Override + public LeaveRequestState nextState() { + System.out.println("Reviewing the Leave Request and escalating to Department Manager."); + return Approved; + } + + @Override + public String responsiblePerson() { + return "Team Leader"; + } + }, + Approved { + @Override + public LeaveRequestState nextState() { + System.out.println("Approving the Leave Request."); + return this; + } + + @Override + public String responsiblePerson() { + return "Department Manager"; + } + }; + + public abstract String responsiblePerson(); + + public abstract LeaveRequestState nextState(); + +} diff --git a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java new file mode 100644 index 0000000000..b209dcb2fb --- /dev/null +++ b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java @@ -0,0 +1,41 @@ +package com.baeldung.algorithms.enumstatemachine; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class LeaveRequestStateTest { + + @Test + public void givenLeaveRequest_whenStateEscalated_thenResponsibleIsTeamLeader() { + LeaveRequestState state = LeaveRequestState.Escalated; + + String responsible = state.responsiblePerson(); + + assertEquals(responsible, "Team Leader"); + } + + + @Test + public void givenLeaveRequest_whenStateApproved_thenResponsibleIsDepartmentManager() { + LeaveRequestState state = LeaveRequestState.Approved; + + String responsible = state.responsiblePerson(); + + assertEquals(responsible, "Department Manager"); + } + + @Test + public void givenLeaveRequest_whenNextStateIsCalled_thenStateIsChanged() { + LeaveRequestState state = LeaveRequestState.Submitted; + + state = state.nextState(); + assertEquals(state, LeaveRequestState.Escalated); + + state = state.nextState(); + assertEquals(state, LeaveRequestState.Approved); + + state = state.nextState(); + assertEquals(state, LeaveRequestState.Approved); + } +} From 22e98e06eafae25dbbf7a9eaaf7e858d4b11d519 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Tue, 15 Jan 2019 18:45:36 -0200 Subject: [PATCH 236/441] Removed most exception handlers from spring-rest-full (except the ones used in other articles) and moved them to spring-boot-rest --- .../RestResponseEntityExceptionHandler.java | 86 +++++++++++++++++++ .../web/exception/MyDataAccessException.java | 21 +++++ .../MyDataIntegrityViolationException.java | 21 +++++ .../MyResourceNotFoundException.java | 21 +++++ spring-rest-full/.attach_pid28499 | 0 spring-rest-full/pom.xml | 43 ---------- .../RestResponseEntityExceptionHandler.java | 61 +------------ ...{TestSuite.java => TestSuiteLiveTest.java} | 6 +- ...tSuite.java => LiveTestSuiteLiveTest.java} | 2 +- 9 files changed, 154 insertions(+), 107 deletions(-) create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataAccessException.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataIntegrityViolationException.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java create mode 100644 spring-rest-full/.attach_pid28499 rename spring-rest-full/src/test/java/org/baeldung/{TestSuite.java => TestSuiteLiveTest.java} (68%) rename spring-rest-full/src/test/java/org/baeldung/web/{LiveTestSuite.java => LiveTestSuiteLiveTest.java} (87%) diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-boot-rest/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java new file mode 100644 index 0000000000..fe0465156d --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -0,0 +1,86 @@ +package com.baeldung.web.error; + +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +import com.baeldung.web.exception.MyDataAccessException; +import com.baeldung.web.exception.MyDataIntegrityViolationException; +import com.baeldung.web.exception.MyResourceNotFoundException; + +@ControllerAdvice +public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { + + public RestResponseEntityExceptionHandler() { + super(); + } + + // API + + // 400 + /* + * Some examples of exceptions that we could retrieve as 400 (BAD_REQUEST) responses: + * Hibernate's ConstraintViolationException + * Spring's DataIntegrityViolationException + */ + @ExceptionHandler({ MyDataIntegrityViolationException.class }) + public ResponseEntity handleBadRequest(final MyDataIntegrityViolationException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); + } + + @Override + protected ResponseEntity handleHttpMessageNotReadable(final HttpMessageNotReadableException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + // ex.getCause() instanceof JsonMappingException, JsonParseException // for additional information later on + return handleExceptionInternal(ex, bodyOfResponse, headers, HttpStatus.BAD_REQUEST, request); + } + + @Override + protected ResponseEntity handleMethodArgumentNotValid(final MethodArgumentNotValidException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, headers, HttpStatus.BAD_REQUEST, request); + } + + + // 404 + /* + * Some examples of exceptions that we could retrieve as 404 (NOT_FOUND) responses: + * Java Persistence's EntityNotFoundException + */ + @ExceptionHandler(value = { MyResourceNotFoundException.class }) + protected ResponseEntity handleNotFound(final RuntimeException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request); + } + + // 409 + /* + * Some examples of exceptions that we could retrieve as 409 (CONFLICT) responses: + * Spring's InvalidDataAccessApiUsageException + * Spring's DataAccessException + */ + @ExceptionHandler({ MyDataAccessException.class}) + protected ResponseEntity handleConflict(final RuntimeException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.CONFLICT, request); + } + + // 412 + + // 500 + + @ExceptionHandler({ NullPointerException.class, IllegalArgumentException.class, IllegalStateException.class }) + /*500*/public ResponseEntity handleInternal(final RuntimeException ex, final WebRequest request) { + logger.error("500 Status Code", ex); + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request); + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataAccessException.java b/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataAccessException.java new file mode 100644 index 0000000000..8fc9a3a0ea --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataAccessException.java @@ -0,0 +1,21 @@ +package com.baeldung.web.exception; + +public final class MyDataAccessException extends RuntimeException { + + public MyDataAccessException() { + super(); + } + + public MyDataAccessException(final String message, final Throwable cause) { + super(message, cause); + } + + public MyDataAccessException(final String message) { + super(message); + } + + public MyDataAccessException(final Throwable cause) { + super(cause); + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataIntegrityViolationException.java b/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataIntegrityViolationException.java new file mode 100644 index 0000000000..50adb09c09 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataIntegrityViolationException.java @@ -0,0 +1,21 @@ +package com.baeldung.web.exception; + +public final class MyDataIntegrityViolationException extends RuntimeException { + + public MyDataIntegrityViolationException() { + super(); + } + + public MyDataIntegrityViolationException(final String message, final Throwable cause) { + super(message, cause); + } + + public MyDataIntegrityViolationException(final String message) { + super(message); + } + + public MyDataIntegrityViolationException(final Throwable cause) { + super(cause); + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java b/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java new file mode 100644 index 0000000000..fd002efc28 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java @@ -0,0 +1,21 @@ +package com.baeldung.web.exception; + +public final class MyResourceNotFoundException extends RuntimeException { + + public MyResourceNotFoundException() { + super(); + } + + public MyResourceNotFoundException(final String message, final Throwable cause) { + super(message, cause); + } + + public MyResourceNotFoundException(final String message) { + super(message); + } + + public MyResourceNotFoundException(final Throwable cause) { + super(cause); + } + +} diff --git a/spring-rest-full/.attach_pid28499 b/spring-rest-full/.attach_pid28499 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spring-rest-full/pom.xml b/spring-rest-full/pom.xml index 81c938a289..ddc7e042b5 100644 --- a/spring-rest-full/pom.xml +++ b/spring-rest-full/pom.xml @@ -212,23 +212,6 @@ org.apache.maven.plugins maven-war-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - 3 - true - - **/*IntegrationTest.java - **/*IntTest.java - **/*LongRunningUnitTest.java - **/*ManualTest.java - **/*LiveTest.java - **/*TestSuite.java - - - org.codehaus.cargo cargo-maven2-plugin @@ -274,32 +257,6 @@ live - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*IntegrationTest.java - **/*IntTest.java - - - **/*LiveTest.java - - - - - - - json - - - org.codehaus.cargo cargo-maven2-plugin diff --git a/spring-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java index b593116c4a..c0639acef4 100644 --- a/spring-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java +++ b/spring-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -1,17 +1,9 @@ package org.baeldung.web.error; -import javax.persistence.EntityNotFoundException; - import org.baeldung.web.exception.MyResourceNotFoundException; -import org.hibernate.exception.ConstraintViolationException; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.context.request.WebRequest; @@ -24,61 +16,10 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH super(); } - // API - - // 400 - - @ExceptionHandler({ ConstraintViolationException.class }) - public ResponseEntity handleBadRequest(final ConstraintViolationException ex, final WebRequest request) { - final String bodyOfResponse = "This should be application specific"; - return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); - } - - @ExceptionHandler({ DataIntegrityViolationException.class }) - public ResponseEntity handleBadRequest(final DataIntegrityViolationException ex, final WebRequest request) { - final String bodyOfResponse = "This should be application specific"; - return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); - } - - @Override - protected ResponseEntity handleHttpMessageNotReadable(final HttpMessageNotReadableException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { - final String bodyOfResponse = "This should be application specific"; - // ex.getCause() instanceof JsonMappingException, JsonParseException // for additional information later on - return handleExceptionInternal(ex, bodyOfResponse, headers, HttpStatus.BAD_REQUEST, request); - } - - @Override - protected ResponseEntity handleMethodArgumentNotValid(final MethodArgumentNotValidException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { - final String bodyOfResponse = "This should be application specific"; - return handleExceptionInternal(ex, bodyOfResponse, headers, HttpStatus.BAD_REQUEST, request); - } - - - // 404 - - @ExceptionHandler(value = { EntityNotFoundException.class, MyResourceNotFoundException.class }) + @ExceptionHandler(value = { MyResourceNotFoundException.class }) protected ResponseEntity handleNotFound(final RuntimeException ex, final WebRequest request) { final String bodyOfResponse = "This should be application specific"; return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request); } - // 409 - - @ExceptionHandler({ InvalidDataAccessApiUsageException.class, DataAccessException.class }) - protected ResponseEntity handleConflict(final RuntimeException ex, final WebRequest request) { - final String bodyOfResponse = "This should be application specific"; - return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.CONFLICT, request); - } - - // 412 - - // 500 - - @ExceptionHandler({ NullPointerException.class, IllegalArgumentException.class, IllegalStateException.class }) - /*500*/public ResponseEntity handleInternal(final RuntimeException ex, final WebRequest request) { - logger.error("500 Status Code", ex); - final String bodyOfResponse = "This should be application specific"; - return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request); - } - } diff --git a/spring-rest-full/src/test/java/org/baeldung/TestSuite.java b/spring-rest-full/src/test/java/org/baeldung/TestSuiteLiveTest.java similarity index 68% rename from spring-rest-full/src/test/java/org/baeldung/TestSuite.java rename to spring-rest-full/src/test/java/org/baeldung/TestSuiteLiveTest.java index cd5fa4661f..76215bb6e3 100644 --- a/spring-rest-full/src/test/java/org/baeldung/TestSuite.java +++ b/spring-rest-full/src/test/java/org/baeldung/TestSuiteLiveTest.java @@ -1,7 +1,7 @@ package org.baeldung; import org.baeldung.persistence.PersistenceTestSuite; -import org.baeldung.web.LiveTestSuite; +import org.baeldung.web.LiveTestSuiteLiveTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -9,8 +9,8 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ // @formatter:off PersistenceTestSuite.class - ,LiveTestSuite.class + ,LiveTestSuiteLiveTest.class }) // -public class TestSuite { +public class TestSuiteLiveTest { } diff --git a/spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuite.java b/spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuiteLiveTest.java similarity index 87% rename from spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuite.java rename to spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuiteLiveTest.java index 6d5b94a686..71a61ed338 100644 --- a/spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuite.java +++ b/spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuiteLiveTest.java @@ -10,6 +10,6 @@ import org.junit.runners.Suite; ,FooLiveTest.class ,FooPageableLiveTest.class }) // -public class LiveTestSuite { +public class LiveTestSuiteLiveTest { } From 9f798d483d03f07d179dd5542101af8eaa1fd9ef Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Wed, 16 Jan 2019 13:18:04 +0400 Subject: [PATCH 237/441] test the methods with Unit test --- .../java/com/baeldung/string/MatchWords.java | 27 ++------- .../baeldung/string/MatchWordsUnitTest.java | 59 +++++++++++++++++++ 2 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index 647b60af9a..d322d192fa 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -12,22 +12,7 @@ import java.util.stream.Stream; public class MatchWords { - public static void main(String[] args) { - String[] words = {"hello", "Baeldung"}; - String inputString = "hello there, Baeldung"; - - containsWords(inputString, words); - - containsWordsJava8(inputString, words); - - containsWordsPatternMatch(inputString, words); - - containsWordsAhoCorasick(inputString, words); - - containsWordsIndexOf(inputString, words); - } - - private static boolean containsWordsIndexOf(String inputString, String[] words) { + public static boolean containsWordsIndexOf(String inputString, String[] words) { boolean found = true; for (String word : words) { int index = inputString.indexOf(word); @@ -39,7 +24,7 @@ public class MatchWords { return found; } - private static boolean containsWords(String inputString, String[] items) { + public static boolean containsWords(String inputString, String[] items) { boolean found = true; for (String item : items) { if (!inputString.contains(item)) { @@ -50,7 +35,7 @@ public class MatchWords { return found; } - private static boolean containsWordsAhoCorasick(String inputString, String[] words) { + public static boolean containsWordsAhoCorasick(String inputString, String[] words) { Trie trie = Trie.builder() .onlyWholeWords() .addKeywords(words) @@ -71,7 +56,7 @@ public class MatchWords { return found; } - private static boolean containsWordsPatternMatch(String inputString, String[] words) { + public static boolean containsWordsPatternMatch(String inputString, String[] words) { StringBuilder regexp = new StringBuilder(); for (String word : words) { @@ -85,14 +70,14 @@ public class MatchWords { return false; } - private static boolean containsWordsJava8(String inputString, String[] words) { + public static boolean containsWordsJava8(String inputString, String[] words) { ArrayList inputStringList = new ArrayList<>(Arrays.asList(inputString.split(" "))); ArrayList wordsList = new ArrayList<>(Arrays.asList(words)); return wordsList.stream().allMatch(inputStringList::contains); } - private static boolean containsWordsArray(String inputString, String[] words) { + public static boolean containsWordsArray(String inputString, String[] words) { ArrayList inputStringList = new ArrayList<>(Arrays.asList(inputString.split(" "))); ArrayList wordsList = new ArrayList<>(Arrays.asList(words)); diff --git a/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java b/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java new file mode 100644 index 0000000000..0b25a265b3 --- /dev/null +++ b/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java @@ -0,0 +1,59 @@ +package com.baeldung.string; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MatchWordsUnitTest { + + private final String[] words = {"hello", "Baeldung"}; + private final String inputString = "hello there, Baeldung"; + + @Test + public void givenText_whenCallingStringContains_shouldMatchWords() { + + final boolean result = MatchWords.containsWords(inputString, words); + + assertThat(result).isEqualTo(true); + } + + @Test + public void givenText_whenCallingJava8_shouldMatchWords() { + + final boolean result = MatchWords.containsWordsJava8(inputString, words); + + assertThat(result).isEqualTo(true); + } + + @Test + public void givenText_whenCallingPattern_shouldMatchWords() { + + final boolean result = MatchWords.containsWordsPatternMatch(inputString, words); + + assertThat(result).isEqualTo(true); + } + + @Test + public void givenText_whenCallingAhoCorasick_shouldMatchWords() { + + final boolean result = MatchWords.containsWordsAhoCorasick(inputString, words); + + assertThat(result).isEqualTo(true); + } + + @Test + public void givenText_whenCallingIndexOf_shouldMatchWords() { + + final boolean result = MatchWords.containsWordsIndexOf(inputString, words); + + assertThat(result).isEqualTo(true); + } + + @Test + public void givenText_whenCallingArrayList_shouldMatchWords() { + + final boolean result = MatchWords.containsWordsArray(inputString, words); + + assertThat(result).isEqualTo(true); + } +} From 438ff48c275d1d1dd92bbf3e210b300b422c19d7 Mon Sep 17 00:00:00 2001 From: cror Date: Wed, 16 Jan 2019 17:09:44 +0100 Subject: [PATCH 238/441] BAEL-2546: added Stream.count examples --- .../stream/filter/StreamCountUnitTest.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 java-streams/src/test/java/com/baeldung/stream/filter/StreamCountUnitTest.java diff --git a/java-streams/src/test/java/com/baeldung/stream/filter/StreamCountUnitTest.java b/java-streams/src/test/java/com/baeldung/stream/filter/StreamCountUnitTest.java new file mode 100644 index 0000000000..1cad710e14 --- /dev/null +++ b/java-streams/src/test/java/com/baeldung/stream/filter/StreamCountUnitTest.java @@ -0,0 +1,72 @@ +package com.baeldung.stream.filter; + +import org.junit.Test; +import org.junit.Before; + +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class StreamCountUnitTest { + + private List customers; + + @Before + public void setUp() { + Customer john = new Customer("John P.", 15, "https://images.unsplash.com/photo-1543320485-d0d5a49c2b2e"); + Customer sarah = new Customer("Sarah M.", 200); + Customer charles = new Customer("Charles B.", 150); + Customer mary = new Customer("Mary T.", 1, "https://images.unsplash.com/photo-1543297057-25167dfc180e"); + customers = Arrays.asList(john, sarah, charles, mary); + } + + @Test + public void givenListOfCustomers_whenCount_thenGetListSize() { + long count = customers + .stream() + .count(); + + assertThat(count).isEqualTo(4L); + } + + @Test + public void givenListOfCustomers_whenFilterByPointsOver100AndCount_thenGetTwo() { + long countBigCustomers = customers + .stream() + .filter(c -> c.getPoints() > 100) + .count(); + + assertThat(countBigCustomers).isEqualTo(2L); + } + + @Test + public void givenListOfCustomers_whenFilterByPointsAndNameAndCount_thenGetOne() { + long count = customers + .stream() + .filter(c -> c.getPoints() > 10 && c.getName().startsWith("Charles")) + .count(); + + assertThat(count).isEqualTo(1L); + } + + @Test + public void givenListOfCustomers_whenNoneMatchesFilterAndCount_thenGetZero() { + long count = customers + .stream() + .filter(c -> c.getPoints() > 500) + .count(); + + assertThat(count).isEqualTo(0L); + } + + @Test + public void givenListOfCustomers_whenUsingMethodOverHundredPointsAndCount_thenGetTwo() { + long count = customers + .stream() + .filter(Customer::hasOverThousandPoints) + .count(); + + assertThat(count).isEqualTo(2L); + } +} From 2b7e66a3989bebd92e76d4d116f74b72db2edcc4 Mon Sep 17 00:00:00 2001 From: cror Date: Wed, 16 Jan 2019 17:14:35 +0100 Subject: [PATCH 239/441] renaming method according to content: thousand -> hundred --- .../src/main/java/com/baeldung/stream/filter/Customer.java | 2 +- .../java/com/baeldung/stream/filter/StreamCountUnitTest.java | 2 +- .../java/com/baeldung/stream/filter/StreamFilterUnitTest.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/java-streams/src/main/java/com/baeldung/stream/filter/Customer.java b/java-streams/src/main/java/com/baeldung/stream/filter/Customer.java index 49da6e7175..fd4f6021ff 100644 --- a/java-streams/src/main/java/com/baeldung/stream/filter/Customer.java +++ b/java-streams/src/main/java/com/baeldung/stream/filter/Customer.java @@ -32,7 +32,7 @@ public class Customer { return this.points > points; } - public boolean hasOverThousandPoints() { + public boolean hasOverHundredPoints() { return this.points > 100; } diff --git a/java-streams/src/test/java/com/baeldung/stream/filter/StreamCountUnitTest.java b/java-streams/src/test/java/com/baeldung/stream/filter/StreamCountUnitTest.java index 1cad710e14..742e5aedc9 100644 --- a/java-streams/src/test/java/com/baeldung/stream/filter/StreamCountUnitTest.java +++ b/java-streams/src/test/java/com/baeldung/stream/filter/StreamCountUnitTest.java @@ -64,7 +64,7 @@ public class StreamCountUnitTest { public void givenListOfCustomers_whenUsingMethodOverHundredPointsAndCount_thenGetTwo() { long count = customers .stream() - .filter(Customer::hasOverThousandPoints) + .filter(Customer::hasOverHundredPoints) .count(); assertThat(count).isEqualTo(2L); diff --git a/java-streams/src/test/java/com/baeldung/stream/filter/StreamFilterUnitTest.java b/java-streams/src/test/java/com/baeldung/stream/filter/StreamFilterUnitTest.java index cf82802940..29190f7298 100644 --- a/java-streams/src/test/java/com/baeldung/stream/filter/StreamFilterUnitTest.java +++ b/java-streams/src/test/java/com/baeldung/stream/filter/StreamFilterUnitTest.java @@ -62,7 +62,7 @@ public class StreamFilterUnitTest { List customersWithMoreThan100Points = customers .stream() - .filter(Customer::hasOverThousandPoints) + .filter(Customer::hasOverHundredPoints) .collect(Collectors.toList()); assertThat(customersWithMoreThan100Points).hasSize(2); @@ -81,7 +81,7 @@ public class StreamFilterUnitTest { .flatMap(c -> c .map(Stream::of) .orElseGet(Stream::empty)) - .filter(Customer::hasOverThousandPoints) + .filter(Customer::hasOverHundredPoints) .collect(Collectors.toList()); assertThat(customersWithMoreThan100Points).hasSize(2); From 212ea5d83b68a5b053a3cda462bed2d3b9b1086b Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Thu, 17 Jan 2019 00:30:52 +0530 Subject: [PATCH 240/441] BAEL-2129 Added Unit test for Void Type in Kotlin article (#5944) --- .../baeldung/voidtypes/VoidTypesUnitTest.kt | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 core-kotlin/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt new file mode 100644 index 0000000000..5c285c3135 --- /dev/null +++ b/core-kotlin/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt @@ -0,0 +1,51 @@ +package com.baeldung.voidtypes + +import org.junit.jupiter.api.Test +import kotlin.test.assertNull +import kotlin.test.assertTrue + +class VoidTypesUnitTest { + + fun returnTypeAsVoid(): Void? { + println("Function can have Void as return type") + return null + } + + fun unitReturnTypeForNonMeaningfulReturns(): Unit { + println("No meaningful return") + } + + fun unitReturnTypeIsImplicit() { + println("Unit Return type is implicit") + } + + fun alwaysThrowException(): Nothing { + throw IllegalArgumentException() + } + + fun invokeANothingOnlyFunction() { + alwaysThrowException() + + var name = "Tom" + } + + @Test + fun givenJavaVoidFunction_thenMappedToKotlinUnit() { + assertTrue(System.out.println() is Unit) + } + + @Test + fun givenVoidReturnType_thenReturnsNullOnly() { + assertNull(returnTypeAsVoid()) + } + + @Test + fun givenUnitReturnTypeDeclared_thenReturnsOfTypeUnit() { + assertTrue(unitReturnTypeForNonMeaningfulReturns() is Unit) + } + + @Test + fun givenUnitReturnTypeNotDeclared_thenReturnsOfTypeUnit() { + assertTrue(unitReturnTypeIsImplicit() is Unit) + } +} \ No newline at end of file From e6e0c065d509357f6a04bef853ad0f52c4c9e420 Mon Sep 17 00:00:00 2001 From: Rajesh Bhojwani Date: Thu, 17 Jan 2019 15:17:09 +0530 Subject: [PATCH 241/441] Added test file to demo the deletion of file content --- .../file/FilesClearDataManualTest.java | 98 +++++++++++++++++++ .../src/test/resources/fileexample.txt | 1 + 2 files changed, 99 insertions(+) create mode 100644 core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java create mode 100644 core-java-io/src/test/resources/fileexample.txt diff --git a/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java b/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java new file mode 100644 index 0000000000..8a4b3a7380 --- /dev/null +++ b/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java @@ -0,0 +1,98 @@ +package com.baeldung.file; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.channels.FileChannel; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; + +import org.apache.commons.io.FileUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.baeldung.util.StreamUtils; + +public class FilesClearDataManualTest { + + public static final String FILE_PATH = "src/test/resources/fileexample.txt"; + + @Before + @After + public void setup() throws IOException { + PrintWriter writer = new PrintWriter(FILE_PATH); + writer.print("This example shows how we can delete the file contents without deleting the file"); + writer.close(); + } + + @Test + public void givenExistingFile_whenDeleteContentUsingPrintWritter_thenEmptyFile() throws IOException { + PrintWriter writer = new PrintWriter(FILE_PATH); + writer.print(""); + writer.close(); + assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); + } + + @Test + public void givenExistingFile_whenDeleteContentUsingPrintWritterWithougObject_thenEmptyFile() throws IOException { + new PrintWriter(FILE_PATH).close(); + assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); + } + + + @Test + public void givenExistingFile_whenDeleteContentUsingFileWriter_thenEmptyFile() throws IOException { + new FileWriter(FILE_PATH, false).close(); + + assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); + } + + @Test + public void givenExistingFile_whenDeleteContentUsingFileOutputStream_thenEmptyFile() throws IOException { + new FileOutputStream(FILE_PATH).close(); + + assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); + } + + @Test + public void givenExistingFile_whenDeleteContentUsingFileUtils_thenEmptyFile() throws IOException { + FileUtils.write(new File(FILE_PATH), "", Charset.defaultCharset()); + + assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); + } + + @Test + public void givenExistingFile_whenDeleteContentUsingNIOFiles_thenEmptyFile() throws IOException { + BufferedWriter writer = Files.newBufferedWriter(Paths.get(FILE_PATH)); + writer.write(""); + writer.flush(); + + assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); + } + + @Test + public void givenExistingFile_whenDeleteContentUsingNIOFileChannel_thenEmptyFile() throws IOException { + FileChannel.open(Paths.get(FILE_PATH), StandardOpenOption.WRITE).truncate(0).close(); + + assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); + } + + @Test + public void givenExistingFile_whenDeleteContentUsingGuava_thenEmptyFile() throws IOException { + File file = new File(FILE_PATH); + byte[] empty = new byte[0]; + com.google.common.io.Files.write(empty, file); + + assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); + } + +} diff --git a/core-java-io/src/test/resources/fileexample.txt b/core-java-io/src/test/resources/fileexample.txt new file mode 100644 index 0000000000..ee48fdfb84 --- /dev/null +++ b/core-java-io/src/test/resources/fileexample.txt @@ -0,0 +1 @@ +This example shows how we can delete the file contents without deleting the file \ No newline at end of file From 273c569b88de74d048a1b7989021c686c9764dbf Mon Sep 17 00:00:00 2001 From: Rajesh Bhojwani Date: Thu, 17 Jan 2019 15:20:25 +0530 Subject: [PATCH 242/441] remove space --- .../test/java/com/baeldung/file/FilesClearDataManualTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java b/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java index 8a4b3a7380..c00290168c 100644 --- a/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java +++ b/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java @@ -47,7 +47,6 @@ public class FilesClearDataManualTest { new PrintWriter(FILE_PATH).close(); assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); } - @Test public void givenExistingFile_whenDeleteContentUsingFileWriter_thenEmptyFile() throws IOException { From b47140fdd2607b6565df0c49bda7933ab2300252 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 17 Jan 2019 15:44:27 +0100 Subject: [PATCH 243/441] Delete . .. --- java-streams/src/main/java/com/baeldung/stream/sum/. .. | 1 - 1 file changed, 1 deletion(-) delete mode 100644 java-streams/src/main/java/com/baeldung/stream/sum/. .. diff --git a/java-streams/src/main/java/com/baeldung/stream/sum/. .. b/java-streams/src/main/java/com/baeldung/stream/sum/. .. deleted file mode 100644 index 8b13789179..0000000000 --- a/java-streams/src/main/java/com/baeldung/stream/sum/. .. +++ /dev/null @@ -1 +0,0 @@ - From af1636fe23675e77fbb914d11c4f745978ed1a4e Mon Sep 17 00:00:00 2001 From: "Erick Audet M.Sc" Date: Thu, 17 Jan 2019 12:21:30 -0500 Subject: [PATCH 244/441] BAEL-2509 * New section in InputStream to byte array article and recreating branch. * Minor typo * Code reformat using intellij formatter. * Code reformat using intellij formatter. * guava implementation to be completed * guava implementation * Added assert to guava test * Fix formatting * Formatting using Baeldung format * Based on Josh comments, I removed some code BAEL-2509 * Removed all references to File * Update fork from upstream * Update fork from upstream * Merhe Upstream * Remove all references to FileInputStream (Josh Comments) * Delete CustomBaeldungQueueUnitTest.java --- .../io/InputStreamToByteBufferUnitTest.java | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java b/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java index fedadde04b..37f52fefea 100644 --- a/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java +++ b/core-java-io/src/test/java/org/baeldung/java/io/InputStreamToByteBufferUnitTest.java @@ -1,60 +1,56 @@ package org.baeldung.java.io; - +import com.google.common.io.ByteSource; import com.google.common.io.ByteStreams; import org.apache.commons.io.IOUtils; -import org.junit.jupiter.api.Test; +import org.junit.Test; -import java.io.File; -import java.io.FileInputStream; +import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.channels.ReadableByteChannel; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static java.nio.channels.Channels.newChannel; +import static org.junit.Assert.assertEquals; -class InputStreamToByteBufferUnitTest { +public class InputStreamToByteBufferUnitTest { @Test - public void givenUsingCoreClasses_whenWritingAFileIntoAByteBuffer_thenBytesLengthMustMatch() throws IOException { - File inputFile = getFile(); - ByteBuffer bufferByte = ByteBuffer.allocate((int) inputFile.length()); - FileInputStream in = new FileInputStream(inputFile); - in.getChannel().read(bufferByte); + public void givenUsingCoreClasses_whenByteArrayInputStreamToAByteBuffer_thenLengthMustMatch() throws IOException { + byte[] input = new byte[] { 0, 1, 2 }; + InputStream initialStream = new ByteArrayInputStream(input); + ByteBuffer byteBuffer = ByteBuffer.allocate(3); + while (initialStream.available() > 0) { + byteBuffer.put((byte) initialStream.read()); + } - assertEquals(bufferByte.position(), inputFile.length()); + assertEquals(byteBuffer.position(), input.length); } @Test - public void givenUsingCommonsIo_whenWritingAFileIntoAByteBuffer_thenBytesLengthMustMatch() throws IOException { - File inputFile = getFile(); - ByteBuffer bufferByte = ByteBuffer.allocateDirect((int) inputFile.length()); - ReadableByteChannel readableByteChannel = new FileInputStream(inputFile).getChannel(); - IOUtils.readFully(readableByteChannel, bufferByte); - - assertEquals(bufferByte.position(), inputFile.length()); - } - - @Test - public void givenUsingGuava_whenWritingAFileIntoAByteBuffer_thenBytesLengthMustMatch() throws IOException { - File inputFile = getFile(); - FileInputStream in = new FileInputStream(inputFile); - byte[] targetArray = ByteStreams.toByteArray(in); + public void givenUsingGuava__whenByteArrayInputStreamToAByteBuffer_thenLengthMustMatch() throws IOException { + InputStream initialStream = ByteSource + .wrap(new byte[] { 0, 1, 2 }) + .openStream(); + byte[] targetArray = ByteStreams.toByteArray(initialStream); ByteBuffer bufferByte = ByteBuffer.wrap(targetArray); - bufferByte.rewind(); while (bufferByte.hasRemaining()) { bufferByte.get(); } - - assertEquals(bufferByte.position(), inputFile.length()); + + assertEquals(bufferByte.position(), targetArray.length); } - private File getFile() { - ClassLoader classLoader = new InputStreamToByteBufferUnitTest().getClass().getClassLoader(); + @Test + public void givenUsingCommonsIo_whenByteArrayInputStreamToAByteBuffer_thenLengthMustMatch() throws IOException { + byte[] input = new byte[] { 0, 1, 2 }; + InputStream initialStream = new ByteArrayInputStream(input); + ByteBuffer byteBuffer = ByteBuffer.allocate(3); + ReadableByteChannel channel = newChannel(initialStream); + IOUtils.readFully(channel, byteBuffer); - String fileName = "frontenac-2257154_960_720.jpg"; - - return new File(classLoader.getResource(fileName).getFile()); + assertEquals(byteBuffer.position(), input.length); } } From 684ee6040e4fad45a30da1d7d46b86ce49913b34 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Thu, 17 Jan 2019 17:44:49 -0200 Subject: [PATCH 245/441] Added example for spring boot exception handling --- spring-boot-rest/README.md | 1 + spring-boot-rest/pom.xml | 11 ++++ .../boot/ErrorHandlingBootApplication.java | 15 +++++ .../MyCustomErrorAttributes.java | 23 +++++++ .../configurations/MyErrorController.java | 31 +++++++++ .../boot/web/FaultyRestController.java | 15 +++++ .../web/SpringBootRestApplication.java | 2 +- .../errorhandling-application.properties | 3 + .../boot/ErrorHandlingLiveTest.java | 65 +++++++++++++++++++ .../web/SpringContextIntegrationTest.java | 2 +- spring-rest-full/README.md | 1 - 11 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/web/FaultyRestController.java create mode 100644 spring-boot-rest/src/main/resources/errorhandling-application.properties create mode 100644 spring-boot-rest/src/test/java/com/baeldung/errorhandling/boot/ErrorHandlingLiveTest.java diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index 0a8d13cf76..2b955ddc5b 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -1,3 +1,4 @@ Module for the articles that 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. [Error Handling for REST with Spring](http://www.baeldung.com/exception-handling-for-rest-with-spring) diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index baf9d35a09..3b8cf7e39e 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -20,12 +20,22 @@ org.springframework.boot spring-boot-starter-web + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + org.springframework.boot spring-boot-starter-test test + + net.sourceforge.htmlunit + htmlunit + ${htmlunit.version} + test + @@ -39,5 +49,6 @@ com.baeldung.SpringBootRestApplication + 2.32 diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java new file mode 100644 index 0000000000..0885ecbbf7 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.errorhandling.boot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; + +@SpringBootApplication +@PropertySource("errorhandling-application.properties") +public class ErrorHandlingBootApplication { + + public static void main(String[] args) { + SpringApplication.run(ErrorHandlingBootApplication.class, args); + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java new file mode 100644 index 0000000000..e2c62cb907 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java @@ -0,0 +1,23 @@ +package com.baeldung.errorhandling.boot.configurations; + +import java.util.Map; + +import org.springframework.boot.web.servlet.error.DefaultErrorAttributes; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.WebRequest; + +@Component +public class MyCustomErrorAttributes extends DefaultErrorAttributes { + + @Override + public Map getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) { + Map errorAttributes = super.getErrorAttributes(webRequest, includeStackTrace); + errorAttributes.put("locale", webRequest.getLocale() + .toString()); + errorAttributes.remove("error"); + errorAttributes.put("cause", errorAttributes.get("message")); + errorAttributes.remove("message"); + errorAttributes.put("status", String.valueOf(errorAttributes.get("status"))); + return errorAttributes; + } +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java new file mode 100644 index 0000000000..427a0b43d7 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java @@ -0,0 +1,31 @@ +package com.baeldung.errorhandling.boot.configurations; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.boot.autoconfigure.web.ErrorProperties; +import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; + +@Component +public class MyErrorController extends BasicErrorController { + + public MyErrorController(ErrorAttributes errorAttributes) { + super(errorAttributes, new ErrorProperties()); + } + + @RequestMapping(produces = MediaType.APPLICATION_XML_VALUE) + public ResponseEntity> xmlError(HttpServletRequest request) { + Map body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.APPLICATION_XML)); + body.put("xmlkey", "the XML response is different!"); + HttpStatus status = getStatus(request); + return new ResponseEntity<>(body, status); + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/web/FaultyRestController.java b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/web/FaultyRestController.java new file mode 100644 index 0000000000..e56e395754 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/web/FaultyRestController.java @@ -0,0 +1,15 @@ +package com.baeldung.errorhandling.boot.web; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class FaultyRestController { + + @GetMapping("/exception") + public ResponseEntity requestWithException() { + throw new NullPointerException("Error in the faulty controller!"); + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java b/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java index 62aae7619d..c945b20aa1 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.web; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-boot-rest/src/main/resources/errorhandling-application.properties b/spring-boot-rest/src/main/resources/errorhandling-application.properties new file mode 100644 index 0000000000..994c517163 --- /dev/null +++ b/spring-boot-rest/src/main/resources/errorhandling-application.properties @@ -0,0 +1,3 @@ + +#server.error.whitelabel.enabled=false +#server.error.include-stacktrace=always \ No newline at end of file diff --git a/spring-boot-rest/src/test/java/com/baeldung/errorhandling/boot/ErrorHandlingLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/errorhandling/boot/ErrorHandlingLiveTest.java new file mode 100644 index 0000000000..e587b67fcf --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/errorhandling/boot/ErrorHandlingLiveTest.java @@ -0,0 +1,65 @@ +package com.baeldung.errorhandling.boot; + +import static io.restassured.RestAssured.given; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasKey; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.isA; +import static org.hamcrest.Matchers.not; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; + +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlPage; + +public class ErrorHandlingLiveTest { + + private static final String BASE_URL = "http://localhost:8080"; + private static final String EXCEPTION_ENDPOINT = "/exception"; + + private static final String ERROR_RESPONSE_KEY_PATH = "error"; + private static final String XML_RESPONSE_KEY_PATH = "xmlkey"; + private static final String LOCALE_RESPONSE_KEY_PATH = "locale"; + private static final String CAUSE_RESPONSE_KEY_PATH = "cause"; + private static final String RESPONSE_XML_ROOT = "Map"; + private static final String XML_RESPONSE_KEY_XML_PATH = RESPONSE_XML_ROOT + "." + XML_RESPONSE_KEY_PATH; + private static final String LOCALE_RESPONSE_KEY_XML_PATH = RESPONSE_XML_ROOT + "." + LOCALE_RESPONSE_KEY_PATH; + private static final String CAUSE_RESPONSE_KEY_XML_PATH = RESPONSE_XML_ROOT + "." + CAUSE_RESPONSE_KEY_PATH; + private static final String CAUSE_RESPONSE_VALUE = "Error in the faulty controller!"; + private static final String XML_RESPONSE_VALUE = "the XML response is different!"; + + @Test + public void whenRequestingFaultyEndpointAsJson_thenReceiveDefaultResponseWithConfiguredAttrs() { + given().header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE) + .get(EXCEPTION_ENDPOINT) + .then() + .body("$", hasKey(LOCALE_RESPONSE_KEY_PATH)) + .body(CAUSE_RESPONSE_KEY_PATH, is(CAUSE_RESPONSE_VALUE)) + .body("$", not(hasKey(ERROR_RESPONSE_KEY_PATH))) + .body("$", not(hasKey(XML_RESPONSE_KEY_PATH))); + } + + @Test + public void whenRequestingFaultyEndpointAsXml_thenReceiveXmlResponseWithConfiguredAttrs() { + given().header(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML_VALUE) + .get(EXCEPTION_ENDPOINT) + .then() + .body(LOCALE_RESPONSE_KEY_XML_PATH, isA(String.class)) + .body(CAUSE_RESPONSE_KEY_XML_PATH, is(CAUSE_RESPONSE_VALUE)) + .body(RESPONSE_XML_ROOT, not(hasKey(ERROR_RESPONSE_KEY_PATH))) + .body(XML_RESPONSE_KEY_XML_PATH, is(XML_RESPONSE_VALUE)); + } + + @Test + public void whenRequestingFaultyEndpointAsHtml_thenReceiveWhitelabelPageResponse() throws Exception { + try (WebClient webClient = new WebClient()) { + webClient.getOptions() + .setThrowExceptionOnFailingStatusCode(false); + HtmlPage page = webClient.getPage(BASE_URL + EXCEPTION_ENDPOINT); + assertThat(page.getBody() + .asText()).contains("Whitelabel Error Page"); + } + } +} diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java index 0c1fdf372b..1e49df2909 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.boot.rest; +package com.baeldung.web; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-rest-full/README.md b/spring-rest-full/README.md index d429e17671..3a8d0a727a 100644 --- a/spring-rest-full/README.md +++ b/spring-rest-full/README.md @@ -18,7 +18,6 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com - [Metrics for your Spring REST API](http://www.baeldung.com/spring-rest-api-metrics) - [Bootstrap a Web Application with Spring 4](http://www.baeldung.com/bootstraping-a-web-application-with-spring-and-java-based-configuration) - [Build a REST API with Spring and Java Config](http://www.baeldung.com/building-a-restful-web-service-with-spring-and-java-based-configuration) -- [Error Handling for REST with Spring](http://www.baeldung.com/exception-handling-for-rest-with-spring) - [Spring Security Expressions - hasRole Example](https://www.baeldung.com/spring-security-expressions-basic) From 85eab12c0356015c763a97ba9f3deb5bf1b53d42 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 17 Jan 2019 23:22:05 +0200 Subject: [PATCH 246/441] Update and rename LeaveRequestStateTest.java to LeaveRequestStateUnitTest.java --- ...eaveRequestStateTest.java => LeaveRequestStateUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/{LeaveRequestStateTest.java => LeaveRequestStateUnitTest.java} (96%) diff --git a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateUnitTest.java similarity index 96% rename from algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java rename to algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateUnitTest.java index b209dcb2fb..796998907d 100644 --- a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java +++ b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateUnitTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; -public class LeaveRequestStateTest { +public class LeaveRequestStateUnitTest { @Test public void givenLeaveRequest_whenStateEscalated_thenResponsibleIsTeamLeader() { From 735b0a10b28a9868baeab71807e6ff5ab7e57119 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 17 Jan 2019 23:25:26 +0200 Subject: [PATCH 247/441] Update StreamFilterUnitTest.java --- .../java/com/baeldung/stream/filter/StreamFilterUnitTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java-streams/src/test/java/com/baeldung/stream/filter/StreamFilterUnitTest.java b/java-streams/src/test/java/com/baeldung/stream/filter/StreamFilterUnitTest.java index 29190f7298..5ad875f61e 100644 --- a/java-streams/src/test/java/com/baeldung/stream/filter/StreamFilterUnitTest.java +++ b/java-streams/src/test/java/com/baeldung/stream/filter/StreamFilterUnitTest.java @@ -156,4 +156,5 @@ public class StreamFilterUnitTest { }) .collect(Collectors.toList())).isInstanceOf(RuntimeException.class); } + } From 8510b07a5642e261eceb76711c3739e4379d359b Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 17 Jan 2019 23:27:50 +0200 Subject: [PATCH 248/441] Update FilesClearDataManualTest.java --- .../test/java/com/baeldung/file/FilesClearDataManualTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java b/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java index c00290168c..6abe677acf 100644 --- a/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java +++ b/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java @@ -93,5 +93,4 @@ public class FilesClearDataManualTest { assertEquals(0, StreamUtils.getStringFromInputStream(new FileInputStream(FILE_PATH)).length()); } - } From 98c9d22151efa5f098ee46d09511d436ec1e661f Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Thu, 17 Jan 2019 20:06:22 -0600 Subject: [PATCH 249/441] BAEL-2335 and BAEL-2413 README updates (#6152) * BAEL-2246: add link back to article * BAEL-2174: rename core-java-net module to core-java-networking * BAEL-2174: add link back to article * BAEL-2363 BAEL-2337 BAEL-1996 BAEL-2277 add links back to articles * BAEL-2367: add link back to article * BAEL-2335: add link back to article * BAEL-2413: add link back to article * Update README.MD --- core-java-collections-list/README.md | 1 + persistence-modules/spring-boot-persistence/README.MD | 2 ++ 2 files changed, 3 insertions(+) diff --git a/core-java-collections-list/README.md b/core-java-collections-list/README.md index a35e714006..d1112047ba 100644 --- a/core-java-collections-list/README.md +++ b/core-java-collections-list/README.md @@ -26,3 +26,4 @@ - [ClassCastException: Arrays$ArrayList cannot be cast to ArrayList](https://www.baeldung.com/java-classcastexception-arrays-arraylist) - [Flattening Nested Collections in Java](http://www.baeldung.com/java-flatten-nested-collections) - [Intersection of Two Lists in Java](https://www.baeldung.com/java-lists-intersection) +- [Multi Dimensional ArrayList in Java](https://www.baeldung.com/java-multi-dimensional-arraylist) diff --git a/persistence-modules/spring-boot-persistence/README.MD b/persistence-modules/spring-boot-persistence/README.MD index 8988fb4ebd..cab6be1ec8 100644 --- a/persistence-modules/spring-boot-persistence/README.MD +++ b/persistence-modules/spring-boot-persistence/README.MD @@ -5,3 +5,5 @@ - [Quick Guide on data.sql and schema.sql Files in Spring Boot](http://www.baeldung.com/spring-boot-data-sql-and-schema-sql) - [Configuring a Tomcat Connection Pool in Spring Boot](https://www.baeldung.com/spring-boot-tomcat-connection-pool) - [Hibernate Field Naming with Spring Boot](https://www.baeldung.com/hibernate-field-naming-spring-boot) +- [Integrating Spring Boot with HSQLDB](https://www.baeldung.com/spring-boot-hsqldb) + From af9a60bddfa284ceecc9a9396f5350be084186d3 Mon Sep 17 00:00:00 2001 From: Maiklins Date: Fri, 18 Jan 2019 04:31:13 +0100 Subject: [PATCH 250/441] BAEL-2217 forEach within forEach (#6166) --- .../kotlin/com/baeldung/forEach/forEach.kt | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 core-kotlin/src/main/kotlin/com/baeldung/forEach/forEach.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/forEach/forEach.kt b/core-kotlin/src/main/kotlin/com/baeldung/forEach/forEach.kt new file mode 100644 index 0000000000..ef56009c71 --- /dev/null +++ b/core-kotlin/src/main/kotlin/com/baeldung/forEach/forEach.kt @@ -0,0 +1,61 @@ +package com.baeldung.forEach + + +class Country(val name : String, val cities : List) + +class City(val name : String, val streets : List) + +class World { + + private val streetsOfAmsterdam = listOf("Herengracht", "Prinsengracht") + private val streetsOfBerlin = listOf("Unter den Linden","Tiergarten") + private val streetsOfMaastricht = listOf("Grote Gracht", "Vrijthof") + private val countries = listOf( + Country("Netherlands", listOf(City("Maastricht", streetsOfMaastricht), + City("Amsterdam", streetsOfAmsterdam))), + Country("Germany", listOf(City("Berlin", streetsOfBerlin)))) + + fun allCountriesIt() { + countries.forEach { println(it.name) } + } + + fun allCountriesItExplicit() { + countries.forEach { it -> println(it.name) } + } + + //here we cannot refer to 'it' anymore inside the forEach + fun allCountriesExplicit() { + countries.forEach { c -> println(c.name) } + } + + fun allNested() { + countries.forEach { + println(it.name) + it.cities.forEach { + println(" ${it.name}") + it.streets.forEach { println(" $it") } + } + } + } + + fun allTable() { + countries.forEach { c -> + c.cities.forEach { p -> + p.streets.forEach { println("${c.name} ${p.name} $it") } + } + } + } +} + +fun main(args : Array) { + + val world = World() + + world.allCountriesExplicit() + + world.allNested() + + world.allTable() +} + + From d83101854c35218ea54bbaa5f6ce6747d16d44bf Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Fri, 18 Jan 2019 11:05:26 +0400 Subject: [PATCH 251/441] primitive collections libraries added --- core-java-arrays/pom.xml | 16 ++++ .../baeldung/array/PrimitiveCollections.java | 34 ++++++++ .../array/PrimitivesListPerformance.java | 77 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java create mode 100644 core-java-arrays/src/main/java/com/baeldung/array/PrimitivesListPerformance.java diff --git a/core-java-arrays/pom.xml b/core-java-arrays/pom.xml index d2d0453e87..6d4109804e 100644 --- a/core-java-arrays/pom.xml +++ b/core-java-arrays/pom.xml @@ -52,6 +52,22 @@ spring-web ${springframework.spring-web.version} + + + net.sf.trove4j + trove4j + 3.0.2 + + + it.unimi.dsi + fastutil + 8.1.0 + + + colt + colt + 1.2.0 + diff --git a/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java b/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java new file mode 100644 index 0000000000..115c5fe5c3 --- /dev/null +++ b/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java @@ -0,0 +1,34 @@ +package com.baeldung.array; + +import com.google.common.primitives.ImmutableIntArray; +import com.google.common.primitives.Ints; +import gnu.trove.list.array.TIntArrayList; + +import java.util.Arrays; +import java.util.List; + +public class PrimitiveCollections { + + public static void main(String[] args) { + + int[] primitives = new int[] {5, 10, 0, 2}; + + guavaPrimitives(primitives); + + trovePrimitives(primitives); + } + + private static void trovePrimitives(int[] primitives) { + TIntArrayList list = new TIntArrayList(primitives); + } + + private static void guavaPrimitives(int[] primitives) { + + ImmutableIntArray list = ImmutableIntArray.builder().addAll(primitives).build(); + + List integers = Ints.asList(primitives); + + int[] primitive = Ints.toArray(Arrays.asList(1, 2, 3, 4, 5)); + System.out.println(Arrays.toString(primitive)); + } +} diff --git a/core-java-arrays/src/main/java/com/baeldung/array/PrimitivesListPerformance.java b/core-java-arrays/src/main/java/com/baeldung/array/PrimitivesListPerformance.java new file mode 100644 index 0000000000..9db3a75574 --- /dev/null +++ b/core-java-arrays/src/main/java/com/baeldung/array/PrimitivesListPerformance.java @@ -0,0 +1,77 @@ +package com.baeldung.array; + +import it.unimi.dsi.fastutil.ints.IntArrayList; +import gnu.trove.list.array.TIntArrayList; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Warmup(iterations = 10) +public class PrimitivesListPerformance { + + @State(Scope.Thread) + public static class Initialize { + + List arrayList = new ArrayList<>(); + TIntArrayList tList = new TIntArrayList(); + cern.colt.list.IntArrayList coltList = new cern.colt.list.IntArrayList(); + IntArrayList fastUtilList = new IntArrayList(); + + int getValue = 10; + + final int iterations = 100000; + + @Setup(Level.Trial) + public void setUp() { + + for (int i = 0; i < iterations; i++) { + arrayList.add(i); + tList.add(i); + coltList.add(i); + fastUtilList.add(i); + } + + arrayList.add(getValue); + tList.add(getValue); + coltList.add(getValue); + fastUtilList.add(getValue); + } + } + + @Benchmark + public boolean containsArrayList(PrimitivesListPerformance.Initialize state) { + return state.arrayList.contains(state.getValue); + } + + @Benchmark + public boolean containsTIntList(PrimitivesListPerformance.Initialize state) { + return state.tList.contains(state.getValue); + } + + @Benchmark + public boolean containsColtIntList(PrimitivesListPerformance.Initialize state) { + return state.coltList.contains(state.getValue); + } + + @Benchmark + public boolean containsFastUtilIntList(PrimitivesListPerformance.Initialize state) { + return state.fastUtilList.contains(state.getValue); + } + + public static void main(String[] args) throws Exception { + Options options = new OptionsBuilder() + .include(PrimitivesListPerformance.class.getSimpleName()).threads(1) + .forks(1).shouldFailOnError(true) + .shouldDoGC(true) + .jvmArgs("-server").build(); + new Runner(options).run(); + } +} From 97273bab7e5d1d615b5c9d3aae044ca2e7043510 Mon Sep 17 00:00:00 2001 From: PRIFTI Date: Fri, 18 Jan 2019 13:17:52 +0100 Subject: [PATCH 252/441] BAEL-2441: Removed the responsible variable. --- .../enumstatemachine/LeaveRequestStateTest.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java index b209dcb2fb..c246c16912 100644 --- a/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java +++ b/algorithms-miscellaneous-1/src/test/java/com/baeldung/algorithms/enumstatemachine/LeaveRequestStateTest.java @@ -10,9 +10,7 @@ public class LeaveRequestStateTest { public void givenLeaveRequest_whenStateEscalated_thenResponsibleIsTeamLeader() { LeaveRequestState state = LeaveRequestState.Escalated; - String responsible = state.responsiblePerson(); - - assertEquals(responsible, "Team Leader"); + assertEquals(state.responsiblePerson(), "Team Leader"); } @@ -20,9 +18,7 @@ public class LeaveRequestStateTest { public void givenLeaveRequest_whenStateApproved_thenResponsibleIsDepartmentManager() { LeaveRequestState state = LeaveRequestState.Approved; - String responsible = state.responsiblePerson(); - - assertEquals(responsible, "Department Manager"); + assertEquals(state.responsiblePerson(), "Department Manager"); } @Test From eb7cde988bceac9c5eb6f160d6dd186cdd254705 Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Sat, 19 Jan 2019 05:38:13 +0330 Subject: [PATCH 253/441] JUnit 5 parameterized tests Issue: BAEL-1665 --- testing-modules/junit-5/pom.xml | 5 + .../BlankStringsArgumentsProvider.java | 19 +++ .../baeldung/parameterized/EnumsUnitTest.java | 50 ++++++++ .../parameterized/LocalDateUnitTest.java | 18 +++ .../com/baeldung/parameterized/Numbers.java | 8 ++ .../parameterized/NumbersUnitTest.java | 15 +++ .../com/baeldung/parameterized/Person.java | 20 ++++ .../parameterized/PersonAggregator.java | 15 +++ .../parameterized/PersonUnitTest.java | 31 +++++ .../parameterized/SlashyDateConverter.java | 27 +++++ .../baeldung/parameterized/StringParams.java | 10 ++ .../com/baeldung/parameterized/Strings.java | 8 ++ .../parameterized/StringsUnitTest.java | 108 ++++++++++++++++++ .../VariableArgumentsProvider.java | 45 ++++++++ .../parameterized/VariableSource.java | 19 +++ .../junit-5/src/test/resources/data.csv | 4 + 16 files changed, 402 insertions(+) create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java create mode 100644 testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java create mode 100644 testing-modules/junit-5/src/test/resources/data.csv diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index b7600267d9..a5a1ddaf0b 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -21,6 +21,11 @@ junit-platform-engine ${junit.platform.version} + + org.junit.jupiter + junit-jupiter-params + ${junit.jupiter.version} + org.junit.platform junit-platform-runner diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java new file mode 100644 index 0000000000..1d2c76d37b --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/BlankStringsArgumentsProvider.java @@ -0,0 +1,19 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; + +import java.util.stream.Stream; + +class BlankStringsArgumentsProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) { + return Stream.of( + Arguments.of((String) null), + Arguments.of(""), + Arguments.of(" ") + ); + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java new file mode 100644 index 0000000000..0b2068dbf1 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/EnumsUnitTest.java @@ -0,0 +1,50 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.EnumSource; + +import java.time.Month; +import java.util.EnumSet; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class EnumsUnitTest { + + @ParameterizedTest + @EnumSource(Month.class) + void getValueForAMonth_IsAlwaysBetweenOneAndTwelve(Month month) { + int monthNumber = month.getValue(); + assertTrue(monthNumber >= 1 && monthNumber <= 12); + } + + @ParameterizedTest(name = "{index} {0} is 30 days long") + @EnumSource(value = Month.class, names = {"APRIL", "JUNE", "SEPTEMBER", "NOVEMBER"}) + void someMonths_Are30DaysLong(Month month) { + final boolean isALeapYear = false; + assertEquals(30, month.length(isALeapYear)); + } + + @ParameterizedTest + @EnumSource(value = Month.class, names = {"APRIL", "JUNE", "SEPTEMBER", "NOVEMBER", "FEBRUARY"}, mode = EnumSource.Mode.EXCLUDE) + void exceptFourMonths_OthersAre31DaysLong(Month month) { + final boolean isALeapYear = false; + assertEquals(31, month.length(isALeapYear)); + } + + @ParameterizedTest + @EnumSource(value = Month.class, names = ".+BER", mode = EnumSource.Mode.MATCH_ANY) + void fourMonths_AreEndingWithBer(Month month) { + EnumSet months = EnumSet.of(Month.SEPTEMBER, Month.OCTOBER, Month.NOVEMBER, Month.DECEMBER); + assertTrue(months.contains(month)); + } + + @ParameterizedTest + @CsvSource({"APRIL", "JUNE", "SEPTEMBER", "NOVEMBER"}) + void someMonths_Are30DaysLongCsv(Month month) { + final boolean isALeapYear = false; + assertEquals(30, month.length(isALeapYear)); + } + +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java new file mode 100644 index 0000000000..95487705f5 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/LocalDateUnitTest.java @@ -0,0 +1,18 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; +import org.junit.jupiter.params.provider.CsvSource; + +import java.time.LocalDate; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class LocalDateUnitTest { + + @ParameterizedTest + @CsvSource({"2018/12/25,2018", "2019/02/11,2019"}) + void getYear_ShouldWorkAsExpected(@ConvertWith(SlashyDateConverter.class) LocalDate date, int expected) { + assertEquals(expected, date.getYear()); + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java new file mode 100644 index 0000000000..8a9b229aac --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Numbers.java @@ -0,0 +1,8 @@ +package com.baeldung.parameterized; + +public class Numbers { + + public static boolean isOdd(int number) { + return number % 2 != 0; + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java new file mode 100644 index 0000000000..b3a3371bb2 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/NumbersUnitTest.java @@ -0,0 +1,15 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +class NumbersUnitTest { + + @ParameterizedTest + @ValueSource(ints = {1, 3, 5, -3, 15, Integer.MAX_VALUE}) + void isOdd_ShouldReturnTrueForOddNumbers(int number) { + assertTrue(Numbers.isOdd(number)); + } +} \ No newline at end of file diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java new file mode 100644 index 0000000000..225f11ba29 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Person.java @@ -0,0 +1,20 @@ +package com.baeldung.parameterized; + +class Person { + + private final String firstName; + private final String middleName; + private final String lastName; + + public Person(String firstName, String middleName, String lastName) { + this.firstName = firstName; + this.middleName = middleName; + this.lastName = lastName; + } + + public String fullName() { + if (middleName == null || middleName.trim().isEmpty()) return String.format("%s %s", firstName, lastName); + + return String.format("%s %s %s", firstName, middleName, lastName); + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java new file mode 100644 index 0000000000..df2ddc9e66 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonAggregator.java @@ -0,0 +1,15 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.params.aggregator.ArgumentsAccessor; +import org.junit.jupiter.params.aggregator.ArgumentsAggregationException; +import org.junit.jupiter.params.aggregator.ArgumentsAggregator; + +class PersonAggregator implements ArgumentsAggregator { + + @Override + public Object aggregateArguments(ArgumentsAccessor accessor, ParameterContext context) + throws ArgumentsAggregationException { + return new Person(accessor.getString(1), accessor.getString(2), accessor.getString(3)); + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java new file mode 100644 index 0000000000..b30ecc748e --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/PersonUnitTest.java @@ -0,0 +1,31 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.aggregator.AggregateWith; +import org.junit.jupiter.params.aggregator.ArgumentsAccessor; +import org.junit.jupiter.params.provider.CsvSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class PersonUnitTest { + + @ParameterizedTest + @CsvSource({"Isaac,,Newton, Isaac Newton", "Charles,Robert,Darwin,Charles Robert Darwin"}) + void fullName_ShouldGenerateTheExpectedFullName(ArgumentsAccessor argumentsAccessor) { + String firstName = argumentsAccessor.getString(0); + String middleName = (String) argumentsAccessor.get(1); + String lastName = argumentsAccessor.get(2, String.class); + String expectedFullName = argumentsAccessor.getString(3); + + Person person = new Person(firstName, middleName, lastName); + assertEquals(expectedFullName, person.fullName()); + } + + @ParameterizedTest + @CsvSource({"Isaac Newton,Isaac,,Newton", "Charles Robert Darwin,Charles,Robert,Darwin"}) + void fullName_ShouldGenerateTheExpectedFullName(String expectedFullName, + @AggregateWith(PersonAggregator.class) Person person) { + + assertEquals(expectedFullName, person.fullName()); + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java new file mode 100644 index 0000000000..40773d29a9 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/SlashyDateConverter.java @@ -0,0 +1,27 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.params.converter.ArgumentConversionException; +import org.junit.jupiter.params.converter.ArgumentConverter; + +import java.time.LocalDate; + +class SlashyDateConverter implements ArgumentConverter { + + @Override + public Object convert(Object source, ParameterContext context) throws ArgumentConversionException { + if (!(source instanceof String)) + throw new IllegalArgumentException("The argument should be a string: " + source); + + try { + String[] parts = ((String) source).split("/"); + int year = Integer.parseInt(parts[0]); + int month = Integer.parseInt(parts[1]); + int day = Integer.parseInt(parts[2]); + + return LocalDate.of(year, month, day); + } catch (Exception e) { + throw new IllegalArgumentException("Failed to convert", e); + } + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java new file mode 100644 index 0000000000..bc9f881bd4 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringParams.java @@ -0,0 +1,10 @@ +package com.baeldung.parameterized; + +import java.util.stream.Stream; + +public class StringParams { + + static Stream blankStrings() { + return Stream.of(null, "", " "); + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java new file mode 100644 index 0000000000..f8e29f6b7f --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/Strings.java @@ -0,0 +1,8 @@ +package com.baeldung.parameterized; + +class Strings { + + static boolean isBlank(String input) { + return input == null || input.trim().isEmpty(); + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java new file mode 100644 index 0000000000..7d02a5a74b --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/StringsUnitTest.java @@ -0,0 +1,108 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.*; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class StringsUnitTest { + + static Stream arguments = Stream.of( + Arguments.of(null, true), // null strings should be considered blank + Arguments.of("", true), + Arguments.of(" ", true), + Arguments.of("not blank", false) + ); + + @ParameterizedTest + @VariableSource("arguments") + void isBlank_ShouldReturnTrueForNullOrBlankStringsVariableSource(String input, boolean expected) { + assertEquals(expected, Strings.isBlank(input)); + } + + @ParameterizedTest + @ValueSource(strings = {"", " "}) + void isBlank_ShouldReturnTrueForNullOrBlankStrings(String input) { + assertTrue(Strings.isBlank(input)); + } + + @ParameterizedTest + @MethodSource("provideStringsForIsBlank") + void isBlank_ShouldReturnTrueForNullOrBlankStrings(String input, boolean expected) { + assertEquals(expected, Strings.isBlank(input)); + } + + @ParameterizedTest + @MethodSource // Please note method name is not provided + void isBlank_ShouldReturnTrueForNullOrBlankStringsOneArgument(String input) { + assertTrue(Strings.isBlank(input)); + } + + @ParameterizedTest + @MethodSource("com.baeldung.parameterized.StringParams#blankStrings") + void isBlank_ShouldReturnTrueForNullOrBlankStringsExternalSource(String input) { + assertTrue(Strings.isBlank(input)); + } + + @ParameterizedTest + @ArgumentsSource(BlankStringsArgumentsProvider.class) + void isBlank_ShouldReturnTrueForNullOrBlankStringsArgProvider(String input) { + assertTrue(Strings.isBlank(input)); + } + + private static Stream isBlank_ShouldReturnTrueForNullOrBlankStringsOneArgument() { + return Stream.of(null, "", " "); + } + + @ParameterizedTest + @MethodSource("provideStringsForIsBlankList") + void isBlank_ShouldReturnTrueForNullOrBlankStringsList(String input, boolean expected) { + assertEquals(expected, Strings.isBlank(input)); + } + + @ParameterizedTest + @CsvSource({"test,TEST", "tEst,TEST", "Java,JAVA"}) // Passing a CSV pair per test execution + void toUpperCase_ShouldGenerateTheExpectedUppercaseValue(String input, String expected) { + String actualValue = input.toUpperCase(); + assertEquals(expected, actualValue); + } + + @ParameterizedTest + @CsvSource(value = {"test:test", "tEst:test", "Java:java"}, delimiter =':') // Using : as the column separator. + void toLowerCase_ShouldGenerateTheExpectedLowercaseValue(String input, String expected) { + String actualValue = input.toLowerCase(); + assertEquals(expected, actualValue); + } + + @ParameterizedTest + @CsvFileSource(resources = "/data.csv", numLinesToSkip = 1) + void toUpperCase_ShouldGenerateTheExpectedUppercaseValueCSVFile(String input, String expected) { + String actualValue = input.toUpperCase(); + assertEquals(expected, actualValue); + } + + + + private static Stream provideStringsForIsBlank() { + return Stream.of( + Arguments.of(null, true), // null strings should be considered blank + Arguments.of("", true), + Arguments.of(" ", true), + Arguments.of("not blank", false) + ); + } + + private static List provideStringsForIsBlankList() { + return Arrays.asList( + Arguments.of(null, true), // null strings should be considered blank + Arguments.of("", true), + Arguments.of(" ", true), + Arguments.of("not blank", false) + ); + } +} \ No newline at end of file diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java new file mode 100644 index 0000000000..a96d01e854 --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableArgumentsProvider.java @@ -0,0 +1,45 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; +import org.junit.jupiter.params.support.AnnotationConsumer; + +import java.lang.reflect.Field; +import java.util.stream.Stream; + +class VariableArgumentsProvider implements ArgumentsProvider, AnnotationConsumer { + + private String variableName; + + @Override + public Stream provideArguments(ExtensionContext context) { + return context.getTestClass() + .map(this::getField) + .map(this::getValue) + .orElseThrow(() -> new IllegalArgumentException("Failed to load test arguments")); + } + + @Override + public void accept(VariableSource variableSource) { + variableName = variableSource.value(); + } + + private Field getField(Class clazz) { + try { + return clazz.getDeclaredField(variableName); + } catch (Exception e) { + return null; + } + } + + @SuppressWarnings("unchecked") + private Stream getValue(Field field) { + Object value = null; + try { + value = field.get(null); + } catch (Exception ignored) {} + + return value == null ? null : (Stream) value; + } +} diff --git a/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java new file mode 100644 index 0000000000..9c1d07c1be --- /dev/null +++ b/testing-modules/junit-5/src/test/java/com/baeldung/parameterized/VariableSource.java @@ -0,0 +1,19 @@ +package com.baeldung.parameterized; + +import org.junit.jupiter.params.provider.ArgumentsSource; + +import java.lang.annotation.*; + +@Documented +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@ArgumentsSource(VariableArgumentsProvider.class) +public @interface VariableSource { + + /** + * Represents the name of the static variable to load the test arguments from. + * + * @return Static variable name. + */ + String value(); +} diff --git a/testing-modules/junit-5/src/test/resources/data.csv b/testing-modules/junit-5/src/test/resources/data.csv new file mode 100644 index 0000000000..321554cc23 --- /dev/null +++ b/testing-modules/junit-5/src/test/resources/data.csv @@ -0,0 +1,4 @@ +input,expected +test,TEST +tEst,TEST +Java,JAVA \ No newline at end of file From 2acd1e27929ec4c4e06f0d79f2bc52a4a502dc0c Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 19 Jan 2019 10:06:35 +0100 Subject: [PATCH 254/441] [BAEL-2424] Updated tests to illustrate modifiers filtering and to disable order checking --- .../baeldung/reflection/MonthEmployee.java | 2 +- .../java/com/baeldung/reflection/Person.java | 2 +- .../PersonAndEmployeeReflectionUnitTest.java | 138 ++++++++++-------- 3 files changed, 82 insertions(+), 60 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java b/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java index 697ecc1500..df2a19bbff 100644 --- a/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java +++ b/core-java/src/main/java/com/baeldung/reflection/MonthEmployee.java @@ -2,6 +2,6 @@ package com.baeldung.reflection; public class MonthEmployee extends Employee { - private double reward; + protected double reward; } diff --git a/core-java/src/main/java/com/baeldung/reflection/Person.java b/core-java/src/main/java/com/baeldung/reflection/Person.java index 23b312cdd9..e036ab5223 100644 --- a/core-java/src/main/java/com/baeldung/reflection/Person.java +++ b/core-java/src/main/java/com/baeldung/reflection/Person.java @@ -2,7 +2,7 @@ package com.baeldung.reflection; public class Person { - public String lastName; + protected String lastName; private String firstName; } diff --git a/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java b/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java index c051f165f1..b1a6a1fe57 100644 --- a/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java +++ b/core-java/src/test/java/com/baeldung/reflection/PersonAndEmployeeReflectionUnitTest.java @@ -3,10 +3,13 @@ package com.baeldung.reflection; import org.junit.Test; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; import static org.junit.Assert.*; @@ -26,30 +29,14 @@ public class PersonAndEmployeeReflectionUnitTest { // Then assertEquals(2, allFields.length); - Field lastNameField = allFields[0]; - assertEquals(LAST_NAME_FIELD, lastNameField.getName()); - assertEquals(String.class, lastNameField.getType()); - - Field firstNameField = allFields[1]; - assertEquals(FIRST_NAME_FIELD, firstNameField.getName()); - assertEquals(String.class, firstNameField.getType()); - } - - @Test - public void givenEmployeeClass_whenSuperClassGetDeclaredFields_thenOneField() { - // When - Field[] allFields = Employee.class.getSuperclass().getDeclaredFields(); - - // Then - assertEquals(2, allFields.length); - - Field lastNameField = allFields[0]; - assertEquals(LAST_NAME_FIELD, lastNameField.getName()); - assertEquals(String.class, lastNameField.getType()); - - Field firstNameField = allFields[1]; - assertEquals(FIRST_NAME_FIELD, firstNameField.getName()); - assertEquals(String.class, firstNameField.getType()); + assertTrue(Arrays.stream(allFields).anyMatch(field -> + field.getName().equals(LAST_NAME_FIELD) + && field.getType().equals(String.class)) + ); + assertTrue(Arrays.stream(allFields).anyMatch(field -> + field.getName().equals(FIRST_NAME_FIELD) + && field.getType().equals(String.class)) + ); } @Test @@ -60,9 +47,28 @@ public class PersonAndEmployeeReflectionUnitTest { // Then assertEquals(1, allFields.length); - Field employeeIdField = allFields[0]; - assertEquals(EMPLOYEE_ID_FIELD, employeeIdField.getName()); - assertEquals(int.class, employeeIdField.getType()); + assertTrue(Arrays.stream(allFields).anyMatch(field -> + field.getName().equals(EMPLOYEE_ID_FIELD) + && field.getType().equals(int.class)) + ); + } + + @Test + public void givenEmployeeClass_whenSuperClassGetDeclaredFields_thenOneField() { + // When + Field[] allFields = Employee.class.getSuperclass().getDeclaredFields(); + + // Then + assertEquals(2, allFields.length); + + assertTrue(Arrays.stream(allFields).anyMatch(field -> + field.getName().equals(LAST_NAME_FIELD) + && field.getType().equals(String.class)) + ); + assertTrue(Arrays.stream(allFields).anyMatch(field -> + field.getName().equals(FIRST_NAME_FIELD) + && field.getType().equals(String.class)) + ); } @Test @@ -76,42 +82,56 @@ public class PersonAndEmployeeReflectionUnitTest { // Then assertEquals(3, allFields.length); - Field lastNameField = allFields[0]; - assertEquals(LAST_NAME_FIELD, lastNameField.getName()); - assertEquals(String.class, lastNameField.getType()); - - Field firstNameField = allFields[1]; - assertEquals(FIRST_NAME_FIELD, firstNameField.getName()); - assertEquals(String.class, firstNameField.getType()); - - Field employeeIdField = allFields[2]; - assertEquals(EMPLOYEE_ID_FIELD, employeeIdField.getName()); - assertEquals(int.class, employeeIdField.getType()); + assertTrue(Arrays.stream(allFields).anyMatch(field -> + field.getName().equals(LAST_NAME_FIELD) + && field.getType().equals(String.class)) + ); + assertTrue(Arrays.stream(allFields).anyMatch(field -> + field.getName().equals(FIRST_NAME_FIELD) + && field.getType().equals(String.class)) + ); + assertTrue(Arrays.stream(allFields).anyMatch(field -> + field.getName().equals(EMPLOYEE_ID_FIELD) + && field.getType().equals(int.class)) + ); } @Test - public void givenMonthEmployeeClass_whenGetAllFields_thenFourFields() { + public void givenEmployeeClass_whenGetDeclaredFieldsOnEmployeeSuperclassWithModifiersFilter_thenOneFields() { + // When + List personFields = Arrays.stream(Employee.class.getSuperclass().getDeclaredFields()) + .filter(f -> Modifier.isPublic(f.getModifiers()) || Modifier.isProtected(f.getModifiers())) + .collect(Collectors.toList()); + + // Then + assertEquals(1, personFields.size()); + + assertTrue(personFields.stream().anyMatch(field -> + field.getName().equals(LAST_NAME_FIELD) + && field.getType().equals(String.class)) + ); + } + + @Test + public void givenMonthEmployeeClass_whenGetAllFields_thenThreeFields() { // When List allFields = getAllFields(MonthEmployee.class); // Then - assertEquals(4, allFields.size()); + assertEquals(3, allFields.size()); - Field lastNameField = allFields.get(0); - assertEquals(LAST_NAME_FIELD, lastNameField.getName()); - assertEquals(String.class, lastNameField.getType()); - - Field firstNameField = allFields.get(1); - assertEquals(FIRST_NAME_FIELD, firstNameField.getName()); - assertEquals(String.class, firstNameField.getType()); - - Field employeeIdField = allFields.get(2); - assertEquals(EMPLOYEE_ID_FIELD, employeeIdField.getName()); - assertEquals(int.class, employeeIdField.getType()); - - Field monthEmployeeRewardField = allFields.get(3); - assertEquals(MONTH_EMPLOYEE_REWARD_FIELD, monthEmployeeRewardField.getName()); - assertEquals(double.class, monthEmployeeRewardField.getType()); + assertTrue(allFields.stream().anyMatch(field -> + field.getName().equals(LAST_NAME_FIELD) + && field.getType().equals(String.class)) + ); + assertTrue(allFields.stream().anyMatch(field -> + field.getName().equals(EMPLOYEE_ID_FIELD) + && field.getType().equals(int.class)) + ); + assertTrue(allFields.stream().anyMatch(field -> + field.getName().equals(MONTH_EMPLOYEE_REWARD_FIELD) + && field.getType().equals(double.class)) + ); } public List getAllFields(Class clazz) { @@ -119,9 +139,11 @@ public class PersonAndEmployeeReflectionUnitTest { return Collections.emptyList(); } - List result = new ArrayList<>(); - result.addAll(getAllFields(clazz.getSuperclass())); - result.addAll(Arrays.asList(clazz.getDeclaredFields())); + List result = new ArrayList<>(getAllFields(clazz.getSuperclass())); + List filteredFields = Arrays.stream(clazz.getDeclaredFields()) + .filter(f -> Modifier.isPublic(f.getModifiers()) || Modifier.isProtected(f.getModifiers())) + .collect(Collectors.toList()); + result.addAll(filteredFields); return result; } From 8a307c1aba5b8d186f893e68273733ce67cbd882 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Sat, 19 Jan 2019 09:32:54 -0200 Subject: [PATCH 255/441] moved new package to existing one --- .../boot/ErrorHandlingBootApplication.java | 15 --------------- .../config}/MyCustomErrorAttributes.java | 2 +- .../config}/MyErrorController.java | 2 +- .../controller}/FaultyRestController.java | 4 ++-- .../src/main/resources/application.properties | 3 +++ .../errorhandling-application.properties | 3 --- .../boot => web/error}/ErrorHandlingLiveTest.java | 2 +- 7 files changed, 8 insertions(+), 23 deletions(-) delete mode 100644 spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java rename spring-boot-rest/src/main/java/com/baeldung/{errorhandling/boot/configurations => web/config}/MyCustomErrorAttributes.java (93%) rename spring-boot-rest/src/main/java/com/baeldung/{errorhandling/boot/configurations => web/config}/MyErrorController.java (95%) rename spring-boot-rest/src/main/java/com/baeldung/{errorhandling/boot/web => web/controller}/FaultyRestController.java (73%) delete mode 100644 spring-boot-rest/src/main/resources/errorhandling-application.properties rename spring-boot-rest/src/test/java/com/baeldung/{errorhandling/boot => web/error}/ErrorHandlingLiveTest.java (98%) diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java deleted file mode 100644 index 0885ecbbf7..0000000000 --- a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.errorhandling.boot; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.PropertySource; - -@SpringBootApplication -@PropertySource("errorhandling-application.properties") -public class ErrorHandlingBootApplication { - - public static void main(String[] args) { - SpringApplication.run(ErrorHandlingBootApplication.class, args); - } - -} diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyCustomErrorAttributes.java similarity index 93% rename from spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java rename to spring-boot-rest/src/main/java/com/baeldung/web/config/MyCustomErrorAttributes.java index e2c62cb907..1948d5552f 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyCustomErrorAttributes.java @@ -1,4 +1,4 @@ -package com.baeldung.errorhandling.boot.configurations; +package com.baeldung.web.config; import java.util.Map; diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyErrorController.java similarity index 95% rename from spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java rename to spring-boot-rest/src/main/java/com/baeldung/web/config/MyErrorController.java index 427a0b43d7..e3716ec113 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyErrorController.java @@ -1,4 +1,4 @@ -package com.baeldung.errorhandling.boot.configurations; +package com.baeldung.web.config; import java.util.Map; diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/web/FaultyRestController.java b/spring-boot-rest/src/main/java/com/baeldung/web/controller/FaultyRestController.java similarity index 73% rename from spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/web/FaultyRestController.java rename to spring-boot-rest/src/main/java/com/baeldung/web/controller/FaultyRestController.java index e56e395754..bf7b7a5f99 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/web/FaultyRestController.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/controller/FaultyRestController.java @@ -1,4 +1,4 @@ -package com.baeldung.errorhandling.boot.web; +package com.baeldung.web.controller; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -9,7 +9,7 @@ public class FaultyRestController { @GetMapping("/exception") public ResponseEntity requestWithException() { - throw new NullPointerException("Error in the faulty controller!"); + throw new RuntimeException("Error in the faulty controller!"); } } diff --git a/spring-boot-rest/src/main/resources/application.properties b/spring-boot-rest/src/main/resources/application.properties index e69de29bb2..e65440e2b9 100644 --- a/spring-boot-rest/src/main/resources/application.properties +++ b/spring-boot-rest/src/main/resources/application.properties @@ -0,0 +1,3 @@ +### Spring Boot default error handling configurations +#server.error.whitelabel.enabled=false +#server.error.include-stacktrace=always \ No newline at end of file diff --git a/spring-boot-rest/src/main/resources/errorhandling-application.properties b/spring-boot-rest/src/main/resources/errorhandling-application.properties deleted file mode 100644 index 994c517163..0000000000 --- a/spring-boot-rest/src/main/resources/errorhandling-application.properties +++ /dev/null @@ -1,3 +0,0 @@ - -#server.error.whitelabel.enabled=false -#server.error.include-stacktrace=always \ No newline at end of file diff --git a/spring-boot-rest/src/test/java/com/baeldung/errorhandling/boot/ErrorHandlingLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java similarity index 98% rename from spring-boot-rest/src/test/java/com/baeldung/errorhandling/boot/ErrorHandlingLiveTest.java rename to spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java index e587b67fcf..ea1b6ab227 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/errorhandling/boot/ErrorHandlingLiveTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java @@ -1,4 +1,4 @@ -package com.baeldung.errorhandling.boot; +package com.baeldung.web.error; import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; From dea88da77728edb77c12475ca551045ac2960503 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Sat, 19 Jan 2019 17:00:30 -0200 Subject: [PATCH 256/441] Adding dao dependencies and exception handling of original classes --- spring-boot-rest/pom.xml | 8 ++++ .../RestResponseEntityExceptionHandler.java | 41 +++++++++---------- .../web/exception/MyDataAccessException.java | 21 ---------- .../MyDataIntegrityViolationException.java | 21 ---------- 4 files changed, 28 insertions(+), 63 deletions(-) delete mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataAccessException.java delete mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataIntegrityViolationException.java diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index 3b8cf7e39e..f05d242072 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -24,6 +24,14 @@ com.fasterxml.jackson.dataformat jackson-dataformat-xml + + org.hibernate + hibernate-entitymanager + + + org.springframework + spring-jdbc + org.springframework.boot diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-boot-rest/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java index fe0465156d..2e2672f510 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -1,5 +1,11 @@ package com.baeldung.web.error; +import javax.persistence.EntityNotFoundException; + +import org.hibernate.exception.ConstraintViolationException; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -10,8 +16,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; -import com.baeldung.web.exception.MyDataAccessException; -import com.baeldung.web.exception.MyDataIntegrityViolationException; import com.baeldung.web.exception.MyResourceNotFoundException; @ControllerAdvice @@ -24,13 +28,15 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH // API // 400 - /* - * Some examples of exceptions that we could retrieve as 400 (BAD_REQUEST) responses: - * Hibernate's ConstraintViolationException - * Spring's DataIntegrityViolationException - */ - @ExceptionHandler({ MyDataIntegrityViolationException.class }) - public ResponseEntity handleBadRequest(final MyDataIntegrityViolationException ex, final WebRequest request) { + + @ExceptionHandler({ ConstraintViolationException.class }) + public ResponseEntity handleBadRequest(final ConstraintViolationException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); + } + + @ExceptionHandler({ DataIntegrityViolationException.class }) + public ResponseEntity handleBadRequest(final DataIntegrityViolationException ex, final WebRequest request) { final String bodyOfResponse = "This should be application specific"; return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); } @@ -50,23 +56,16 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH // 404 - /* - * Some examples of exceptions that we could retrieve as 404 (NOT_FOUND) responses: - * Java Persistence's EntityNotFoundException - */ - @ExceptionHandler(value = { MyResourceNotFoundException.class }) + + @ExceptionHandler(value = { EntityNotFoundException.class, MyResourceNotFoundException.class }) protected ResponseEntity handleNotFound(final RuntimeException ex, final WebRequest request) { final String bodyOfResponse = "This should be application specific"; return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request); } // 409 - /* - * Some examples of exceptions that we could retrieve as 409 (CONFLICT) responses: - * Spring's InvalidDataAccessApiUsageException - * Spring's DataAccessException - */ - @ExceptionHandler({ MyDataAccessException.class}) + + @ExceptionHandler({ InvalidDataAccessApiUsageException.class, DataAccessException.class }) protected ResponseEntity handleConflict(final RuntimeException ex, final WebRequest request) { final String bodyOfResponse = "This should be application specific"; return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.CONFLICT, request); @@ -83,4 +82,4 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request); } -} +} \ No newline at end of file diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataAccessException.java b/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataAccessException.java deleted file mode 100644 index 8fc9a3a0ea..0000000000 --- a/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataAccessException.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.web.exception; - -public final class MyDataAccessException extends RuntimeException { - - public MyDataAccessException() { - super(); - } - - public MyDataAccessException(final String message, final Throwable cause) { - super(message, cause); - } - - public MyDataAccessException(final String message) { - super(message); - } - - public MyDataAccessException(final Throwable cause) { - super(cause); - } - -} diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataIntegrityViolationException.java b/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataIntegrityViolationException.java deleted file mode 100644 index 50adb09c09..0000000000 --- a/spring-boot-rest/src/main/java/com/baeldung/web/exception/MyDataIntegrityViolationException.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.web.exception; - -public final class MyDataIntegrityViolationException extends RuntimeException { - - public MyDataIntegrityViolationException() { - super(); - } - - public MyDataIntegrityViolationException(final String message, final Throwable cause) { - super(message, cause); - } - - public MyDataIntegrityViolationException(final String message) { - super(message); - } - - public MyDataIntegrityViolationException(final Throwable cause) { - super(cause); - } - -} From e03c0871ae561caf0a9b25695cf971c2bab0a921 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 19 Jan 2019 23:14:25 +0100 Subject: [PATCH 257/441] [REORG-2531] Updated a test to illustrate use of File.separator --- .../java/com/baeldung/directories/NewDirectoryUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java b/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java index e0111c2702..d645782955 100644 --- a/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java +++ b/core-java-io/src/test/java/com/baeldung/directories/NewDirectoryUnitTest.java @@ -62,7 +62,7 @@ public class NewDirectoryUnitTest { @Test public void givenUnexistingNestedDirectories_whenMkdirs_thenTrue() { - File newDirectory = new File(TEMP_DIRECTORY, "new_directory"); + File newDirectory = new File(System.getProperty("java.io.tmpdir") + File.separator + "new_directory"); File nestedDirectory = new File(newDirectory, "nested_directory"); assertFalse(newDirectory.exists()); assertFalse(nestedDirectory.exists()); From 5408ed78fe23ace31fbb09317721ba5fa04746d2 Mon Sep 17 00:00:00 2001 From: Eric Martin Date: Sat, 19 Jan 2019 18:15:26 -0600 Subject: [PATCH 258/441] Delete . .. --- java-streams/src/test/java/com/baeldung/stream/sum/. .. | 1 - 1 file changed, 1 deletion(-) delete mode 100644 java-streams/src/test/java/com/baeldung/stream/sum/. .. diff --git a/java-streams/src/test/java/com/baeldung/stream/sum/. .. b/java-streams/src/test/java/com/baeldung/stream/sum/. .. deleted file mode 100644 index 8b13789179..0000000000 --- a/java-streams/src/test/java/com/baeldung/stream/sum/. .. +++ /dev/null @@ -1 +0,0 @@ - From c19558f42077593bf03445b8b4294603f1dc335b Mon Sep 17 00:00:00 2001 From: eric-martin Date: Sat, 19 Jan 2019 18:38:13 -0600 Subject: [PATCH 259/441] BAEL-2521: Moving LocalDateConverter to java-jpa --- .../src/main/java/com/baeldung/util/LocalDateConverter.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename persistence-modules/{spring-boot-persistence => java-jpa}/src/main/java/com/baeldung/util/LocalDateConverter.java (100%) diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java b/persistence-modules/java-jpa/src/main/java/com/baeldung/util/LocalDateConverter.java similarity index 100% rename from persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/util/LocalDateConverter.java rename to persistence-modules/java-jpa/src/main/java/com/baeldung/util/LocalDateConverter.java From e2d10d45dbd5000879eb3598cd2a3ddd261480b7 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 20 Jan 2019 17:21:45 +0200 Subject: [PATCH 260/441] Update pom.xml --- lombok/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lombok/pom.xml b/lombok/pom.xml index 7ad2e3dc83..72bff8828a 100644 --- a/lombok/pom.xml +++ b/lombok/pom.xml @@ -80,7 +80,7 @@ 1.0.0.Final - 1.16.10.0 + 1.18.4.0 3.8.0 From c22af13c21fd2ce158e0177e82c7fd0dacc5ae1c Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 20 Jan 2019 17:26:27 +0200 Subject: [PATCH 261/441] Update pom.xml --- lombok/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lombok/pom.xml b/lombok/pom.xml index 72bff8828a..2acf9e240d 100644 --- a/lombok/pom.xml +++ b/lombok/pom.xml @@ -76,7 +76,7 @@ - 1.16.18 + 1.18.4 1.0.0.Final From c7a8627f1005c462b1bc213ed141612323ec9ca3 Mon Sep 17 00:00:00 2001 From: Alejandro Gervasio Date: Sun, 20 Jan 2019 13:52:39 -0300 Subject: [PATCH 262/441] BAEL-2545 - Configuring a DataSource Programatically in Spring Boot (#6139) * Initial Commit * Update UserRepositoryIntegrationTest.java * Update UserRepositoryIntegrationTest --- .../application/Application.java | 27 +++++++++++ .../datasources/DataSourceBean.java | 20 ++++++++ .../application/entities/User.java | 46 +++++++++++++++++++ .../repositories/UserRepository.java | 8 ++++ .../tests/UserRepositoryIntegrationTest.java | 28 +++++++++++ 5 files changed, 129 insertions(+) create mode 100644 persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/Application.java create mode 100644 persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/datasources/DataSourceBean.java create mode 100644 persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/entities/User.java create mode 100644 persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/repositories/UserRepository.java create mode 100644 persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootdatasourceconfig/tests/UserRepositoryIntegrationTest.java diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/Application.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/Application.java new file mode 100644 index 0000000000..e1f67c0185 --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/Application.java @@ -0,0 +1,27 @@ +package com.baeldung.springbootdatasourceconfig.application; + +import com.baeldung.springbootdatasourceconfig.application.entities.User; +import com.baeldung.springbootdatasourceconfig.application.repositories.UserRepository; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + @Bean + public CommandLineRunner run(UserRepository userRepository) throws Exception { + return (String[] args) -> { + User user1 = new User("John", "john@domain.com"); + User user2 = new User("Julie", "julie@domain.com"); + userRepository.save(user1); + userRepository.save(user2); + userRepository.findAll().forEach(user -> System.out.println(user.getName())); + }; + } +} diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/datasources/DataSourceBean.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/datasources/DataSourceBean.java new file mode 100644 index 0000000000..9ef9b77aed --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/datasources/DataSourceBean.java @@ -0,0 +1,20 @@ +package com.baeldung.springbootdatasourceconfig.application.datasources; + +import javax.sql.DataSource; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class DataSourceBean { + + @Bean + public DataSource getDataSource() { + DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create(); + dataSourceBuilder.driverClassName("org.h2.Driver"); + dataSourceBuilder.url("jdbc:h2:mem:test"); + dataSourceBuilder.username("SA"); + dataSourceBuilder.password(""); + return dataSourceBuilder.build(); + } +} diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/entities/User.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/entities/User.java new file mode 100644 index 0000000000..518a11701f --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/entities/User.java @@ -0,0 +1,46 @@ +package com.baeldung.springbootdatasourceconfig.application.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "users") +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + private String name; + private String email; + + public User(){} + + public User(String name, String email) { + this.name = name; + this.email = email; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public String toString() { + return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; + } +} diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/repositories/UserRepository.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/repositories/UserRepository.java new file mode 100644 index 0000000000..27929ead44 --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/repositories/UserRepository.java @@ -0,0 +1,8 @@ +package com.baeldung.springbootdatasourceconfig.application.repositories; + +import com.baeldung.springbootdatasourceconfig.application.entities.User; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface UserRepository extends CrudRepository {} diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootdatasourceconfig/tests/UserRepositoryIntegrationTest.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootdatasourceconfig/tests/UserRepositoryIntegrationTest.java new file mode 100644 index 0000000000..f27681021e --- /dev/null +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootdatasourceconfig/tests/UserRepositoryIntegrationTest.java @@ -0,0 +1,28 @@ +package com.baeldung.springbootdatasourceconfig.tests; + +import com.baeldung.springbootdatasourceconfig.application.entities.User; +import com.baeldung.springbootdatasourceconfig.application.repositories.UserRepository; +import java.util.List; +import java.util.Optional; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.runner.RunWith; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@DataJpaTest +public class UserRepositoryIntegrationTest { + + @Autowired + private UserRepository userRepository; + + @Test + public void whenCalledSave_thenCorrectNumberOfUsers() { + userRepository.save(new User("Bob", "bob@domain.com")); + List users = (List) userRepository.findAll(); + + assertThat(users.size()).isEqualTo(1); + } +} From 0fb2adfe99fdbbb5d313c41c3d04e5cb9478425c Mon Sep 17 00:00:00 2001 From: Philippe M Date: Sun, 20 Jan 2019 19:38:14 +0100 Subject: [PATCH 263/441] Fix performance issues of JMeter Test Plan (#5979) --- .../resources/scripts/JMeter/Test Plan.jmx | 289 +++++++++--------- 1 file changed, 142 insertions(+), 147 deletions(-) diff --git a/testing-modules/load-testing-comparison/src/main/resources/scripts/JMeter/Test Plan.jmx b/testing-modules/load-testing-comparison/src/main/resources/scripts/JMeter/Test Plan.jmx index da32a13a22..97640dfac7 100644 --- a/testing-modules/load-testing-comparison/src/main/resources/scripts/JMeter/Test Plan.jmx +++ b/testing-modules/load-testing-comparison/src/main/resources/scripts/JMeter/Test Plan.jmx @@ -1,5 +1,5 @@ - + @@ -25,80 +25,116 @@ - - true - 1 - - - - - - Content-Type - application/json + + + + Content-Type + application/json + + + + + + true + + + + false + {"customerRewardsId":null,"customerId":${random},"transactionDate":null} + = - + + localhost + 8080 + http + + /transactions/add + POST + true + false + true + false + + + + + + + txnId + $.id + 1 + all + foo + - + + txnDate + $.transactionDate + 1 + Never + + + + custId + $.customerId + 1 + all + bob + + + + + + + + localhost + 8080 + + + /rewards/find/${custId} + GET + true + false + true + false + + + + + + + rwdId + $.id + 1 + 0 + all + + + + + ${__jexl3(${rwdId} == 0,)} + true + true + + + true false - {"customerRewardsId":null,"customerId":${random},"transactionDate":null} + {"customerId":${custId}} = localhost 8080 - http - - /transactions/add - POST - true - false - true - false - - - - - - - txnId - $.id - 1 - all - foo - - - - txnDate - $.transactionDate - 1 - Never - - - - custId - $.customerId - 1 - all - bob - - - - - - - - localhost - 8080 - /rewards/find/${custId} - GET + /rewards/add + POST true false true @@ -112,98 +148,57 @@ rwdId $.id 1 - 0 + bar all - - ${rwdId} == 0 - true - - - - true - - - - false - {"customerId":${custId}} - = - - - - localhost - 8080 - - - /rewards/add - POST - true - false - true - false - - - - - - - rwdId - $.id - 1 - bar - all - - - - - - true - - - - false - {"id":${txnId},"customerRewardsId":${rwdId},"customerId":${custId},"transactionDate":"${txnDate}"} - = - - - - localhost - 8080 - - - /transactions/add - POST - true - false - true - false - - - - - - - - - - localhost - 8080 - - - /transactions/findAll/${rwdId} - GET - true - false - true - false - - - - - + + true + + + + false + {"id":${txnId},"customerRewardsId":${rwdId},"customerId":${custId},"transactionDate":"${txnDate}"} + = + + + + localhost + 8080 + + + /transactions/add + POST + true + false + true + false + + + + + + + + + + localhost + 8080 + + + /transactions/findAll/${rwdId} + GET + true + false + true + false + + + + + 10000 1 @@ -213,7 +208,7 @@ random - + false saveConfig From 89ff253342752027c17b8088b8940df972a5d17f Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 20 Jan 2019 21:56:30 +0200 Subject: [PATCH 264/441] Update TaskScheduler.java --- .../java/com/baeldung/scheduling/shedlock/TaskScheduler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/TaskScheduler.java b/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/TaskScheduler.java index b1b1ad921f..060afe660e 100644 --- a/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/TaskScheduler.java +++ b/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/TaskScheduler.java @@ -7,9 +7,9 @@ import org.springframework.stereotype.Component; @Component class TaskScheduler { - @Scheduled(cron = "*/15 * * * * *") + @Scheduled(cron = "*/15 * * * *") @SchedulerLock(name = "TaskScheduler_scheduledTask", lockAtLeastForString = "PT5M", lockAtMostForString = "PT14M") public void scheduledTask() { System.out.println("Running ShedLock task"); } -} \ No newline at end of file +} From 08b8c427bd1784f0dc0de4f43f7638a0aabcdfc3 Mon Sep 17 00:00:00 2001 From: Rajesh Bhojwani Date: Mon, 21 Jan 2019 08:15:38 +0530 Subject: [PATCH 265/441] rename file --- ...ilesClearDataManualTest.java => FilesClearDataUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-java-io/src/test/java/com/baeldung/file/{FilesClearDataManualTest.java => FilesClearDataUnitTest.java} (98%) diff --git a/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java b/core-java-io/src/test/java/com/baeldung/file/FilesClearDataUnitTest.java similarity index 98% rename from core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java rename to core-java-io/src/test/java/com/baeldung/file/FilesClearDataUnitTest.java index c00290168c..653c4320c0 100644 --- a/core-java-io/src/test/java/com/baeldung/file/FilesClearDataManualTest.java +++ b/core-java-io/src/test/java/com/baeldung/file/FilesClearDataUnitTest.java @@ -22,7 +22,7 @@ import org.junit.Test; import com.baeldung.util.StreamUtils; -public class FilesClearDataManualTest { +public class FilesClearDataUnitTest { public static final String FILE_PATH = "src/test/resources/fileexample.txt"; From c713ddee6da9f3b3efc13a0b1935582c2581fee0 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Mon, 21 Jan 2019 09:26:47 +0400 Subject: [PATCH 266/441] trove list --- .../java/com/baeldung/array/PrimitiveCollections.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java b/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java index 115c5fe5c3..b991dcb598 100644 --- a/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java +++ b/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java @@ -2,6 +2,7 @@ package com.baeldung.array; import com.google.common.primitives.ImmutableIntArray; import com.google.common.primitives.Ints; +import gnu.trove.list.TIntList; import gnu.trove.list.array.TIntArrayList; import java.util.Arrays; @@ -13,13 +14,16 @@ public class PrimitiveCollections { int[] primitives = new int[] {5, 10, 0, 2}; - guavaPrimitives(primitives); + //guavaPrimitives(primitives); trovePrimitives(primitives); } private static void trovePrimitives(int[] primitives) { - TIntArrayList list = new TIntArrayList(primitives); + TIntList tList = new TIntArrayList(primitives); + tList.reverse(); + System.out.println(tList); + System.out.println(tList.size()); } private static void guavaPrimitives(int[] primitives) { From 3aff027b7a7e47a4700604b0b44ae45f48fa3c9b Mon Sep 17 00:00:00 2001 From: Urvy Agrawal Date: Mon, 21 Jan 2019 11:23:24 +0530 Subject: [PATCH 267/441] Adding file for BAEL-2558 --- .../BitwiseOperatorExample.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/bitwiseoperator/BitwiseOperatorExample.java diff --git a/core-java/src/main/java/com/baeldung/bitwiseoperator/BitwiseOperatorExample.java b/core-java/src/main/java/com/baeldung/bitwiseoperator/BitwiseOperatorExample.java new file mode 100644 index 0000000000..4fef92102a --- /dev/null +++ b/core-java/src/main/java/com/baeldung/bitwiseoperator/BitwiseOperatorExample.java @@ -0,0 +1,56 @@ +package com.baeldung.bitwiseoperator; + +public class BitwiseOperatorExample { + + public static void main(String[] args) { + + int value1 = 6; + int value2 = 5; + + // Bitwise AND Operator + int result = value1 & value2; + System.out.println("result : " + result); + + // Bitwise OR Operator + result = value1 | value2; + System.out.println("result : " + result); + + // Bitwise Exclusive OR Operator + result = value1 ^ value2; + System.out.println("result : " + result); + + // Bitwise NOT operator + result = ~value1; + System.out.println("result : " + result); + + // Right Shift Operator with positive number + int value = 12; + int rightShift = value >> 2; + System.out.println("rightShift result with positive number : " + rightShift); + + // Right Shift Operator with negative number + value = -12; + rightShift = value >> 2; + System.out.println("rightShift result with negative number : " + rightShift); + + // Left Shift Operator with positive number + value = 1; + int leftShift = value << 1; + System.out.println("leftShift result with positive number : " + leftShift); + + // Left Shift Operator with negative number + value = -12; + leftShift = value << 2; + System.out.println("leftShift result with negative number : " + leftShift); + + // Unsigned Right Shift Operator with positive number + value = 12; + int unsignedRightShift = value >>> 2; + System.out.println("unsignedRightShift result with positive number : " + unsignedRightShift); + + // Unsigned Right Shift Operator with negative number + value = -12; + unsignedRightShift = value >>> 2; + System.out.println("unsignedRightShift result with negative number : " + unsignedRightShift); + } +} From 5c1a0a06292115d99e24493ca1d69e32414e09b6 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Mon, 21 Jan 2019 09:57:15 +0400 Subject: [PATCH 268/441] change the ArrayList into List --- .../src/main/java/com/baeldung/string/MatchWords.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index d322d192fa..4baaa49227 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -71,15 +71,15 @@ public class MatchWords { } public static boolean containsWordsJava8(String inputString, String[] words) { - ArrayList inputStringList = new ArrayList<>(Arrays.asList(inputString.split(" "))); - ArrayList wordsList = new ArrayList<>(Arrays.asList(words)); + List inputStringList = Arrays.asList(inputString.split(" ")); + List wordsList = Arrays.asList(words); return wordsList.stream().allMatch(inputStringList::contains); } public static boolean containsWordsArray(String inputString, String[] words) { - ArrayList inputStringList = new ArrayList<>(Arrays.asList(inputString.split(" "))); - ArrayList wordsList = new ArrayList<>(Arrays.asList(words)); + List inputStringList = Arrays.asList(inputString.split(" ")); + List wordsList = Arrays.asList(words); return inputStringList.containsAll(wordsList); } From 369655aa02adf178b3d813edbc97ee603a963ffc Mon Sep 17 00:00:00 2001 From: pcoates33 Date: Mon, 21 Jan 2019 08:14:06 +0000 Subject: [PATCH 269/441] spring-boot ehcache example added (#6136) --- .../cachetest/config/CacheConfig.java | 49 +------------------ .../cachetest/config/CacheEventLogger.java | 11 ++--- .../cachetest/rest/NumberController.java | 16 +++--- .../cachetest/service/NumberService.java | 15 +++--- .../src/main/resources/application.properties | 1 + spring-ehcache/src/main/resources/ehcache.xml | 31 ++++++++++++ 6 files changed, 54 insertions(+), 69 deletions(-) create mode 100644 spring-ehcache/src/main/resources/application.properties create mode 100644 spring-ehcache/src/main/resources/ehcache.xml diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java b/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java index 3cf2309cb9..5e72b5dcfc 100644 --- a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java +++ b/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheConfig.java @@ -1,57 +1,10 @@ package com.baeldung.cachetest.config; -import java.math.BigDecimal; -import java.time.Duration; - -import javax.cache.CacheManager; - -import org.ehcache.config.CacheConfiguration; -import org.ehcache.config.ResourcePools; -import org.ehcache.config.builders.CacheConfigurationBuilder; -import org.ehcache.config.builders.CacheEventListenerConfigurationBuilder; -import org.ehcache.config.builders.ExpiryPolicyBuilder; -import org.ehcache.config.builders.ResourcePoolsBuilder; -import org.ehcache.config.units.EntryUnit; -import org.ehcache.config.units.MemoryUnit; -import org.ehcache.event.EventType; -import org.ehcache.jsr107.Eh107Configuration; -import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer; import org.springframework.cache.annotation.EnableCaching; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration @EnableCaching public class CacheConfig { - - private static final int ON_HEAP_CACHE_SIZE_ENTRIES = 2; - private static final int OFF_HEAP_CACHE_SIZE_MB = 10; - private static final int CACHE_EXPIRY_SECONDS = 30; - - @Bean - public JCacheManagerCustomizer jcacheManagerCustomizer() { - return new JCacheManagerCustomizer() { - - @Override - public void customize(CacheManager cacheManager) { - ResourcePools resourcePools = ResourcePoolsBuilder.newResourcePoolsBuilder() - .heap(ON_HEAP_CACHE_SIZE_ENTRIES, EntryUnit.ENTRIES) - .offheap(OFF_HEAP_CACHE_SIZE_MB, MemoryUnit.MB).build(); - - CacheEventListenerConfigurationBuilder eventLoggerConfig = CacheEventListenerConfigurationBuilder - .newEventListenerConfiguration(new CacheEventLogger(), EventType.CREATED, EventType.EXPIRED) - .unordered().asynchronous(); - - CacheConfiguration cacheConfiguration = CacheConfigurationBuilder - .newCacheConfigurationBuilder(Long.class, BigDecimal.class, resourcePools) - .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(CACHE_EXPIRY_SECONDS))) - .add(eventLoggerConfig).build(); - - cacheManager.createCache("squareCache", - Eh107Configuration.fromEhcacheCacheConfiguration(cacheConfiguration)); - - } - }; - } - + } diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java b/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java index c8ead85f1e..dcaec57010 100644 --- a/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java +++ b/spring-ehcache/src/main/java/com/baeldung/cachetest/config/CacheEventLogger.java @@ -7,12 +7,11 @@ import org.slf4j.LoggerFactory; public class CacheEventLogger implements CacheEventListener { - private static final Logger log = LoggerFactory.getLogger(CacheEventLogger.class); + private static final Logger log = LoggerFactory.getLogger(CacheEventLogger.class); - @Override - public void onEvent(CacheEvent cacheEvent) { - log.info("Cache event {} for item with key {}. Old value = {}, New value = {}", cacheEvent.getType(), - cacheEvent.getKey(), cacheEvent.getOldValue(), cacheEvent.getNewValue()); - } + @Override + public void onEvent(CacheEvent cacheEvent) { + log.info("Cache event {} for item with key {}. Old value = {}, New value = {}", cacheEvent.getType(), cacheEvent.getKey(), cacheEvent.getOldValue(), cacheEvent.getNewValue()); + } } diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java b/spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java index 4115c34cc4..15b5c93dfe 100644 --- a/spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java +++ b/spring-ehcache/src/main/java/com/baeldung/cachetest/rest/NumberController.java @@ -15,15 +15,15 @@ import com.baeldung.cachetest.service.NumberService; @RequestMapping(path = "/number", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public class NumberController { - private final static Logger log = LoggerFactory.getLogger(NumberController.class); + private final static Logger log = LoggerFactory.getLogger(NumberController.class); - @Autowired - private NumberService numberService; + @Autowired + private NumberService numberService; - @GetMapping(path = "/square/{number}") - public String getThing(@PathVariable Long number) { - log.info("call numberService to square {}", number); - return String.format("{\"square\": %s}", numberService.square(number)); - } + @GetMapping(path = "/square/{number}") + public String getThing(@PathVariable Long number) { + log.info("call numberService to square {}", number); + return String.format("{\"square\": %s}", numberService.square(number)); + } } diff --git a/spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java b/spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java index bcd930f5e1..45fb841867 100644 --- a/spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java +++ b/spring-ehcache/src/main/java/com/baeldung/cachetest/service/NumberService.java @@ -10,13 +10,14 @@ import org.springframework.stereotype.Service; @Service public class NumberService { - private final static Logger log = LoggerFactory.getLogger(NumberService.class); + private final static Logger log = LoggerFactory.getLogger(NumberService.class); - @Cacheable(value = "squareCache", key = "#number", condition = "#number>10") - public BigDecimal square(Long number) { - BigDecimal square = BigDecimal.valueOf(number).multiply(BigDecimal.valueOf(number)); - log.info("square of {} is {}", number, square); - return square; - } + @Cacheable(value = "squareCache", key = "#number", condition = "#number>10") + public BigDecimal square(Long number) { + BigDecimal square = BigDecimal.valueOf(number) + .multiply(BigDecimal.valueOf(number)); + log.info("square of {} is {}", number, square); + return square; + } } diff --git a/spring-ehcache/src/main/resources/application.properties b/spring-ehcache/src/main/resources/application.properties new file mode 100644 index 0000000000..a5c2964d32 --- /dev/null +++ b/spring-ehcache/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.cache.jcache.config=classpath:ehcache.xml \ No newline at end of file diff --git a/spring-ehcache/src/main/resources/ehcache.xml b/spring-ehcache/src/main/resources/ehcache.xml new file mode 100644 index 0000000000..caba0f2cc4 --- /dev/null +++ b/spring-ehcache/src/main/resources/ehcache.xml @@ -0,0 +1,31 @@ + + + + java.lang.Long + java.math.BigDecimal + + 30 + + + + + com.baeldung.cachetest.config.CacheEventLogger + ASYNCHRONOUS + UNORDERED + CREATED + EXPIRED + + + + + 2 + 10 + + + + \ No newline at end of file From 81f23992cb19ef7860cc4faa57df167a5d6d8ecd Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Mon, 21 Jan 2019 13:08:09 +0400 Subject: [PATCH 270/441] primitive collections --- .../baeldung/array/PrimitiveCollections.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java b/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java index b991dcb598..85f4dd2498 100644 --- a/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java +++ b/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java @@ -2,8 +2,6 @@ package com.baeldung.array; import com.google.common.primitives.ImmutableIntArray; import com.google.common.primitives.Ints; -import gnu.trove.list.TIntList; -import gnu.trove.list.array.TIntArrayList; import java.util.Arrays; import java.util.List; @@ -14,25 +12,21 @@ public class PrimitiveCollections { int[] primitives = new int[] {5, 10, 0, 2}; - //guavaPrimitives(primitives); - - trovePrimitives(primitives); + guavaPrimitives(primitives); } - private static void trovePrimitives(int[] primitives) { - TIntList tList = new TIntArrayList(primitives); - tList.reverse(); - System.out.println(tList); - System.out.println(tList.size()); - } private static void guavaPrimitives(int[] primitives) { - ImmutableIntArray list = ImmutableIntArray.builder().addAll(primitives).build(); + ImmutableIntArray immutableIntArray = ImmutableIntArray.builder().addAll(primitives).build(); + System.out.println(immutableIntArray); - List integers = Ints.asList(primitives); + List list = Ints.asList(primitives); - int[] primitive = Ints.toArray(Arrays.asList(1, 2, 3, 4, 5)); - System.out.println(Arrays.toString(primitive)); + int[] primitiveArray = Ints.toArray(list); + + int[] concatenated = Ints.concat(primitiveArray, primitives); + + System.out.println(Arrays.toString(concatenated)); } } From a608d7cd1553ae67508054446c30a44b54b9c5c8 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Mon, 21 Jan 2019 15:12:25 +0000 Subject: [PATCH 271/441] BAEL-2491: Conditionally enable spring scheduled jobs --- spring-scheduling/.gitignore | 25 ++ .../.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 48337 bytes .../.mvn/wrapper/maven-wrapper.properties | 1 + spring-scheduling/mvnw | 286 ++++++++++++++++++ spring-scheduling/mvnw.cmd | 161 ++++++++++ spring-scheduling/pom.xml | 42 +++ .../scheduling/ScheduleJobsByProfile.java | 20 ++ .../com/baeldung/scheduling/ScheduledJob.java | 21 ++ .../scheduling/ScheduledJobsWithBoolean.java | 28 ++ .../ScheduledJobsWithConditional.java | 20 ++ .../ScheduledJobsWithExpression.java | 23 ++ .../scheduling/SchedulingApplication.java | 16 + .../src/main/resources/application.properties | 0 .../SchedulingApplicationTests.java | 17 ++ 14 files changed, 660 insertions(+) create mode 100644 spring-scheduling/.gitignore create mode 100644 spring-scheduling/.mvn/wrapper/maven-wrapper.jar create mode 100644 spring-scheduling/.mvn/wrapper/maven-wrapper.properties create mode 100755 spring-scheduling/mvnw create mode 100644 spring-scheduling/mvnw.cmd create mode 100644 spring-scheduling/pom.xml create mode 100644 spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java create mode 100644 spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJob.java create mode 100644 spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java create mode 100644 spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java create mode 100644 spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java create mode 100644 spring-scheduling/src/main/java/com/baeldung/scheduling/SchedulingApplication.java create mode 100644 spring-scheduling/src/main/resources/application.properties create mode 100644 spring-scheduling/src/test/java/com/baeldung/scheduling/SchedulingApplicationTests.java diff --git a/spring-scheduling/.gitignore b/spring-scheduling/.gitignore new file mode 100644 index 0000000000..82eca336e3 --- /dev/null +++ b/spring-scheduling/.gitignore @@ -0,0 +1,25 @@ +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/build/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ \ No newline at end of file diff --git a/spring-scheduling/.mvn/wrapper/maven-wrapper.jar b/spring-scheduling/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..01e67997377a393fd672c7dcde9dccbedf0cb1e9 GIT binary patch literal 48337 zcmbTe1CV9Qwl>;j+wQV$+qSXFw%KK)%eHN!%U!l@+x~l>b1vR}@9y}|TM-#CBjy|< zb7YRpp)Z$$Gzci_H%LgxZ{NNV{%Qa9gZlF*E2<($D=8;N5Asbx8se{Sz5)O13x)rc z5cR(k$_mO!iis+#(8-D=#R@|AF(8UQ`L7dVNSKQ%v^P|1A%aF~Lye$@HcO@sMYOb3 zl`5!ThJ1xSJwsg7hVYFtE5vS^5UE0$iDGCS{}RO;R#3y#{w-1hVSg*f1)7^vfkxrm!!N|oTR0Hj?N~IbVk+yC#NK} z5myv()UMzV^!zkX@O=Yf!(Z_bF7}W>k*U4@--&RH0tHiHY0IpeezqrF#@8{E$9d=- z7^kT=1Bl;(Q0k{*_vzz1Et{+*lbz%mkIOw(UA8)EE-Pkp{JtJhe@VXQ8sPNTn$Vkj zicVp)sV%0omhsj;NCmI0l8zzAipDV#tp(Jr7p_BlL$}Pys_SoljztS%G-Wg+t z&Q#=<03Hoga0R1&L!B);r{Cf~b$G5p#@?R-NNXMS8@cTWE^7V!?ixz(Ag>lld;>COenWc$RZ61W+pOW0wh>sN{~j; zCBj!2nn|4~COwSgXHFH?BDr8pK323zvmDK-84ESq25b;Tg%9(%NneBcs3;r znZpzntG%E^XsSh|md^r-k0Oen5qE@awGLfpg;8P@a-s<{Fwf?w3WapWe|b-CQkqlo z46GmTdPtkGYdI$e(d9Zl=?TU&uv94VR`g|=7xB2Ur%=6id&R2 z4e@fP7`y58O2sl;YBCQFu7>0(lVt-r$9|06Q5V>4=>ycnT}Fyz#9p;3?86`ZD23@7 z7n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Mej|VcK+?iew zQ3=DH4zz;i>z{Yv_l@j*?{936kxM{c7eK$1cf8wxL>>O#`+vsu*KR)te$adfTD*w( zAStXnZk<6N3V-Vs#GB%vXZat+(EFWbkbky#{yGY`rOvN)?{5qUuFv=r=dyYZrULf%MppWuNRUWc z8|YaIn}P0DGkwSZ(njAO$Zhr3Yw`3O1A+&F*2UjO{0`P%kK(qL;kEkfjRC=lxPRjL z{{4PO3-*5RZ_B3LUB&?ZpJ4nk1E4L&eT~HX0Jo(|uGQCW3utB@p)rF@W*n$==TlS zKiTfzhrLbAeRqru%D;fUwXOUcHud{pw@Ib1xxQ}<2)?KC&%y5PVef<7rcu2l!8dsy z?lvdaHJ#s$0m18y{x#fB$o=l)-sV?Qya5GWf#8Vd{~Grn@qgX#!EI`Y>++l%1A;eL z{_7t6jMeEr@a+oxyCL^+_}9Qc;i0&Xd%LXp?to*R|26LKHG(m0)*QF4*h;5%YG5<9)c> z1vq!7bIJSv1^27i-mcH!zX>ep3Iw0^{nx<1jOy)N_UoFD8v}x~2mEWapI3m~kMQkR z#&@4FuEGBn`mgtSx6jeY7vUQNf=^}sTZErIEpH!cy|@7Z zU4h_Oxxd2s=f{}$XXy4}%JqTSjRC \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/spring-scheduling/mvnw.cmd b/spring-scheduling/mvnw.cmd new file mode 100644 index 0000000000..e5cfb0ae9e --- /dev/null +++ b/spring-scheduling/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/spring-scheduling/pom.xml b/spring-scheduling/pom.xml new file mode 100644 index 0000000000..d739985f7c --- /dev/null +++ b/spring-scheduling/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.2.RELEASE + + + com.baeldung + scheduling + 0.0.1-SNAPSHOT + scheduling + Example of conditionally enabling spring scheduled jobs + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java new file mode 100644 index 0000000000..33cd44331f --- /dev/null +++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java @@ -0,0 +1,20 @@ +package com.baeldung.scheduling; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +@Configuration +public class ScheduleJobsByProfile { + + private final static Logger LOG = LoggerFactory.getLogger(ScheduleJobsByProfile.class); + + @Profile("prod") + @Bean + public ScheduledJob scheduledJob() + { + return new ScheduledJob("@Profile"); + } +} diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJob.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJob.java new file mode 100644 index 0000000000..df7cefcd3c --- /dev/null +++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJob.java @@ -0,0 +1,21 @@ +package com.baeldung.scheduling; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Scheduled; + +public class ScheduledJob { + + private String source; + + public ScheduledJob(String source) { + this.source = source; + } + + private final static Logger LOG = LoggerFactory.getLogger(ScheduledJob.class); + + @Scheduled(fixedDelay = 60000) + public void cleanTempDir() { + LOG.info("Cleaning temp directory via {}", source); + } +} diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java new file mode 100644 index 0000000000..b03de61641 --- /dev/null +++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java @@ -0,0 +1,28 @@ +package com.baeldung.scheduling; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +@Configuration +public class ScheduledJobsWithBoolean { + + private final static Logger LOG = LoggerFactory.getLogger(ScheduledJobsWithBoolean.class); + + @Value("${jobs.enabled:true}") + private boolean isEnabled; + + /** + * A scheduled job controlled via application property. The job always + * executes, but the logic inside is protected by a configurable boolean + * flag. + */ + @Scheduled(fixedDelay = 60000) + public void cleanTempDirectory() { + if(isEnabled) { + LOG.info("Cleaning temp directory via boolean flag"); + } + } +} diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java new file mode 100644 index 0000000000..081c8d990a --- /dev/null +++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java @@ -0,0 +1,20 @@ +package com.baeldung.scheduling; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ScheduledJobsWithConditional +{ + /** + * This uses @ConditionalOnProperty to conditionally create a bean, which itself + * is a scheduled job. + * @return ScheduledJob + */ + @Bean + @ConditionalOnProperty(value = "jobs.enabled", matchIfMissing = true, havingValue = "true") + public ScheduledJob runMyCronTask() { + return new ScheduledJob("@ConditionalOnProperty"); + } +} diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java new file mode 100644 index 0000000000..577a01f241 --- /dev/null +++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java @@ -0,0 +1,23 @@ +package com.baeldung.scheduling; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +@Configuration +public class ScheduledJobsWithExpression +{ + private final static Logger LOG = + LoggerFactory.getLogger(ScheduledJobsWithExpression.class); + + /** + * A scheduled job controlled via application property. The job always + * executes, but the logic inside is protected by a configurable boolean + * flag. + */ + @Scheduled(cron = "${jobs.cronSchedule:-}") + public void cleanTempDirectory() { + LOG.info("Cleaning temp directory via placeholder"); + } +} diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/SchedulingApplication.java b/spring-scheduling/src/main/java/com/baeldung/scheduling/SchedulingApplication.java new file mode 100644 index 0000000000..913e2137f8 --- /dev/null +++ b/spring-scheduling/src/main/java/com/baeldung/scheduling/SchedulingApplication.java @@ -0,0 +1,16 @@ +package com.baeldung.scheduling; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +@EnableScheduling +public class SchedulingApplication { + + public static void main(String[] args) { + SpringApplication.run(SchedulingApplication.class, args); + } + +} + diff --git a/spring-scheduling/src/main/resources/application.properties b/spring-scheduling/src/main/resources/application.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spring-scheduling/src/test/java/com/baeldung/scheduling/SchedulingApplicationTests.java b/spring-scheduling/src/test/java/com/baeldung/scheduling/SchedulingApplicationTests.java new file mode 100644 index 0000000000..60e6d820bb --- /dev/null +++ b/spring-scheduling/src/test/java/com/baeldung/scheduling/SchedulingApplicationTests.java @@ -0,0 +1,17 @@ +package com.baeldung.scheduling; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SchedulingApplicationTests { + + @Test + public void contextLoads() { + } + +} + From 196c17e612c00e789d2aee0138709ae8c49362fb Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Mon, 21 Jan 2019 15:14:13 +0000 Subject: [PATCH 272/441] BAEL-2491: Conditionally enable spring scheduled jobs --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1c0738cafb..1f25dd0691 100644 --- a/pom.xml +++ b/pom.xml @@ -714,7 +714,7 @@ spring-rest-simple spring-resttemplate spring-roo - + spring-scheduling spring-security-acl spring-security-angular/server spring-security-cache-control From 974950923c1069448c873033f27f42463d1c2350 Mon Sep 17 00:00:00 2001 From: Trevor Gowing Date: Mon, 24 Dec 2018 17:15:46 +0200 Subject: [PATCH 273/441] Refactor Passenger Entity Change seat number type to integer wrapper. Enable QuerybyExample (QBE) BAEL-2406 --- .../src/main/java/com/baeldung/passenger/Passenger.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/Passenger.java b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/Passenger.java index 24ae47e597..a96b1edb20 100644 --- a/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/Passenger.java +++ b/persistence-modules/spring-data-jpa/src/main/java/com/baeldung/passenger/Passenger.java @@ -25,15 +25,15 @@ class Passenger { @Basic(optional = false) @Column(nullable = false) - private int seatNumber; + private Integer seatNumber; - private Passenger(String firstName, String lastName, int seatNumber) { + private Passenger(String firstName, String lastName, Integer seatNumber) { this.firstName = firstName; this.lastName = lastName; this.seatNumber = seatNumber; } - static Passenger from(String firstName, String lastName, int seatNumber) { + static Passenger from(String firstName, String lastName, Integer seatNumber) { return new Passenger(firstName, lastName, seatNumber); } @@ -76,7 +76,7 @@ class Passenger { return lastName; } - int getSeatNumber() { + Integer getSeatNumber() { return seatNumber; } } From 14b65b327f571594f1572df4c145a0097cd272e8 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Sun, 20 Jan 2019 18:19:52 -0200 Subject: [PATCH 274/441] moved Rest Pagination article code from spring-rest-full to spring-boot-rest --- spring-boot-rest/README.md | 1 + spring-boot-rest/pom.xml | 30 ++++- .../{web => }/SpringBootRestApplication.java | 2 +- .../com/baeldung/persistence/IOperations.java | 16 +++ .../com/baeldung/persistence/dao/IFooDao.java | 9 ++ .../com/baeldung/persistence/model/Foo.java | 83 ++++++++++++++ .../persistence/service/IFooService.java | 13 +++ .../service/common/AbstractService.java | 31 ++++++ .../persistence/service/impl/FooService.java | 40 +++++++ .../baeldung/spring/PersistenceConfig.java | 85 +++++++++++++++ .../java/com/baeldung/spring/WebConfig.java | 43 ++++++++ .../web/config/MyErrorController.java | 1 - .../com/baeldung/web/config/WebConfig.java | 8 -- .../web/controller/FooController.java | 89 +++++++++++++++ .../web/controller/RootController.java | 40 +++++++ .../event/PaginatedResultsRetrievedEvent.java | 2 +- .../hateoas/event/ResourceCreatedEvent.java | 28 +++++ ...sultsRetrievedDiscoverabilityListener.java | 6 +- ...esourceCreatedDiscoverabilityListener.java | 36 ++++++ .../java/com/baeldung/web/util/LinkUtil.java | 36 ++++++ .../baeldung/web/util/RestPreconditions.java | 48 ++++++++ .../src/main/resources/application.properties | 3 + .../main/resources/persistence-h2.properties | 22 ++++ .../resources/persistence-mysql.properties | 10 ++ .../resources/springDataPersistenceConfig.xml | 12 ++ .../src/test/java/com/baeldung/Consts.java | 5 + .../SpringContextIntegrationTest.java | 2 +- .../common/web/AbstractBasicLiveTest.java | 103 ++++++++++++++++++ .../baeldung/common/web/AbstractLiveTest.java | 65 +++++++++++ .../spring/ConfigIntegrationTest.java | 17 +++ .../java/com/baeldung/test/IMarshaller.java | 15 +++ .../com/baeldung/test/JacksonMarshaller.java | 81 ++++++++++++++ .../baeldung/test/TestMarshallerFactory.java | 49 +++++++++ .../java/com/baeldung/web/FooLiveTest.java | 36 ++++++ .../baeldung/web/FooPageableLiveTest.java | 22 ++-- .../baeldung/web/LiveTestSuiteLiveTest.java | 14 +++ .../web/error/ErrorHandlingLiveTest.java | 7 +- .../baeldung/web/util/HTTPLinkHeaderUtil.java | 36 ++++++ spring-rest-full/README.md | 1 - .../org/baeldung/persistence/IOperations.java | 4 - .../persistence/service/IFooService.java | 4 - .../service/common/AbstractService.java | 7 -- .../persistence/service/impl/FooService.java | 7 -- .../web/controller/FooController.java | 31 ------ .../baeldung/web/util/RestPreconditions.java | 3 +- .../common/web/AbstractBasicLiveTest.java | 80 +------------- .../web/AbstractDiscoverabilityLiveTest.java | 5 +- .../baeldung/web/LiveTestSuiteLiveTest.java | 1 - 48 files changed, 1125 insertions(+), 164 deletions(-) rename spring-boot-rest/src/main/java/com/baeldung/{web => }/SpringBootRestApplication.java (92%) create mode 100644 spring-boot-rest/src/main/java/com/baeldung/persistence/IOperations.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/persistence/dao/IFooDao.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/persistence/model/Foo.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/persistence/service/IFooService.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/persistence/service/common/AbstractService.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/persistence/service/impl/FooService.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java delete mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/config/WebConfig.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/controller/FooController.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/controller/RootController.java rename {spring-rest-full/src/main/java/org => spring-boot-rest/src/main/java/com}/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java (97%) create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/ResourceCreatedEvent.java rename {spring-rest-full/src/main/java/org => spring-boot-rest/src/main/java/com}/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java (96%) create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/util/LinkUtil.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/util/RestPreconditions.java create mode 100644 spring-boot-rest/src/main/resources/persistence-h2.properties create mode 100644 spring-boot-rest/src/main/resources/persistence-mysql.properties create mode 100644 spring-boot-rest/src/main/resources/springDataPersistenceConfig.xml create mode 100644 spring-boot-rest/src/test/java/com/baeldung/Consts.java rename spring-boot-rest/src/test/java/com/baeldung/{web => }/SpringContextIntegrationTest.java (92%) create mode 100644 spring-boot-rest/src/test/java/com/baeldung/common/web/AbstractBasicLiveTest.java create mode 100644 spring-boot-rest/src/test/java/com/baeldung/common/web/AbstractLiveTest.java create mode 100644 spring-boot-rest/src/test/java/com/baeldung/spring/ConfigIntegrationTest.java create mode 100644 spring-boot-rest/src/test/java/com/baeldung/test/IMarshaller.java create mode 100644 spring-boot-rest/src/test/java/com/baeldung/test/JacksonMarshaller.java create mode 100644 spring-boot-rest/src/test/java/com/baeldung/test/TestMarshallerFactory.java create mode 100644 spring-boot-rest/src/test/java/com/baeldung/web/FooLiveTest.java rename {spring-rest-full/src/test/java/org => spring-boot-rest/src/test/java/com}/baeldung/web/FooPageableLiveTest.java (86%) create mode 100644 spring-boot-rest/src/test/java/com/baeldung/web/LiveTestSuiteLiveTest.java create mode 100644 spring-boot-rest/src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index 2b955ddc5b..2c89a64a00 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -2,3 +2,4 @@ Module for the articles that 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. [Error Handling for REST with Spring](http://www.baeldung.com/exception-handling-for-rest-with-spring) +3. [REST Pagination in Spring](http://www.baeldung.com/rest-api-pagination-in-spring) \ No newline at end of file diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index f05d242072..bcd0381603 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -1,5 +1,6 @@ - 4.0.0 com.baeldung.web @@ -24,7 +25,7 @@ com.fasterxml.jackson.dataformat jackson-dataformat-xml - + org.hibernate hibernate-entitymanager @@ -32,6 +33,30 @@ org.springframework spring-jdbc + + org.springframework.data + spring-data-jpa + + + com.h2database + h2 + + + org.springframework + spring-tx + + + org.springframework.data + spring-data-commons + + + + + + com.google.guava + guava + ${guava.version} + org.springframework.boot @@ -58,5 +83,6 @@ com.baeldung.SpringBootRestApplication 2.32 + 27.0.1-jre diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java b/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java similarity index 92% rename from spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java rename to spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java index c945b20aa1..62aae7619d 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java +++ b/spring-boot-rest/src/main/java/com/baeldung/SpringBootRestApplication.java @@ -1,4 +1,4 @@ -package com.baeldung.web; +package com.baeldung; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/IOperations.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/IOperations.java new file mode 100644 index 0000000000..d8996ca50d --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/IOperations.java @@ -0,0 +1,16 @@ +package com.baeldung.persistence; + +import java.io.Serializable; + +import org.springframework.data.domain.Page; + +public interface IOperations { + + // read - all + + Page findPaginated(int page, int size); + + // write + + T create(final T entity); +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/dao/IFooDao.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 0000000000..59394d0d28 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,9 @@ +package com.baeldung.persistence.dao; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.baeldung.persistence.model.Foo; + +public interface IFooDao extends JpaRepository { + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Foo.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Foo.java new file mode 100644 index 0000000000..9af3d07bed --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/model/Foo.java @@ -0,0 +1,83 @@ +package com.baeldung.persistence.model; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Foo implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @Column(nullable = false) + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/service/IFooService.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/IFooService.java new file mode 100644 index 0000000000..0f165238eb --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/IFooService.java @@ -0,0 +1,13 @@ +package com.baeldung.persistence.service; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import com.baeldung.persistence.IOperations; +import com.baeldung.persistence.model.Foo; + +public interface IFooService extends IOperations { + + Page findPaginated(Pageable pageable); + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/service/common/AbstractService.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/common/AbstractService.java new file mode 100644 index 0000000000..871f768895 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/common/AbstractService.java @@ -0,0 +1,31 @@ +package com.baeldung.persistence.service.common; + +import java.io.Serializable; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.transaction.annotation.Transactional; + +import com.baeldung.persistence.IOperations; + +@Transactional +public abstract class AbstractService implements IOperations { + + // read - all + + @Override + public Page findPaginated(final int page, final int size) { + return getDao().findAll(PageRequest.of(page, size)); + } + + // write + + @Override + public T create(final T entity) { + return getDao().save(entity); + } + + protected abstract PagingAndSortingRepository getDao(); + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/service/impl/FooService.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/impl/FooService.java new file mode 100644 index 0000000000..9d705f51d3 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/impl/FooService.java @@ -0,0 +1,40 @@ +package com.baeldung.persistence.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.persistence.service.common.AbstractService; + +@Service +@Transactional +public class FooService extends AbstractService implements IFooService { + + @Autowired + private IFooDao dao; + + public FooService() { + super(); + } + + // API + + @Override + protected PagingAndSortingRepository getDao() { + return dao; + } + + // custom methods + + @Override + public Page findPaginated(Pageable pageable) { + return dao.findAll(pageable); + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java new file mode 100644 index 0000000000..4a4b9eee3f --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -0,0 +1,85 @@ +package com.baeldung.spring; + +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import com.google.common.base.Preconditions; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-${envTarget:h2}.properties" }) +@ComponentScan({ "com.baeldung.persistence" }) +// @ImportResource("classpath*:springDataPersistenceConfig.xml") +@EnableJpaRepositories(basePackages = "com.baeldung.persistence.dao") +public class PersistenceConfig { + + @Autowired + private Environment env; + + public PersistenceConfig() { + super(); + } + + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(dataSource()); + em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + + final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + // vendorAdapter.set + em.setJpaVendorAdapter(vendorAdapter); + em.setJpaProperties(additionalProperties()); + + return em; + } + + @Bean + public DataSource dataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public PlatformTransactionManager transactionManager() { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); + + return transactionManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + final Properties additionalProperties() { + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; + } + +} \ No newline at end of file diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java new file mode 100644 index 0000000000..39aade174b --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java @@ -0,0 +1,43 @@ +package com.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.view.InternalResourceViewResolver; + +@Configuration +@ComponentScan("com.baeldung.web") +@EnableWebMvc +public class WebConfig implements WebMvcConfigurer { + + public WebConfig() { + super(); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); + viewResolver.setPrefix("/WEB-INF/view/"); + viewResolver.setSuffix(".jsp"); + return viewResolver; + } + + // API + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + registry.addViewController("/graph.html"); + registry.addViewController("/homepage.html"); + } + + @Override + public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { + configurer.defaultContentType(MediaType.APPLICATION_JSON); + } + +} \ No newline at end of file diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/config/MyErrorController.java b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyErrorController.java index e3716ec113..cf3f9c4dbd 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/web/config/MyErrorController.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyErrorController.java @@ -27,5 +27,4 @@ public class MyErrorController extends BasicErrorController { HttpStatus status = getStatus(request); return new ResponseEntity<>(body, status); } - } diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/config/WebConfig.java b/spring-boot-rest/src/main/java/com/baeldung/web/config/WebConfig.java deleted file mode 100644 index 808e946218..0000000000 --- a/spring-boot-rest/src/main/java/com/baeldung/web/config/WebConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.web.config; - -import org.springframework.context.annotation.Configuration; - -@Configuration -public class WebConfig { - -} \ No newline at end of file diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/controller/FooController.java b/spring-boot-rest/src/main/java/com/baeldung/web/controller/FooController.java new file mode 100644 index 0000000000..b35295cf99 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/controller/FooController.java @@ -0,0 +1,89 @@ +package com.baeldung.web.controller; + +import java.util.List; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.util.UriComponentsBuilder; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.web.exception.MyResourceNotFoundException; +import com.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; +import com.baeldung.web.hateoas.event.ResourceCreatedEvent; +import com.google.common.base.Preconditions; + +@Controller +@RequestMapping(value = "/auth/foos") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + @Autowired + private IFooService service; + + public FooController() { + super(); + } + + // API + + // read - all + + @RequestMapping(params = { "page", "size" }, method = RequestMethod.GET) + @ResponseBody + public List findPaginated(@RequestParam("page") final int page, @RequestParam("size") final int size, + final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + final Page resultPage = service.findPaginated(page, size); + if (page > resultPage.getTotalPages()) { + throw new MyResourceNotFoundException(); + } + eventPublisher.publishEvent(new PaginatedResultsRetrievedEvent(Foo.class, uriBuilder, response, page, + resultPage.getTotalPages(), size)); + + return resultPage.getContent(); + } + + @GetMapping("/pageable") + @ResponseBody + public List findPaginatedWithPageable(Pageable pageable, final UriComponentsBuilder uriBuilder, + final HttpServletResponse response) { + final Page resultPage = service.findPaginated(pageable); + if (pageable.getPageNumber() > resultPage.getTotalPages()) { + throw new MyResourceNotFoundException(); + } + eventPublisher.publishEvent(new PaginatedResultsRetrievedEvent(Foo.class, uriBuilder, response, + pageable.getPageNumber(), resultPage.getTotalPages(), pageable.getPageSize())); + + return resultPage.getContent(); + } + + // write + + @RequestMapping(method = RequestMethod.POST) + @ResponseStatus(HttpStatus.CREATED) + @ResponseBody + public Foo create(@RequestBody final Foo resource, final HttpServletResponse response) { + Preconditions.checkNotNull(resource); + final Foo foo = service.create(resource); + final Long idOfCreatedResource = foo.getId(); + + eventPublisher.publishEvent(new ResourceCreatedEvent(this, response, idOfCreatedResource)); + + return foo; + } +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/controller/RootController.java b/spring-boot-rest/src/main/java/com/baeldung/web/controller/RootController.java new file mode 100644 index 0000000000..436e41e8eb --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/controller/RootController.java @@ -0,0 +1,40 @@ +package com.baeldung.web.controller; + +import java.net.URI; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.util.UriTemplate; + +import com.baeldung.web.util.LinkUtil; + +@Controller +@RequestMapping(value = "/auth/") +public class RootController { + + public RootController() { + super(); + } + + // API + + // discover + + @RequestMapping(value = "admin", method = RequestMethod.GET) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void adminRoot(final HttpServletRequest request, final HttpServletResponse response) { + final String rootUri = request.getRequestURL() + .toString(); + + final URI fooUri = new UriTemplate("{rootUri}/{resource}").expand(rootUri, "foo"); + final String linkToFoo = LinkUtil.createLinkHeader(fooUri.toASCIIString(), "collection"); + response.addHeader("Link", linkToFoo); + } + +} diff --git a/spring-rest-full/src/main/java/org/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java similarity index 97% rename from spring-rest-full/src/main/java/org/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java rename to spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java index 01f7e658f1..f62fbf6247 100644 --- a/spring-rest-full/src/main/java/org/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/PaginatedResultsRetrievedEvent.java @@ -1,4 +1,4 @@ -package org.baeldung.web.hateoas.event; +package com.baeldung.web.hateoas.event; import java.io.Serializable; diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/ResourceCreatedEvent.java b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/ResourceCreatedEvent.java new file mode 100644 index 0000000000..b602f7ec4b --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/ResourceCreatedEvent.java @@ -0,0 +1,28 @@ +package com.baeldung.web.hateoas.event; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class ResourceCreatedEvent extends ApplicationEvent { + private final HttpServletResponse response; + private final long idOfNewResource; + + public ResourceCreatedEvent(final Object source, final HttpServletResponse response, final long idOfNewResource) { + super(source); + + this.response = response; + this.idOfNewResource = idOfNewResource; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + + public long getIdOfNewResource() { + return idOfNewResource; + } + +} diff --git a/spring-rest-full/src/main/java/org/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java similarity index 96% rename from spring-rest-full/src/main/java/org/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java rename to spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java index 603c91007d..bb60bab171 100644 --- a/spring-rest-full/src/main/java/org/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java @@ -1,13 +1,13 @@ -package org.baeldung.web.hateoas.listener; +package com.baeldung.web.hateoas.listener; import javax.servlet.http.HttpServletResponse; -import org.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; -import org.baeldung.web.util.LinkUtil; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; import org.springframework.web.util.UriComponentsBuilder; +import com.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; +import com.baeldung.web.util.LinkUtil; import com.google.common.base.Preconditions; import com.google.common.net.HttpHeaders; diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java new file mode 100644 index 0000000000..37afcdace4 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/ResourceCreatedDiscoverabilityListener.java @@ -0,0 +1,36 @@ +package com.baeldung.web.hateoas.listener; + +import java.net.URI; + +import javax.servlet.http.HttpServletResponse; + +import org.apache.http.HttpHeaders; +import com.baeldung.web.hateoas.event.ResourceCreatedEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +import com.google.common.base.Preconditions; + +@Component +class ResourceCreatedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final ResourceCreatedEvent resourceCreatedEvent) { + Preconditions.checkNotNull(resourceCreatedEvent); + + final HttpServletResponse response = resourceCreatedEvent.getResponse(); + final long idOfNewResource = resourceCreatedEvent.getIdOfNewResource(); + + addLinkHeaderOnResourceCreation(response, idOfNewResource); + } + + void addLinkHeaderOnResourceCreation(final HttpServletResponse response, final long idOfNewResource) { + // final String requestUrl = request.getRequestURL().toString(); + // final URI uri = new UriTemplate("{requestUrl}/{idOfNewResource}").expand(requestUrl, idOfNewResource); + + final URI uri = ServletUriComponentsBuilder.fromCurrentRequestUri().path("/{idOfNewResource}").buildAndExpand(idOfNewResource).toUri(); + response.setHeader(HttpHeaders.LOCATION, uri.toASCIIString()); + } + +} \ No newline at end of file diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/util/LinkUtil.java b/spring-boot-rest/src/main/java/com/baeldung/web/util/LinkUtil.java new file mode 100644 index 0000000000..3ebba8ae1c --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/util/LinkUtil.java @@ -0,0 +1,36 @@ +package com.baeldung.web.util; + +import javax.servlet.http.HttpServletResponse; + +/** + * Provides some constants and utility methods to build a Link Header to be stored in the {@link HttpServletResponse} object + */ +public final class LinkUtil { + + public static final String REL_COLLECTION = "collection"; + public static final String REL_NEXT = "next"; + public static final String REL_PREV = "prev"; + public static final String REL_FIRST = "first"; + public static final String REL_LAST = "last"; + + private LinkUtil() { + throw new AssertionError(); + } + + // + + /** + * Creates a Link Header to be stored in the {@link HttpServletResponse} to provide Discoverability features to the user + * + * @param uri + * the base uri + * @param rel + * the relative path + * + * @return the complete url + */ + public static String createLinkHeader(final String uri, final String rel) { + return "<" + uri + ">; rel=\"" + rel + "\""; + } + +} diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/util/RestPreconditions.java b/spring-boot-rest/src/main/java/com/baeldung/web/util/RestPreconditions.java new file mode 100644 index 0000000000..d86aeeebd1 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/util/RestPreconditions.java @@ -0,0 +1,48 @@ +package com.baeldung.web.util; + +import org.springframework.http.HttpStatus; + +import com.baeldung.web.exception.MyResourceNotFoundException; + +/** + * Simple static methods to be called at the start of your own methods to verify correct arguments and state. If the Precondition fails, an {@link HttpStatus} code is thrown + */ +public final class RestPreconditions { + + private RestPreconditions() { + throw new AssertionError(); + } + + // API + + /** + * Check if some value was found, otherwise throw exception. + * + * @param expression + * has value true if found, otherwise false + * @throws MyResourceNotFoundException + * if expression is false, means value not found. + */ + public static void checkFound(final boolean expression) { + if (!expression) { + throw new MyResourceNotFoundException(); + } + } + + /** + * Check if some value was found, otherwise throw exception. + * + * @param expression + * has value true if found, otherwise false + * @throws MyResourceNotFoundException + * if expression is false, means value not found. + */ + public static T checkFound(final T resource) { + if (resource == null) { + throw new MyResourceNotFoundException(); + } + + return resource; + } + +} diff --git a/spring-boot-rest/src/main/resources/application.properties b/spring-boot-rest/src/main/resources/application.properties index e65440e2b9..a0179f1e4b 100644 --- a/spring-boot-rest/src/main/resources/application.properties +++ b/spring-boot-rest/src/main/resources/application.properties @@ -1,3 +1,6 @@ +server.port=8082 +server.servlet.context-path=/spring-boot-rest + ### Spring Boot default error handling configurations #server.error.whitelabel.enabled=false #server.error.include-stacktrace=always \ No newline at end of file diff --git a/spring-boot-rest/src/main/resources/persistence-h2.properties b/spring-boot-rest/src/main/resources/persistence-h2.properties new file mode 100644 index 0000000000..839a466533 --- /dev/null +++ b/spring-boot-rest/src/main/resources/persistence-h2.properties @@ -0,0 +1,22 @@ +## jdbc.X +#jdbc.driverClassName=com.mysql.jdbc.Driver +#jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true +#jdbc.user=tutorialuser +#jdbc.pass=tutorialmy5ql +# +## hibernate.X +#hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +#hibernate.show_sql=false +#hibernate.hbm2ddl.auto=create-drop + + +# jdbc.X +jdbc.driverClassName=org.h2.Driver +jdbc.url=jdbc:h2:mem:security_permission;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE +jdbc.user=sa +jdbc.pass= + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-boot-rest/src/main/resources/persistence-mysql.properties b/spring-boot-rest/src/main/resources/persistence-mysql.properties new file mode 100644 index 0000000000..8263b0d9ac --- /dev/null +++ b/spring-boot-rest/src/main/resources/persistence-mysql.properties @@ -0,0 +1,10 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true +jdbc.user=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop diff --git a/spring-boot-rest/src/main/resources/springDataPersistenceConfig.xml b/spring-boot-rest/src/main/resources/springDataPersistenceConfig.xml new file mode 100644 index 0000000000..5ea2d9c05b --- /dev/null +++ b/spring-boot-rest/src/main/resources/springDataPersistenceConfig.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/spring-boot-rest/src/test/java/com/baeldung/Consts.java b/spring-boot-rest/src/test/java/com/baeldung/Consts.java new file mode 100644 index 0000000000..e33efd589e --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/Consts.java @@ -0,0 +1,5 @@ +package com.baeldung; + +public interface Consts { + int APPLICATION_PORT = 8082; +} diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java similarity index 92% rename from spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java rename to spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java index 1e49df2909..25fbc4cc02 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/web/SpringContextIntegrationTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.web; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-rest/src/test/java/com/baeldung/common/web/AbstractBasicLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/common/web/AbstractBasicLiveTest.java new file mode 100644 index 0000000000..61eb9400cc --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/common/web/AbstractBasicLiveTest.java @@ -0,0 +1,103 @@ +package com.baeldung.common.web; + +import static com.baeldung.web.util.HTTPLinkHeaderUtil.extractURIByRel; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; + +import java.io.Serializable; +import java.util.List; + +import org.junit.Test; + +import com.google.common.net.HttpHeaders; + +import io.restassured.RestAssured; +import io.restassured.response.Response; + +public abstract class AbstractBasicLiveTest extends AbstractLiveTest { + + public AbstractBasicLiveTest(final Class clazzToSet) { + super(clazzToSet); + } + + // find - all - paginated + + @Test + public void whenResourcesAreRetrievedPaged_then200IsReceived() { + create(); + + final Response response = RestAssured.get(getURL() + "?page=0&size=10"); + + assertThat(response.getStatusCode(), is(200)); + } + + @Test + public void whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived() { + final String url = getURL() + "?page=" + randomNumeric(5) + "&size=10"; + final Response response = RestAssured.get(url); + + assertThat(response.getStatusCode(), is(404)); + } + + @Test + public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { + create(); + + final Response response = RestAssured.get(getURL() + "?page=0&size=10"); + + assertFalse(response.body().as(List.class).isEmpty()); + } + + @Test + public void whenFirstPageOfResourcesAreRetrieved_thenSecondPageIsNext() { + create(); + create(); + create(); + + final Response response = RestAssured.get(getURL() + "?page=0&size=2"); + + final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); + assertEquals(getURL() + "?page=1&size=2", uriToNextPage); + } + + @Test + public void whenFirstPageOfResourcesAreRetrieved_thenNoPreviousPage() { + final Response response = RestAssured.get(getURL() + "?page=0&size=2"); + + final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); + assertNull(uriToPrevPage); + } + + @Test + public void whenSecondPageOfResourcesAreRetrieved_thenFirstPageIsPrevious() { + create(); + create(); + + final Response response = RestAssured.get(getURL() + "?page=1&size=2"); + + final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); + assertEquals(getURL() + "?page=0&size=2", uriToPrevPage); + } + + @Test + public void whenLastPageOfResourcesIsRetrieved_thenNoNextPageIsDiscoverable() { + create(); + create(); + create(); + + final Response first = RestAssured.get(getURL() + "?page=0&size=2"); + final String uriToLastPage = extractURIByRel(first.getHeader(HttpHeaders.LINK), "last"); + + final Response response = RestAssured.get(uriToLastPage); + + final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); + assertNull(uriToNextPage); + } + + // count + +} diff --git a/spring-boot-rest/src/test/java/com/baeldung/common/web/AbstractLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/common/web/AbstractLiveTest.java new file mode 100644 index 0000000000..d26632bc38 --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/common/web/AbstractLiveTest.java @@ -0,0 +1,65 @@ +package com.baeldung.common.web; + +import io.restassured.RestAssured; +import io.restassured.response.Response; + +import static com.baeldung.Consts.APPLICATION_PORT; + +import java.io.Serializable; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.baeldung.test.IMarshaller; +import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; + +public abstract class AbstractLiveTest { + + protected final Class clazz; + + @Autowired + protected IMarshaller marshaller; + + public AbstractLiveTest(final Class clazzToSet) { + super(); + + Preconditions.checkNotNull(clazzToSet); + clazz = clazzToSet; + } + + // template method + + public abstract void create(); + + public abstract String createAsUri(); + + protected final void create(final T resource) { + createAsUri(resource); + } + + protected final String createAsUri(final T resource) { + final Response response = createAsResponse(resource); + Preconditions.checkState(response.getStatusCode() == 201, "create operation: " + response.getStatusCode()); + + final String locationOfCreatedResource = response.getHeader(HttpHeaders.LOCATION); + Preconditions.checkNotNull(locationOfCreatedResource); + return locationOfCreatedResource; + } + + final Response createAsResponse(final T resource) { + Preconditions.checkNotNull(resource); + + final String resourceAsString = marshaller.encode(resource); + return RestAssured.given() + .contentType(marshaller.getMime()) + .body(resourceAsString) + .post(getURL()); + } + + // + + protected String getURL() { + return "http://localhost:" + APPLICATION_PORT + "/spring-boot-rest/auth/foos"; + } + +} diff --git a/spring-boot-rest/src/test/java/com/baeldung/spring/ConfigIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/spring/ConfigIntegrationTest.java new file mode 100644 index 0000000000..da8421ea6c --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/spring/ConfigIntegrationTest.java @@ -0,0 +1,17 @@ +package com.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@ComponentScan("com.baeldung.test") +public class ConfigIntegrationTest implements WebMvcConfigurer { + + public ConfigIntegrationTest() { + super(); + } + + // API + +} \ No newline at end of file diff --git a/spring-boot-rest/src/test/java/com/baeldung/test/IMarshaller.java b/spring-boot-rest/src/test/java/com/baeldung/test/IMarshaller.java new file mode 100644 index 0000000000..e2198ecb59 --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/test/IMarshaller.java @@ -0,0 +1,15 @@ +package com.baeldung.test; + +import java.util.List; + +public interface IMarshaller { + + String encode(final T entity); + + T decode(final String entityAsString, final Class clazz); + + List decodeList(final String entitiesAsString, final Class clazz); + + String getMime(); + +} diff --git a/spring-boot-rest/src/test/java/com/baeldung/test/JacksonMarshaller.java b/spring-boot-rest/src/test/java/com/baeldung/test/JacksonMarshaller.java new file mode 100644 index 0000000000..23b5d60b6b --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/test/JacksonMarshaller.java @@ -0,0 +1,81 @@ +package com.baeldung.test; + +import java.io.IOException; +import java.util.List; + +import com.baeldung.persistence.model.Foo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.MediaType; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Preconditions; + +public final class JacksonMarshaller implements IMarshaller { + private final Logger logger = LoggerFactory.getLogger(JacksonMarshaller.class); + + private final ObjectMapper objectMapper; + + public JacksonMarshaller() { + super(); + + objectMapper = new ObjectMapper(); + } + + // API + + @Override + public final String encode(final T resource) { + Preconditions.checkNotNull(resource); + String entityAsJSON = null; + try { + entityAsJSON = objectMapper.writeValueAsString(resource); + } catch (final IOException ioEx) { + logger.error("", ioEx); + } + + return entityAsJSON; + } + + @Override + public final T decode(final String resourceAsString, final Class clazz) { + Preconditions.checkNotNull(resourceAsString); + + T entity = null; + try { + entity = objectMapper.readValue(resourceAsString, clazz); + } catch (final IOException ioEx) { + logger.error("", ioEx); + } + + return entity; + } + + @SuppressWarnings("unchecked") + @Override + public final List decodeList(final String resourcesAsString, final Class clazz) { + Preconditions.checkNotNull(resourcesAsString); + + List entities = null; + try { + if (clazz.equals(Foo.class)) { + entities = objectMapper.readValue(resourcesAsString, new TypeReference>() { + // ... + }); + } else { + entities = objectMapper.readValue(resourcesAsString, List.class); + } + } catch (final IOException ioEx) { + logger.error("", ioEx); + } + + return entities; + } + + @Override + public final String getMime() { + return MediaType.APPLICATION_JSON.toString(); + } + +} diff --git a/spring-boot-rest/src/test/java/com/baeldung/test/TestMarshallerFactory.java b/spring-boot-rest/src/test/java/com/baeldung/test/TestMarshallerFactory.java new file mode 100644 index 0000000000..740ee07839 --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/test/TestMarshallerFactory.java @@ -0,0 +1,49 @@ +package com.baeldung.test; + +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +@Profile("test") +public class TestMarshallerFactory implements FactoryBean { + + @Autowired + private Environment env; + + public TestMarshallerFactory() { + super(); + } + + // API + + @Override + public IMarshaller getObject() { + final String testMime = env.getProperty("test.mime"); + if (testMime != null) { + switch (testMime) { + case "json": + return new JacksonMarshaller(); + case "xml": + // If we need to implement xml marshaller we can include spring-rest-full XStreamMarshaller + throw new IllegalStateException(); + default: + throw new IllegalStateException(); + } + } + + return new JacksonMarshaller(); + } + + @Override + public Class getObjectType() { + return IMarshaller.class; + } + + @Override + public boolean isSingleton() { + return true; + } +} \ No newline at end of file diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/FooLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/FooLiveTest.java new file mode 100644 index 0000000000..f721489eff --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/web/FooLiveTest.java @@ -0,0 +1,36 @@ +package com.baeldung.web; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import org.junit.runner.RunWith; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.common.web.AbstractBasicLiveTest; +import com.baeldung.persistence.model.Foo; +import com.baeldung.spring.ConfigIntegrationTest; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { ConfigIntegrationTest.class }, loader = AnnotationConfigContextLoader.class) +@ActiveProfiles("test") +public class FooLiveTest extends AbstractBasicLiveTest { + + public FooLiveTest() { + super(Foo.class); + } + + // API + + @Override + public final void create() { + create(new Foo(randomAlphabetic(6))); + } + + @Override + public final String createAsUri() { + return createAsUri(new Foo(randomAlphabetic(6))); + } + +} diff --git a/spring-rest-full/src/test/java/org/baeldung/web/FooPageableLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/FooPageableLiveTest.java similarity index 86% rename from spring-rest-full/src/test/java/org/baeldung/web/FooPageableLiveTest.java rename to spring-boot-rest/src/test/java/com/baeldung/web/FooPageableLiveTest.java index 3f637c5213..359a62a4d8 100644 --- a/spring-rest-full/src/test/java/org/baeldung/web/FooPageableLiveTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/web/FooPageableLiveTest.java @@ -1,19 +1,14 @@ -package org.baeldung.web; +package com.baeldung.web; +import static com.baeldung.Consts.APPLICATION_PORT; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; -import static org.baeldung.Consts.APPLICATION_PORT; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; -import io.restassured.RestAssured; -import io.restassured.response.Response; import java.util.List; -import org.baeldung.common.web.AbstractBasicLiveTest; -import org.baeldung.persistence.model.Foo; -import org.baeldung.spring.ConfigIntegrationTest; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ActiveProfiles; @@ -21,6 +16,13 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; +import com.baeldung.common.web.AbstractBasicLiveTest; +import com.baeldung.persistence.model.Foo; +import com.baeldung.spring.ConfigIntegrationTest; + +import io.restassured.RestAssured; +import io.restassured.response.Response; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { ConfigIntegrationTest.class }, loader = AnnotationConfigContextLoader.class) @ActiveProfiles("test") @@ -34,7 +36,7 @@ public class FooPageableLiveTest extends AbstractBasicLiveTest { @Override public final void create() { - create(new Foo(randomAlphabetic(6))); + super.create(new Foo(randomAlphabetic(6))); } @Override @@ -45,6 +47,8 @@ public class FooPageableLiveTest extends AbstractBasicLiveTest { @Override @Test public void whenResourcesAreRetrievedPaged_then200IsReceived() { + this.create(); + final Response response = RestAssured.get(getPageableURL() + "?page=0&size=10"); assertThat(response.getStatusCode(), is(200)); @@ -70,7 +74,7 @@ public class FooPageableLiveTest extends AbstractBasicLiveTest { } protected String getPageableURL() { - return "http://localhost:" + APPLICATION_PORT + "/spring-rest-full/auth/foos/pageable"; + return "http://localhost:" + APPLICATION_PORT + "/spring-boot-rest/auth/foos/pageable"; } } diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/LiveTestSuiteLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/LiveTestSuiteLiveTest.java new file mode 100644 index 0000000000..1e2ddd5ec5 --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/web/LiveTestSuiteLiveTest.java @@ -0,0 +1,14 @@ +package com.baeldung.web; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ +// @formatter:off + FooLiveTest.class + ,FooPageableLiveTest.class +}) // +public class LiveTestSuiteLiveTest { + +} diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java index ea1b6ab227..3e21af524f 100644 --- a/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java +++ b/spring-boot-rest/src/test/java/com/baeldung/web/error/ErrorHandlingLiveTest.java @@ -6,6 +6,7 @@ import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.isA; import static org.hamcrest.Matchers.not; +import static com.baeldung.Consts.APPLICATION_PORT; import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; @@ -16,8 +17,8 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage; public class ErrorHandlingLiveTest { - private static final String BASE_URL = "http://localhost:8080"; - private static final String EXCEPTION_ENDPOINT = "/exception"; + private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-boot-rest"; + private static final String EXCEPTION_ENDPOINT = BASE_URL + "/exception"; private static final String ERROR_RESPONSE_KEY_PATH = "error"; private static final String XML_RESPONSE_KEY_PATH = "xmlkey"; @@ -57,7 +58,7 @@ public class ErrorHandlingLiveTest { try (WebClient webClient = new WebClient()) { webClient.getOptions() .setThrowExceptionOnFailingStatusCode(false); - HtmlPage page = webClient.getPage(BASE_URL + EXCEPTION_ENDPOINT); + HtmlPage page = webClient.getPage(EXCEPTION_ENDPOINT); assertThat(page.getBody() .asText()).contains("Whitelabel Error Page"); } diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java b/spring-boot-rest/src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java new file mode 100644 index 0000000000..54d62b64e8 --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java @@ -0,0 +1,36 @@ +package com.baeldung.web.util; + +public final class HTTPLinkHeaderUtil { + + private HTTPLinkHeaderUtil() { + throw new AssertionError(); + } + + // + + public static String extractURIByRel(final String linkHeader, final String rel) { + if (linkHeader == null) { + return null; + } + + String uriWithSpecifiedRel = null; + final String[] links = linkHeader.split(", "); + String linkRelation; + for (final String link : links) { + final int positionOfSeparator = link.indexOf(';'); + linkRelation = link.substring(positionOfSeparator + 1, link.length()).trim(); + if (extractTypeOfRelation(linkRelation).equals(rel)) { + uriWithSpecifiedRel = link.substring(1, positionOfSeparator - 1); + break; + } + } + + return uriWithSpecifiedRel; + } + + private static Object extractTypeOfRelation(final String linkRelation) { + final int positionOfEquals = linkRelation.indexOf('='); + return linkRelation.substring(positionOfEquals + 2, linkRelation.length() - 1).trim(); + } + +} diff --git a/spring-rest-full/README.md b/spring-rest-full/README.md index 3a8d0a727a..2ef3a09e37 100644 --- a/spring-rest-full/README.md +++ b/spring-rest-full/README.md @@ -8,7 +8,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [REST Pagination in Spring](http://www.baeldung.com/rest-api-pagination-in-spring) - [HATEOAS for a Spring REST Service](http://www.baeldung.com/rest-api-discoverability-with-spring) - [REST API Discoverability and HATEOAS](http://www.baeldung.com/restful-web-service-discoverability) - [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) diff --git a/spring-rest-full/src/main/java/org/baeldung/persistence/IOperations.java b/spring-rest-full/src/main/java/org/baeldung/persistence/IOperations.java index d4f3f0982c..8c5593c3e8 100644 --- a/spring-rest-full/src/main/java/org/baeldung/persistence/IOperations.java +++ b/spring-rest-full/src/main/java/org/baeldung/persistence/IOperations.java @@ -3,8 +3,6 @@ package org.baeldung.persistence; import java.io.Serializable; import java.util.List; -import org.springframework.data.domain.Page; - public interface IOperations { // read - one @@ -15,8 +13,6 @@ public interface IOperations { List findAll(); - Page findPaginated(int page, int size); - // write T create(final T entity); diff --git a/spring-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java b/spring-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java index a3d16d9c15..60d607b9ef 100644 --- a/spring-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java +++ b/spring-rest-full/src/main/java/org/baeldung/persistence/service/IFooService.java @@ -2,13 +2,9 @@ package org.baeldung.persistence.service; import org.baeldung.persistence.IOperations; import org.baeldung.persistence.model.Foo; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; public interface IFooService extends IOperations { Foo retrieveByName(String name); - - Page findPaginated(Pageable pageable); } diff --git a/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java b/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java index 5987bbae5f..59ccea8b12 100644 --- a/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java +++ b/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java @@ -4,8 +4,6 @@ import java.io.Serializable; import java.util.List; import org.baeldung.persistence.IOperations; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.transaction.annotation.Transactional; @@ -30,11 +28,6 @@ public abstract class AbstractService implements IOperat return Lists.newArrayList(getDao().findAll()); } - @Override - public Page findPaginated(final int page, final int size) { - return getDao().findAll(new PageRequest(page, size)); - } - // write @Override diff --git a/spring-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java index 376082b2d5..d46f1bfe90 100644 --- a/spring-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java +++ b/spring-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -7,8 +7,6 @@ import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; import org.baeldung.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -48,9 +46,4 @@ public class FooService extends AbstractService implements IFooService { return Lists.newArrayList(getDao().findAll()); } - @Override - public Page findPaginated(Pageable pageable) { - return dao.findAll(pageable); - } - } diff --git a/spring-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 484a59f8ef..443d0908ee 100644 --- a/spring-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -6,27 +6,20 @@ import javax.servlet.http.HttpServletResponse; import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; -import org.baeldung.web.exception.MyResourceNotFoundException; -import org.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; import org.baeldung.web.hateoas.event.ResourceCreatedEvent; import org.baeldung.web.hateoas.event.SingleResourceRetrievedEvent; import org.baeldung.web.util.RestPreconditions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.util.UriComponentsBuilder; import com.google.common.base.Preconditions; @@ -72,30 +65,6 @@ public class FooController { return service.findAll(); } - @RequestMapping(params = { "page", "size" }, method = RequestMethod.GET) - @ResponseBody - public List findPaginated(@RequestParam("page") final int page, @RequestParam("size") final int size, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { - final Page resultPage = service.findPaginated(page, size); - if (page > resultPage.getTotalPages()) { - throw new MyResourceNotFoundException(); - } - eventPublisher.publishEvent(new PaginatedResultsRetrievedEvent(Foo.class, uriBuilder, response, page, resultPage.getTotalPages(), size)); - - return resultPage.getContent(); - } - - @GetMapping("/pageable") - @ResponseBody - public List findPaginatedWithPageable(Pageable pageable, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { - final Page resultPage = service.findPaginated(pageable); - if (pageable.getPageNumber() > resultPage.getTotalPages()) { - throw new MyResourceNotFoundException(); - } - eventPublisher.publishEvent(new PaginatedResultsRetrievedEvent(Foo.class, uriBuilder, response, pageable.getPageNumber(), resultPage.getTotalPages(), pageable.getPageSize())); - - return resultPage.getContent(); - } - // write @RequestMapping(method = RequestMethod.POST) diff --git a/spring-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java b/spring-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java index 18cb8219ec..4e211ccb10 100644 --- a/spring-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java +++ b/spring-rest-full/src/main/java/org/baeldung/web/util/RestPreconditions.java @@ -1,8 +1,9 @@ package org.baeldung.web.util; -import org.baeldung.web.exception.MyResourceNotFoundException; import org.springframework.http.HttpStatus; +import org.baeldung.web.exception.MyResourceNotFoundException; + /** * Simple static methods to be called at the start of your own methods to verify correct arguments and state. If the Precondition fails, an {@link HttpStatus} code is thrown */ diff --git a/spring-rest-full/src/test/java/org/baeldung/common/web/AbstractBasicLiveTest.java b/spring-rest-full/src/test/java/org/baeldung/common/web/AbstractBasicLiveTest.java index 4e0007d036..d64807d97f 100644 --- a/spring-rest-full/src/test/java/org/baeldung/common/web/AbstractBasicLiveTest.java +++ b/spring-rest-full/src/test/java/org/baeldung/common/web/AbstractBasicLiveTest.java @@ -1,26 +1,19 @@ package org.baeldung.common.web; import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; -import static org.baeldung.web.util.HTTPLinkHeaderUtil.extractURIByRel; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -import io.restassured.RestAssured; -import io.restassured.response.Response; import java.io.Serializable; -import java.util.List; import org.junit.Ignore; import org.junit.Test; import com.google.common.net.HttpHeaders; +import io.restassured.RestAssured; +import io.restassured.response.Response; + public abstract class AbstractBasicLiveTest extends AbstractLiveTest { public AbstractBasicLiveTest(final Class clazzToSet) { @@ -104,71 +97,4 @@ public abstract class AbstractBasicLiveTest extends Abst // find - one // find - all - - // find - all - paginated - - @Test - public void whenResourcesAreRetrievedPaged_then200IsReceived() { - final Response response = RestAssured.get(getURL() + "?page=0&size=10"); - - assertThat(response.getStatusCode(), is(200)); - } - - @Test - public void whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived() { - final String url = getURL() + "?page=" + randomNumeric(5) + "&size=10"; - final Response response = RestAssured.get(url); - - assertThat(response.getStatusCode(), is(404)); - } - - @Test - public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { - create(); - - final Response response = RestAssured.get(getURL() + "?page=0&size=10"); - - assertFalse(response.body().as(List.class).isEmpty()); - } - - @Test - public void whenFirstPageOfResourcesAreRetrieved_thenSecondPageIsNext() { - final Response response = RestAssured.get(getURL() + "?page=0&size=2"); - - final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); - assertEquals(getURL() + "?page=1&size=2", uriToNextPage); - } - - @Test - public void whenFirstPageOfResourcesAreRetrieved_thenNoPreviousPage() { - final Response response = RestAssured.get(getURL() + "?page=0&size=2"); - - final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); - assertNull(uriToPrevPage); - } - - @Test - public void whenSecondPageOfResourcesAreRetrieved_thenFirstPageIsPrevious() { - create(); - create(); - - final Response response = RestAssured.get(getURL() + "?page=1&size=2"); - - final String uriToPrevPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "prev"); - assertEquals(getURL() + "?page=0&size=2", uriToPrevPage); - } - - @Test - public void whenLastPageOfResourcesIsRetrieved_thenNoNextPageIsDiscoverable() { - final Response first = RestAssured.get(getURL() + "?page=0&size=2"); - final String uriToLastPage = extractURIByRel(first.getHeader(HttpHeaders.LINK), "last"); - - final Response response = RestAssured.get(uriToLastPage); - - final String uriToNextPage = extractURIByRel(response.getHeader(HttpHeaders.LINK), "next"); - assertNull(uriToNextPage); - } - - // count - } diff --git a/spring-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java b/spring-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java index c2dd3d84c7..96d796349a 100644 --- a/spring-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java +++ b/spring-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java @@ -5,8 +5,6 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; -import io.restassured.RestAssured; -import io.restassured.response.Response; import java.io.Serializable; @@ -18,6 +16,9 @@ import org.springframework.http.MediaType; import com.google.common.net.HttpHeaders; +import io.restassured.RestAssured; +import io.restassured.response.Response; + public abstract class AbstractDiscoverabilityLiveTest extends AbstractLiveTest { public AbstractDiscoverabilityLiveTest(final Class clazzToSet) { diff --git a/spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuiteLiveTest.java b/spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuiteLiveTest.java index 71a61ed338..da736392c4 100644 --- a/spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuiteLiveTest.java +++ b/spring-rest-full/src/test/java/org/baeldung/web/LiveTestSuiteLiveTest.java @@ -8,7 +8,6 @@ import org.junit.runners.Suite; // @formatter:off FooDiscoverabilityLiveTest.class ,FooLiveTest.class - ,FooPageableLiveTest.class }) // public class LiveTestSuiteLiveTest { From 4187df5ce9b2c2b06a68742f97e4639a2274b0c9 Mon Sep 17 00:00:00 2001 From: Trevor Gowing Date: Mon, 24 Dec 2018 17:17:50 +0200 Subject: [PATCH 275/441] QueryByExample (QBE) Examples BAEL-2406 --- .../PassengerRepositoryIntegrationTest.java | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java index c57e771345..59380c1427 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.data.domain.Example; +import org.springframework.data.domain.ExampleMatcher; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; @@ -13,10 +15,12 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import java.util.List; +import java.util.Optional; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; @DataJpaTest @RunWith(SpringRunner.class) @@ -61,7 +65,8 @@ public class PassengerRepositoryIntegrationTest { public void givenSeveralPassengersWhenFindPageSortedByThenThePassengerInTheFirstFilledSeatIsReturned() { Passenger expected = Passenger.from("Fred", "Bloggs", 22); - Page page = repository.findAll(PageRequest.of(0, 1, Sort.by(Sort.Direction.ASC, "seatNumber"))); + Page page = repository.findAll(PageRequest.of(0, 1, + Sort.by(Sort.Direction.ASC, "seatNumber"))); assertEquals(page.getContent().size(), 1); @@ -94,5 +99,61 @@ public class PassengerRepositoryIntegrationTest { assertThat(passengers, contains(fred, ricki, jill, siya, eve)); } - + + @Test + public void givenPassengers_whenFindByExampleDefaultMatcher_thenExpectedReturned() { + Example example = Example.of(Passenger.from("Fred", "Bloggs", null)); + + Optional actual = repository.findOne(example); + + assertTrue(actual.isPresent()); + assertEquals(actual.get(), Passenger.from("Fred", "Bloggs", 22)); + } + + @Test + public void givenPassengers_whenFindByExampleCaseInsensitiveMatcher_thenExpectedReturned() { + ExampleMatcher caseInsensitiveExampleMatcher = ExampleMatcher.matchingAll().withIgnoreCase(); + Example example = Example.of(Passenger.from("fred", "bloggs", null), + caseInsensitiveExampleMatcher); + + Optional actual = repository.findOne(example); + + assertTrue(actual.isPresent()); + assertEquals(actual.get(), Passenger.from("Fred", "Bloggs", 22)); + } + + @Test + public void givenPassengers_whenFindByExampleCustomMatcher_thenExpectedReturned() { + Passenger jill = Passenger.from("Jill", "Smith", 50); + Passenger eve = Passenger.from("Eve", "Jackson", 95); + Passenger fred = Passenger.from("Fred", "Bloggs", 22); + Passenger siya = Passenger.from("Siya", "Kolisi", 85); + + ExampleMatcher customExampleMatcher = ExampleMatcher.matchingAny().withMatcher("firstName", + ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase()).withMatcher("lastName", + ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase()); + + Example example = Example.of(Passenger.from("e", "s", null), + customExampleMatcher); + + List passengers = repository.findAll(example); + + assertThat(passengers, contains(jill, eve, fred, siya)); + } + +@Test +public void givenPassengers_whenFindByIgnoringMatcher_thenExpectedReturned() { + Passenger fred = Passenger.from("Fred", "Bloggs", 22); + Passenger ricki = Passenger.from("Ricki", "Bobbie", 36); + + ExampleMatcher ignoringExampleMatcher = ExampleMatcher.matchingAny().withMatcher("lastName", + ExampleMatcher.GenericPropertyMatchers.startsWith().ignoreCase()).withIgnorePaths("firstName", "seatNumber"); + + Example example = Example.of(Passenger.from(null, "b", null), + ignoringExampleMatcher); + + List passengers = repository.findAll(example); + + assertThat(passengers, contains(fred, ricki)); +} } From b50ef0b4002f61131de4d6496f869940eb584d16 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Mon, 21 Jan 2019 23:14:03 -0200 Subject: [PATCH 276/441] improved slightly link generation code --- ...sultsRetrievedDiscoverabilityListener.java | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java index bb60bab171..31555ef353 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/PaginatedResultsRetrievedDiscoverabilityListener.java @@ -1,5 +1,7 @@ package com.baeldung.web.hateoas.listener; +import java.util.StringJoiner; + import javax.servlet.http.HttpServletResponse; import org.springframework.context.ApplicationListener; @@ -27,32 +29,32 @@ class PaginatedResultsRetrievedDiscoverabilityListener implements ApplicationLis public final void onApplicationEvent(final PaginatedResultsRetrievedEvent ev) { Preconditions.checkNotNull(ev); - addLinkHeaderOnPagedResourceRetrieval(ev.getUriBuilder(), ev.getResponse(), ev.getClazz(), ev.getPage(), ev.getTotalPages(), ev.getPageSize()); + addLinkHeaderOnPagedResourceRetrieval(ev.getUriBuilder(), ev.getResponse(), ev.getClazz(), ev.getPage(), + ev.getTotalPages(), ev.getPageSize()); } // - note: at this point, the URI is transformed into plural (added `s`) in a hardcoded way - this will change in the future - final void addLinkHeaderOnPagedResourceRetrieval(final UriComponentsBuilder uriBuilder, final HttpServletResponse response, final Class clazz, final int page, final int totalPages, final int pageSize) { + final void addLinkHeaderOnPagedResourceRetrieval(final UriComponentsBuilder uriBuilder, + final HttpServletResponse response, final Class clazz, final int page, final int totalPages, + final int pageSize) { plural(uriBuilder, clazz); - final StringBuilder linkHeader = new StringBuilder(); + final StringJoiner linkHeader = new StringJoiner(", "); if (hasNextPage(page, totalPages)) { final String uriForNextPage = constructNextPageUri(uriBuilder, page, pageSize); - linkHeader.append(LinkUtil.createLinkHeader(uriForNextPage, LinkUtil.REL_NEXT)); + linkHeader.add(LinkUtil.createLinkHeader(uriForNextPage, LinkUtil.REL_NEXT)); } if (hasPreviousPage(page)) { final String uriForPrevPage = constructPrevPageUri(uriBuilder, page, pageSize); - appendCommaIfNecessary(linkHeader); - linkHeader.append(LinkUtil.createLinkHeader(uriForPrevPage, LinkUtil.REL_PREV)); + linkHeader.add(LinkUtil.createLinkHeader(uriForPrevPage, LinkUtil.REL_PREV)); } if (hasFirstPage(page)) { final String uriForFirstPage = constructFirstPageUri(uriBuilder, pageSize); - appendCommaIfNecessary(linkHeader); - linkHeader.append(LinkUtil.createLinkHeader(uriForFirstPage, LinkUtil.REL_FIRST)); + linkHeader.add(LinkUtil.createLinkHeader(uriForFirstPage, LinkUtil.REL_FIRST)); } if (hasLastPage(page, totalPages)) { final String uriForLastPage = constructLastPageUri(uriBuilder, totalPages, pageSize); - appendCommaIfNecessary(linkHeader); - linkHeader.append(LinkUtil.createLinkHeader(uriForLastPage, LinkUtil.REL_LAST)); + linkHeader.add(LinkUtil.createLinkHeader(uriForLastPage, LinkUtil.REL_LAST)); } if (linkHeader.length() > 0) { @@ -61,19 +63,35 @@ class PaginatedResultsRetrievedDiscoverabilityListener implements ApplicationLis } final String constructNextPageUri(final UriComponentsBuilder uriBuilder, final int page, final int size) { - return uriBuilder.replaceQueryParam(PAGE, page + 1).replaceQueryParam("size", size).build().encode().toUriString(); + return uriBuilder.replaceQueryParam(PAGE, page + 1) + .replaceQueryParam("size", size) + .build() + .encode() + .toUriString(); } final String constructPrevPageUri(final UriComponentsBuilder uriBuilder, final int page, final int size) { - return uriBuilder.replaceQueryParam(PAGE, page - 1).replaceQueryParam("size", size).build().encode().toUriString(); + return uriBuilder.replaceQueryParam(PAGE, page - 1) + .replaceQueryParam("size", size) + .build() + .encode() + .toUriString(); } final String constructFirstPageUri(final UriComponentsBuilder uriBuilder, final int size) { - return uriBuilder.replaceQueryParam(PAGE, 0).replaceQueryParam("size", size).build().encode().toUriString(); + return uriBuilder.replaceQueryParam(PAGE, 0) + .replaceQueryParam("size", size) + .build() + .encode() + .toUriString(); } final String constructLastPageUri(final UriComponentsBuilder uriBuilder, final int totalPages, final int size) { - return uriBuilder.replaceQueryParam(PAGE, totalPages).replaceQueryParam("size", size).build().encode().toUriString(); + return uriBuilder.replaceQueryParam(PAGE, totalPages) + .replaceQueryParam("size", size) + .build() + .encode() + .toUriString(); } final boolean hasNextPage(final int page, final int totalPages) { @@ -92,16 +110,11 @@ class PaginatedResultsRetrievedDiscoverabilityListener implements ApplicationLis return (totalPages > 1) && hasNextPage(page, totalPages); } - final void appendCommaIfNecessary(final StringBuilder linkHeader) { - if (linkHeader.length() > 0) { - linkHeader.append(", "); - } - } - // template protected void plural(final UriComponentsBuilder uriBuilder, final Class clazz) { - final String resourceName = clazz.getSimpleName().toLowerCase() + "s"; + final String resourceName = clazz.getSimpleName() + .toLowerCase() + "s"; uriBuilder.path("/auth/" + resourceName); } From 34907bfb0bb6b237c39cec3ac3a4ae00f09b17ee Mon Sep 17 00:00:00 2001 From: aietcn Date: Tue, 22 Jan 2019 14:24:38 +0800 Subject: [PATCH 277/441] BAEL-2551 add parallelprefix section in Arrays (#6184) --- .../arrays/ParallelPrefixBenchmark.java | 44 ++++++++++++++++ .../com/baeldung/arrays/ArraysUnitTest.java | 51 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java diff --git a/core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java b/core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java new file mode 100644 index 0000000000..ac54aea402 --- /dev/null +++ b/core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java @@ -0,0 +1,44 @@ +package com.baeldung.arrays; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; + +import java.util.Arrays; + +public class ParallelPrefixBenchmark { + private static final int ARRAY_SIZE = 200_000_000; + + @State(Scope.Benchmark) + public static class BigArray { + + int[] data; + + @Setup(Level.Iteration) + public void prepare() { + data = new int[ARRAY_SIZE]; + for(int j = 0; j< ARRAY_SIZE; j++) { + data[j] = 1; + } + } + + @TearDown(Level.Iteration) + public void destroy() { + data = null; + } + + } + + @Benchmark + public void largeArrayLoopSum(BigArray bigArray, Blackhole blackhole) { + for (int i = 0; i < ARRAY_SIZE - 1; i++) { + bigArray.data[i + 1] += bigArray.data[i]; + } + blackhole.consume(bigArray.data); + } + + @Benchmark + public void largeArrayParallelPrefixSum(BigArray bigArray, Blackhole blackhole) { + Arrays.parallelPrefix(bigArray.data, (left, right) -> left + right); + blackhole.consume(bigArray.data); + } +} diff --git a/core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java b/core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java index 9e6d3d6131..b6801612b9 100644 --- a/core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java +++ b/core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java @@ -1,5 +1,7 @@ package com.baeldung.arrays; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.*; import org.junit.Before; @@ -9,6 +11,7 @@ import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.List; +import java.util.Random; import java.util.stream.Stream; public class ArraysUnitTest { @@ -150,4 +153,52 @@ public class ArraysUnitTest { exception.expect(UnsupportedOperationException.class); rets.add("the"); } + + @Test + public void givenIntArray_whenPrefixAdd_thenAllAccumulated() { + int[] arri = new int[] { 1, 2, 3, 4}; + Arrays.parallelPrefix(arri, (left, right) -> left + right); + assertThat(arri, is(new int[] { 1, 3, 6, 10})); + } + + @Test + public void givenStringArray_whenPrefixConcat_thenAllMerged() { + String[] arrs = new String[] { "1", "2", "3" }; + Arrays.parallelPrefix(arrs, (left, right) -> left + right); + assertThat(arrs, is(new String[] { "1", "12", "123" })); + } + + @Test + public void whenPrefixAddWithRange_thenRangeAdded() { + int[] arri = new int[] { 1, 2, 3, 4, 5 }; + Arrays.parallelPrefix(arri, 1, 4, (left, right) -> left + right); + assertThat(arri, is(new int[] { 1, 2, 5, 9, 5 })); + } + + @Test + public void whenPrefixNonAssociative_thenError() { + boolean consistent = true; + Random r = new Random(); + for (int k = 0; k < 100_000; k++) { + int[] arrA = r.ints(100, 1, 5).toArray(); + int[] arrB = Arrays.copyOf(arrA, arrA.length); + + Arrays.parallelPrefix(arrA, this::nonassociativeFunc); + + for (int i = 1; i < arrB.length; i++) { + arrB[i] = nonassociativeFunc(arrB[i - 1], arrB[i]); + } + consistent = Arrays.equals(arrA, arrB); + if(!consistent) break; + } + assertFalse(consistent); + } + + /** + * non-associative int binary operator + */ + private int nonassociativeFunc(int left, int right) { + return left + right*left; + } + } From 2fb3e867d75aa291a53cf69d0d2f75230404c324 Mon Sep 17 00:00:00 2001 From: Urvy Agrawal Date: Tue, 22 Jan 2019 14:28:12 +0530 Subject: [PATCH 278/441] Adding test file for bitwise operators --- .../BitwiseOperatorExample.java | 56 ------------- .../test/BitwiseOperatorUnitTest.java | 81 +++++++++++++++++++ 2 files changed, 81 insertions(+), 56 deletions(-) delete mode 100644 core-java/src/main/java/com/baeldung/bitwiseoperator/BitwiseOperatorExample.java create mode 100644 core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java diff --git a/core-java/src/main/java/com/baeldung/bitwiseoperator/BitwiseOperatorExample.java b/core-java/src/main/java/com/baeldung/bitwiseoperator/BitwiseOperatorExample.java deleted file mode 100644 index 4fef92102a..0000000000 --- a/core-java/src/main/java/com/baeldung/bitwiseoperator/BitwiseOperatorExample.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.baeldung.bitwiseoperator; - -public class BitwiseOperatorExample { - - public static void main(String[] args) { - - int value1 = 6; - int value2 = 5; - - // Bitwise AND Operator - int result = value1 & value2; - System.out.println("result : " + result); - - // Bitwise OR Operator - result = value1 | value2; - System.out.println("result : " + result); - - // Bitwise Exclusive OR Operator - result = value1 ^ value2; - System.out.println("result : " + result); - - // Bitwise NOT operator - result = ~value1; - System.out.println("result : " + result); - - // Right Shift Operator with positive number - int value = 12; - int rightShift = value >> 2; - System.out.println("rightShift result with positive number : " + rightShift); - - // Right Shift Operator with negative number - value = -12; - rightShift = value >> 2; - System.out.println("rightShift result with negative number : " + rightShift); - - // Left Shift Operator with positive number - value = 1; - int leftShift = value << 1; - System.out.println("leftShift result with positive number : " + leftShift); - - // Left Shift Operator with negative number - value = -12; - leftShift = value << 2; - System.out.println("leftShift result with negative number : " + leftShift); - - // Unsigned Right Shift Operator with positive number - value = 12; - int unsignedRightShift = value >>> 2; - System.out.println("unsignedRightShift result with positive number : " + unsignedRightShift); - - // Unsigned Right Shift Operator with negative number - value = -12; - unsignedRightShift = value >>> 2; - System.out.println("unsignedRightShift result with negative number : " + unsignedRightShift); - } -} diff --git a/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java b/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java new file mode 100644 index 0000000000..139d3a2512 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java @@ -0,0 +1,81 @@ +package com.baeldung.bitwiseoperator.test; + +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +public class BitwiseOperatorUnitTest { + + @Test + public void givenTwoIntegers_whenAndOperator_thenNewDecimalNumber() { + int value1 = 6; + int value2 = 5; + int result = value1 & value2; + Assert.assertEquals(result, 4); + } + + @Test + public void givenTwoIntegers_whenOrOperator_thenNewDecimalNumber() { + int value1 = 6; + int value2 = 5; + int result = value1 | value2; + Assert.assertEquals(result, 7); + } + + @Test + public void givenTwoIntegers_whenXorOperator_thenNewDecimalNumber() { + int value1 = 6; + int value2 = 5; + int result = value1 ^ value2; + Assert.assertEquals(result, 3); + } + + @Test + public void givenOneInteger_whenNotOperator_thenNewDecimalNumber() { + int value1 = 6; + int result = ~value1; + Assert.assertEquals(result, -7); + } + + @Test + public void givenOnePositiveInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { + int value = 12; + int rightShift = value >> 2; + Assert.assertEquals(rightShift, 3); + } + + @Test + public void givenOneNegativeInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { + int value = -12; + int rightShift = value >> 2; + Assert.assertEquals(rightShift, -3); + } + + @Test + public void givenOnePositiveInteger_whenLeftShiftOperator_thenNewDecimalNumber() { + int value = 12; + int leftShift = value << 2; + Assert.assertEquals(leftShift, 48); + } + + @Test + public void givenOneNegativeInteger_whenLeftShiftOperator_thenNewDecimalNumber() { + int value = -12; + int leftShift = value << 2; + Assert.assertEquals(leftShift, -48); + } + + @Test + public void givenOnePositiveInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { + int value = 12; + int unsignedRightShift = value >>> 2; + Assert.assertEquals(unsignedRightShift, 3); + } + + @Test + public void givenOneNegativeInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { + int value = -12; + int unsignedRightShift = value >>> 2; + Assert.assertEquals(unsignedRightShift, 1073741821); + } + +} From 5bbc85c6c1cedb411019e62f506fae42f618bc6d Mon Sep 17 00:00:00 2001 From: enpy Date: Tue, 22 Jan 2019 17:18:11 +0100 Subject: [PATCH 279/441] classes and objects code added (#6173) * classes and objects code added * Car class and test added * fixes and enhancements * code moved to core-java-lang --- .../main/java/com/baeldung/objects/Car.java | 51 +++++++++++++++++++ .../com/baeldung/objects/CarUnitTest.java | 38 ++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 core-java-lang/src/main/java/com/baeldung/objects/Car.java create mode 100644 core-java-lang/src/test/java/com/baeldung/objects/CarUnitTest.java diff --git a/core-java-lang/src/main/java/com/baeldung/objects/Car.java b/core-java-lang/src/main/java/com/baeldung/objects/Car.java new file mode 100644 index 0000000000..35ef8585b2 --- /dev/null +++ b/core-java-lang/src/main/java/com/baeldung/objects/Car.java @@ -0,0 +1,51 @@ +package com.baeldung.objects; + +public class Car { + + private String type; + private String model; + private String color; + private int speed; + + public Car(String type, String model, String color) { + this.type = type; + this.model = model; + this.color = color; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public int getSpeed() { + return speed; + } + + public int increaseSpeed(int increment) { + if (increment > 0) { + this.speed += increment; + } else { + System.out.println("Increment can't be negative."); + } + return this.speed; + } + + public int decreaseSpeed(int decrement) { + if (decrement > 0 && decrement <= this.speed) { + this.speed -= decrement; + } else { + System.out.println("Decrement can't be negative or greater than current speed."); + } + return this.speed; + } + + @Override + public String toString() { + return "Car [type=" + type + ", model=" + model + ", color=" + color + ", speed=" + speed + "]"; + } + +} diff --git a/core-java-lang/src/test/java/com/baeldung/objects/CarUnitTest.java b/core-java-lang/src/test/java/com/baeldung/objects/CarUnitTest.java new file mode 100644 index 0000000000..a1ef20523e --- /dev/null +++ b/core-java-lang/src/test/java/com/baeldung/objects/CarUnitTest.java @@ -0,0 +1,38 @@ +package com.baeldung.objects; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +public class CarUnitTest { + + private Car car; + + @Before + public void setUp() throws Exception { + car = new Car("Ford", "Focus", "red"); + } + + @Test + public final void when_speedIncreased_then_verifySpeed() { + car.increaseSpeed(30); + assertEquals(30, car.getSpeed()); + + car.increaseSpeed(20); + assertEquals(50, car.getSpeed()); + } + + @Test + public final void when_speedDecreased_then_verifySpeed() { + car.increaseSpeed(50); + assertEquals(50, car.getSpeed()); + + car.decreaseSpeed(30); + assertEquals(20, car.getSpeed()); + + car.decreaseSpeed(20); + assertEquals(0, car.getSpeed()); + } + +} From 39ea408549fbce7be95e1b7160525c3b45f64e09 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Tue, 22 Jan 2019 19:58:57 +0200 Subject: [PATCH 280/441] Update BitwiseOperatorUnitTest.java --- .../test/BitwiseOperatorUnitTest.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java b/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java index 139d3a2512..d8af4b0833 100644 --- a/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java +++ b/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java @@ -1,6 +1,6 @@ package com.baeldung.bitwiseoperator.test; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; import org.junit.jupiter.api.Test; public class BitwiseOperatorUnitTest { @@ -10,7 +10,7 @@ public class BitwiseOperatorUnitTest { int value1 = 6; int value2 = 5; int result = value1 & value2; - Assert.assertEquals(result, 4); + assertEquals(result, 4); } @Test @@ -18,7 +18,7 @@ public class BitwiseOperatorUnitTest { int value1 = 6; int value2 = 5; int result = value1 | value2; - Assert.assertEquals(result, 7); + assertEquals(result, 7); } @Test @@ -26,56 +26,56 @@ public class BitwiseOperatorUnitTest { int value1 = 6; int value2 = 5; int result = value1 ^ value2; - Assert.assertEquals(result, 3); + assertEquals(result, 3); } @Test public void givenOneInteger_whenNotOperator_thenNewDecimalNumber() { int value1 = 6; int result = ~value1; - Assert.assertEquals(result, -7); + assertEquals(result, -7); } @Test public void givenOnePositiveInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { int value = 12; int rightShift = value >> 2; - Assert.assertEquals(rightShift, 3); + assertEquals(rightShift, 3); } @Test public void givenOneNegativeInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { int value = -12; int rightShift = value >> 2; - Assert.assertEquals(rightShift, -3); + assertEquals(rightShift, -3); } @Test public void givenOnePositiveInteger_whenLeftShiftOperator_thenNewDecimalNumber() { int value = 12; int leftShift = value << 2; - Assert.assertEquals(leftShift, 48); + assertEquals(leftShift, 48); } @Test public void givenOneNegativeInteger_whenLeftShiftOperator_thenNewDecimalNumber() { int value = -12; int leftShift = value << 2; - Assert.assertEquals(leftShift, -48); + assertEquals(leftShift, -48); } @Test public void givenOnePositiveInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { int value = 12; int unsignedRightShift = value >>> 2; - Assert.assertEquals(unsignedRightShift, 3); + assertEquals(unsignedRightShift, 3); } @Test public void givenOneNegativeInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { int value = -12; int unsignedRightShift = value >>> 2; - Assert.assertEquals(unsignedRightShift, 1073741821); + assertEquals(unsignedRightShift, 1073741821); } } From 8c18214c558dc21ca0f956d50ad0587c19be1362 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Wed, 23 Jan 2019 09:44:05 +0400 Subject: [PATCH 281/441] more unit tests --- .../baeldung/string/MatchWordsUnitTest.java | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java b/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java index 0b25a265b3..1c2288068b 100644 --- a/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java +++ b/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java @@ -8,52 +8,59 @@ public class MatchWordsUnitTest { private final String[] words = {"hello", "Baeldung"}; private final String inputString = "hello there, Baeldung"; + private final String wholeInput = "helloBaeldung"; @Test public void givenText_whenCallingStringContains_shouldMatchWords() { - final boolean result = MatchWords.containsWords(inputString, words); - assertThat(result).isEqualTo(true); } @Test public void givenText_whenCallingJava8_shouldMatchWords() { - final boolean result = MatchWords.containsWordsJava8(inputString, words); - assertThat(result).isEqualTo(true); } + @Test + public void givenText_whenCallingJava8_shouldNotMatchWords() { + final boolean result = MatchWords.containsWordsJava8(wholeInput, words); + assertThat(result).isEqualTo(false); + } + @Test public void givenText_whenCallingPattern_shouldMatchWords() { - final boolean result = MatchWords.containsWordsPatternMatch(inputString, words); - assertThat(result).isEqualTo(true); } @Test public void givenText_whenCallingAhoCorasick_shouldMatchWords() { - final boolean result = MatchWords.containsWordsAhoCorasick(inputString, words); - assertThat(result).isEqualTo(true); } + @Test + public void givenText_whenCallingAhoCorasick_shouldNotMatchWords() { + final boolean result = MatchWords.containsWordsAhoCorasick(wholeInput, words); + assertThat(result).isEqualTo(false); + } + @Test public void givenText_whenCallingIndexOf_shouldMatchWords() { - final boolean result = MatchWords.containsWordsIndexOf(inputString, words); - assertThat(result).isEqualTo(true); } @Test public void givenText_whenCallingArrayList_shouldMatchWords() { - final boolean result = MatchWords.containsWordsArray(inputString, words); - assertThat(result).isEqualTo(true); } + + @Test + public void givenText_whenCallingArrayList_shouldNotMatchWords() { + final boolean result = MatchWords.containsWordsArray(wholeInput, words); + assertThat(result).isEqualTo(false); + } } From 7fa2aba180074969b59b4599a20f9792e76c1dc5 Mon Sep 17 00:00:00 2001 From: Fabian Rivera Date: Tue, 22 Jan 2019 23:54:24 -0600 Subject: [PATCH 282/441] BAEL-2414 Guide to problem-spring-web (#6147) * Fix issue with package name and folder name mismatch * Add problem-spring-web code samples * Use the latest version of the problem-spring-web library. Add spring security exceptions handling samples * Fix issue with security configuration. Fix sample for forbidden operation * Update ProblemDemoConfiguration.java * Add integration tests to validate problems are correctly handled and responses are generated using the problem library --- spring-boot-libraries/pom.xml | 270 +++++++++--------- .../com/baeldung/{ => boot}/Application.java | 2 +- .../problem/SpringProblemApplication.java | 19 ++ .../boot/problem/advice/ExceptionHandler.java | 9 + .../advice/SecurityExceptionHandler.java | 9 + .../ProblemDemoConfiguration.java | 17 ++ .../configuration/SecurityConfiguration.java | 31 ++ .../controller/ProblemDemoController.java | 56 ++++ .../com/baeldung/boot/problem/dto/Task.java | 32 +++ .../problem/problems/TaskNotFoundProblem.java | 16 ++ .../resources/application-problem.properties | 3 + .../ProblemDemoControllerIntegrationTest.java | 75 +++++ 12 files changed, 409 insertions(+), 130 deletions(-) rename spring-boot-libraries/src/main/java/com/baeldung/{ => boot}/Application.java (93%) create mode 100644 spring-boot-libraries/src/main/java/com/baeldung/boot/problem/SpringProblemApplication.java create mode 100644 spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/ExceptionHandler.java create mode 100644 spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/SecurityExceptionHandler.java create mode 100644 spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/ProblemDemoConfiguration.java create mode 100644 spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/SecurityConfiguration.java create mode 100644 spring-boot-libraries/src/main/java/com/baeldung/boot/problem/controller/ProblemDemoController.java create mode 100644 spring-boot-libraries/src/main/java/com/baeldung/boot/problem/dto/Task.java create mode 100644 spring-boot-libraries/src/main/java/com/baeldung/boot/problem/problems/TaskNotFoundProblem.java create mode 100644 spring-boot-libraries/src/main/resources/application-problem.properties create mode 100644 spring-boot-libraries/src/test/java/com/baeldung/boot/problem/controller/ProblemDemoControllerIntegrationTest.java diff --git a/spring-boot-libraries/pom.xml b/spring-boot-libraries/pom.xml index c28128c5f0..66aa66bdfd 100644 --- a/spring-boot-libraries/pom.xml +++ b/spring-boot-libraries/pom.xml @@ -1,144 +1,156 @@ - 4.0.0 - spring-boot-libraries - war - spring-boot-libraries - This is simple boot application for Spring boot actuator test + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + spring-boot-libraries + war + spring-boot-libraries + This is simple boot application for Spring boot actuator test - - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../parent-boot-2 - + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - - - org.springframework.boot - spring-boot-starter-test - test - + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-tomcat + + + org.springframework.boot + spring-boot-starter-test + test + + + + + org.zalando + problem-spring-web + ${problem-spring-web.version} + - - - net.javacrumbs.shedlock - shedlock-spring - 2.1.0 - - - net.javacrumbs.shedlock - shedlock-provider-jdbc-template - 2.1.0 - + + + net.javacrumbs.shedlock + shedlock-spring + 2.1.0 + + + net.javacrumbs.shedlock + shedlock-provider-jdbc-template + 2.1.0 + - + - - spring-boot - - - src/main/resources - true - - + + spring-boot + + + src/main/resources + true + + - + - - org.apache.maven.plugins - maven-war-plugin - + + org.apache.maven.plugins + maven-war-plugin + - - pl.project13.maven - git-commit-id-plugin - ${git-commit-id-plugin.version} - - - get-the-git-infos - - revision - - initialize - - - validate-the-git-infos - - validateRevision - - package - - - - true - ${project.build.outputDirectory}/git.properties - - + + pl.project13.maven + git-commit-id-plugin + ${git-commit-id-plugin.version} + + + get-the-git-infos + + revision + + initialize + + + validate-the-git-infos + + validateRevision + + package + + + + true + ${project.build.outputDirectory}/git.properties + + - + - + - - - autoconfiguration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*LiveTest.java - **/*IntegrationTest.java - **/*IntTest.java - - - **/AutoconfigurationTest.java - - - - - - - json - - - - - - - + + + autoconfiguration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + **/*IntegrationTest.java + **/*IntTest.java + + + **/AutoconfigurationTest.java + + + + + + + json + + + + + + + - - - com.baeldung.intro.App - 8.5.11 - 2.4.1.Final - 1.9.0 - 2.0.0 - 5.0.2 - 5.0.2 - 5.2.4 - 18.0 - 2.2.4 - 2.3.2 - + + + com.baeldung.intro.App + 8.5.11 + 2.4.1.Final + 1.9.0 + 2.0.0 + 5.0.2 + 5.0.2 + 5.2.4 + 18.0 + 2.2.4 + 2.3.2 + 0.23.0 + diff --git a/spring-boot-libraries/src/main/java/com/baeldung/Application.java b/spring-boot-libraries/src/main/java/com/baeldung/boot/Application.java similarity index 93% rename from spring-boot-libraries/src/main/java/com/baeldung/Application.java rename to spring-boot-libraries/src/main/java/com/baeldung/boot/Application.java index c1b6558b26..cb0d0c1532 100644 --- a/spring-boot-libraries/src/main/java/com/baeldung/Application.java +++ b/spring-boot-libraries/src/main/java/com/baeldung/boot/Application.java @@ -1,4 +1,4 @@ -package org.baeldung.boot; +package com.baeldung.boot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/SpringProblemApplication.java b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/SpringProblemApplication.java new file mode 100644 index 0000000000..7ca9881fb9 --- /dev/null +++ b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/SpringProblemApplication.java @@ -0,0 +1,19 @@ +package com.baeldung.boot.problem; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@EnableAutoConfiguration(exclude = ErrorMvcAutoConfiguration.class) +@ComponentScan("com.baeldung.boot.problem") +public class SpringProblemApplication { + + public static void main(String[] args) { + System.setProperty("spring.profiles.active", "problem"); + SpringApplication.run(SpringProblemApplication.class, args); + } + +} diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/ExceptionHandler.java b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/ExceptionHandler.java new file mode 100644 index 0000000000..7b4cbac7f7 --- /dev/null +++ b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/ExceptionHandler.java @@ -0,0 +1,9 @@ +package com.baeldung.boot.problem.advice; + +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.zalando.problem.spring.web.advice.ProblemHandling; + +@ControllerAdvice +public class ExceptionHandler implements ProblemHandling { + +} diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/SecurityExceptionHandler.java b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/SecurityExceptionHandler.java new file mode 100644 index 0000000000..8013cbf5c3 --- /dev/null +++ b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/advice/SecurityExceptionHandler.java @@ -0,0 +1,9 @@ +package com.baeldung.boot.problem.advice; + +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.zalando.problem.spring.web.advice.security.SecurityAdviceTrait; + +@ControllerAdvice +public class SecurityExceptionHandler implements SecurityAdviceTrait { + +} \ No newline at end of file diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/ProblemDemoConfiguration.java b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/ProblemDemoConfiguration.java new file mode 100644 index 0000000000..209ff553c7 --- /dev/null +++ b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/ProblemDemoConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.boot.problem.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.zalando.problem.ProblemModule; +import org.zalando.problem.validation.ConstraintViolationProblemModule; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@Configuration +public class ProblemDemoConfiguration { + + @Bean + public ObjectMapper objectMapper() { + return new ObjectMapper().registerModules(new ProblemModule(), new ConstraintViolationProblemModule()); + } +} diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/SecurityConfiguration.java b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/SecurityConfiguration.java new file mode 100644 index 0000000000..0cb8048981 --- /dev/null +++ b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/configuration/SecurityConfiguration.java @@ -0,0 +1,31 @@ +package com.baeldung.boot.problem.configuration; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.zalando.problem.spring.web.advice.security.SecurityProblemSupport; + +@Configuration +@EnableWebSecurity +@Import(SecurityProblemSupport.class) +public class SecurityConfiguration extends WebSecurityConfigurerAdapter { + + @Autowired + private SecurityProblemSupport problemSupport; + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable(); + + http.authorizeRequests() + .antMatchers("/") + .permitAll(); + + http.exceptionHandling() + .authenticationEntryPoint(problemSupport) + .accessDeniedHandler(problemSupport); + } +} diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/controller/ProblemDemoController.java b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/controller/ProblemDemoController.java new file mode 100644 index 0000000000..50f1ad5137 --- /dev/null +++ b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/controller/ProblemDemoController.java @@ -0,0 +1,56 @@ +package com.baeldung.boot.problem.controller; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.http.MediaType; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.boot.problem.dto.Task; +import com.baeldung.boot.problem.problems.TaskNotFoundProblem; + +@RestController +@RequestMapping("/tasks") +public class ProblemDemoController { + + private static final Map MY_TASKS; + + static { + MY_TASKS = new HashMap<>(); + MY_TASKS.put(1L, new Task(1L, "My first task")); + MY_TASKS.put(2L, new Task(2L, "My second task")); + } + + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public List getTasks() { + return new ArrayList<>(MY_TASKS.values()); + } + + @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) + public Task getTasks(@PathVariable("id") Long taskId) { + if (MY_TASKS.containsKey(taskId)) { + return MY_TASKS.get(taskId); + } else { + throw new TaskNotFoundProblem(taskId); + } + } + + @PutMapping("/{id}") + public void updateTask(@PathVariable("id") Long id) { + throw new UnsupportedOperationException(); + } + + @DeleteMapping("/{id}") + public void deleteTask(@PathVariable("id") Long id) { + throw new AccessDeniedException("You can't delete this task"); + } + +} diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/dto/Task.java b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/dto/Task.java new file mode 100644 index 0000000000..a5f39474e7 --- /dev/null +++ b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/dto/Task.java @@ -0,0 +1,32 @@ +package com.baeldung.boot.problem.dto; + +public class Task { + + private Long id; + private String description; + + public Task() { + } + + public Task(Long id, String description) { + this.id = id; + this.description = description; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/problems/TaskNotFoundProblem.java b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/problems/TaskNotFoundProblem.java new file mode 100644 index 0000000000..cc3f21d4a5 --- /dev/null +++ b/spring-boot-libraries/src/main/java/com/baeldung/boot/problem/problems/TaskNotFoundProblem.java @@ -0,0 +1,16 @@ +package com.baeldung.boot.problem.problems; + +import java.net.URI; + +import org.zalando.problem.AbstractThrowableProblem; +import org.zalando.problem.Status; + +public class TaskNotFoundProblem extends AbstractThrowableProblem { + + private static final URI TYPE = URI.create("https://example.org/not-found"); + + public TaskNotFoundProblem(Long taskId) { + super(TYPE, "Not found", Status.NOT_FOUND, String.format("Task '%s' not found", taskId)); + } + +} diff --git a/spring-boot-libraries/src/main/resources/application-problem.properties b/spring-boot-libraries/src/main/resources/application-problem.properties new file mode 100644 index 0000000000..7d0b0a2720 --- /dev/null +++ b/spring-boot-libraries/src/main/resources/application-problem.properties @@ -0,0 +1,3 @@ +spring.resources.add-mappings=false +spring.mvc.throw-exception-if-no-handler-found=true +spring.http.encoding.force=true diff --git a/spring-boot-libraries/src/test/java/com/baeldung/boot/problem/controller/ProblemDemoControllerIntegrationTest.java b/spring-boot-libraries/src/test/java/com/baeldung/boot/problem/controller/ProblemDemoControllerIntegrationTest.java new file mode 100644 index 0000000000..3b7e43a565 --- /dev/null +++ b/spring-boot-libraries/src/test/java/com/baeldung/boot/problem/controller/ProblemDemoControllerIntegrationTest.java @@ -0,0 +1,75 @@ +package com.baeldung.boot.problem.controller; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import com.baeldung.boot.problem.SpringProblemApplication; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = SpringProblemApplication.class) +@AutoConfigureMockMvc +public class ProblemDemoControllerIntegrationTest { + + @Autowired + private MockMvc mockMvc; + + @Test + public void whenRequestingAllTasks_thenReturnSuccessfulResponseWithArrayWithTwoTasks() throws Exception { + mockMvc.perform(get("/tasks").contentType(MediaType.APPLICATION_JSON_VALUE)) + .andDo(print()) + .andExpect(jsonPath("$.length()", equalTo(2))) + .andExpect(status().isOk()); + } + + @Test + public void whenRequestingExistingTask_thenReturnSuccessfulResponse() throws Exception { + mockMvc.perform(get("/tasks/1").contentType(MediaType.APPLICATION_JSON_VALUE)) + .andDo(print()) + .andExpect(jsonPath("$.id", equalTo(1))) + .andExpect(status().isOk()); + } + + @Test + public void whenRequestingMissingTask_thenReturnNotFoundProblemResponse() throws Exception { + mockMvc.perform(get("/tasks/5").contentType(MediaType.APPLICATION_PROBLEM_JSON_VALUE)) + .andDo(print()) + .andExpect(jsonPath("$.title", equalTo("Not found"))) + .andExpect(jsonPath("$.status", equalTo(404))) + .andExpect(jsonPath("$.detail", equalTo("Task '5' not found"))) + .andExpect(status().isNotFound()); + } + + @Test + public void whenMakePutCall_thenReturnNotImplementedProblemResponse() throws Exception { + mockMvc.perform(put("/tasks/1").contentType(MediaType.APPLICATION_PROBLEM_JSON_VALUE)) + .andDo(print()) + .andExpect(jsonPath("$.title", equalTo("Not Implemented"))) + .andExpect(jsonPath("$.status", equalTo(501))) + .andExpect(status().isNotImplemented()); + } + + @Test + public void whenMakeDeleteCall_thenReturnForbiddenProblemResponse() throws Exception { + mockMvc.perform(delete("/tasks/2").contentType(MediaType.APPLICATION_PROBLEM_JSON_VALUE)) + .andDo(print()) + .andExpect(jsonPath("$.title", equalTo("Forbidden"))) + .andExpect(jsonPath("$.status", equalTo(403))) + .andExpect(jsonPath("$.detail", equalTo("You can't delete this task"))) + .andExpect(status().isForbidden()); + } + +} From effde80333489fa4b74cb173261c812456de8134 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Wed, 23 Jan 2019 14:19:48 +0200 Subject: [PATCH 283/441] BAEL - 2420 Converting Float to Byte Array and vice-versa in Java (#6194) * Hexagonal Architecture in Java - Spring boot app * create README.md * Update README.md * Update README.md * BAEL-2420 Converting Float to Byte Array and vice-versa in Java * BAEL-2420 Converting Float to Byte Array and vice-versa in Java - conversions package added * Hexagonal architecture code removed --- .../array/conversions/FloatToByteArray.java | 44 ++++++++++++++++++ .../conversions/FloatToByteArrayUnitTest.java | 46 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 core-java-arrays/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java create mode 100644 core-java-arrays/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java diff --git a/core-java-arrays/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java b/core-java-arrays/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java new file mode 100644 index 0000000000..b831e436a5 --- /dev/null +++ b/core-java-arrays/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java @@ -0,0 +1,44 @@ +package com.baeldung.array.conversions; + +import java.nio.ByteBuffer; + +public class FloatToByteArray { + + /** + * convert float into byte array using Float API floatToIntBits + * @param value + * @return byte[] + */ + public static byte[] floatToByteArray(float value) { + int intBits = Float.floatToIntBits(value); + return new byte[] {(byte) (intBits >> 24), (byte) (intBits >> 16), (byte) (intBits >> 8), (byte) (intBits) }; + } + + /** + * convert byte array into float using Float API intBitsToFloat + * @param bytes + * @return float + */ + public static float byteArrayToFloat(byte[] bytes) { + int intBits = bytes[0] << 24 | (bytes[1] & 0xFF) << 16 | (bytes[2] & 0xFF) << 8 | (bytes[3] & 0xFF); + return Float.intBitsToFloat(intBits); + } + + /** + * convert float into byte array using ByteBuffer + * @param value + * @return byte[] + */ + public static byte[] floatToByteArrayWithByteBuffer(float value) { + return ByteBuffer.allocate(4).putFloat(value).array(); + } + + /** + * convert byte array into float using ByteBuffer + * @param bytes + * @return float + */ + public static float byteArrayToFloatWithByteBuffer(byte[] bytes) { + return ByteBuffer.wrap(bytes).getFloat(); + } +} diff --git a/core-java-arrays/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java b/core-java-arrays/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java new file mode 100644 index 0000000000..a2cd273f21 --- /dev/null +++ b/core-java-arrays/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java @@ -0,0 +1,46 @@ +package com.baeldung.array.conversions; + +import static com.baeldung.array.conversions.FloatToByteArray.byteArrayToFloat; +import static com.baeldung.array.conversions.FloatToByteArray.byteArrayToFloatWithByteBuffer; +import static com.baeldung.array.conversions.FloatToByteArray.floatToByteArray; +import static com.baeldung.array.conversions.FloatToByteArray.floatToByteArrayWithByteBuffer; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class FloatToByteArrayUnitTest { + + @Test + public void givenAFloat_thenConvertToByteArray() { + assertArrayEquals(new byte[] { 63, -116, -52, -51}, floatToByteArray(1.1f)); + } + + @Test + public void givenAByteArray_thenConvertToFloat() { + assertEquals(1.1f, byteArrayToFloat(new byte[] { 63, -116, -52, -51}), 0); + } + + @Test + public void givenAFloat_thenConvertToByteArrayUsingByteBuffer() { + assertArrayEquals(new byte[] { 63, -116, -52, -51}, floatToByteArrayWithByteBuffer(1.1f)); + } + + @Test + public void givenAByteArray_thenConvertToFloatUsingByteBuffer() { + assertEquals(1.1f, byteArrayToFloatWithByteBuffer(new byte[] { 63, -116, -52, -51}), 0); + } + + @Test + public void givenAFloat_thenConvertToByteArray_thenConvertToFloat() { + float floatToConvert = 200.12f; + byte[] byteArray = floatToByteArray(floatToConvert); + assertEquals(200.12f, byteArrayToFloat(byteArray), 0); + } + + @Test + public void givenAFloat_thenConvertToByteArrayWithByteBuffer_thenConvertToFloatWithByteBuffer() { + float floatToConvert = 30100.42f; + byte[] byteArray = floatToByteArrayWithByteBuffer(floatToConvert); + assertEquals(30100.42f, byteArrayToFloatWithByteBuffer(byteArray), 0); + } +} From 4c7ef02bf3781299a09db3430c2989648f6d5841 Mon Sep 17 00:00:00 2001 From: Andrea Ligios Date: Wed, 23 Jan 2019 18:12:06 +0100 Subject: [PATCH 284/441] BAEL-2294 (#6191) * BAEL-2294 * BAEL-2294 * live tests... * formatting * Live Tests! But not parent pom. Yet. --- blade/README.md | 5 + blade/pom.xml | 189 ++++++++++++++++++ .../java/com/baeldung/blade/sample/App.java | 38 ++++ .../sample/AttributesExampleController.java | 37 ++++ .../blade/sample/LogExampleController.java | 22 ++ .../ParameterInjectionExampleController.java | 71 +++++++ .../blade/sample/RouteExampleController.java | 78 ++++++++ .../configuration/BaeldungException.java | 9 + .../configuration/GlobalExceptionHandler.java | 25 +++ .../sample/configuration/LoadConfig.java | 23 +++ .../sample/configuration/ScheduleExample.java | 15 ++ .../sample/interceptors/BaeldungHook.java | 17 ++ .../interceptors/BaeldungMiddleware.java | 15 ++ .../com/baeldung/blade/sample/vo/User.java | 16 ++ .../src/main/resources/application.properties | 5 + .../src/main/resources/custom-static/icon.png | Bin 0 -> 28893 bytes blade/src/main/resources/favicon.ico | Bin 0 -> 650 bytes blade/src/main/resources/static/app.css | 1 + blade/src/main/resources/static/app.js | 0 .../main/resources/static/file-upload.html | 43 ++++ .../src/main/resources/static/user-post.html | 25 +++ .../main/resources/templates/allmatch.html | 1 + .../src/main/resources/templates/delete.html | 1 + blade/src/main/resources/templates/get.html | 1 + blade/src/main/resources/templates/index.html | 30 +++ .../src/main/resources/templates/my-404.html | 10 + .../src/main/resources/templates/my-500.html | 12 ++ blade/src/main/resources/templates/post.html | 1 + blade/src/main/resources/templates/put.html | 1 + .../templates/template-output-test.html | 1 + .../baeldung/blade/sample/AppLiveTest.java | 56 ++++++ .../AttributesExampleControllerLiveTest.java | 55 +++++ ...terInjectionExampleControllerLiveTest.java | 82 ++++++++ .../RouteExampleControllerLiveTest.java | 117 +++++++++++ pom.xml | 2 + 35 files changed, 1004 insertions(+) create mode 100644 blade/README.md create mode 100644 blade/pom.xml create mode 100644 blade/src/main/java/com/baeldung/blade/sample/App.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java create mode 100644 blade/src/main/java/com/baeldung/blade/sample/vo/User.java create mode 100644 blade/src/main/resources/application.properties create mode 100644 blade/src/main/resources/custom-static/icon.png create mode 100644 blade/src/main/resources/favicon.ico create mode 100644 blade/src/main/resources/static/app.css create mode 100644 blade/src/main/resources/static/app.js create mode 100644 blade/src/main/resources/static/file-upload.html create mode 100644 blade/src/main/resources/static/user-post.html create mode 100644 blade/src/main/resources/templates/allmatch.html create mode 100644 blade/src/main/resources/templates/delete.html create mode 100644 blade/src/main/resources/templates/get.html create mode 100644 blade/src/main/resources/templates/index.html create mode 100644 blade/src/main/resources/templates/my-404.html create mode 100644 blade/src/main/resources/templates/my-500.html create mode 100644 blade/src/main/resources/templates/post.html create mode 100644 blade/src/main/resources/templates/put.html create mode 100644 blade/src/main/resources/templates/template-output-test.html create mode 100644 blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java create mode 100644 blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java create mode 100644 blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java create mode 100644 blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java diff --git a/blade/README.md b/blade/README.md new file mode 100644 index 0000000000..d823de775f --- /dev/null +++ b/blade/README.md @@ -0,0 +1,5 @@ +### Relevant Articles: + +- [Blade - A Complete GuideBook](http://www.baeldung.com/blade) + +Run Integration Tests with `mvn integration-test` \ No newline at end of file diff --git a/blade/pom.xml b/blade/pom.xml new file mode 100644 index 0000000000..6bad505f4a --- /dev/null +++ b/blade/pom.xml @@ -0,0 +1,189 @@ + + + 4.0.0 + blade + blade + + + com.baeldung + 1.0.0-SNAPSHOT + + + + + + + + + + 1.8 + 1.8 + + + + + com.bladejava + blade-mvc + 2.0.14.RELEASE + + + + org.webjars + bootstrap + 4.2.1 + + + + org.apache.commons + commons-lang3 + 3.8.1 + + + + + org.projectlombok + lombok + 1.18.4 + provided + + + + + junit + junit + 4.12 + test + + + org.assertj + assertj-core + 3.11.1 + test + + + org.apache.httpcomponents + httpclient + 4.5.6 + test + + + org.apache.httpcomponents + httpmime + 4.5.6 + test + + + org.apache.httpcomponents + httpcore + 4.4.10 + test + + + + sample-blade-app + + + + org.apache.maven.plugins + maven-surefire-plugin + + 3 + true + + **/*LiveTest.java + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M3 + + + **/*LiveTest.java + + + + + + integration-test + verify + + + + + + + com.bazaarvoice.maven.plugins + process-exec-maven-plugin + 0.7 + + + + blade-process + pre-integration-test + + start + + + Blade + false + + java + -jar + sample-blade-app.jar + + + + + + + stop-all + post-integration-test + + stop-all + + + + + + + + maven-assembly-plugin + 3.1.0 + + ${project.build.finalName} + false + + + com.baeldung.blade.sample.App + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + maven-compiler-plugin + + 1.8 + 1.8 + UTF-8 + + + + + diff --git a/blade/src/main/java/com/baeldung/blade/sample/App.java b/blade/src/main/java/com/baeldung/blade/sample/App.java new file mode 100644 index 0000000000..f3f3d4aebd --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/App.java @@ -0,0 +1,38 @@ +package com.baeldung.blade.sample; + +import com.baeldung.blade.sample.interceptors.BaeldungMiddleware; +import com.blade.Blade; +import com.blade.event.EventType; +import com.blade.mvc.WebContext; +import com.blade.mvc.http.Session; + +public class App { + + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(App.class); + + public static void main(String[] args) { + + Blade.of() + .get("/", ctx -> ctx.render("index.html")) + .get("/basic-route-example", ctx -> ctx.text("GET called")) + .post("/basic-route-example", ctx -> ctx.text("POST called")) + .put("/basic-route-example", ctx -> ctx.text("PUT called")) + .delete("/basic-route-example", ctx -> ctx.text("DELETE called")) + .addStatics("/custom-static") + // .showFileList(true) + .enableCors(true) + .before("/user/*", ctx -> log.info("[NarrowedHook] Before '/user/*', URL called: " + ctx.uri())) + .on(EventType.SERVER_STARTED, e -> { + String version = WebContext.blade() + .env("app.version") + .orElse("N/D"); + log.info("[Event::serverStarted] Loading 'app.version' from configuration, value: " + version); + }) + .on(EventType.SESSION_CREATED, e -> { + Session session = (Session) e.attribute("session"); + session.attribute("mySessionValue", "Baeldung"); + }) + .use(new BaeldungMiddleware()) + .start(App.class, args); + } +} diff --git a/blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java b/blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java new file mode 100644 index 0000000000..339ba701f7 --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/AttributesExampleController.java @@ -0,0 +1,37 @@ +package com.baeldung.blade.sample; + +import com.blade.mvc.annotation.GetRoute; +import com.blade.mvc.annotation.Path; +import com.blade.mvc.http.Request; +import com.blade.mvc.http.Response; +import com.blade.mvc.http.Session; + +@Path +public class AttributesExampleController { + + public final static String REQUEST_VALUE = "Some Request value"; + public final static String SESSION_VALUE = "1337"; + public final static String HEADER = "Some Header"; + + @GetRoute("/request-attribute-example") + public void getRequestAttribute(Request request, Response response) { + request.attribute("request-val", REQUEST_VALUE); + String requestVal = request.attribute("request-val"); + response.text(requestVal); + } + + @GetRoute("/session-attribute-example") + public void getSessionAttribute(Request request, Response response) { + Session session = request.session(); + session.attribute("session-val", SESSION_VALUE); + String sessionVal = session.attribute("session-val"); + response.text(sessionVal); + } + + @GetRoute("/header-example") + public void getHeader(Request request, Response response) { + String headerVal = request.header("a-header", HEADER); + response.header("a-header", headerVal); + } + +} diff --git a/blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java b/blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java new file mode 100644 index 0000000000..f0c22c70dd --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/LogExampleController.java @@ -0,0 +1,22 @@ +package com.baeldung.blade.sample; + +import com.blade.mvc.annotation.Path; +import com.blade.mvc.annotation.Route; +import com.blade.mvc.http.Response; + +@Path +public class LogExampleController { + + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExampleController.class); + + @Route(value = "/test-logs") + public void testLogs(Response response) { + log.trace("This is a TRACE Message"); + log.debug("This is a DEBUG Message"); + log.info("This is an INFO Message"); + log.warn("This is a WARN Message"); + log.error("This is an ERROR Message"); + response.text("Check in ./logs"); + } + +} diff --git a/blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java b/blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java new file mode 100644 index 0000000000..bc28244022 --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/ParameterInjectionExampleController.java @@ -0,0 +1,71 @@ +package com.baeldung.blade.sample; + +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; + +import com.baeldung.blade.sample.vo.User; +import com.blade.mvc.annotation.CookieParam; +import com.blade.mvc.annotation.GetRoute; +import com.blade.mvc.annotation.HeaderParam; +import com.blade.mvc.annotation.JSON; +import com.blade.mvc.annotation.MultipartParam; +import com.blade.mvc.annotation.Param; +import com.blade.mvc.annotation.Path; +import com.blade.mvc.annotation.PathParam; +import com.blade.mvc.annotation.PostRoute; +import com.blade.mvc.http.Response; +import com.blade.mvc.multipart.FileItem; +import com.blade.mvc.ui.RestResponse; + +@Path +public class ParameterInjectionExampleController { + + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ParameterInjectionExampleController.class); + + @GetRoute("/params/form") + public void formParam(@Param String name, Response response) { + log.info("name: " + name); + response.text(name); + } + + @GetRoute("/params/path/:uid") + public void restfulParam(@PathParam Integer uid, Response response) { + log.info("uid: " + uid); + response.text(String.valueOf(uid)); + } + + @PostRoute("/params-file") // DO NOT USE A SLASH WITHIN THE ROUTE OR IT WILL BREAK (?) + @JSON + public RestResponse fileParam(@MultipartParam FileItem fileItem) throws Exception { + try { + byte[] fileContent = fileItem.getData(); + + log.debug("Saving the uploaded file"); + java.nio.file.Path tempFile = Files.createTempFile("baeldung_tempfiles", ".tmp"); + Files.write(tempFile, fileContent, StandardOpenOption.WRITE); + + return RestResponse.ok(); + } catch (Exception e) { + log.error(e.getMessage(), e); + return RestResponse.fail(e.getMessage()); + } + } + + @GetRoute("/params/header") + public void headerParam(@HeaderParam String customheader, Response response) { + log.info("Custom header: " + customheader); + response.text(customheader); + } + + @GetRoute("/params/cookie") + public void cookieParam(@CookieParam(defaultValue = "default value") String myCookie, Response response) { + log.info("myCookie: " + myCookie); + response.text(myCookie); + } + + @PostRoute("/params/vo") + public void voParam(@Param User user, Response response) { + log.info("user as voParam: " + user.toString()); + response.html(user.toString() + "

Back"); + } +} \ No newline at end of file diff --git a/blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java b/blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java new file mode 100644 index 0000000000..7ba2a270a9 --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/RouteExampleController.java @@ -0,0 +1,78 @@ +package com.baeldung.blade.sample; + +import com.baeldung.blade.sample.configuration.BaeldungException; +import com.blade.mvc.WebContext; +import com.blade.mvc.annotation.DeleteRoute; +import com.blade.mvc.annotation.GetRoute; +import com.blade.mvc.annotation.Path; +import com.blade.mvc.annotation.PostRoute; +import com.blade.mvc.annotation.PutRoute; +import com.blade.mvc.annotation.Route; +import com.blade.mvc.http.HttpMethod; +import com.blade.mvc.http.Request; +import com.blade.mvc.http.Response; + +@Path +public class RouteExampleController { + + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(RouteExampleController.class); + + @GetRoute("/route-example") + public String get() { + return "get.html"; + } + + @PostRoute("/route-example") + public String post() { + return "post.html"; + } + + @PutRoute("/route-example") + public String put() { + return "put.html"; + } + + @DeleteRoute("/route-example") + public String delete() { + return "delete.html"; + } + + @Route(value = "/another-route-example", method = HttpMethod.GET) + public String anotherGet() { + return "get.html"; + } + + @Route(value = "/allmatch-route-example") + public String allmatch() { + return "allmatch.html"; + } + + @Route(value = "/triggerInternalServerError") + public void triggerInternalServerError() { + int x = 1 / 0; + } + + @Route(value = "/triggerBaeldungException") + public void triggerBaeldungException() throws BaeldungException { + throw new BaeldungException("Foobar Exception to threat differently"); + } + + @Route(value = "/user/foo") + public void urlCoveredByNarrowedWebhook(Response response) { + response.text("Check out for the WebHook covering '/user/*' in the logs"); + } + + @GetRoute("/load-configuration-in-a-route") + public void loadConfigurationInARoute(Response response) { + String authors = WebContext.blade() + .env("app.authors", "Unknown authors"); + log.info("[/load-configuration-in-a-route] Loading 'app.authors' from configuration, value: " + authors); + response.render("index.html"); + } + + @GetRoute("/template-output-test") + public void templateOutputTest(Request request, Response response) { + request.attribute("name", "Blade"); + response.render("template-output-test.html"); + } +} diff --git a/blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java b/blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java new file mode 100644 index 0000000000..01a030b7e7 --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/configuration/BaeldungException.java @@ -0,0 +1,9 @@ +package com.baeldung.blade.sample.configuration; + +public class BaeldungException extends RuntimeException { + + public BaeldungException(String message) { + super(message); + } + +} \ No newline at end of file diff --git a/blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java b/blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java new file mode 100644 index 0000000000..ab7b81c0dc --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/configuration/GlobalExceptionHandler.java @@ -0,0 +1,25 @@ +package com.baeldung.blade.sample.configuration; + +import com.blade.ioc.annotation.Bean; +import com.blade.mvc.WebContext; +import com.blade.mvc.handler.DefaultExceptionHandler; + +@Bean +public class GlobalExceptionHandler extends DefaultExceptionHandler { + + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(GlobalExceptionHandler.class); + + @Override + public void handle(Exception e) { + if (e instanceof BaeldungException) { + Exception baeldungException = (BaeldungException) e; + String msg = baeldungException.getMessage(); + log.error("[GlobalExceptionHandler] Intercepted an exception to threat with additional logic. Error message: " + msg); + WebContext.response() + .render("index.html"); + + } else { + super.handle(e); + } + } +} \ No newline at end of file diff --git a/blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java b/blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java new file mode 100644 index 0000000000..0f1aab1b52 --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/configuration/LoadConfig.java @@ -0,0 +1,23 @@ +package com.baeldung.blade.sample.configuration; + +import com.blade.Blade; +import com.blade.ioc.annotation.Bean; +import com.blade.loader.BladeLoader; +import com.blade.mvc.WebContext; + +@Bean +public class LoadConfig implements BladeLoader { + + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoadConfig.class); + + @Override + public void load(Blade blade) { + String version = WebContext.blade() + .env("app.version") + .orElse("N/D"); + String authors = WebContext.blade() + .env("app.authors", "Unknown authors"); + + log.info("[LoadConfig] loaded 'app.version' (" + version + ") and 'app.authors' (" + authors + ") in a configuration bean"); + } +} \ No newline at end of file diff --git a/blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java b/blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java new file mode 100644 index 0000000000..c170975818 --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/configuration/ScheduleExample.java @@ -0,0 +1,15 @@ +package com.baeldung.blade.sample.configuration; + +import com.blade.ioc.annotation.Bean; +import com.blade.task.annotation.Schedule; + +@Bean +public class ScheduleExample { + + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ScheduleExample.class); + + @Schedule(name = "baeldungTask", cron = "0 */1 * * * ?") + public void runScheduledTask() { + log.info("[ScheduleExample] This is a scheduled Task running once per minute."); + } +} diff --git a/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java b/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java new file mode 100644 index 0000000000..4d0d178b0d --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungHook.java @@ -0,0 +1,17 @@ +package com.baeldung.blade.sample.interceptors; + +import com.blade.ioc.annotation.Bean; +import com.blade.mvc.RouteContext; +import com.blade.mvc.hook.WebHook; + +@Bean +public class BaeldungHook implements WebHook { + + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(BaeldungHook.class); + + @Override + public boolean before(RouteContext ctx) { + log.info("[BaeldungHook] called before Route method"); + return true; + } +} \ No newline at end of file diff --git a/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java b/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java new file mode 100644 index 0000000000..3342cd8b01 --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/interceptors/BaeldungMiddleware.java @@ -0,0 +1,15 @@ +package com.baeldung.blade.sample.interceptors; + +import com.blade.mvc.RouteContext; +import com.blade.mvc.hook.WebHook; + +public class BaeldungMiddleware implements WebHook { + + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(BaeldungMiddleware.class); + + @Override + public boolean before(RouteContext context) { + log.info("[BaeldungMiddleware] called before Route method and other WebHooks"); + return true; + } +} \ No newline at end of file diff --git a/blade/src/main/java/com/baeldung/blade/sample/vo/User.java b/blade/src/main/java/com/baeldung/blade/sample/vo/User.java new file mode 100644 index 0000000000..b493dc3663 --- /dev/null +++ b/blade/src/main/java/com/baeldung/blade/sample/vo/User.java @@ -0,0 +1,16 @@ +package com.baeldung.blade.sample.vo; + +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; + +import lombok.Getter; +import lombok.Setter; + +public class User { + @Getter @Setter private String name; + @Getter @Setter private String site; + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } +} \ No newline at end of file diff --git a/blade/src/main/resources/application.properties b/blade/src/main/resources/application.properties new file mode 100644 index 0000000000..ebf365406a --- /dev/null +++ b/blade/src/main/resources/application.properties @@ -0,0 +1,5 @@ +mvc.statics.show-list=true +mvc.view.404=my-404.html +mvc.view.500=my-500.html +app.version=0.0.1 +app.authors=Andrea Ligios diff --git a/blade/src/main/resources/custom-static/icon.png b/blade/src/main/resources/custom-static/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..59af395afc55f38e5a727a119b4627088753c28e GIT binary patch literal 28893 zcmV)5K*_&}P)Pyg07*naRCodGy$86iXIba_t-f|k4=IEsq!J=Tz)*sYFgC15l%sQWJZDq}buLFa zqnF1viiTKFQ4uN9^f-<~l+ig@r--8>f)pL3qyV8LArN-zPIg)4{D1%deZTL!*4jyS z3Nzq@7(-suVk0z=jLYmQMsyDN4#@2riVDr zEilZPAu>OYZe*LL*&t_}k`2FXwv1Ini(Z7wym6w(5truVrT%TOHjHVSYp}sVZNofK zGgXfU^APAl!(xq#mbuA;o^c1A@Y;subr>*h0(?4~0}Ha@g* zc=MV&Z$13BKYrQG?|koHee956*7c(Jrp0JP(H?e7v=0x)Yb1#77c^e@vKO3l{O3LQ z(a+s;+~V_=mgk;6H$S(F1*ExvH0h;M0Tw+VAi<>=8Pn*d`sT5OBC6ipg4?nbP#8Yy z&~R-ZC3qHt&p!)8i+-l{CfLSfg?lB&g&m6yCVUr`Wvc*6i6WZnS8YTd=O+4HT!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KZWdk}j0oC$^<=YmXS8`|w0d^ChIze-e7=i*zm0*x zkgnIa!QjZ=@8a+F@b&uk_WJkt`}p|#`TG3&{Qdl3v2$j#cxJPCXta81wR>x}eQdXW zZMT1Jw|{Q9fN;2ha=C+Zx`TDPg?GD$dAx{uyoq|fiGRP2f5480!m3{>-FyJ_3rQY@$mQY@c8ob`1AAm^z`}l^!oPs z{QCU<{r&#^{r>*`{{H^||Amb{2><{9_(?=TR5;7!kwtdHKoCUd&q$VJcFYiFW@ct) zW`_GOv(Qc>`v6IAe|6QXZXy2iD5El$@wlpljiKwsKsj$I!@Zl2tVlm<$lB=evibA_ zNk4&Vnm)QK0>HdagmTV40C>*vHK_|!$ECZR-+d)Ns7I)z%h}$5`%b-P!-dPu#1)*@ z=?1Y30O_u|Pgv6vWK|I0rZ0L6*@1F`v}31$lX|^mb@v0`W{+GbLSf8nU<5+3)k1Eo z*_wR=QeiJ|o!QTn&PPOKDGQkG-i~to{l%PWw4B2d1b5oB8yGF4iHJ1piM`{4^?qCV kz0ndv2qkJlQi^{#zhk}{OSDILr~m)}07*qoM6N<$f)M?L^Z)<= literal 0 HcmV?d00001 diff --git a/blade/src/main/resources/static/app.css b/blade/src/main/resources/static/app.css new file mode 100644 index 0000000000..9fff13d9b6 --- /dev/null +++ b/blade/src/main/resources/static/app.css @@ -0,0 +1 @@ +/* App CSS */ \ No newline at end of file diff --git a/blade/src/main/resources/static/app.js b/blade/src/main/resources/static/app.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/blade/src/main/resources/static/file-upload.html b/blade/src/main/resources/static/file-upload.html new file mode 100644 index 0000000000..b805be81b1 --- /dev/null +++ b/blade/src/main/resources/static/file-upload.html @@ -0,0 +1,43 @@ + + + + +Title + + + + + +

File Upload and download test

+
+ + +
+ +
+ Back + + + + \ No newline at end of file diff --git a/blade/src/main/resources/static/user-post.html b/blade/src/main/resources/static/user-post.html new file mode 100644 index 0000000000..ccfc4e8d0b --- /dev/null +++ b/blade/src/main/resources/static/user-post.html @@ -0,0 +1,25 @@ + + + + +Title + + + + + +

User POJO post test

+ + +
+ Person POJO: + + + +
+ +
+ Back + + + \ No newline at end of file diff --git a/blade/src/main/resources/templates/allmatch.html b/blade/src/main/resources/templates/allmatch.html new file mode 100644 index 0000000000..7a4bfa070f --- /dev/null +++ b/blade/src/main/resources/templates/allmatch.html @@ -0,0 +1 @@ +ALLMATCH called \ No newline at end of file diff --git a/blade/src/main/resources/templates/delete.html b/blade/src/main/resources/templates/delete.html new file mode 100644 index 0000000000..1acb4b0b62 --- /dev/null +++ b/blade/src/main/resources/templates/delete.html @@ -0,0 +1 @@ +DELETE called \ No newline at end of file diff --git a/blade/src/main/resources/templates/get.html b/blade/src/main/resources/templates/get.html new file mode 100644 index 0000000000..2c37aa1058 --- /dev/null +++ b/blade/src/main/resources/templates/get.html @@ -0,0 +1 @@ +GET called \ No newline at end of file diff --git a/blade/src/main/resources/templates/index.html b/blade/src/main/resources/templates/index.html new file mode 100644 index 0000000000..6b7c2e77ad --- /dev/null +++ b/blade/src/main/resources/templates/index.html @@ -0,0 +1,30 @@ + + + + +Baeldung Blade App • Written by Andrea Ligios + + + +

Baeldung Blade App - Showcase

+ +

Manual tests

+

The following are tests which are not covered by integration tests, but that can be run manually in order to check the functionality, either in the browser or in the logs, depending on the case.

+ + + + +

Session value created in App.java

+

mySessionValue = ${mySessionValue}

+ + + + + \ No newline at end of file diff --git a/blade/src/main/resources/templates/my-404.html b/blade/src/main/resources/templates/my-404.html new file mode 100644 index 0000000000..0fa694f241 --- /dev/null +++ b/blade/src/main/resources/templates/my-404.html @@ -0,0 +1,10 @@ + + + + + 404 Not found + + + Custom Error 404 Page + + \ No newline at end of file diff --git a/blade/src/main/resources/templates/my-500.html b/blade/src/main/resources/templates/my-500.html new file mode 100644 index 0000000000..cc8438bfd6 --- /dev/null +++ b/blade/src/main/resources/templates/my-500.html @@ -0,0 +1,12 @@ + + + + + 500 Internal Server Error + + +

Custom Error 500 Page

+

The following error occurred: "${message}"

+
 ${stackTrace} 
+ + \ No newline at end of file diff --git a/blade/src/main/resources/templates/post.html b/blade/src/main/resources/templates/post.html new file mode 100644 index 0000000000..b7a8a931cd --- /dev/null +++ b/blade/src/main/resources/templates/post.html @@ -0,0 +1 @@ +POST called \ No newline at end of file diff --git a/blade/src/main/resources/templates/put.html b/blade/src/main/resources/templates/put.html new file mode 100644 index 0000000000..bdbe6d3285 --- /dev/null +++ b/blade/src/main/resources/templates/put.html @@ -0,0 +1 @@ +PUT called \ No newline at end of file diff --git a/blade/src/main/resources/templates/template-output-test.html b/blade/src/main/resources/templates/template-output-test.html new file mode 100644 index 0000000000..233b12fb88 --- /dev/null +++ b/blade/src/main/resources/templates/template-output-test.html @@ -0,0 +1 @@ +

Hello, ${name}!

\ No newline at end of file diff --git a/blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java b/blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java new file mode 100644 index 0000000000..1172e6755f --- /dev/null +++ b/blade/src/test/java/com/baeldung/blade/sample/AppLiveTest.java @@ -0,0 +1,56 @@ +package com.baeldung.blade.sample; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.junit.Test; + +public class AppLiveTest { + + @Test + public void givenBasicRoute_whenGet_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/basic-route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("GET called"); + } + } + + @Test + public void givenBasicRoute_whenPost_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpPost("http://localhost:9000/basic-route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("POST called"); + } + } + + @Test + public void givenBasicRoute_whenPut_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpPut("http://localhost:9000/basic-route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("PUT called"); + } + } + + @Test + public void givenBasicRoute_whenDelete_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpDelete("http://localhost:9000/basic-route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("DELETE called"); + } + } +} diff --git a/blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java b/blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java new file mode 100644 index 0000000000..7cf00c2d4b --- /dev/null +++ b/blade/src/test/java/com/baeldung/blade/sample/AttributesExampleControllerLiveTest.java @@ -0,0 +1,55 @@ +package com.baeldung.blade.sample; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.junit.Test; + +public class AttributesExampleControllerLiveTest { + + @Test + public void givenRequestAttribute_whenSet_thenRetrieveWithGet() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/request-attribute-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo(AttributesExampleController.REQUEST_VALUE); + } + } + + @Test + public void givenSessionAttribute_whenSet_thenRetrieveWithGet() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/session-attribute-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo(AttributesExampleController.SESSION_VALUE); + } + } + + @Test + public void givenHeader_whenSet_thenRetrieveWithGet() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/header-example"); + request.addHeader("a-header","foobar"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(httpResponse.getHeaders("a-header")[0].getValue()).isEqualTo("foobar"); + } + } + + @Test + public void givenNoHeader_whenSet_thenRetrieveDefaultValueWithGet() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/header-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(httpResponse.getHeaders("a-header")[0].getValue()).isEqualTo(AttributesExampleController.HEADER); + } + } + +} diff --git a/blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java b/blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java new file mode 100644 index 0000000000..fbd5280116 --- /dev/null +++ b/blade/src/test/java/com/baeldung/blade/sample/ParameterInjectionExampleControllerLiveTest.java @@ -0,0 +1,82 @@ +package com.baeldung.blade.sample; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.junit.Test; + +public class ParameterInjectionExampleControllerLiveTest { + + @Test + public void givenFormParam_whenSet_thenRetrieveWithGet() throws Exception { + URIBuilder builder = new URIBuilder("http://localhost:9000/params/form"); + builder.setParameter("name", "Andrea Ligios"); + + final HttpUriRequest request = new HttpGet(builder.build()); + + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("Andrea Ligios"); + } + } + + @Test + public void givenPathParam_whenSet_thenRetrieveWithGet() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/params/path/1337"); + + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("1337"); + } + } + + // @Test + // public void givenFileParam_whenSet_thenRetrieveWithGet() throws Exception { + // + // byte[] data = "this is some temp file content".getBytes("UTF-8"); + // java.nio.file.Path tempFile = Files.createTempFile("baeldung_test_tempfiles", ".tmp"); + // Files.write(tempFile, data, StandardOpenOption.WRITE); + // + // //HttpEntity entity = MultipartEntityBuilder.create().addPart("file", new FileBody(tempFile.toFile())).build(); + // HttpEntity entity = MultipartEntityBuilder.create().addTextBody("field1", "value1") + // .addBinaryBody("fileItem", tempFile.toFile(), ContentType.create("application/octet-stream"), "file1.txt").build(); + // + // final HttpPost post = new HttpPost("http://localhost:9000/params-file"); + // post.setEntity(entity); + // + // try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create().build().execute(post);) { + // assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("file1.txt"); + // } + // } + + @Test + public void givenHeader_whenSet_thenRetrieveWithGet() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/params/header"); + request.addHeader("customheader", "foobar"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("foobar"); + } + } + + @Test + public void givenNoCookie_whenCalled_thenReadDefaultValue() throws Exception { + + final HttpUriRequest request = new HttpGet("http://localhost:9000/params/cookie"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("default value"); + } + + } + +} diff --git a/blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java b/blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java new file mode 100644 index 0000000000..df8e70c461 --- /dev/null +++ b/blade/src/test/java/com/baeldung/blade/sample/RouteExampleControllerLiveTest.java @@ -0,0 +1,117 @@ +package com.baeldung.blade.sample; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.junit.Test; + +public class RouteExampleControllerLiveTest { + + @Test + public void givenRoute_whenGet_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("GET called"); + } + } + + @Test + public void givenRoute_whenPost_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpPost("http://localhost:9000/route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("POST called"); + } + } + + @Test + public void givenRoute_whenPut_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpPut("http://localhost:9000/route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("PUT called"); + } + } + + @Test + public void givenRoute_whenDelete_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpDelete("http://localhost:9000/route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("DELETE called"); + } + } + + @Test + public void givenAnotherRoute_whenGet_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/another-route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("GET called"); + } + } + + @Test + public void givenAllMatchRoute_whenGet_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/allmatch-route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("ALLMATCH called"); + } + } + + @Test + public void givenAllMatchRoute_whenPost_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpPost("http://localhost:9000/allmatch-route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("ALLMATCH called"); + } + } + + @Test + public void givenAllMatchRoute_whenPut_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpPut("http://localhost:9000/allmatch-route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("ALLMATCH called"); + } + } + + @Test + public void givenAllMatchRoute_whenDelete_thenCorrectOutput() throws Exception { + final HttpUriRequest request = new HttpDelete("http://localhost:9000/allmatch-route-example"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("ALLMATCH called"); + } + } + + @Test + public void givenRequestAttribute_whenRenderedWithTemplate_thenCorrectlyEvaluateIt() throws Exception { + final HttpUriRequest request = new HttpGet("http://localhost:9000/template-output-test"); + try (final CloseableHttpResponse httpResponse = HttpClientBuilder.create() + .build() + .execute(request);) { + assertThat(EntityUtils.toString(httpResponse.getEntity())).isEqualTo("

Hello, Blade!

"); + } + } + +} diff --git a/pom.xml b/pom.xml index 1c0738cafb..d084d0f7af 100644 --- a/pom.xml +++ b/pom.xml @@ -367,6 +367,8 @@ axon azure + blade + bootique cas/cas-secured-app From f2d26dfa38941c9088883ebfc6fd6c5f0877f736 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 23 Jan 2019 17:45:07 -0700 Subject: [PATCH 285/441] Move new code under different module --- pom.xml | 1 - .../scheduling/ScheduleJobsByProfile.java | 0 .../com/baeldung/scheduling/ScheduledJob.java | 0 .../scheduling/ScheduledJobsWithBoolean.java | 0 .../ScheduledJobsWithConditional.java | 0 .../ScheduledJobsWithExpression.java | 0 .../scheduling/SchedulingApplication.java | 0 spring-scheduling/.gitignore | 25 -- .../.mvn/wrapper/maven-wrapper.jar | Bin 48337 -> 0 bytes .../.mvn/wrapper/maven-wrapper.properties | 1 - spring-scheduling/mvnw | 286 ------------------ spring-scheduling/mvnw.cmd | 161 ---------- spring-scheduling/pom.xml | 42 --- .../src/main/resources/application.properties | 0 .../SchedulingApplicationTests.java | 17 -- 15 files changed, 533 deletions(-) rename {spring-scheduling => spring-boot-mvc}/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java (100%) rename {spring-scheduling => spring-boot-mvc}/src/main/java/com/baeldung/scheduling/ScheduledJob.java (100%) rename {spring-scheduling => spring-boot-mvc}/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java (100%) rename {spring-scheduling => spring-boot-mvc}/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java (100%) rename {spring-scheduling => spring-boot-mvc}/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java (100%) rename {spring-scheduling => spring-boot-mvc}/src/main/java/com/baeldung/scheduling/SchedulingApplication.java (100%) delete mode 100644 spring-scheduling/.gitignore delete mode 100644 spring-scheduling/.mvn/wrapper/maven-wrapper.jar delete mode 100644 spring-scheduling/.mvn/wrapper/maven-wrapper.properties delete mode 100755 spring-scheduling/mvnw delete mode 100644 spring-scheduling/mvnw.cmd delete mode 100644 spring-scheduling/pom.xml delete mode 100644 spring-scheduling/src/main/resources/application.properties delete mode 100644 spring-scheduling/src/test/java/com/baeldung/scheduling/SchedulingApplicationTests.java diff --git a/pom.xml b/pom.xml index 1f25dd0691..1dd2768793 100644 --- a/pom.xml +++ b/pom.xml @@ -714,7 +714,6 @@ spring-rest-simple spring-resttemplate spring-roo - spring-scheduling spring-security-acl spring-security-angular/server spring-security-cache-control diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java b/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java similarity index 100% rename from spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java rename to spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduleJobsByProfile.java diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJob.java b/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJob.java similarity index 100% rename from spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJob.java rename to spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJob.java diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java b/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java similarity index 100% rename from spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java rename to spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithBoolean.java diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java b/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java similarity index 100% rename from spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java rename to spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithConditional.java diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java b/spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java similarity index 100% rename from spring-scheduling/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java rename to spring-boot-mvc/src/main/java/com/baeldung/scheduling/ScheduledJobsWithExpression.java diff --git a/spring-scheduling/src/main/java/com/baeldung/scheduling/SchedulingApplication.java b/spring-boot-mvc/src/main/java/com/baeldung/scheduling/SchedulingApplication.java similarity index 100% rename from spring-scheduling/src/main/java/com/baeldung/scheduling/SchedulingApplication.java rename to spring-boot-mvc/src/main/java/com/baeldung/scheduling/SchedulingApplication.java diff --git a/spring-scheduling/.gitignore b/spring-scheduling/.gitignore deleted file mode 100644 index 82eca336e3..0000000000 --- a/spring-scheduling/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -/target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/build/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ \ No newline at end of file diff --git a/spring-scheduling/.mvn/wrapper/maven-wrapper.jar b/spring-scheduling/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 01e67997377a393fd672c7dcde9dccbedf0cb1e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 48337 zcmbTe1CV9Qwl>;j+wQV$+qSXFw%KK)%eHN!%U!l@+x~l>b1vR}@9y}|TM-#CBjy|< zb7YRpp)Z$$Gzci_H%LgxZ{NNV{%Qa9gZlF*E2<($D=8;N5Asbx8se{Sz5)O13x)rc z5cR(k$_mO!iis+#(8-D=#R@|AF(8UQ`L7dVNSKQ%v^P|1A%aF~Lye$@HcO@sMYOb3 zl`5!ThJ1xSJwsg7hVYFtE5vS^5UE0$iDGCS{}RO;R#3y#{w-1hVSg*f1)7^vfkxrm!!N|oTR0Hj?N~IbVk+yC#NK} z5myv()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w0^{nx<1jOy)N_UoFD8v}x~2mEWapI3m~kMQkR z#&@4FuEGBn`mgtSx6jeY7vUQNf=^}sTZErIEpH!cy|@7Z zU4h_Oxxd2s=f{}$XXy4}%JqTSjRC \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - wget "$jarUrl" -O "$wrapperJarPath" - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - curl -o "$wrapperJarPath" "$jarUrl" - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/spring-scheduling/mvnw.cmd b/spring-scheduling/mvnw.cmd deleted file mode 100644 index e5cfb0ae9e..0000000000 --- a/spring-scheduling/mvnw.cmd +++ /dev/null @@ -1,161 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" -FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - echo Found %WRAPPER_JAR% -) else ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" - echo Finished downloading %WRAPPER_JAR% -) -@REM End of extension - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/spring-scheduling/pom.xml b/spring-scheduling/pom.xml deleted file mode 100644 index d739985f7c..0000000000 --- a/spring-scheduling/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.1.2.RELEASE - - - com.baeldung - scheduling - 0.0.1-SNAPSHOT - scheduling - Example of conditionally enabling spring scheduled jobs - - - 1.8 - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/spring-scheduling/src/main/resources/application.properties b/spring-scheduling/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-scheduling/src/test/java/com/baeldung/scheduling/SchedulingApplicationTests.java b/spring-scheduling/src/test/java/com/baeldung/scheduling/SchedulingApplicationTests.java deleted file mode 100644 index 60e6d820bb..0000000000 --- a/spring-scheduling/src/test/java/com/baeldung/scheduling/SchedulingApplicationTests.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.scheduling; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class SchedulingApplicationTests { - - @Test - public void contextLoads() { - } - -} - From 24cf6b473d903256b1d906305b47e2f9c88ca066 Mon Sep 17 00:00:00 2001 From: Diego Moreira Date: Thu, 24 Jan 2019 21:32:29 -0300 Subject: [PATCH 286/441] BAEL-2270 Refactor - Moved classes from libraries to libraries-server (#6210) --- libraries-server/pom.xml | 25 +++++++++++++++++++ .../java/com/baeldung/smack/StanzaThread.java | 0 .../baeldung/smack/SmackIntegrationTest.java | 0 libraries/pom.xml | 24 ------------------ 4 files changed, 25 insertions(+), 24 deletions(-) rename {libraries => libraries-server}/src/main/java/com/baeldung/smack/StanzaThread.java (100%) rename {libraries => libraries-server}/src/test/java/com/baeldung/smack/SmackIntegrationTest.java (100%) diff --git a/libraries-server/pom.xml b/libraries-server/pom.xml index 661f5f01d5..f60e664fa7 100644 --- a/libraries-server/pom.xml +++ b/libraries-server/pom.xml @@ -71,6 +71,30 @@ tomcat-catalina ${tomcat.version} + + + org.igniterealtime.smack + smack-tcp + ${smack.version} + + + + org.igniterealtime.smack + smack-im + ${smack.version} + + + + org.igniterealtime.smack + smack-extensions + ${smack.version} + + + + org.igniterealtime.smack + smack-java7 + ${smack.version} + @@ -82,6 +106,7 @@ 4.1 4.12 8.5.24 + 4.3.1 \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/smack/StanzaThread.java b/libraries-server/src/main/java/com/baeldung/smack/StanzaThread.java similarity index 100% rename from libraries/src/main/java/com/baeldung/smack/StanzaThread.java rename to libraries-server/src/main/java/com/baeldung/smack/StanzaThread.java diff --git a/libraries/src/test/java/com/baeldung/smack/SmackIntegrationTest.java b/libraries-server/src/test/java/com/baeldung/smack/SmackIntegrationTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/smack/SmackIntegrationTest.java rename to libraries-server/src/test/java/com/baeldung/smack/SmackIntegrationTest.java diff --git a/libraries/pom.xml b/libraries/pom.xml index 301fa86c8d..d067525315 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -676,29 +676,6 @@ test - - org.igniterealtime.smack - smack-tcp - ${smack.version} - - - - org.igniterealtime.smack - smack-im - ${smack.version} - - - - org.igniterealtime.smack - smack-extensions - ${smack.version} - - - - org.igniterealtime.smack - smack-java7 - ${smack.version} - @@ -920,7 +897,6 @@ 1.1.0 2.7.1 3.6 - 4.3.1
From 4c540b764c9911a1e7f90cd01eea7087a9c170cd Mon Sep 17 00:00:00 2001 From: jose Date: Thu, 24 Jan 2019 23:04:56 -0300 Subject: [PATCH 287/441] Moving classes into core-java-lang --- .../baeldung/scope/BracketScopeExample.java | 14 -------------- .../com/baeldung/scope/ClassScopeExample.java | 14 -------------- .../com/baeldung/scope/LoopScopeExample.java | 18 ------------------ .../com/baeldung/scope/MethodScopeExample.java | 13 ------------- .../baeldung/scope/NestedScopesExample.java | 12 ------------ 5 files changed, 71 deletions(-) delete mode 100644 core-java/src/main/java/com/baeldung/scope/BracketScopeExample.java delete mode 100644 core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java delete mode 100644 core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java delete mode 100644 core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java delete mode 100644 core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java diff --git a/core-java/src/main/java/com/baeldung/scope/BracketScopeExample.java b/core-java/src/main/java/com/baeldung/scope/BracketScopeExample.java deleted file mode 100644 index 37ae211dcb..0000000000 --- a/core-java/src/main/java/com/baeldung/scope/BracketScopeExample.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.variable.scope.examples; - -public class BracketScopeExample { - - public void mathOperationExample() { - Integer sum = 0; - { - Integer number = 2; - sum = sum + number; - } - // compiler error, number cannot be solved as a variable - // number++; - } -} \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java b/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java deleted file mode 100644 index 241c6b466e..0000000000 --- a/core-java/src/main/java/com/baeldung/scope/ClassScopeExample.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.baeldung.variable.scope.examples; - -public class ClassScopeExample { - - Integer amount = 0; - - public void exampleMethod() { - amount++; - } - - public void anotherExampleMethod() { - Integer anotherAmount = amount + 4; - } -} \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java b/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java deleted file mode 100644 index 7bf92a6d26..0000000000 --- a/core-java/src/main/java/com/baeldung/scope/LoopScopeExample.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.baeldung.variable.scope.examples; - -import java.util.Arrays; -import java.util.List; - -public class LoopScopeExample { - - List listOfNames = Arrays.asList("Joe", "Susan", "Pattrick"); - - public void iterationOfNames() { - String allNames = ""; - for (String name : listOfNames) { - allNames = allNames + " " + name; - } - // compiler error, name cannot be resolved to a variable - // String lastNameUsed = name; - } -} diff --git a/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java b/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java deleted file mode 100644 index e62c6a2a1c..0000000000 --- a/core-java/src/main/java/com/baeldung/scope/MethodScopeExample.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.baeldung.variable.scope.examples; - -public class MethodScopeExample { - - public void methodA() { - Integer area = 2; - } - - public void methodB() { - // compiler error, area cannot be resolved to a variable - // area = area + 2; - } -} \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java b/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java deleted file mode 100644 index fcd23e5ae0..0000000000 --- a/core-java/src/main/java/com/baeldung/scope/NestedScopesExample.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung.variable.scope.examples; - -public class NestedScopesExample { - - String title = "Baeldung"; - - public void printTitle() { - System.out.println(title); - String title = "John Doe"; - System.out.println(title); - } -} \ No newline at end of file From ca5ff8ac8c70ea1f12148b363ce1a83824131c07 Mon Sep 17 00:00:00 2001 From: jose Date: Thu, 24 Jan 2019 23:06:51 -0300 Subject: [PATCH 288/441] Moving classes into core-java-lang --- .../baeldung/scope/BracketScopeExample.java | 14 ++++++++++++++ .../com/baeldung/scope/ClassScopeExample.java | 14 ++++++++++++++ .../com/baeldung/scope/LoopScopeExample.java | 18 ++++++++++++++++++ .../com/baeldung/scope/MethodScopeExample.java | 13 +++++++++++++ .../baeldung/scope/NestedScopesExample.java | 12 ++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 core-java-lang/src/main/java/com/baeldung/scope/BracketScopeExample.java create mode 100644 core-java-lang/src/main/java/com/baeldung/scope/ClassScopeExample.java create mode 100644 core-java-lang/src/main/java/com/baeldung/scope/LoopScopeExample.java create mode 100644 core-java-lang/src/main/java/com/baeldung/scope/MethodScopeExample.java create mode 100644 core-java-lang/src/main/java/com/baeldung/scope/NestedScopesExample.java diff --git a/core-java-lang/src/main/java/com/baeldung/scope/BracketScopeExample.java b/core-java-lang/src/main/java/com/baeldung/scope/BracketScopeExample.java new file mode 100644 index 0000000000..37ae211dcb --- /dev/null +++ b/core-java-lang/src/main/java/com/baeldung/scope/BracketScopeExample.java @@ -0,0 +1,14 @@ +package org.baeldung.variable.scope.examples; + +public class BracketScopeExample { + + public void mathOperationExample() { + Integer sum = 0; + { + Integer number = 2; + sum = sum + number; + } + // compiler error, number cannot be solved as a variable + // number++; + } +} \ No newline at end of file diff --git a/core-java-lang/src/main/java/com/baeldung/scope/ClassScopeExample.java b/core-java-lang/src/main/java/com/baeldung/scope/ClassScopeExample.java new file mode 100644 index 0000000000..241c6b466e --- /dev/null +++ b/core-java-lang/src/main/java/com/baeldung/scope/ClassScopeExample.java @@ -0,0 +1,14 @@ +package org.baeldung.variable.scope.examples; + +public class ClassScopeExample { + + Integer amount = 0; + + public void exampleMethod() { + amount++; + } + + public void anotherExampleMethod() { + Integer anotherAmount = amount + 4; + } +} \ No newline at end of file diff --git a/core-java-lang/src/main/java/com/baeldung/scope/LoopScopeExample.java b/core-java-lang/src/main/java/com/baeldung/scope/LoopScopeExample.java new file mode 100644 index 0000000000..7bf92a6d26 --- /dev/null +++ b/core-java-lang/src/main/java/com/baeldung/scope/LoopScopeExample.java @@ -0,0 +1,18 @@ +package org.baeldung.variable.scope.examples; + +import java.util.Arrays; +import java.util.List; + +public class LoopScopeExample { + + List listOfNames = Arrays.asList("Joe", "Susan", "Pattrick"); + + public void iterationOfNames() { + String allNames = ""; + for (String name : listOfNames) { + allNames = allNames + " " + name; + } + // compiler error, name cannot be resolved to a variable + // String lastNameUsed = name; + } +} diff --git a/core-java-lang/src/main/java/com/baeldung/scope/MethodScopeExample.java b/core-java-lang/src/main/java/com/baeldung/scope/MethodScopeExample.java new file mode 100644 index 0000000000..e62c6a2a1c --- /dev/null +++ b/core-java-lang/src/main/java/com/baeldung/scope/MethodScopeExample.java @@ -0,0 +1,13 @@ +package org.baeldung.variable.scope.examples; + +public class MethodScopeExample { + + public void methodA() { + Integer area = 2; + } + + public void methodB() { + // compiler error, area cannot be resolved to a variable + // area = area + 2; + } +} \ No newline at end of file diff --git a/core-java-lang/src/main/java/com/baeldung/scope/NestedScopesExample.java b/core-java-lang/src/main/java/com/baeldung/scope/NestedScopesExample.java new file mode 100644 index 0000000000..fcd23e5ae0 --- /dev/null +++ b/core-java-lang/src/main/java/com/baeldung/scope/NestedScopesExample.java @@ -0,0 +1,12 @@ +package org.baeldung.variable.scope.examples; + +public class NestedScopesExample { + + String title = "Baeldung"; + + public void printTitle() { + System.out.println(title); + String title = "John Doe"; + System.out.println(title); + } +} \ No newline at end of file From ae344b37ec7d7c0ed2cb0141e96c9811ad4eea71 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Fri, 25 Jan 2019 09:51:15 +0400 Subject: [PATCH 289/441] move the code into core-java-collections-lists module --- core-java-arrays/pom.xml | 16 ---------- core-java-collections-list/pom.xml | 29 +++++++++++++++++++ .../list/primitive}/PrimitiveCollections.java | 2 +- .../primitive}/PrimitivesListPerformance.java | 3 +- 4 files changed, 31 insertions(+), 19 deletions(-) rename {core-java-arrays/src/main/java/com/baeldung/array => core-java-collections-list/src/main/java/com/baeldung/list/primitive}/PrimitiveCollections.java (95%) rename {core-java-arrays/src/main/java/com/baeldung/array => core-java-collections-list/src/main/java/com/baeldung/list/primitive}/PrimitivesListPerformance.java (97%) diff --git a/core-java-arrays/pom.xml b/core-java-arrays/pom.xml index 6d4109804e..d2d0453e87 100644 --- a/core-java-arrays/pom.xml +++ b/core-java-arrays/pom.xml @@ -52,22 +52,6 @@ spring-web ${springframework.spring-web.version} - - - net.sf.trove4j - trove4j - 3.0.2 - - - it.unimi.dsi - fastutil - 8.1.0 - - - colt - colt - 1.2.0 - diff --git a/core-java-collections-list/pom.xml b/core-java-collections-list/pom.xml index ee99e470d0..bc71882683 100644 --- a/core-java-collections-list/pom.xml +++ b/core-java-collections-list/pom.xml @@ -36,6 +36,33 @@ ${lombok.version} provided + + + org.openjdk.jmh + jmh-core + ${jmh-core.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh-generator-annprocess.version} + + + + net.sf.trove4j + trove4j + 3.0.2 + + + it.unimi.dsi + fastutil + 8.1.0 + + + colt + colt + 1.2.0 + @@ -44,5 +71,7 @@ 1.7.0 3.11.1 1.16.12 + 1.19 + 1.19 diff --git a/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java similarity index 95% rename from core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java rename to core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java index 85f4dd2498..d6da32d899 100644 --- a/core-java-arrays/src/main/java/com/baeldung/array/PrimitiveCollections.java +++ b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java @@ -1,4 +1,4 @@ -package com.baeldung.array; +package com.baeldung.list.primitive; import com.google.common.primitives.ImmutableIntArray; import com.google.common.primitives.Ints; diff --git a/core-java-arrays/src/main/java/com/baeldung/array/PrimitivesListPerformance.java b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java similarity index 97% rename from core-java-arrays/src/main/java/com/baeldung/array/PrimitivesListPerformance.java rename to core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java index 9db3a75574..f57c8d65a6 100644 --- a/core-java-arrays/src/main/java/com/baeldung/array/PrimitivesListPerformance.java +++ b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java @@ -1,4 +1,4 @@ -package com.baeldung.array; +package com.baeldung.list.primitive; import it.unimi.dsi.fastutil.ints.IntArrayList; import gnu.trove.list.array.TIntArrayList; @@ -9,7 +9,6 @@ import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.ArrayList; import java.util.List; -import java.util.Random; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) From 2f5ef3480b97cea30ec57dafb9370a114f9f8b18 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Fri, 25 Jan 2019 10:54:59 +0400 Subject: [PATCH 290/441] remove Ints examples --- .../com/baeldung/list/primitive/PrimitiveCollections.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java index d6da32d899..5a8ddc0acd 100644 --- a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java +++ b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java @@ -20,13 +20,5 @@ public class PrimitiveCollections { ImmutableIntArray immutableIntArray = ImmutableIntArray.builder().addAll(primitives).build(); System.out.println(immutableIntArray); - - List list = Ints.asList(primitives); - - int[] primitiveArray = Ints.toArray(list); - - int[] concatenated = Ints.concat(primitiveArray, primitives); - - System.out.println(Arrays.toString(concatenated)); } } From 1293f4e17232fd39d3eb5dd97b141bd98b934533 Mon Sep 17 00:00:00 2001 From: Loredana Date: Fri, 25 Jan 2019 22:40:12 +0200 Subject: [PATCH 291/441] update boot dependencies, config --- spring-boot-rest/pom.xml | 27 ++++---------- .../baeldung/spring/PersistenceConfig.java | 1 - .../java/com/baeldung/spring/WebConfig.java | 35 +------------------ .../resources/springDataPersistenceConfig.xml | 12 ------- 4 files changed, 7 insertions(+), 68 deletions(-) delete mode 100644 spring-boot-rest/src/main/resources/springDataPersistenceConfig.xml diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index bcd0381603..cf4ac0371b 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -25,31 +25,16 @@ com.fasterxml.jackson.dataformat jackson-dataformat-xml - - org.hibernate - hibernate-entitymanager - - - org.springframework - spring-jdbc - - - org.springframework.data - spring-data-jpa - + com.h2database h2 - - org.springframework - spring-tx - - - org.springframework.data - spring-data-commons - - + + org.springframework.boot + spring-boot-starter-data-jpa + + diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java index 4a4b9eee3f..5179c66978 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ b/spring-boot-rest/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -25,7 +25,6 @@ import com.google.common.base.Preconditions; @EnableTransactionManagement @PropertySource({ "classpath:persistence-${envTarget:h2}.properties" }) @ComponentScan({ "com.baeldung.persistence" }) -// @ImportResource("classpath*:springDataPersistenceConfig.xml") @EnableJpaRepositories(basePackages = "com.baeldung.persistence.dao") public class PersistenceConfig { diff --git a/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java b/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java index 39aade174b..80ee975e84 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java +++ b/spring-boot-rest/src/main/java/com/baeldung/spring/WebConfig.java @@ -1,43 +1,10 @@ package com.baeldung.spring; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.view.InternalResourceViewResolver; + @Configuration -@ComponentScan("com.baeldung.web") -@EnableWebMvc public class WebConfig implements WebMvcConfigurer { - public WebConfig() { - super(); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); - viewResolver.setPrefix("/WEB-INF/view/"); - viewResolver.setSuffix(".jsp"); - return viewResolver; - } - - // API - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - registry.addViewController("/graph.html"); - registry.addViewController("/homepage.html"); - } - - @Override - public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { - configurer.defaultContentType(MediaType.APPLICATION_JSON); - } - } \ No newline at end of file diff --git a/spring-boot-rest/src/main/resources/springDataPersistenceConfig.xml b/spring-boot-rest/src/main/resources/springDataPersistenceConfig.xml deleted file mode 100644 index 5ea2d9c05b..0000000000 --- a/spring-boot-rest/src/main/resources/springDataPersistenceConfig.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file From 06023ec09f889214970fdc9615325e92f14769b3 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Sat, 26 Jan 2019 06:45:40 +0530 Subject: [PATCH 292/441] Feature/bael 2129 (#6182) * BAEL-2129 Added Unit test for Void Type in Kotlin article * BAEL-2129 Updated test case * BAEL-2129 Added comment for commented code --- .../com/baeldung/voidtypes/VoidTypesUnitTest.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core-kotlin/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt index 5c285c3135..468352dbed 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt +++ b/core-kotlin/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt @@ -6,7 +6,19 @@ import kotlin.test.assertTrue class VoidTypesUnitTest { - fun returnTypeAsVoid(): Void? { + // Un-commenting below methods will result into compilation error + // as the syntax used is incorrect and is used for explanation in tutorial. + + // fun returnTypeAsVoidAttempt1(): Void { + // println("Trying with Void as return type") + // } + + // fun returnTypeAsVoidAttempt2(): Void { + // println("Trying with Void as return type") + // return null + // } + + fun returnTypeAsVoidSuccess(): Void? { println("Function can have Void as return type") return null } @@ -36,7 +48,7 @@ class VoidTypesUnitTest { @Test fun givenVoidReturnType_thenReturnsNullOnly() { - assertNull(returnTypeAsVoid()) + assertNull(returnTypeAsVoidSuccess()) } @Test From 931dc2ae18577e9189ba83e44f2344b087c1563f Mon Sep 17 00:00:00 2001 From: alv21 Date: Fri, 25 Jan 2019 21:15:59 -0800 Subject: [PATCH 293/441] BAEL-2466 spring soap --- spring-soap/.gitignore | 1 + spring-soap/pom.xml | 68 +++++++++ .../com/baeldung/springsoap/Application.java | 12 ++ .../baeldung/springsoap/CountryEndpoint.java | 30 ++++ .../springsoap/CountryRepository.java | 47 ++++++ .../baeldung/springsoap/WebServiceConfig.java | 41 +++++ .../com/baeldung/springsoap/gen/Country.java | 144 ++++++++++++++++++ .../com/baeldung/springsoap/gen/Currency.java | 47 ++++++ .../springsoap/gen/GetCountryRequest.java | 71 +++++++++ .../springsoap/gen/GetCountryResponse.java | 71 +++++++++ .../springsoap/gen/ObjectFactory.java | 63 ++++++++ .../baeldung/springsoap/gen/package-info.java | 9 ++ spring-soap/src/main/resources/countries.xsd | 37 +++++ spring-soap/src/main/resources/request.xml | 23 +++ .../ApplicationIntegrationTest.java | 39 +++++ 15 files changed, 703 insertions(+) create mode 100644 spring-soap/.gitignore create mode 100644 spring-soap/pom.xml create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/Application.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/CountryEndpoint.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/CountryRepository.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/WebServiceConfig.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/Country.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/Currency.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryRequest.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryResponse.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/ObjectFactory.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/package-info.java create mode 100644 spring-soap/src/main/resources/countries.xsd create mode 100644 spring-soap/src/main/resources/request.xml create mode 100644 spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java diff --git a/spring-soap/.gitignore b/spring-soap/.gitignore new file mode 100644 index 0000000000..b83d22266a --- /dev/null +++ b/spring-soap/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/spring-soap/pom.xml b/spring-soap/pom.xml new file mode 100644 index 0000000000..54a1d86038 --- /dev/null +++ b/spring-soap/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + org.springframework + spring-soap + 1.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.0.5.RELEASE + + + + 1.8 + + + + + + org.springframework.boot + spring-boot-starter-web-services + + + wsdl4j + wsdl4j + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + org.codehaus.mojo + jaxb2-maven-plugin + 1.6 + + + xjc + + xjc + + + + + ${project.basedir}/src/main/resources/ + ${project.basedir}/src/main/java + false + + + + + + + diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/Application.java b/spring-soap/src/main/java/com/baeldung/springsoap/Application.java new file mode 100644 index 0000000000..ad9258447c --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/Application.java @@ -0,0 +1,12 @@ +package com.baeldung.springsoap; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/CountryEndpoint.java b/spring-soap/src/main/java/com/baeldung/springsoap/CountryEndpoint.java new file mode 100644 index 0000000000..745131767a --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/CountryEndpoint.java @@ -0,0 +1,30 @@ +package com.baeldung.springsoap; + +import com.baeldung.springsoap.gen.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ws.server.endpoint.annotation.Endpoint; +import org.springframework.ws.server.endpoint.annotation.PayloadRoot; +import org.springframework.ws.server.endpoint.annotation.RequestPayload; +import org.springframework.ws.server.endpoint.annotation.ResponsePayload; + +@Endpoint +public class CountryEndpoint { + + private static final String NAMESPACE_URI = "http://www.baeldung.com/springsoap/gen"; + + private CountryRepository countryRepository; + + @Autowired + public CountryEndpoint(CountryRepository countryRepository) { + this.countryRepository = countryRepository; + } + + @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCountryRequest") + @ResponsePayload + public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) { + GetCountryResponse response = new GetCountryResponse(); + response.setCountry(countryRepository.findCountry(request.getName())); + + return response; + } +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/CountryRepository.java b/spring-soap/src/main/java/com/baeldung/springsoap/CountryRepository.java new file mode 100644 index 0000000000..8a0f58a64e --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/CountryRepository.java @@ -0,0 +1,47 @@ +package com.baeldung.springsoap; + +import com.baeldung.springsoap.gen.*; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; + +import javax.annotation.PostConstruct; +import java.util.HashMap; +import java.util.Map; + +@Component +public class CountryRepository { + + private static final Map countries = new HashMap<>(); + + @PostConstruct + public void initData() { + Country spain = new Country(); + spain.setName("Spain"); + spain.setCapital("Madrid"); + spain.setCurrency(Currency.EUR); + spain.setPopulation(46704314); + + countries.put(spain.getName(), spain); + + Country poland = new Country(); + poland.setName("Poland"); + poland.setCapital("Warsaw"); + poland.setCurrency(Currency.PLN); + poland.setPopulation(38186860); + + countries.put(poland.getName(), poland); + + Country uk = new Country(); + uk.setName("United Kingdom"); + uk.setCapital("London"); + uk.setCurrency(Currency.GBP); + uk.setPopulation(63705000); + + countries.put(uk.getName(), uk); + } + + public Country findCountry(String name) { + Assert.notNull(name, "The country's name must not be null"); + return countries.get(name); + } +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/WebServiceConfig.java b/spring-soap/src/main/java/com/baeldung/springsoap/WebServiceConfig.java new file mode 100644 index 0000000000..930a961208 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/WebServiceConfig.java @@ -0,0 +1,41 @@ +package com.baeldung.springsoap; + +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.ws.config.annotation.EnableWs; +import org.springframework.ws.config.annotation.WsConfigurerAdapter; +import org.springframework.ws.transport.http.MessageDispatcherServlet; +import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; +import org.springframework.xml.xsd.SimpleXsdSchema; +import org.springframework.xml.xsd.XsdSchema; + +@EnableWs +@Configuration +public class WebServiceConfig extends WsConfigurerAdapter { + + @Bean + public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { + MessageDispatcherServlet servlet = new MessageDispatcherServlet(); + servlet.setApplicationContext(applicationContext); + servlet.setTransformWsdlLocations(true); + return new ServletRegistrationBean(servlet, "/ws/*"); + } + + @Bean(name = "countries") + public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) { + DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); + wsdl11Definition.setPortTypeName("CountriesPort"); + wsdl11Definition.setLocationUri("/ws"); + wsdl11Definition.setTargetNamespace("http://www.baeldung.com/springsoap/gen"); + wsdl11Definition.setSchema(countriesSchema); + return wsdl11Definition; + } + + @Bean + public XsdSchema countriesSchema() { + return new SimpleXsdSchema(new ClassPathResource("countries.xsd")); + } +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/gen/Country.java b/spring-soap/src/main/java/com/baeldung/springsoap/gen/Country.java new file mode 100644 index 0000000000..e3eb686d6b --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/gen/Country.java @@ -0,0 +1,144 @@ +// +// Questo file è stato generato dall'architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.7 +// Vedere http://java.sun.com/xml/jaxb +// Qualsiasi modifica a questo file andrà persa durante la ricompilazione dello schema di origine. +// Generato il: 2019.01.25 alle 06:06:58 PM PST +// + + +package com.baeldung.springsoap.gen; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Classe Java per country complex type. + * + *

Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe. + * + *

+ * <complexType name="country">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="capital" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="currency" type="{http://www.baeldung.com/springsoap/gen}currency"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "country", propOrder = { + "name", + "population", + "capital", + "currency" +}) +public class Country { + + @XmlElement(required = true) + protected String name; + protected int population; + @XmlElement(required = true) + protected String capital; + @XmlElement(required = true) + protected Currency currency; + + /** + * Recupera il valore della proprietà name. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Imposta il valore della proprietà name. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Recupera il valore della proprietà population. + * + */ + public int getPopulation() { + return population; + } + + /** + * Imposta il valore della proprietà population. + * + */ + public void setPopulation(int value) { + this.population = value; + } + + /** + * Recupera il valore della proprietà capital. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCapital() { + return capital; + } + + /** + * Imposta il valore della proprietà capital. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCapital(String value) { + this.capital = value; + } + + /** + * Recupera il valore della proprietà currency. + * + * @return + * possible object is + * {@link Currency } + * + */ + public Currency getCurrency() { + return currency; + } + + /** + * Imposta il valore della proprietà currency. + * + * @param value + * allowed object is + * {@link Currency } + * + */ + public void setCurrency(Currency value) { + this.currency = value; + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/gen/Currency.java b/spring-soap/src/main/java/com/baeldung/springsoap/gen/Currency.java new file mode 100644 index 0000000000..9b0660466f --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/gen/Currency.java @@ -0,0 +1,47 @@ +// +// Questo file è stato generato dall'architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.7 +// Vedere http://java.sun.com/xml/jaxb +// Qualsiasi modifica a questo file andrà persa durante la ricompilazione dello schema di origine. +// Generato il: 2019.01.25 alle 06:06:58 PM PST +// + + +package com.baeldung.springsoap.gen; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Classe Java per currency. + * + *

Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe. + *

+ *

+ * <simpleType name="currency">
+ *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ *     <enumeration value="GBP"/>
+ *     <enumeration value="EUR"/>
+ *     <enumeration value="PLN"/>
+ *   </restriction>
+ * </simpleType>
+ * 
+ * + */ +@XmlType(name = "currency") +@XmlEnum +public enum Currency { + + GBP, + EUR, + PLN; + + public String value() { + return name(); + } + + public static Currency fromValue(String v) { + return valueOf(v); + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryRequest.java b/spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryRequest.java new file mode 100644 index 0000000000..7e1f151929 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryRequest.java @@ -0,0 +1,71 @@ +// +// Questo file è stato generato dall'architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.7 +// Vedere http://java.sun.com/xml/jaxb +// Qualsiasi modifica a questo file andrà persa durante la ricompilazione dello schema di origine. +// Generato il: 2019.01.25 alle 06:06:58 PM PST +// + + +package com.baeldung.springsoap.gen; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Classe Java per anonymous complex type. + * + *

Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "name" +}) +@XmlRootElement(name = "getCountryRequest") +public class GetCountryRequest { + + @XmlElement(required = true) + protected String name; + + /** + * Recupera il valore della proprietà name. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Imposta il valore della proprietà name. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryResponse.java b/spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryResponse.java new file mode 100644 index 0000000000..38c49193b4 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryResponse.java @@ -0,0 +1,71 @@ +// +// Questo file è stato generato dall'architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.7 +// Vedere http://java.sun.com/xml/jaxb +// Qualsiasi modifica a questo file andrà persa durante la ricompilazione dello schema di origine. +// Generato il: 2019.01.25 alle 06:06:58 PM PST +// + + +package com.baeldung.springsoap.gen; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Classe Java per anonymous complex type. + * + *

Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="country" type="{http://www.baeldung.com/springsoap/gen}country"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "country" +}) +@XmlRootElement(name = "getCountryResponse") +public class GetCountryResponse { + + @XmlElement(required = true) + protected Country country; + + /** + * Recupera il valore della proprietà country. + * + * @return + * possible object is + * {@link Country } + * + */ + public Country getCountry() { + return country; + } + + /** + * Imposta il valore della proprietà country. + * + * @param value + * allowed object is + * {@link Country } + * + */ + public void setCountry(Country value) { + this.country = value; + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/gen/ObjectFactory.java b/spring-soap/src/main/java/com/baeldung/springsoap/gen/ObjectFactory.java new file mode 100644 index 0000000000..6b9691efc0 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/gen/ObjectFactory.java @@ -0,0 +1,63 @@ +// +// Questo file è stato generato dall'architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.7 +// Vedere http://java.sun.com/xml/jaxb +// Qualsiasi modifica a questo file andrà persa durante la ricompilazione dello schema di origine. +// Generato il: 2019.01.25 alle 06:06:58 PM PST +// + + +package com.baeldung.springsoap.gen; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.baeldung.springsoap.gen package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.springsoap.gen + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link GetCountryRequest } + * + */ + public GetCountryRequest createGetCountryRequest() { + return new GetCountryRequest(); + } + + /** + * Create an instance of {@link GetCountryResponse } + * + */ + public GetCountryResponse createGetCountryResponse() { + return new GetCountryResponse(); + } + + /** + * Create an instance of {@link Country } + * + */ + public Country createCountry() { + return new Country(); + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/gen/package-info.java b/spring-soap/src/main/java/com/baeldung/springsoap/gen/package-info.java new file mode 100644 index 0000000000..9638be3d94 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/gen/package-info.java @@ -0,0 +1,9 @@ +// +// Questo file è stato generato dall'architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.7 +// Vedere http://java.sun.com/xml/jaxb +// Qualsiasi modifica a questo file andrà persa durante la ricompilazione dello schema di origine. +// Generato il: 2019.01.25 alle 06:06:58 PM PST +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.baeldung.com/springsoap/gen", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package com.baeldung.springsoap.gen; diff --git a/spring-soap/src/main/resources/countries.xsd b/spring-soap/src/main/resources/countries.xsd new file mode 100644 index 0000000000..524e5ac2d5 --- /dev/null +++ b/spring-soap/src/main/resources/countries.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-soap/src/main/resources/request.xml b/spring-soap/src/main/resources/request.xml new file mode 100644 index 0000000000..7a94aeeee6 --- /dev/null +++ b/spring-soap/src/main/resources/request.xml @@ -0,0 +1,23 @@ + + + + + Spain + + + + + + + + + + Spain + 46704314 + Madrid + EUR + + + + \ No newline at end of file diff --git a/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java b/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java new file mode 100644 index 0000000000..18c8a96576 --- /dev/null +++ b/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java @@ -0,0 +1,39 @@ +package com.baeldung.springsoap; + +import com.baeldung.springsoap.gen.GetCountryRequest; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.util.ClassUtils; +import org.springframework.ws.client.core.WebServiceTemplate; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class ApplicationIntegrationTest { + + private Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); + + @LocalServerPort private int port = 0; + + @Before + public void init() throws Exception { + marshaller.setPackagesToScan(ClassUtils.getPackageName(GetCountryRequest.class)); + marshaller.afterPropertiesSet(); + } + + @Test + public void whenSendRequest_thenResponseIsNotNull() { + WebServiceTemplate ws = new WebServiceTemplate(marshaller); + GetCountryRequest request = new GetCountryRequest(); + request.setName("Spain"); + + assertThat(ws.marshalSendAndReceive("http://localhost:" + port + "/ws", request)).isNotNull(); + } +} \ No newline at end of file From c6e808348ddbcb70a90045db7b86affdf6ad9e38 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 26 Jan 2019 10:41:54 +0200 Subject: [PATCH 294/441] Update README.md --- spring-cloud/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/spring-cloud/README.md b/spring-cloud/README.md index eb2e46c3d0..fede3cc12d 100644 --- a/spring-cloud/README.md +++ b/spring-cloud/README.md @@ -15,8 +15,6 @@ ### Relevant Articles: - [Intro to Spring Cloud Netflix - Hystrix](http://www.baeldung.com/spring-cloud-netflix-hystrix) - [Dockerizing a Spring Boot Application](http://www.baeldung.com/dockerizing-spring-boot-application) -- [Using a Spring Cloud App Starter](http://www.baeldung.com/using-a-spring-cloud-app-starter) -- [Using a Spring Cloud App Starter](http://www.baeldung.com/spring-cloud-app-starter) - [Instance Profile Credentials using Spring Cloud](http://www.baeldung.com/spring-cloud-instance-profiles) - [Running Spring Boot Applications With Minikube](http://www.baeldung.com/spring-boot-minikube) From 2437a265006e4f7a485952d254058914bd2d8d0f Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 26 Jan 2019 10:42:34 +0200 Subject: [PATCH 295/441] Create README.md --- spring-cloud/spring-cloud-stream-starters/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-cloud/spring-cloud-stream-starters/README.md diff --git a/spring-cloud/spring-cloud-stream-starters/README.md b/spring-cloud/spring-cloud-stream-starters/README.md new file mode 100644 index 0000000000..761d54abbd --- /dev/null +++ b/spring-cloud/spring-cloud-stream-starters/README.md @@ -0,0 +1,3 @@ +#Revelant Articles: + +- [Using a Spring Cloud App Starter](http://www.baeldung.com/spring-cloud-app-starter) From 720c32ab78b18e3fc092700e674c4e84724ef33b Mon Sep 17 00:00:00 2001 From: amdegregorio Date: Sat, 26 Jan 2019 09:00:26 -0500 Subject: [PATCH 296/441] BAEL-2542 Creating a Jar - example code --- .../java/com/baeldung/jar/Dimensioner.java | 27 ++++++++++++ .../java/com/baeldung/jar/JarExample.java | 31 +++++++++++++ .../main/java/com/baeldung/jar/Rectangle.java | 44 +++++++++++++++++++ .../resources/META-INF/example_manifest.txt | 1 + .../src/main/resources/files/dimensions.txt | 3 ++ 5 files changed, 106 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/jar/Dimensioner.java create mode 100644 core-java/src/main/java/com/baeldung/jar/JarExample.java create mode 100644 core-java/src/main/java/com/baeldung/jar/Rectangle.java create mode 100644 core-java/src/main/resources/META-INF/example_manifest.txt create mode 100644 core-java/src/main/resources/files/dimensions.txt diff --git a/core-java/src/main/java/com/baeldung/jar/Dimensioner.java b/core-java/src/main/java/com/baeldung/jar/Dimensioner.java new file mode 100644 index 0000000000..bc5cea4010 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/jar/Dimensioner.java @@ -0,0 +1,27 @@ +package com.baeldung.jar; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +public class Dimensioner { + + public List loadFromFile(String dimensionFile) throws FileNotFoundException, IOException { + List rectangles = new ArrayList(); + try (BufferedReader br = new BufferedReader(new InputStreamReader(Dimensioner.class.getResourceAsStream(dimensionFile)))) { + String line; + while ((line = br.readLine()) != null) { + String[] dimensions = line.split(","); + if (dimensions.length == 2) { + Rectangle rectangle = new Rectangle(Integer.valueOf(dimensions[0]), Integer.valueOf(dimensions[1])); + rectangles.add(rectangle); + } + } + } + return rectangles; + } + +} diff --git a/core-java/src/main/java/com/baeldung/jar/JarExample.java b/core-java/src/main/java/com/baeldung/jar/JarExample.java new file mode 100644 index 0000000000..262df3a5ec --- /dev/null +++ b/core-java/src/main/java/com/baeldung/jar/JarExample.java @@ -0,0 +1,31 @@ +package com.baeldung.jar; + +import java.io.IOException; +import java.util.List; + +public class JarExample { + private static final String DIMENSION_FILE = "/dimensions.txt"; + + public static void main(String[] args) { + String environment = System.getProperty("environment"); + if (environment != null && environment.equalsIgnoreCase("prod")) { + Dimensioner dimensioner = new Dimensioner(); + try { + List rectangles = dimensioner.loadFromFile(DIMENSION_FILE); + rectangles.forEach(rectangle -> { + rectangle.printArea(); + rectangle.printPerimeter(); + }); + } catch (IOException e) { + System.err.println("Exception loading dimensions"); + } + } else if (args.length > 0) { + int length = Integer.valueOf(args[0]); + int width = (args.length > 1) ? Integer.valueOf(args[1]) : Integer.valueOf(args[0]); + Rectangle rectangle = new Rectangle(length, width); + rectangle.printArea(); + rectangle.printPerimeter(); + } + } + +} diff --git a/core-java/src/main/java/com/baeldung/jar/Rectangle.java b/core-java/src/main/java/com/baeldung/jar/Rectangle.java new file mode 100644 index 0000000000..f2a174c819 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/jar/Rectangle.java @@ -0,0 +1,44 @@ +package com.baeldung.jar; + +public class Rectangle { + private int length; + private int width; + + public Rectangle(int length, int width) { + this.length = length; + this.width = width; + } + + public int area() { + return length * width; + } + + public int perimeter() { + return (length * 2) + (width * 2); + } + + public void printArea() { + System.out.println("Area: " + area()); + } + + public void printPerimeter() { + System.out.println("Perimeter: " + perimeter()); + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length = length; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + +} diff --git a/core-java/src/main/resources/META-INF/example_manifest.txt b/core-java/src/main/resources/META-INF/example_manifest.txt new file mode 100644 index 0000000000..90e83e9b42 --- /dev/null +++ b/core-java/src/main/resources/META-INF/example_manifest.txt @@ -0,0 +1 @@ +Main-Class: com.baeldung.jar.JarExample diff --git a/core-java/src/main/resources/files/dimensions.txt b/core-java/src/main/resources/files/dimensions.txt new file mode 100644 index 0000000000..0397c2a610 --- /dev/null +++ b/core-java/src/main/resources/files/dimensions.txt @@ -0,0 +1,3 @@ +12,16 +24,6 +7,19 \ No newline at end of file From 4c1c93e1f698c06137de54737fb11fc828b27857 Mon Sep 17 00:00:00 2001 From: alv21 Date: Sat, 26 Jan 2019 09:14:27 -0800 Subject: [PATCH 297/441] BAEL-2466 spring-soap module added --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index d084d0f7af..fe55a9bf44 100644 --- a/pom.xml +++ b/pom.xml @@ -749,6 +749,7 @@ spring-security-x509 spring-session spring-sleuth + spring-soap spring-social-login spring-spel spring-state-machine @@ -1458,6 +1459,7 @@ spring-security-x509 spring-session spring-sleuth + spring-soap spring-social-login spring-spel spring-state-machine From 630d07277e7851ef2c4b5952ac2206f5fe57107d Mon Sep 17 00:00:00 2001 From: eric-martin Date: Sat, 26 Jan 2019 15:25:41 -0600 Subject: [PATCH 298/441] BAEL-2406: Improve asserts in PassengerRepositoryIntegrationTest --- .../PassengerRepositoryIntegrationTest.java | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java index 59380c1427..8cd19cec03 100644 --- a/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa/src/test/java/com/baeldung/passenger/PassengerRepositoryIntegrationTest.java @@ -1,5 +1,17 @@ package com.baeldung.passenger; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.core.IsNot.not; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.List; +import java.util.Optional; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -12,16 +24,6 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.test.context.junit4.SpringRunner; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import java.util.List; -import java.util.Optional; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - @DataJpaTest @RunWith(SpringRunner.class) public class PassengerRepositoryIntegrationTest { @@ -49,7 +51,7 @@ public class PassengerRepositoryIntegrationTest { assertEquals(1, passengers.size()); Passenger actual = passengers.get(0); - assertEquals(actual, expected); + assertEquals(expected, actual); } @Test @@ -58,7 +60,7 @@ public class PassengerRepositoryIntegrationTest { Passenger actual = repository.findFirstByOrderBySeatNumberAsc(); - assertEquals(actual, expected); + assertEquals(expected, actual); } @Test @@ -68,7 +70,7 @@ public class PassengerRepositoryIntegrationTest { Page page = repository.findAll(PageRequest.of(0, 1, Sort.by(Sort.Direction.ASC, "seatNumber"))); - assertEquals(page.getContent().size(), 1); + assertEquals(1, page.getContent().size()); Passenger actual = page.getContent().get(0); assertEquals(expected, actual); @@ -107,7 +109,7 @@ public class PassengerRepositoryIntegrationTest { Optional actual = repository.findOne(example); assertTrue(actual.isPresent()); - assertEquals(actual.get(), Passenger.from("Fred", "Bloggs", 22)); + assertEquals(Passenger.from("Fred", "Bloggs", 22), actual.get()); } @Test @@ -119,7 +121,7 @@ public class PassengerRepositoryIntegrationTest { Optional actual = repository.findOne(example); assertTrue(actual.isPresent()); - assertEquals(actual.get(), Passenger.from("Fred", "Bloggs", 22)); + assertEquals(Passenger.from("Fred", "Bloggs", 22), actual.get()); } @Test @@ -128,6 +130,7 @@ public class PassengerRepositoryIntegrationTest { Passenger eve = Passenger.from("Eve", "Jackson", 95); Passenger fred = Passenger.from("Fred", "Bloggs", 22); Passenger siya = Passenger.from("Siya", "Kolisi", 85); + Passenger ricki = Passenger.from("Ricki", "Bobbie", 36); ExampleMatcher customExampleMatcher = ExampleMatcher.matchingAny().withMatcher("firstName", ExampleMatcher.GenericPropertyMatchers.contains().ignoreCase()).withMatcher("lastName", @@ -139,21 +142,28 @@ public class PassengerRepositoryIntegrationTest { List passengers = repository.findAll(example); assertThat(passengers, contains(jill, eve, fred, siya)); + assertThat(passengers, not(contains(ricki))); } -@Test -public void givenPassengers_whenFindByIgnoringMatcher_thenExpectedReturned() { - Passenger fred = Passenger.from("Fred", "Bloggs", 22); - Passenger ricki = Passenger.from("Ricki", "Bobbie", 36); - - ExampleMatcher ignoringExampleMatcher = ExampleMatcher.matchingAny().withMatcher("lastName", - ExampleMatcher.GenericPropertyMatchers.startsWith().ignoreCase()).withIgnorePaths("firstName", "seatNumber"); - - Example example = Example.of(Passenger.from(null, "b", null), - ignoringExampleMatcher); - - List passengers = repository.findAll(example); - - assertThat(passengers, contains(fred, ricki)); -} + @Test + public void givenPassengers_whenFindByIgnoringMatcher_thenExpectedReturned() { + Passenger jill = Passenger.from("Jill", "Smith", 50); + Passenger eve = Passenger.from("Eve", "Jackson", 95); + Passenger fred = Passenger.from("Fred", "Bloggs", 22); + Passenger siya = Passenger.from("Siya", "Kolisi", 85); + Passenger ricki = Passenger.from("Ricki", "Bobbie", 36); + + ExampleMatcher ignoringExampleMatcher = ExampleMatcher.matchingAny().withMatcher("lastName", + ExampleMatcher.GenericPropertyMatchers.startsWith().ignoreCase()).withIgnorePaths("firstName", "seatNumber"); + + Example example = Example.of(Passenger.from(null, "b", null), + ignoringExampleMatcher); + + List passengers = repository.findAll(example); + + assertThat(passengers, contains(fred, ricki)); + assertThat(passengers, not(contains(jill))); + assertThat(passengers, not(contains(eve))); + assertThat(passengers, not(contains(siya))); + } } From 9a567f95b4be0737af8a9a0cd2b02e09d793bc54 Mon Sep 17 00:00:00 2001 From: PranayVJain Date: Sun, 27 Jan 2019 11:51:13 +0530 Subject: [PATCH 299/441] List files within directory Issue: BAEL-2447 --- .../java/com/baeldung/files/ListFiles.java | 64 +++++++++++++++++++ .../com/baeldung/file/ListFilesUnitTest.java | 46 +++++++++++++ .../listFilesUnitTestFolder/country.txt | 1 + .../listFilesUnitTestFolder/employee.json | 1 + .../listFilesUnitTestFolder/students.json | 1 + .../listFilesUnitTestFolder/test.xml | 1 + 6 files changed, 114 insertions(+) create mode 100644 core-java-io/src/main/java/com/baeldung/files/ListFiles.java create mode 100644 core-java-io/src/test/java/com/baeldung/file/ListFilesUnitTest.java create mode 100644 core-java-io/src/test/resources/listFilesUnitTestFolder/country.txt create mode 100644 core-java-io/src/test/resources/listFilesUnitTestFolder/employee.json create mode 100644 core-java-io/src/test/resources/listFilesUnitTestFolder/students.json create mode 100644 core-java-io/src/test/resources/listFilesUnitTestFolder/test.xml diff --git a/core-java-io/src/main/java/com/baeldung/files/ListFiles.java b/core-java-io/src/main/java/com/baeldung/files/ListFiles.java new file mode 100644 index 0000000000..c5de36270c --- /dev/null +++ b/core-java-io/src/main/java/com/baeldung/files/ListFiles.java @@ -0,0 +1,64 @@ +package com.baeldung.files; + +import java.io.File; +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class ListFiles { + public static final int DEPTH = 1; + + public Set listFilesUsingJavaIO(String dir) { + return Stream.of(new File(dir).listFiles()) + .filter(file -> !file.isDirectory()) + .map(File::getName) + .collect(Collectors.toSet()); + } + + public Set listFilesUsingFileWalk(String dir, int depth) throws IOException { + try (Stream stream = Files.walk(Paths.get(dir), depth)) { + return stream.filter(file -> !Files.isDirectory(file)) + .map(Path::getFileName) + .map(Path::toString) + .collect(Collectors.toSet()); + } + } + + public Set listFilesUsingFileWalkAndVisitor(String dir) throws IOException { + Set fileList = new HashSet<>(); + Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + if (!Files.isDirectory(file)) { + fileList.add(file.getFileName() + .toString()); + } + return FileVisitResult.CONTINUE; + } + }); + return fileList; + } + + public Set listFilesUsingDirectoryStream(String dir) throws IOException { + Set fileList = new HashSet<>(); + try (DirectoryStream stream = Files.newDirectoryStream(Paths.get(dir))) { + for (Path path : stream) { + if (!Files.isDirectory(path)) { + fileList.add(path.getFileName() + .toString()); + } + } + } + return fileList; + } + +} diff --git a/core-java-io/src/test/java/com/baeldung/file/ListFilesUnitTest.java b/core-java-io/src/test/java/com/baeldung/file/ListFilesUnitTest.java new file mode 100644 index 0000000000..65710121cc --- /dev/null +++ b/core-java-io/src/test/java/com/baeldung/file/ListFilesUnitTest.java @@ -0,0 +1,46 @@ +package com.baeldung.file; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +import org.junit.Test; + +import com.baeldung.files.ListFiles; + +public class ListFilesUnitTest { + + private ListFiles listFiles = new ListFiles(); + private String DIRECTORY = "src/test/resources/listFilesUnitTestFolder"; + private static final int DEPTH = 1; + private Set EXPECTED_FILE_LIST = new HashSet() { + { + add("test.xml"); + add("employee.json"); + add("students.json"); + add("country.txt"); + } + }; + + @Test + public void givenDir_whenUsingJAVAIO_thenListAllFiles() throws IOException { + assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingJavaIO(DIRECTORY)); + } + + @Test + public void givenDir_whenWalkingTree_thenListAllFiles() throws IOException { + assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingFileWalk(DIRECTORY,DEPTH)); + } + + @Test + public void givenDir_whenWalkingTreeWithVisitor_thenListAllFiles() throws IOException { + assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingFileWalkAndVisitor(DIRECTORY)); + } + + @Test + public void givenDir_whenUsingDirectoryStream_thenListAllFiles() throws IOException { + assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingDirectoryStream(DIRECTORY)); + } +} diff --git a/core-java-io/src/test/resources/listFilesUnitTestFolder/country.txt b/core-java-io/src/test/resources/listFilesUnitTestFolder/country.txt new file mode 100644 index 0000000000..45bfe896dc --- /dev/null +++ b/core-java-io/src/test/resources/listFilesUnitTestFolder/country.txt @@ -0,0 +1 @@ +This is a sample txt file for unit test ListFilesUnitTest \ No newline at end of file diff --git a/core-java-io/src/test/resources/listFilesUnitTestFolder/employee.json b/core-java-io/src/test/resources/listFilesUnitTestFolder/employee.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/core-java-io/src/test/resources/listFilesUnitTestFolder/employee.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/core-java-io/src/test/resources/listFilesUnitTestFolder/students.json b/core-java-io/src/test/resources/listFilesUnitTestFolder/students.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/core-java-io/src/test/resources/listFilesUnitTestFolder/students.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/core-java-io/src/test/resources/listFilesUnitTestFolder/test.xml b/core-java-io/src/test/resources/listFilesUnitTestFolder/test.xml new file mode 100644 index 0000000000..19b16cc72c --- /dev/null +++ b/core-java-io/src/test/resources/listFilesUnitTestFolder/test.xml @@ -0,0 +1 @@ + \ No newline at end of file From 2a308c51cb3c68635a1510190528fdbd168a51c1 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Sun, 27 Jan 2019 10:34:13 +0400 Subject: [PATCH 300/441] suggested refactor --- .../main/java/com/baeldung/string/MatchWords.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/java-strings/src/main/java/com/baeldung/string/MatchWords.java b/java-strings/src/main/java/com/baeldung/string/MatchWords.java index 4baaa49227..0cad52c320 100644 --- a/java-strings/src/main/java/com/baeldung/string/MatchWords.java +++ b/java-strings/src/main/java/com/baeldung/string/MatchWords.java @@ -15,8 +15,7 @@ public class MatchWords { public static boolean containsWordsIndexOf(String inputString, String[] words) { boolean found = true; for (String word : words) { - int index = inputString.indexOf(word); - if (index == -1) { + if (inputString.indexOf(word) == -1) { found = false; break; } @@ -64,21 +63,19 @@ public class MatchWords { } Pattern pattern = Pattern.compile(regexp.toString()); - if (pattern.matcher(inputString).find()) { - return true; - } - return false; + + return pattern.matcher(inputString).find(); } public static boolean containsWordsJava8(String inputString, String[] words) { - List inputStringList = Arrays.asList(inputString.split(" ")); + List inputStringList = Arrays.asList(inputString.split(" ")); List wordsList = Arrays.asList(words); return wordsList.stream().allMatch(inputStringList::contains); } public static boolean containsWordsArray(String inputString, String[] words) { - List inputStringList = Arrays.asList(inputString.split(" ")); + List inputStringList = Arrays.asList(inputString.split(" ")); List wordsList = Arrays.asList(words); return inputStringList.containsAll(wordsList); From 4bd87241ce8cc99f98446b3703cb8ddfba9c2dca Mon Sep 17 00:00:00 2001 From: rodolforfq <31481067+rodolforfq@users.noreply.github.com> Date: Sun, 27 Jan 2019 02:38:38 -0400 Subject: [PATCH 301/441] BAEL-2524 (#6206) * BAEL-2524 Uploading article examples. * Fixing build error Used List.of, which is not available on java 8 (running java 11 on my PC) --- .../java8/lambda/methodreference/Bicycle.java | 29 ++++++++ .../methodreference/BicycleComparator.java | 13 ++++ .../MethodReferenceExamples.java | 70 +++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java create mode 100644 core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/BicycleComparator.java create mode 100644 core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceExamples.java diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java new file mode 100644 index 0000000000..760a24d7c2 --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java @@ -0,0 +1,29 @@ +package com.baeldung.java8.lambda.methodreference; + +public class Bicycle { + + private String brand; + private Integer frameSize; + + public Bicycle(String brand, Integer frameSize) { + this.brand = brand; + this.frameSize = frameSize; + } + + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand = brand; + } + + public Integer getFrameSize() { + return frameSize; + } + + public void setFrameSize(Integer frameSize) { + this.frameSize = frameSize; + } + +} diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/BicycleComparator.java b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/BicycleComparator.java new file mode 100644 index 0000000000..153a7d105a --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/BicycleComparator.java @@ -0,0 +1,13 @@ +package com.baeldung.java8.lambda.methodreference; + +import java.util.Comparator; + +public class BicycleComparator implements Comparator { + + @Override + public int compare(Bicycle a, Bicycle b) { + return a.getFrameSize() + .compareTo(b.getFrameSize()); + } + +} diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceExamples.java b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceExamples.java new file mode 100644 index 0000000000..3b9a5ec6ff --- /dev/null +++ b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceExamples.java @@ -0,0 +1,70 @@ +package com.baeldung.java8.lambda.methodreference; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.function.BiFunction; + +import org.junit.Test; + +public class MethodReferenceExamples { + + private static void doNothingAtAll(Object... o) { + } + + ; + + @Test + public void referenceToStaticMethod() { + List messages = Arrays.asList("Hello", "Baeldung", "readers!"); + messages.forEach((word) -> { + System.out.println(word); + }); + messages.forEach(System.out::println); + } + + @Test + public void referenceToInstanceMethodOfParticularObject() { + BicycleComparator bikeFrameSizeComparator = new BicycleComparator(); + createBicyclesList().stream() + .sorted((a, b) -> bikeFrameSizeComparator.compare(a, b)); + createBicyclesList().stream() + .sorted(bikeFrameSizeComparator::compare); + } + + @Test + public void referenceToInstanceMethodOfArbitratyObjectOfParticularType() { + List numbers = Arrays.asList(5, 3, 50, 24, 40, 2, 9, 18); + numbers.stream() + .sorted((a, b) -> Integer.compare(a, b)); + numbers.stream() + .sorted(Integer::compare); + } + + @Test + public void referenceToConstructor() { + BiFunction bikeCreator = (brand, frameSize) -> new Bicycle(brand, frameSize); + BiFunction bikeCreatorMethodReference = Bicycle::new; + List bikes = new ArrayList<>(); + bikes.add(bikeCreator.apply("Giant", 50)); + bikes.add(bikeCreator.apply("Scott", 20)); + bikes.add(bikeCreatorMethodReference.apply("Trek", 35)); + bikes.add(bikeCreatorMethodReference.apply("GT", 40)); + } + + @Test + public void limitationsAndAdditionalExamples() { + createBicyclesList().forEach(b -> System.out.printf("Bike brand is '%s' and frame size is '%d'%n", b.getBrand(), b.getFrameSize())); + createBicyclesList().forEach((o) -> this.doNothingAtAll(o)); + } + + private List createBicyclesList() { + List bikes = new ArrayList<>(); + bikes.add(new Bicycle("Giant", 50)); + bikes.add(new Bicycle("Scott", 20)); + bikes.add(new Bicycle("Trek", 35)); + bikes.add(new Bicycle("GT", 40)); + return bikes; + } + +} From 8ccec9a413ee3e36eb73d0d1e2294596b2b3681f Mon Sep 17 00:00:00 2001 From: pcoates33 Date: Sun, 27 Jan 2019 06:55:25 +0000 Subject: [PATCH 302/441] BAEL-2510 Add nested properties section (#6212) Add nested properties section to ConfigurationProperties article. --- .../baeldung/properties/ConfigProperties.java | 62 +++++-------------- .../org/baeldung/properties/Credentials.java | 37 +++++++++++ .../src/main/resources/configprops.properties | 2 +- .../ConfigPropertiesIntegrationTest.java | 31 +++++++--- .../resources/configprops-test.properties | 2 +- 5 files changed, 75 insertions(+), 59 deletions(-) create mode 100644 spring-boot/src/main/java/org/baeldung/properties/Credentials.java diff --git a/spring-boot/src/main/java/org/baeldung/properties/ConfigProperties.java b/spring-boot/src/main/java/org/baeldung/properties/ConfigProperties.java index 2d3e56100c..3698d8ef30 100644 --- a/spring-boot/src/main/java/org/baeldung/properties/ConfigProperties.java +++ b/spring-boot/src/main/java/org/baeldung/properties/ConfigProperties.java @@ -8,7 +8,6 @@ import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Pattern; -import org.hibernate.validator.constraints.Length; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; @@ -20,41 +19,8 @@ import org.springframework.validation.annotation.Validated; @Validated public class ConfigProperties { - @Validated - public static class Credentials { - - @Length(max = 4, min = 1) - private String authMethod; - private String username; - private String password; - - public String getAuthMethod() { - return authMethod; - } - - public void setAuthMethod(String authMethod) { - this.authMethod = authMethod; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - } - @NotBlank - private String host; + private String hostName; @Min(1025) @Max(65536) @@ -63,16 +29,16 @@ public class ConfigProperties { @Pattern(regexp = "^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,6}$") private String from; - private Credentials credentials; private List defaultRecipients; private Map additionalHeaders; + private Credentials credentials; - public String getHost() { - return host; + public String getHostName() { + return hostName; } - public void setHost(String host) { - this.host = host; + public void setHostName(String hostName) { + this.hostName = hostName; } public int getPort() { @@ -91,14 +57,6 @@ public class ConfigProperties { this.from = from; } - public Credentials getCredentials() { - return credentials; - } - - public void setCredentials(Credentials credentials) { - this.credentials = credentials; - } - public List getDefaultRecipients() { return defaultRecipients; } @@ -114,4 +72,12 @@ public class ConfigProperties { public void setAdditionalHeaders(Map additionalHeaders) { this.additionalHeaders = additionalHeaders; } + + public Credentials getCredentials() { + return credentials; + } + + public void setCredentials(Credentials credentials) { + this.credentials = credentials; + } } diff --git a/spring-boot/src/main/java/org/baeldung/properties/Credentials.java b/spring-boot/src/main/java/org/baeldung/properties/Credentials.java new file mode 100644 index 0000000000..2d8ac76e62 --- /dev/null +++ b/spring-boot/src/main/java/org/baeldung/properties/Credentials.java @@ -0,0 +1,37 @@ +package org.baeldung.properties; + +import org.hibernate.validator.constraints.Length; +import org.springframework.validation.annotation.Validated; + +@Validated +public class Credentials { + + @Length(max = 4, min = 1) + private String authMethod; + private String username; + private String password; + + public String getAuthMethod() { + return authMethod; + } + + public void setAuthMethod(String authMethod) { + this.authMethod = authMethod; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/spring-boot/src/main/resources/configprops.properties b/spring-boot/src/main/resources/configprops.properties index e5d9ae621d..2dad11f9cc 100644 --- a/spring-boot/src/main/resources/configprops.properties +++ b/spring-boot/src/main/resources/configprops.properties @@ -1,5 +1,5 @@ #Simple properties -mail.host=mailer@mail.com +mail.hostname=host@mail.com mail.port=9000 mail.from=mailer@mail.com diff --git a/spring-boot/src/test/java/org/baeldung/properties/ConfigPropertiesIntegrationTest.java b/spring-boot/src/test/java/org/baeldung/properties/ConfigPropertiesIntegrationTest.java index 3f3b558db9..4ba6bf29d8 100644 --- a/spring-boot/src/test/java/org/baeldung/properties/ConfigPropertiesIntegrationTest.java +++ b/spring-boot/src/test/java/org/baeldung/properties/ConfigPropertiesIntegrationTest.java @@ -1,5 +1,8 @@ package org.baeldung.properties; +import java.util.List; +import java.util.Map; + import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,26 +21,36 @@ public class ConfigPropertiesIntegrationTest { @Test public void whenSimplePropertyQueriedthenReturnsProperty() throws Exception { - Assert.assertTrue("From address is read as null!", properties.getFrom() != null); + Assert.assertEquals("Incorrectly bound hostName property", "host@mail.com", properties.getHostName()); + Assert.assertEquals("Incorrectly bound port property", 9000, properties.getPort()); + Assert.assertEquals("Incorrectly bound from property", "mailer@mail.com", properties.getFrom()); } @Test public void whenListPropertyQueriedthenReturnsProperty() throws Exception { - Assert.assertTrue("Couldn't bind list property!", properties.getDefaultRecipients().size() == 2); - Assert.assertTrue("Incorrectly bound list property. Expected 2 entries!", properties.getDefaultRecipients().size() == 2); + List defaultRecipients = properties.getDefaultRecipients(); + Assert.assertTrue("Couldn't bind list property!", defaultRecipients.size() == 2); + Assert.assertTrue("Incorrectly bound list property. Expected 2 entries!", defaultRecipients.size() == 2); + Assert.assertEquals("Incorrectly bound list[0] property", "admin@mail.com", defaultRecipients.get(0)); + Assert.assertEquals("Incorrectly bound list[1] property", "owner@mail.com", defaultRecipients.get(1)); } @Test public void whenMapPropertyQueriedthenReturnsProperty() throws Exception { - Assert.assertTrue("Couldn't bind map property!", properties.getAdditionalHeaders() != null); - Assert.assertTrue("Incorrectly bound map property. Expected 3 Entries!", properties.getAdditionalHeaders().size() == 3); + Map additionalHeaders = properties.getAdditionalHeaders(); + Assert.assertTrue("Couldn't bind map property!", additionalHeaders != null); + Assert.assertTrue("Incorrectly bound map property. Expected 3 Entries!", additionalHeaders.size() == 3); + Assert.assertEquals("Incorrectly bound map[redelivery] property", "true", additionalHeaders.get("redelivery")); + Assert.assertEquals("Incorrectly bound map[secure] property", "true", additionalHeaders.get("secure")); + Assert.assertEquals("Incorrectly bound map[p3] property", "value", additionalHeaders.get("p3")); } @Test public void whenObjectPropertyQueriedthenReturnsProperty() throws Exception { - Assert.assertTrue("Couldn't bind map property!", properties.getCredentials() != null); - Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getAuthMethod().equals("SHA1")); - Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getUsername().equals("john")); - Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getPassword().equals("password")); + Credentials credentials = properties.getCredentials(); + Assert.assertTrue("Couldn't bind map property!", credentials != null); + Assert.assertEquals("Incorrectly bound object property, authMethod", "SHA1", credentials.getAuthMethod()); + Assert.assertEquals("Incorrectly bound object property, username", "john", credentials.getUsername()); + Assert.assertEquals("Incorrectly bound object property, password", "password", credentials.getPassword()); } } diff --git a/spring-boot/src/test/resources/configprops-test.properties b/spring-boot/src/test/resources/configprops-test.properties index b27cf2107a..697771ae6e 100644 --- a/spring-boot/src/test/resources/configprops-test.properties +++ b/spring-boot/src/test/resources/configprops-test.properties @@ -1,5 +1,5 @@ #Simple properties -mail.host=mailer@mail.com +mail.hostname=host@mail.com mail.port=9000 mail.from=mailer@mail.com From 2e733c38675d49f250861cae91166d5c4b18495b Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Sun, 27 Jan 2019 14:25:36 +0200 Subject: [PATCH 303/441] minor formatting cleanup --- .../java/com/baeldung/config/DbConfig.java | 16 +++--- .../java/com/baeldung/config/MvcConfig.java | 8 +-- .../java/com/baeldung/config/RestConfig.java | 5 +- .../config/ValidatorEventRegister.java | 8 +-- .../baeldung/events/AuthorEventHandler.java | 49 +++++++++--------- .../com/baeldung/events/BookEventHandler.java | 23 +++++---- .../RestResponseEntityExceptionHandler.java | 7 +-- .../java/com/baeldung/models/Address.java | 2 +- .../main/java/com/baeldung/models/Author.java | 2 +- .../main/java/com/baeldung/models/Book.java | 7 ++- .../java/com/baeldung/models/Library.java | 2 +- .../java/com/baeldung/models/Subject.java | 2 +- .../com/baeldung/projections/CustomBook.java | 10 ++-- .../baeldung/repositories/BookRepository.java | 3 +- .../repositories/SubjectRepository.java | 4 +- .../events/AuthorEventHandlerUnitTest.java | 28 +++++------ .../events/BookEventHandlerUnitTest.java | 28 +++++------ .../SpringDataProjectionLiveTest.java | 50 +++++++++---------- 18 files changed, 122 insertions(+), 132 deletions(-) diff --git a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java b/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java index 05fa27bbff..3ca728ec94 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java +++ b/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java @@ -20,7 +20,7 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; // @PropertySource("persistence-h2.properties") // @PropertySource("persistence-hsqldb.properties") // @PropertySource("persistence-derby.properties") -//@PropertySource("persistence-sqlite.properties") +// @PropertySource("persistence-sqlite.properties") public class DbConfig { @Autowired @@ -65,21 +65,23 @@ public class DbConfig { @Configuration @Profile("h2") @PropertySource("classpath:persistence-h2.properties") -class H2Config {} +class H2Config { +} @Configuration @Profile("hsqldb") @PropertySource("classpath:persistence-hsqldb.properties") -class HsqldbConfig {} - +class HsqldbConfig { +} @Configuration @Profile("derby") @PropertySource("classpath:persistence-derby.properties") -class DerbyConfig {} - +class DerbyConfig { +} @Configuration @Profile("sqlite") @PropertySource("classpath:persistence-sqlite.properties") -class SqliteConfig {} +class SqliteConfig { +} diff --git a/spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java b/spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java index e5748f2f55..9d0d3a6687 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java +++ b/spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java @@ -11,11 +11,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @EnableWebMvc public class MvcConfig implements WebMvcConfigurer { - - public MvcConfig(){ + + public MvcConfig() { super(); } - + @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { configurer.enable(); @@ -27,7 +27,7 @@ public class MvcConfig implements WebMvcConfigurer { } @Bean - BookEventHandler bookEventHandler(){ + BookEventHandler bookEventHandler() { return new BookEventHandler(); } diff --git a/spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java b/spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java index 39f90e867b..47cb95693b 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java +++ b/spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java @@ -12,10 +12,9 @@ import org.springframework.http.HttpMethod; public class RestConfig implements RepositoryRestConfigurer { @Override - public void configureRepositoryRestConfiguration(RepositoryRestConfiguration repositoryRestConfiguration){ + public void configureRepositoryRestConfiguration(RepositoryRestConfiguration repositoryRestConfiguration) { repositoryRestConfiguration.getProjectionConfiguration().addProjection(CustomBook.class); ExposureConfiguration config = repositoryRestConfiguration.getExposureConfiguration(); - config.forDomainType(WebsiteUser.class).withItemExposure((metadata, httpMethods) -> - httpMethods.disable(HttpMethod.PATCH)); + config.forDomainType(WebsiteUser.class).withItemExposure((metadata, httpMethods) -> httpMethods.disable(HttpMethod.PATCH)); } } diff --git a/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java b/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java index 8f14d6c1c6..632ad9183a 100644 --- a/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java +++ b/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java @@ -24,13 +24,7 @@ public class ValidatorEventRegister implements InitializingBean { List events = Arrays.asList("beforeCreate", "afterCreate", "beforeSave", "afterSave", "beforeLinkSave", "afterLinkSave", "beforeDelete", "afterDelete"); for (Map.Entry entry : validators.entrySet()) { - events - .stream() - .filter(p -> entry - .getKey() - .startsWith(p)) - .findFirst() - .ifPresent(p -> validatingRepositoryEventListener.addValidator(p, entry.getValue())); + events.stream().filter(p -> entry.getKey().startsWith(p)).findFirst().ifPresent(p -> validatingRepositoryEventListener.addValidator(p, entry.getValue())); } } } diff --git a/spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java b/spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java index 5a8ae05c08..485dc8e221 100644 --- a/spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java +++ b/spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java @@ -8,33 +8,34 @@ import java.util.logging.Logger; @RepositoryEventHandler public class AuthorEventHandler { - Logger logger = Logger.getLogger("Class AuthorEventHandler"); - public AuthorEventHandler(){ - super(); - } + Logger logger = Logger.getLogger("Class AuthorEventHandler"); - @HandleBeforeCreate - public void handleAuthorBeforeCreate(Author author){ - logger.info("Inside Author Before Create...."); - String name = author.getName(); - } + public AuthorEventHandler() { + super(); + } - @HandleAfterCreate - public void handleAuthorAfterCreate(Author author){ - logger.info("Inside Author After Create ...."); - String name = author.getName(); - } + @HandleBeforeCreate + public void handleAuthorBeforeCreate(Author author) { + logger.info("Inside Author Before Create...."); + String name = author.getName(); + } - @HandleBeforeDelete - public void handleAuthorBeforeDelete(Author author){ - logger.info("Inside Author Before Delete ...."); - String name = author.getName(); - } + @HandleAfterCreate + public void handleAuthorAfterCreate(Author author) { + logger.info("Inside Author After Create ...."); + String name = author.getName(); + } - @HandleAfterDelete - public void handleAuthorAfterDelete(Author author){ - logger.info("Inside Author After Delete ...."); - String name = author.getName(); - } + @HandleBeforeDelete + public void handleAuthorBeforeDelete(Author author) { + logger.info("Inside Author Before Delete ...."); + String name = author.getName(); + } + + @HandleAfterDelete + public void handleAuthorAfterDelete(Author author) { + logger.info("Inside Author After Delete ...."); + String name = author.getName(); + } } diff --git a/spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java b/spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java index 3953e6ce0d..36ae62b926 100644 --- a/spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java +++ b/spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java @@ -10,17 +10,18 @@ import org.springframework.data.rest.core.annotation.RepositoryEventHandler; @RepositoryEventHandler public class BookEventHandler { - Logger logger = Logger.getLogger("Class BookEventHandler"); - @HandleBeforeCreate - public void handleBookBeforeCreate(Book book){ + Logger logger = Logger.getLogger("Class BookEventHandler"); - logger.info("Inside Book Before Create ...."); - book.getAuthors(); - } + @HandleBeforeCreate + public void handleBookBeforeCreate(Book book) { - @HandleBeforeCreate - public void handleAuthorBeforeCreate(Author author){ - logger.info("Inside Author Before Create ...."); - author.getBooks(); - } + logger.info("Inside Book Before Create ...."); + book.getAuthors(); + } + + @HandleBeforeCreate + public void handleAuthorBeforeCreate(Author author) { + logger.info("Inside Author Before Create ...."); + author.getBooks(); + } } diff --git a/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java b/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java index aa24fccac7..a3ef91f6d6 100644 --- a/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java +++ b/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java @@ -19,12 +19,7 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH public ResponseEntity handleAccessDeniedException(Exception ex, WebRequest request) { RepositoryConstraintViolationException nevEx = (RepositoryConstraintViolationException) ex; - String errors = nevEx - .getErrors() - .getAllErrors() - .stream() - .map(ObjectError::toString) - .collect(Collectors.joining("\n")); + String errors = nevEx.getErrors().getAllErrors().stream().map(ObjectError::toString).collect(Collectors.joining("\n")); return new ResponseEntity<>(errors, new HttpHeaders(), HttpStatus.NOT_ACCEPTABLE); } diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Address.java b/spring-data-rest/src/main/java/com/baeldung/models/Address.java index 82e3783f3e..713af58ae6 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Address.java +++ b/spring-data-rest/src/main/java/com/baeldung/models/Address.java @@ -11,7 +11,7 @@ import javax.persistence.OneToOne; public class Address { @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(nullable = false) diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Author.java b/spring-data-rest/src/main/java/com/baeldung/models/Author.java index cdd04cbdcf..3f43af9c47 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Author.java +++ b/spring-data-rest/src/main/java/com/baeldung/models/Author.java @@ -16,7 +16,7 @@ import javax.persistence.ManyToMany; public class Author { @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(nullable = false) diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Book.java b/spring-data-rest/src/main/java/com/baeldung/models/Book.java index 002a64e738..07b0d08b84 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Book.java +++ b/spring-data-rest/src/main/java/com/baeldung/models/Book.java @@ -16,14 +16,14 @@ import javax.persistence.ManyToOne; public class Book { @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(nullable = false) private String title; - + private String isbn; - + @ManyToOne @JoinColumn(name = "library_id") private Library library; @@ -63,7 +63,6 @@ public class Book { this.isbn = isbn; } - public Library getLibrary() { return library; } diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Library.java b/spring-data-rest/src/main/java/com/baeldung/models/Library.java index c27512d0e4..091975f5d0 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Library.java +++ b/spring-data-rest/src/main/java/com/baeldung/models/Library.java @@ -17,7 +17,7 @@ import org.springframework.data.rest.core.annotation.RestResource; public class Library { @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Subject.java b/spring-data-rest/src/main/java/com/baeldung/models/Subject.java index b3b9a5b0a0..4e5fa82148 100644 --- a/spring-data-rest/src/main/java/com/baeldung/models/Subject.java +++ b/spring-data-rest/src/main/java/com/baeldung/models/Subject.java @@ -10,7 +10,7 @@ import javax.persistence.Id; public class Subject { @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(nullable = false) diff --git a/spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java b/spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java index 1cd9c01383..3dc6938f5c 100644 --- a/spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java +++ b/spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java @@ -8,15 +8,15 @@ import org.springframework.data.rest.core.config.Projection; import com.baeldung.models.Author; import com.baeldung.models.Book; -@Projection(name = "customBook", types = { Book.class }) +@Projection(name = "customBook", types = { Book.class }) public interface CustomBook { @Value("#{target.id}") - long getId(); - + long getId(); + String getTitle(); - + List getAuthors(); - + @Value("#{target.getAuthors().size()}") int getAuthorCount(); } diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java b/spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java index 34019a9d91..eee44f35d4 100644 --- a/spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java +++ b/spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java @@ -7,4 +7,5 @@ import com.baeldung.models.Book; import com.baeldung.projections.CustomBook; @RepositoryRestResource(excerptProjection = CustomBook.class) -public interface BookRepository extends CrudRepository {} +public interface BookRepository extends CrudRepository { +} diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java b/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java index a91ae2d505..76e34b0799 100644 --- a/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java +++ b/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java @@ -8,8 +8,8 @@ import org.springframework.data.rest.core.annotation.RestResource; import com.baeldung.models.Subject; public interface SubjectRepository extends PagingAndSortingRepository { - + @RestResource(path = "nameContains") public Page findByNameContaining(@Param("name") String name, Pageable p); - + } \ No newline at end of file diff --git a/spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java b/spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java index 6db536c40c..c01d5882a0 100644 --- a/spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java +++ b/spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java @@ -9,21 +9,21 @@ import static org.mockito.Mockito.mock; public class AuthorEventHandlerUnitTest { - @Test - public void whenCreateAuthorThenSuccess() { - Author author = mock(Author.class); - AuthorEventHandler authorEventHandler = new AuthorEventHandler(); - authorEventHandler.handleAuthorBeforeCreate(author); - Mockito.verify(author,Mockito.times(1)).getName(); + @Test + public void whenCreateAuthorThenSuccess() { + Author author = mock(Author.class); + AuthorEventHandler authorEventHandler = new AuthorEventHandler(); + authorEventHandler.handleAuthorBeforeCreate(author); + Mockito.verify(author, Mockito.times(1)).getName(); - } + } - @Test - public void whenDeleteAuthorThenSuccess() { - Author author = mock(Author.class); - AuthorEventHandler authorEventHandler = new AuthorEventHandler(); - authorEventHandler.handleAuthorAfterDelete(author); - Mockito.verify(author,Mockito.times(1)).getName(); + @Test + public void whenDeleteAuthorThenSuccess() { + Author author = mock(Author.class); + AuthorEventHandler authorEventHandler = new AuthorEventHandler(); + authorEventHandler.handleAuthorAfterDelete(author); + Mockito.verify(author, Mockito.times(1)).getName(); - } + } } diff --git a/spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java b/spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java index 28f0b91e1c..d6b8b3b25e 100644 --- a/spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java +++ b/spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java @@ -8,21 +8,21 @@ import org.mockito.Mockito; import static org.mockito.Mockito.mock; public class BookEventHandlerUnitTest { - @Test - public void whenCreateBookThenSuccess() { - Book book = mock(Book.class); - BookEventHandler bookEventHandler = new BookEventHandler(); - bookEventHandler.handleBookBeforeCreate(book); - Mockito.verify(book,Mockito.times(1)).getAuthors(); + @Test + public void whenCreateBookThenSuccess() { + Book book = mock(Book.class); + BookEventHandler bookEventHandler = new BookEventHandler(); + bookEventHandler.handleBookBeforeCreate(book); + Mockito.verify(book, Mockito.times(1)).getAuthors(); - } + } - @Test - public void whenCreateAuthorThenSuccess() { - Author author = mock(Author.class); - BookEventHandler bookEventHandler = new BookEventHandler(); - bookEventHandler.handleAuthorBeforeCreate(author); - Mockito.verify(author,Mockito.times(1)).getBooks(); + @Test + public void whenCreateAuthorThenSuccess() { + Author author = mock(Author.class); + BookEventHandler bookEventHandler = new BookEventHandler(); + bookEventHandler.handleAuthorBeforeCreate(author); + Mockito.verify(author, Mockito.times(1)).getBooks(); - } + } } diff --git a/spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java b/spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java index 702c1521da..ad219ccd53 100644 --- a/spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java +++ b/spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java @@ -29,16 +29,15 @@ public class SpringDataProjectionLiveTest { private static final String BOOK_ENDPOINT = "http://localhost:8080/books"; private static final String AUTHOR_ENDPOINT = "http://localhost:8080/authors"; - @Autowired private BookRepository bookRepo; @Autowired private AuthorRepository authorRepo; - + @Before - public void setup(){ - if(bookRepo.findById(1L) == null){ + public void setup() { + if (bookRepo.findById(1L) == null) { Book book = new Book("Animal Farm"); book.setIsbn("978-1943138425"); book = bookRepo.save(book); @@ -48,45 +47,44 @@ public class SpringDataProjectionLiveTest { author = authorRepo.save(author); } } - + @Test - public void whenGetBook_thenOK(){ - final Response response = RestAssured.get(BOOK_ENDPOINT+"/1"); - + public void whenGetBook_thenOK() { + final Response response = RestAssured.get(BOOK_ENDPOINT + "/1"); + assertEquals(200, response.getStatusCode()); assertTrue(response.asString().contains("isbn")); assertFalse(response.asString().contains("authorCount")); -// System.out.println(response.asString()); + // System.out.println(response.asString()); } - - + @Test - public void whenGetBookProjection_thenOK(){ - final Response response = RestAssured.get(BOOK_ENDPOINT+"/1?projection=customBook"); - + public void whenGetBookProjection_thenOK() { + final Response response = RestAssured.get(BOOK_ENDPOINT + "/1?projection=customBook"); + assertEquals(200, response.getStatusCode()); assertFalse(response.asString().contains("isbn")); - assertTrue(response.asString().contains("authorCount")); -// System.out.println(response.asString()); + assertTrue(response.asString().contains("authorCount")); + // System.out.println(response.asString()); } - + @Test - public void whenGetAllBooks_thenOK(){ + public void whenGetAllBooks_thenOK() { final Response response = RestAssured.get(BOOK_ENDPOINT); - + assertEquals(200, response.getStatusCode()); assertFalse(response.asString().contains("isbn")); - assertTrue(response.asString().contains("authorCount")); - // System.out.println(response.asString()); + assertTrue(response.asString().contains("authorCount")); + // System.out.println(response.asString()); } - + @Test - public void whenGetAuthorBooks_thenOK(){ - final Response response = RestAssured.get(AUTHOR_ENDPOINT+"/1/books"); - + public void whenGetAuthorBooks_thenOK() { + final Response response = RestAssured.get(AUTHOR_ENDPOINT + "/1/books"); + assertEquals(200, response.getStatusCode()); assertFalse(response.asString().contains("isbn")); - assertTrue(response.asString().contains("authorCount")); + assertTrue(response.asString().contains("authorCount")); System.out.println(response.asString()); } } From 2e8d2a7c1e6d827263b3c380e93a49fbb63a59b5 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 27 Jan 2019 15:08:16 +0200 Subject: [PATCH 304/441] Update README.md --- lombok/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lombok/README.md b/lombok/README.md index bd6282fd18..e3d08d4e26 100644 --- a/lombok/README.md +++ b/lombok/README.md @@ -5,3 +5,5 @@ - [Lombok @Builder with Inheritance](https://www.baeldung.com/lombok-builder-inheritance) - [Lombok Builder with Default Value](https://www.baeldung.com/lombok-builder-default-value) - [Lombok Builder with Custom Setter](https://www.baeldung.com/lombok-builder-custom-setter) +- [Setting up Lombok with Eclipse and Intellij](https://www.baeldung.com/lombok-ide) + From aed3e8f829d418a90afea6d659123afed0dd9e4c Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 27 Jan 2019 15:09:00 +0200 Subject: [PATCH 305/441] Update README.md --- core-java/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java/README.md b/core-java/README.md index 5aee69d9a9..d6cb619ed3 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -46,3 +46,4 @@ - [Graphs in Java](https://www.baeldung.com/java-graphs) - [Console I/O in Java](http://www.baeldung.com/java-console-input-output) - [Formatting with printf() in Java](https://www.baeldung.com/java-printstream-printf) +- [Retrieve Fields from a Java Class Using Reflection](https://www.baeldung.com/java-reflection-class-fields) From 79f1babc26b4d96686e1815d4437d0c5f3f0c65f Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 27 Jan 2019 15:09:46 +0200 Subject: [PATCH 306/441] Update README.md --- persistence-modules/java-jpa/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index 2eea5e60b4..5fe119cca4 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -4,3 +4,4 @@ - [A Guide to Stored Procedures with JPA](http://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) From 639e0046d7ef36502edffff27be8a88b7d2d1ad4 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 27 Jan 2019 15:10:33 +0200 Subject: [PATCH 307/441] Update README.md --- core-java-io/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-java-io/README.md b/core-java-io/README.md index 2ad980ca6a..fcb3302a48 100644 --- a/core-java-io/README.md +++ b/core-java-io/README.md @@ -36,4 +36,5 @@ - [Reading a CSV File into an Array](https://www.baeldung.com/java-csv-file-array) - [Guide to BufferedReader](https://www.baeldung.com/java-buffered-reader) - [How to Get the File Extension of a File in Java](http://www.baeldung.com/java-file-extension) -- [Getting a File’s Mime Type in Java](http://www.baeldung.com/java-file-mime-type) \ No newline at end of file +- [Getting a File’s Mime Type in Java](http://www.baeldung.com/java-file-mime-type) +- [Create a Directory in Java](https://www.baeldung.com/java-create-directory) From 242dc1dbcee7394319af5eafb91b209fe39421fc Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 27 Jan 2019 15:11:21 +0200 Subject: [PATCH 308/441] Update README.md --- persistence-modules/hibernate5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate5/README.md b/persistence-modules/hibernate5/README.md index 03bdd9b759..a4e95a9062 100644 --- a/persistence-modules/hibernate5/README.md +++ b/persistence-modules/hibernate5/README.md @@ -29,3 +29,4 @@ - [Hibernate Named Query](https://www.baeldung.com/hibernate-named-query) - [Using c3p0 with Hibernate](https://www.baeldung.com/hibernate-c3p0) - [Persist a JSON Object Using Hibernate](https://www.baeldung.com/hibernate-persist-json-object) +- [Common Hibernate Exceptions](https://www.baeldung.com/hibernate-exceptions) From 8a3d3f934402b3409b3392edfccff8b4f1ad8a5e Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 27 Jan 2019 15:12:01 +0200 Subject: [PATCH 309/441] Update README.md --- java-streams/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-streams/README.md b/java-streams/README.md index 33ca2619a8..f2afd570f6 100644 --- a/java-streams/README.md +++ b/java-streams/README.md @@ -15,3 +15,4 @@ - [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) +- [Counting Matches on a Stream Filter](https://www.baeldung.com/java-stream-filter-count) From ac53498b767eaa5052933373a823a58365263583 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sun, 27 Jan 2019 15:40:36 +0200 Subject: [PATCH 310/441] BAEL-2659 - Reading a file in Groovy --- .../groovy/com/baeldung/file/ReadFile.groovy | 61 +++++++++++++++++++ .../src/main/resources/fileContent.txt | 3 + .../com/baeldung/file/ReadFileUnitTest.groovy | 58 ++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy create mode 100644 core-groovy/src/main/resources/fileContent.txt create mode 100644 core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy diff --git a/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy new file mode 100644 index 0000000000..fca5bde06f --- /dev/null +++ b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy @@ -0,0 +1,61 @@ +package com.baeldung.file + +class ReadFile { + + /** + * reads file content in string using File.text + * @param filePath + * @return + */ + String readFileString(String filePath) { + File file = new File(filePath) + String fileContent = file.text + return fileContent + } + + /** + * reads file content in string with encoding using File.getText + * @param filePath + * @return + */ + String readFileStringWithCharset(String filePath) { + File file = new File(filePath) + String utf8Content = file.getText("UTF-8") + return utf8Content + } + + /** + * reads file content line by line using withReader and reader.readLine + * @param filePath + * @return + */ + int readFileLineByLine(String filePath) { + File file = new File(filePath) + def line, noOfLines = 0; + file.withReader { reader -> + while ((line = reader.readLine())!=null) + { + println "${line}" + noOfLines++ + } + } + return noOfLines + } + + /** + * reads file content in list of lines + * @param filePath + * @return + */ + List readFileInList(String filePath) { + File file = new File(filePath) + def lines = file.readLines() + return lines + } + + public static void main(String[] args) { + def file = new File("../../src") + println file.directorySize + } + +} \ No newline at end of file diff --git a/core-groovy/src/main/resources/fileContent.txt b/core-groovy/src/main/resources/fileContent.txt new file mode 100644 index 0000000000..643e4af3de --- /dev/null +++ b/core-groovy/src/main/resources/fileContent.txt @@ -0,0 +1,3 @@ +Line 1 : Hello World!!! +Line 2 : This is a file content. +Line 3 : String content diff --git a/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy new file mode 100644 index 0000000000..c90cc8b960 --- /dev/null +++ b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy @@ -0,0 +1,58 @@ +package com.baeldung.file + +import spock.lang.Specification + +class ReadFileUnitTest extends Specification { + + ReadFile readFile + + void setup () { + readFile = new ReadFile() + } + + def 'Should return file content in string using ReadFile.readFileString given filePath' () { + given: + def filePath = "src/main/resources/fileContent.txt" + when: + def fileContent = readFile.readFileString(filePath) + then: + fileContent + fileContent instanceof String + fileContent.contains("""Line 1 : Hello World!!! +Line 2 : This is a file content. +Line 3 : String content""") + + } + + def 'Should return UTF-8 encoded file content in string using ReadFile.readFileStringWithCharset given filePath' () { + given: + def filePath = "src/main/resources/fileContent.txt" + when: + def noOfLines = readFile.readFileStringWithCharset(filePath) + then: + noOfLines + noOfLines instanceof String + } + + def 'Should return number of lines in File using ReadFile.readFileLineByLine given filePath' () { + given: + def filePath = "src/main/resources/fileContent.txt" + when: + def noOfLines = readFile.readFileLineByLine(filePath) + then: + noOfLines + noOfLines instanceof Integer + assert noOfLines, 3 + } + + def 'Should return File Content in list of lines using ReadFile.readFileInList given filePath' () { + given: + def filePath = "src/main/resources/fileContent.txt" + when: + def lines = readFile.readFileInList(filePath) + then: + lines + lines instanceof List + assert lines.size(), 3 + } +} \ No newline at end of file From fd70f654b54e3ac59a9477809aed14c833ec15fa Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Sun, 27 Jan 2019 17:45:34 +0400 Subject: [PATCH 311/441] primitive list collections --- .../list/primitive/PrimitiveCollections.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java index 5a8ddc0acd..50f372e9c9 100644 --- a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java +++ b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java @@ -2,6 +2,8 @@ package com.baeldung.list.primitive; import com.google.common.primitives.ImmutableIntArray; import com.google.common.primitives.Ints; +import gnu.trove.list.array.TIntArrayList; +import it.unimi.dsi.fastutil.ints.IntArrayList; import java.util.Arrays; import java.util.List; @@ -13,6 +15,18 @@ public class PrimitiveCollections { int[] primitives = new int[] {5, 10, 0, 2}; guavaPrimitives(primitives); + + TIntArrayList tList = new TIntArrayList(primitives); + + cern.colt.list.IntArrayList coltList = new cern.colt.list.IntArrayList(primitives); + + IntArrayList fastUtilList = new IntArrayList(primitives); + + System.out.println(tList); + + System.out.println(coltList); + + System.out.println(fastUtilList); } From 4845bd82a17f61db82e48e68937fb1887c4eb533 Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Sun, 27 Jan 2019 14:18:13 +0000 Subject: [PATCH 312/441] added solid code (#6226) --- patterns/principles/solid/pom.xml | 23 ++++++++++++++++ .../main/java/com/baeldung/d/Keyboard.java | 4 +++ .../src/main/java/com/baeldung/d/Monitor.java | 6 +++++ .../java/com/baeldung/d/Windows98Machine.java | 15 +++++++++++ .../com/baeldung/d/Windows98MachineDI.java | 12 +++++++++ .../main/java/com/baeldung/i/BearCarer.java | 12 +++++++++ .../main/java/com/baeldung/i/BearCleaner.java | 5 ++++ .../main/java/com/baeldung/i/BearFeeder.java | 5 ++++ .../main/java/com/baeldung/i/BearKeeper.java | 9 +++++++ .../main/java/com/baeldung/i/BearPetter.java | 5 ++++ .../main/java/com/baeldung/i/CrazyPerson.java | 8 ++++++ .../src/main/java/com/baeldung/l/Car.java | 8 ++++++ .../main/java/com/baeldung/l/ElectricCar.java | 12 +++++++++ .../src/main/java/com/baeldung/l/Engine.java | 13 +++++++++ .../main/java/com/baeldung/l/MotorCar.java | 18 +++++++++++++ .../src/main/java/com/baeldung/o/Guitar.java | 10 +++++++ .../baeldung/o/SuperCoolGuitarWithFlames.java | 9 +++++++ .../src/main/java/com/baeldung/s/BadBook.java | 27 +++++++++++++++++++ .../main/java/com/baeldung/s/BookPrinter.java | 13 +++++++++ .../main/java/com/baeldung/s/GoodBook.java | 20 ++++++++++++++ 20 files changed, 234 insertions(+) create mode 100644 patterns/principles/solid/pom.xml create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/d/Keyboard.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/d/Monitor.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/d/Windows98Machine.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/d/Windows98MachineDI.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/i/BearCarer.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/i/BearCleaner.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/i/BearFeeder.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/i/BearKeeper.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/i/BearPetter.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/i/CrazyPerson.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/l/Car.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/l/ElectricCar.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/l/Engine.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/l/MotorCar.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/o/Guitar.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/o/SuperCoolGuitarWithFlames.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/s/BadBook.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/s/BookPrinter.java create mode 100644 patterns/principles/solid/src/main/java/com/baeldung/s/GoodBook.java diff --git a/patterns/principles/solid/pom.xml b/patterns/principles/solid/pom.xml new file mode 100644 index 0000000000..825c7730a5 --- /dev/null +++ b/patterns/principles/solid/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + com.baeldung + solid/artifactId> + 1.0-SNAPSHOT + + + + + + junit + junit + 4.12 + test + + + + + diff --git a/patterns/principles/solid/src/main/java/com/baeldung/d/Keyboard.java b/patterns/principles/solid/src/main/java/com/baeldung/d/Keyboard.java new file mode 100644 index 0000000000..acb50cedb4 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/d/Keyboard.java @@ -0,0 +1,4 @@ +package com.baeldung.d; + +public class Keyboard { +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/d/Monitor.java b/patterns/principles/solid/src/main/java/com/baeldung/d/Monitor.java new file mode 100644 index 0000000000..c0ab7a53b2 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/d/Monitor.java @@ -0,0 +1,6 @@ +package com.baeldung.d; + +public class Monitor { + + +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/d/Windows98Machine.java b/patterns/principles/solid/src/main/java/com/baeldung/d/Windows98Machine.java new file mode 100644 index 0000000000..a9f130aedb --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/d/Windows98Machine.java @@ -0,0 +1,15 @@ +package com.baeldung.d; + +public class Windows98Machine { + + private final Keyboard keyboard; + private final Monitor monitor; + + public Windows98Machine() { + + monitor = new Monitor(); + keyboard = new Keyboard(); + + } + +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/d/Windows98MachineDI.java b/patterns/principles/solid/src/main/java/com/baeldung/d/Windows98MachineDI.java new file mode 100644 index 0000000000..2a6fd74a41 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/d/Windows98MachineDI.java @@ -0,0 +1,12 @@ +package com.baeldung.d; + +public class Windows98MachineDI { + + private final Keyboard keyboard; + private final Monitor monitor; + + public Windows98MachineDI(Keyboard keyboard, Monitor monitor) { + this.keyboard = keyboard; + this.monitor = monitor; + } +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/i/BearCarer.java b/patterns/principles/solid/src/main/java/com/baeldung/i/BearCarer.java new file mode 100644 index 0000000000..3d69211674 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/i/BearCarer.java @@ -0,0 +1,12 @@ +package com.baeldung.i; + +public class BearCarer implements BearCleaner, BearFeeder { + + public void washTheBear() { + //I think we missed a spot.. + } + + public void feedTheBear() { + //Tuna tuesdays.. + } +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/i/BearCleaner.java b/patterns/principles/solid/src/main/java/com/baeldung/i/BearCleaner.java new file mode 100644 index 0000000000..e2b71b2ce8 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/i/BearCleaner.java @@ -0,0 +1,5 @@ +package com.baeldung.i; + +public interface BearCleaner { + void washTheBear(); +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/i/BearFeeder.java b/patterns/principles/solid/src/main/java/com/baeldung/i/BearFeeder.java new file mode 100644 index 0000000000..5d0ba7cd29 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/i/BearFeeder.java @@ -0,0 +1,5 @@ +package com.baeldung.i; + +public interface BearFeeder { + void feedTheBear(); +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/i/BearKeeper.java b/patterns/principles/solid/src/main/java/com/baeldung/i/BearKeeper.java new file mode 100644 index 0000000000..f09774a5ff --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/i/BearKeeper.java @@ -0,0 +1,9 @@ +package com.baeldung.i; + +public interface BearKeeper { + + void washTheBear(); + void feedTheBear(); + void petTheBear(); + +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/i/BearPetter.java b/patterns/principles/solid/src/main/java/com/baeldung/i/BearPetter.java new file mode 100644 index 0000000000..a913cf3d8a --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/i/BearPetter.java @@ -0,0 +1,5 @@ +package com.baeldung.i; + +public interface BearPetter { + void petTheBear(); +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/i/CrazyPerson.java b/patterns/principles/solid/src/main/java/com/baeldung/i/CrazyPerson.java new file mode 100644 index 0000000000..aae0d4c11b --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/i/CrazyPerson.java @@ -0,0 +1,8 @@ +package com.baeldung.i; + +public class CrazyPerson implements BearPetter { + + public void petTheBear() { + //Good luck with that! + } +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/l/Car.java b/patterns/principles/solid/src/main/java/com/baeldung/l/Car.java new file mode 100644 index 0000000000..b3481f894a --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/l/Car.java @@ -0,0 +1,8 @@ +package com.baeldung.l; + +public interface Car { + + void turnOnEngine(); + void accelerate(); + +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/l/ElectricCar.java b/patterns/principles/solid/src/main/java/com/baeldung/l/ElectricCar.java new file mode 100644 index 0000000000..fd919c5659 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/l/ElectricCar.java @@ -0,0 +1,12 @@ +package com.baeldung.l; + +public class ElectricCar implements Car { + + public void turnOnEngine() { + throw new AssertionError("I don't have an engine!"); + } + + public void accelerate() { + //this acceleration is crazy! + } +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/l/Engine.java b/patterns/principles/solid/src/main/java/com/baeldung/l/Engine.java new file mode 100644 index 0000000000..a8e38b8877 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/l/Engine.java @@ -0,0 +1,13 @@ +package com.baeldung.l; + +public class Engine { + + public void on(){ + //vroom. + } + + public void powerOn(int amount){ + //do something + } + +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/l/MotorCar.java b/patterns/principles/solid/src/main/java/com/baeldung/l/MotorCar.java new file mode 100644 index 0000000000..638f315475 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/l/MotorCar.java @@ -0,0 +1,18 @@ +package com.baeldung.l; + +public class MotorCar implements Car { + + private Engine engine; + + //Constructors, getters + setters + + public void turnOnEngine() { + //turn on the engine! + engine.on(); + } + + public void accelerate() { + //move forward! + engine.powerOn(1000); + } +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/o/Guitar.java b/patterns/principles/solid/src/main/java/com/baeldung/o/Guitar.java new file mode 100644 index 0000000000..baab006b5b --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/o/Guitar.java @@ -0,0 +1,10 @@ +package com.baeldung.o; + +public class Guitar { + + private String make; + private String model; + private int volume; + + //Constructors, getters & setters +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/o/SuperCoolGuitarWithFlames.java b/patterns/principles/solid/src/main/java/com/baeldung/o/SuperCoolGuitarWithFlames.java new file mode 100644 index 0000000000..b69e3be74a --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/o/SuperCoolGuitarWithFlames.java @@ -0,0 +1,9 @@ +package com.baeldung.o; + +public class SuperCoolGuitarWithFlames extends Guitar { + + private String flameColour; + + //constructor, getters + setters + +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/s/BadBook.java b/patterns/principles/solid/src/main/java/com/baeldung/s/BadBook.java new file mode 100644 index 0000000000..03c8fcd488 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/s/BadBook.java @@ -0,0 +1,27 @@ +package com.baeldung.s; + +public class BadBook { + + private String name; + private String author; + private String text; + + //constructor, getters and setters + + + //methods that directly relate to the book properties + public String replaceWordInText(String word){ + return text.replaceAll(word, text); + } + + public boolean isWordInText(String word){ + return text.contains(word); + } + + //methods for outputting text to console - should this really be here? + void printTextToConsole(){ + //our code for formatting and printing the text + } + + +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/s/BookPrinter.java b/patterns/principles/solid/src/main/java/com/baeldung/s/BookPrinter.java new file mode 100644 index 0000000000..0c8ef62e01 --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/s/BookPrinter.java @@ -0,0 +1,13 @@ +package com.baeldung.s; + +public class BookPrinter { + + //methods for outputting text + void printTextToConsole(String text){ + //our code for formatting and printing the text + } + + void printTextToAnotherMedium(String text){ + //code for writing to any other location.. + } +} diff --git a/patterns/principles/solid/src/main/java/com/baeldung/s/GoodBook.java b/patterns/principles/solid/src/main/java/com/baeldung/s/GoodBook.java new file mode 100644 index 0000000000..b0993aca2b --- /dev/null +++ b/patterns/principles/solid/src/main/java/com/baeldung/s/GoodBook.java @@ -0,0 +1,20 @@ +package com.baeldung.s; + +public class GoodBook { + + private String name; + private String author; + private String text; + + //constructor, getters and setters + + //methods that directly relate to the book properties + public String replaceWordInText(String word){ + return text.replaceAll(word, text); + } + + public boolean isWordInText(String word){ + return text.contains(word); + } + +} From e67915213a38cf82c0213f617d3c68ec812603b4 Mon Sep 17 00:00:00 2001 From: anuraggoyal1 Date: Sun, 27 Jan 2019 20:42:18 +0530 Subject: [PATCH 313/441] [BAEL-2471] Guide to Apache Commons MultiValuedMap (#6155) * [BAEL-2471] Guide to Apache Commons MultiValuedMap * Update MultiValuedMapUnitTest.java * added empty lines --- .../java/map/MultiValuedMapUnitTest.java | 204 ++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 java-collections-maps/src/test/java/com/baeldung/java/map/MultiValuedMapUnitTest.java diff --git a/java-collections-maps/src/test/java/com/baeldung/java/map/MultiValuedMapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/java/map/MultiValuedMapUnitTest.java new file mode 100644 index 0000000000..67e4a5b0a0 --- /dev/null +++ b/java-collections-maps/src/test/java/com/baeldung/java/map/MultiValuedMapUnitTest.java @@ -0,0 +1,204 @@ +package com.baeldung.java.map; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; +import org.apache.commons.collections4.multimap.HashSetValuedHashMap; +import org.junit.Test; + +public class MultiValuedMapUnitTest { + + @Test + public void givenMultiValuesMap_whenPuttingMultipleValuesUsingPutMethod_thenReturningAllValues() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + + map.put("key", "value1"); + map.put("key", "value2"); + map.put("key", "value2"); + + assertThat((Collection) map.get("key")).containsExactly("value1", "value2", "value2"); + } + + @Test + public void givenMultiValuesMap_whenPuttingMultipleValuesUsingPutAllMethod_thenReturningAllValues() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + + map.putAll("key", Arrays.asList("value1", "value2", "value2")); + + assertThat((Collection) map.get("key")).containsExactly("value1", "value2", "value2"); + } + + @Test + public void givenMultiValuesMap_whenGettingValueUsingGetMethod_thenReturningValue() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + + assertThat((Collection) map.get("key")).containsExactly("value"); + } + + @Test + public void givenMultiValuesMap_whenUsingEntriesMethod_thenReturningMappings() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value1"); + map.put("key", "value2"); + + Collection> entries = (Collection>) map.entries(); + + for(Map.Entry entry : entries) { + assertThat(entry.getKey()).contains("key"); + assertTrue(entry.getValue().equals("value1") || entry.getValue().equals("value2") ); + } + } + + @Test + public void givenMultiValuesMap_whenUsingKeysMethod_thenReturningAllKeys() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + + assertThat(((Collection) map.keys())).contains("key", "key1", "key2"); + } + + @Test + public void givenMultiValuesMap_whenUsingKeySetMethod_thenReturningAllKeys() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + + assertThat((Collection) map.keySet()).contains("key", "key1", "key2"); + } + + @Test + public void givenMultiValuesMap_whenUsingValuesMethod_thenReturningAllValues() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + + assertThat(((Collection) map.values())).contains("value", "value1", "value2"); + } + + @Test + public void givenMultiValuesMap_whenUsingRemoveMethod_thenReturningUpdatedMap() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + assertThat(((Collection) map.values())).contains("value", "value1", "value2"); + + map.remove("key"); + + assertThat(((Collection) map.values())).contains("value1", "value2"); + } + + @Test + public void givenMultiValuesMap_whenUsingRemoveMappingMethod_thenReturningUpdatedMapAfterMappingRemoved() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + assertThat(((Collection) map.values())).contains("value", "value1", "value2"); + + map.removeMapping("key", "value"); + + assertThat(((Collection) map.values())).contains("value1", "value2"); + } + + @Test + public void givenMultiValuesMap_whenUsingClearMethod_thenReturningEmptyMap() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + assertThat(((Collection) map.values())).contains("value", "value1", "value2"); + + map.clear(); + + assertTrue(map.isEmpty()); + } + + @Test + public void givenMultiValuesMap_whenUsingContainsKeyMethod_thenReturningTrue() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + + assertTrue(map.containsKey("key")); + } + + @Test + public void givenMultiValuesMap_whenUsingContainsValueMethod_thenReturningTrue() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + + assertTrue(map.containsValue("value")); + } + + @Test + public void givenMultiValuesMap_whenUsingIsEmptyMethod_thenReturningFalse() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + + assertFalse(map.isEmpty()); + } + + @Test + public void givenMultiValuesMap_whenUsingSizeMethod_thenReturningElementCount() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value"); + map.put("key1", "value1"); + map.put("key2", "value2"); + + assertEquals(3, map.size()); + } + + @Test + public void givenArrayListValuedHashMap_whenPuttingDoubleValues_thenReturningAllValues() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + + map.put("key", "value1"); + map.put("key", "value2"); + map.put("key", "value2"); + + assertThat((Collection) map.get("key")).containsExactly("value1", "value2", "value2"); + } + + @Test + public void givenHashSetValuedHashMap_whenPuttingTwiceTheSame_thenReturningOneValue() { + MultiValuedMap map = new HashSetValuedHashMap<>(); + + map.put("key1", "value1"); + map.put("key1", "value1"); + + assertThat((Collection) map.get("key1")).containsExactly("value1"); + } + + @Test(expected = UnsupportedOperationException.class) + public void givenUnmodifiableMultiValuedMap_whenInserting_thenThrowingException() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key", "value1"); + map.put("key", "value2"); + MultiValuedMap immutableMap = MultiMapUtils.unmodifiableMultiValuedMap(map); + + immutableMap.put("key", "value3"); + } + + +} From f22d1073d19416ba5d327149b316babebb8b4b47 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sun, 27 Jan 2019 22:47:27 +0200 Subject: [PATCH 314/441] BAEL-2659 - Reading a file in Groovy - changed order of functions --- .../groovy/com/baeldung/file/ReadFile.groovy | 48 +++++++++---------- .../com/baeldung/file/ReadFileUnitTest.groovy | 44 ++++++++--------- 2 files changed, 44 insertions(+), 48 deletions(-) diff --git a/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy index fca5bde06f..73208a52c8 100644 --- a/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy +++ b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy @@ -2,28 +2,6 @@ package com.baeldung.file class ReadFile { - /** - * reads file content in string using File.text - * @param filePath - * @return - */ - String readFileString(String filePath) { - File file = new File(filePath) - String fileContent = file.text - return fileContent - } - - /** - * reads file content in string with encoding using File.getText - * @param filePath - * @return - */ - String readFileStringWithCharset(String filePath) { - File file = new File(filePath) - String utf8Content = file.getText("UTF-8") - return utf8Content - } - /** * reads file content line by line using withReader and reader.readLine * @param filePath @@ -52,10 +30,28 @@ class ReadFile { def lines = file.readLines() return lines } - - public static void main(String[] args) { - def file = new File("../../src") - println file.directorySize + + /** + * reads file content in string using File.text + * @param filePath + * @return + */ + String readFileString(String filePath) { + File file = new File(filePath) + String fileContent = file.text + return fileContent } + /** + * reads file content in string with encoding using File.getText + * @param filePath + * @return + */ + String readFileStringWithCharset(String filePath) { + File file = new File(filePath) + String utf8Content = file.getText("UTF-8") + return utf8Content + } + + } \ No newline at end of file diff --git a/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy index c90cc8b960..105a8e157f 100644 --- a/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy @@ -10,6 +10,28 @@ class ReadFileUnitTest extends Specification { readFile = new ReadFile() } + def 'Should return number of lines in File using ReadFile.readFileLineByLine given filePath' () { + given: + def filePath = "src/main/resources/fileContent.txt" + when: + def noOfLines = readFile.readFileLineByLine(filePath) + then: + noOfLines + noOfLines instanceof Integer + assert noOfLines, 3 + } + + def 'Should return File Content in list of lines using ReadFile.readFileInList given filePath' () { + given: + def filePath = "src/main/resources/fileContent.txt" + when: + def lines = readFile.readFileInList(filePath) + then: + lines + lines instanceof List + assert lines.size(), 3 + } + def 'Should return file content in string using ReadFile.readFileString given filePath' () { given: def filePath = "src/main/resources/fileContent.txt" @@ -33,26 +55,4 @@ Line 3 : String content""") noOfLines noOfLines instanceof String } - - def 'Should return number of lines in File using ReadFile.readFileLineByLine given filePath' () { - given: - def filePath = "src/main/resources/fileContent.txt" - when: - def noOfLines = readFile.readFileLineByLine(filePath) - then: - noOfLines - noOfLines instanceof Integer - assert noOfLines, 3 - } - - def 'Should return File Content in list of lines using ReadFile.readFileInList given filePath' () { - given: - def filePath = "src/main/resources/fileContent.txt" - when: - def lines = readFile.readFileInList(filePath) - then: - lines - lines instanceof List - assert lines.size(), 3 - } } \ No newline at end of file From f3faf9234e1d365c8bc9ac4a11316795b4b67b2b Mon Sep 17 00:00:00 2001 From: Alejandro Gervasio Date: Mon, 28 Jan 2019 00:27:43 -0300 Subject: [PATCH 315/441] Initial Commit (#6202) --- .../validation/application/Application.java | 27 ++++++++ .../controllers/UserController.java | 52 ++++++++++++++ .../validation/application/entities/User.java | 50 ++++++++++++++ .../repositories/UserRepository.java | 8 +++ .../tests/UserControllerIntegrationTest.java | 69 +++++++++++++++++++ 5 files changed, 206 insertions(+) create mode 100644 spring-boot/src/main/java/com/baeldung/validation/application/Application.java create mode 100644 spring-boot/src/main/java/com/baeldung/validation/application/controllers/UserController.java create mode 100644 spring-boot/src/main/java/com/baeldung/validation/application/entities/User.java create mode 100644 spring-boot/src/main/java/com/baeldung/validation/application/repositories/UserRepository.java create mode 100644 spring-boot/src/test/java/com/baeldung/validation/tests/UserControllerIntegrationTest.java diff --git a/spring-boot/src/main/java/com/baeldung/validation/application/Application.java b/spring-boot/src/main/java/com/baeldung/validation/application/Application.java new file mode 100644 index 0000000000..af8f768193 --- /dev/null +++ b/spring-boot/src/main/java/com/baeldung/validation/application/Application.java @@ -0,0 +1,27 @@ +package com.baeldung.validation.application; + +import com.baeldung.validation.application.entities.User; +import com.baeldung.validation.application.repositories.UserRepository; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + @Bean + public CommandLineRunner run(UserRepository userRepository) throws Exception { + return (String[] args) -> { + User user1 = new User("Bob", "bob@domain.com"); + User user2 = new User("Jenny", "jenny@domain.com"); + userRepository.save(user1); + userRepository.save(user2); + userRepository.findAll().forEach(System.out::println); + }; + } +} diff --git a/spring-boot/src/main/java/com/baeldung/validation/application/controllers/UserController.java b/spring-boot/src/main/java/com/baeldung/validation/application/controllers/UserController.java new file mode 100644 index 0000000000..a4aeefb70b --- /dev/null +++ b/spring-boot/src/main/java/com/baeldung/validation/application/controllers/UserController.java @@ -0,0 +1,52 @@ +package com.baeldung.validation.application.controllers; + +import com.baeldung.validation.application.entities.User; +import com.baeldung.validation.application.repositories.UserRepository; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.FieldError; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UserController { + + private final UserRepository userRepository; + + @Autowired + public UserController(UserRepository userRepository) { + this.userRepository = userRepository; + } + + @GetMapping("/users") + public List getUsers() { + return (List) userRepository.findAll(); + } + + @PostMapping("/users") + ResponseEntity addUser(@Valid @RequestBody User user) { + return ResponseEntity.ok("User is valid"); + } + + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ExceptionHandler(MethodArgumentNotValidException.class) + public Map handleValidationExceptions(MethodArgumentNotValidException ex) { + Map errors = new HashMap<>(); + ex.getBindingResult().getAllErrors().forEach((error) -> { + String fieldName = ((FieldError) error).getField(); + String errorMessage = error.getDefaultMessage(); + errors.put(fieldName, errorMessage); + }); + return errors; + } +} diff --git a/spring-boot/src/main/java/com/baeldung/validation/application/entities/User.java b/spring-boot/src/main/java/com/baeldung/validation/application/entities/User.java new file mode 100644 index 0000000000..529368f132 --- /dev/null +++ b/spring-boot/src/main/java/com/baeldung/validation/application/entities/User.java @@ -0,0 +1,50 @@ +package com.baeldung.validation.application.entities; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.validation.constraints.NotBlank; + +@Entity +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @NotBlank(message = "Name is mandatory") + private String name; + + @NotBlank(message = "Email is mandatory") + private String email; + + public User(){} + + public User(String name, String email) { + this.name = name; + this.email = email; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public String toString() { + return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; + } +} diff --git a/spring-boot/src/main/java/com/baeldung/validation/application/repositories/UserRepository.java b/spring-boot/src/main/java/com/baeldung/validation/application/repositories/UserRepository.java new file mode 100644 index 0000000000..b579addcaa --- /dev/null +++ b/spring-boot/src/main/java/com/baeldung/validation/application/repositories/UserRepository.java @@ -0,0 +1,8 @@ +package com.baeldung.validation.application.repositories; + +import com.baeldung.validation.application.entities.User; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface UserRepository extends CrudRepository {} diff --git a/spring-boot/src/test/java/com/baeldung/validation/tests/UserControllerIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/validation/tests/UserControllerIntegrationTest.java new file mode 100644 index 0000000000..265c4ec22c --- /dev/null +++ b/spring-boot/src/test/java/com/baeldung/validation/tests/UserControllerIntegrationTest.java @@ -0,0 +1,69 @@ +package com.baeldung.validation.tests; + +import com.baeldung.validation.application.controllers.UserController; +import com.baeldung.validation.application.repositories.UserRepository; +import java.nio.charset.Charset; +import static org.assertj.core.api.Assertions.assertThat; +import org.hamcrest.core.Is; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +@RunWith(SpringRunner.class) +@WebMvcTest +@AutoConfigureMockMvc +public class UserControllerIntegrationTest { + + @MockBean + private UserRepository userRepository; + + @Autowired + UserController userController; + + @Autowired + private MockMvc mockMvc; + + @Test + public void whenUserControllerInjected_thenNotNull() throws Exception { + assertThat(userController).isNotNull(); + } + + @Test + public void whenGetRequestToUsers_thenCorrectResponse() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/users") + .contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)); + + } + + @Test + public void whenPostRequestToUsersAndValidUser_thenCorrectResponse() throws Exception { + MediaType textPlainUtf8 = new MediaType(MediaType.TEXT_PLAIN, Charset.forName("UTF-8")); + String user = "{\"name\": \"bob\", \"email\" : \"bob@domain.com\"}"; + mockMvc.perform(MockMvcRequestBuilders.post("/users") + .content(user) + .contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().contentType(textPlainUtf8)); + } + + @Test + public void whenPostRequestToUsersAndInValidUser_thenCorrectReponse() throws Exception { + String user = "{\"name\": \"\", \"email\" : \"bob@domain.com\"}"; + mockMvc.perform(MockMvcRequestBuilders.post("/users") + .content(user) + .contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(MockMvcResultMatchers.status().isBadRequest()) + .andExpect(MockMvcResultMatchers.jsonPath("$.name", Is.is("Name is mandatory"))) + .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_UTF8)); + } +} From 13f9b875b8385bf875469d50f8dc7d5fa0aa7a2e Mon Sep 17 00:00:00 2001 From: Urvy Agrawal Date: Mon, 28 Jan 2019 13:17:30 +0530 Subject: [PATCH 316/441] Changes in test file --- .../test/BitwiseOperatorUnitTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java b/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java index d8af4b0833..74b8eb6bd2 100644 --- a/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java +++ b/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java @@ -10,7 +10,7 @@ public class BitwiseOperatorUnitTest { int value1 = 6; int value2 = 5; int result = value1 & value2; - assertEquals(result, 4); + assertEquals(4, result); } @Test @@ -18,7 +18,7 @@ public class BitwiseOperatorUnitTest { int value1 = 6; int value2 = 5; int result = value1 | value2; - assertEquals(result, 7); + assertEquals(7, result); } @Test @@ -26,7 +26,7 @@ public class BitwiseOperatorUnitTest { int value1 = 6; int value2 = 5; int result = value1 ^ value2; - assertEquals(result, 3); + assertEquals(3 result); } @Test @@ -40,42 +40,42 @@ public class BitwiseOperatorUnitTest { public void givenOnePositiveInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { int value = 12; int rightShift = value >> 2; - assertEquals(rightShift, 3); + assertEquals(3, rightShift); } @Test public void givenOneNegativeInteger_whenSignedRightShiftOperator_thenNewDecimalNumber() { int value = -12; int rightShift = value >> 2; - assertEquals(rightShift, -3); + assertEquals(-3, rightShift); } @Test public void givenOnePositiveInteger_whenLeftShiftOperator_thenNewDecimalNumber() { int value = 12; int leftShift = value << 2; - assertEquals(leftShift, 48); + assertEquals(48, leftShift); } @Test public void givenOneNegativeInteger_whenLeftShiftOperator_thenNewDecimalNumber() { int value = -12; int leftShift = value << 2; - assertEquals(leftShift, -48); + assertEquals(-48, leftShift); } @Test public void givenOnePositiveInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { int value = 12; int unsignedRightShift = value >>> 2; - assertEquals(unsignedRightShift, 3); + assertEquals(3, unsignedRightShift); } @Test public void givenOneNegativeInteger_whenUnsignedRightShiftOperator_thenNewDecimalNumber() { int value = -12; int unsignedRightShift = value >>> 2; - assertEquals(unsignedRightShift, 1073741821); + assertEquals(1073741821, unsignedRightShift); } } From e5c860192a84df1aee9e06bff059a5fd9cd22b91 Mon Sep 17 00:00:00 2001 From: Urvy Agrawal Date: Mon, 28 Jan 2019 13:28:22 +0530 Subject: [PATCH 317/441] Removed error line from the file --- .../baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java b/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java index 74b8eb6bd2..f74e181e36 100644 --- a/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java +++ b/core-java/src/test/java/com/baeldung/bitwiseoperator/test/BitwiseOperatorUnitTest.java @@ -26,7 +26,7 @@ public class BitwiseOperatorUnitTest { int value1 = 6; int value2 = 5; int result = value1 ^ value2; - assertEquals(3 result); + assertEquals(3, result); } @Test From 44d5be301ce9e69b69f4ef632250f6b8f07cd8c0 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Mon, 28 Jan 2019 15:15:05 +0400 Subject: [PATCH 318/441] remove performance test --- .../primitive/PrimitivesListPerformance.java | 76 ------------------- 1 file changed, 76 deletions(-) delete mode 100644 core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java deleted file mode 100644 index f57c8d65a6..0000000000 --- a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitivesListPerformance.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.baeldung.list.primitive; - -import it.unimi.dsi.fastutil.ints.IntArrayList; -import gnu.trove.list.array.TIntArrayList; -import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.runner.Runner; -import org.openjdk.jmh.runner.options.Options; -import org.openjdk.jmh.runner.options.OptionsBuilder; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -@BenchmarkMode(Mode.AverageTime) -@OutputTimeUnit(TimeUnit.NANOSECONDS) -@Warmup(iterations = 10) -public class PrimitivesListPerformance { - - @State(Scope.Thread) - public static class Initialize { - - List arrayList = new ArrayList<>(); - TIntArrayList tList = new TIntArrayList(); - cern.colt.list.IntArrayList coltList = new cern.colt.list.IntArrayList(); - IntArrayList fastUtilList = new IntArrayList(); - - int getValue = 10; - - final int iterations = 100000; - - @Setup(Level.Trial) - public void setUp() { - - for (int i = 0; i < iterations; i++) { - arrayList.add(i); - tList.add(i); - coltList.add(i); - fastUtilList.add(i); - } - - arrayList.add(getValue); - tList.add(getValue); - coltList.add(getValue); - fastUtilList.add(getValue); - } - } - - @Benchmark - public boolean containsArrayList(PrimitivesListPerformance.Initialize state) { - return state.arrayList.contains(state.getValue); - } - - @Benchmark - public boolean containsTIntList(PrimitivesListPerformance.Initialize state) { - return state.tList.contains(state.getValue); - } - - @Benchmark - public boolean containsColtIntList(PrimitivesListPerformance.Initialize state) { - return state.coltList.contains(state.getValue); - } - - @Benchmark - public boolean containsFastUtilIntList(PrimitivesListPerformance.Initialize state) { - return state.fastUtilList.contains(state.getValue); - } - - public static void main(String[] args) throws Exception { - Options options = new OptionsBuilder() - .include(PrimitivesListPerformance.class.getSimpleName()).threads(1) - .forks(1).shouldFailOnError(true) - .shouldDoGC(true) - .jvmArgs("-server").build(); - new Runner(options).run(); - } -} From d944b67c29a56d83ea31603238aa599de7cb212e Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Mon, 28 Jan 2019 15:23:01 +0400 Subject: [PATCH 319/441] remove JMH dependency --- core-java-collections-list/pom.xml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/core-java-collections-list/pom.xml b/core-java-collections-list/pom.xml index bc71882683..a7e711088a 100644 --- a/core-java-collections-list/pom.xml +++ b/core-java-collections-list/pom.xml @@ -37,17 +37,6 @@ provided - - org.openjdk.jmh - jmh-core - ${jmh-core.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh-generator-annprocess.version} - - net.sf.trove4j trove4j @@ -71,7 +60,5 @@ 1.7.0 3.11.1 1.16.12 - 1.19 - 1.19 From 66c92495fb27780f76c0409408fc38cdcf3f83f4 Mon Sep 17 00:00:00 2001 From: amdegregorio Date: Mon, 28 Jan 2019 06:53:52 -0500 Subject: [PATCH 320/441] BAEL-2542 Update system property name --- core-java/src/main/java/com/baeldung/jar/JarExample.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/jar/JarExample.java b/core-java/src/main/java/com/baeldung/jar/JarExample.java index 262df3a5ec..daa44025d5 100644 --- a/core-java/src/main/java/com/baeldung/jar/JarExample.java +++ b/core-java/src/main/java/com/baeldung/jar/JarExample.java @@ -7,8 +7,8 @@ public class JarExample { private static final String DIMENSION_FILE = "/dimensions.txt"; public static void main(String[] args) { - String environment = System.getProperty("environment"); - if (environment != null && environment.equalsIgnoreCase("prod")) { + String inputType = System.getProperty("input"); + if (inputType != null && inputType.equalsIgnoreCase("file")) { Dimensioner dimensioner = new Dimensioner(); try { List rectangles = dimensioner.loadFromFile(DIMENSION_FILE); From bb6c78f07b5b4e35101a59ea3203c1229cc44188 Mon Sep 17 00:00:00 2001 From: cror Date: Mon, 28 Jan 2019 18:20:21 +0100 Subject: [PATCH 321/441] BAEL-2702 fix: typo => failing SpringContextIntegrationTest --- .../src/main/resources/RedirectionWebSecurityConfig.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml b/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml index 231b5ab57e..0bb73d68ee 100644 --- a/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml +++ b/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml @@ -14,7 +14,7 @@ - + @@ -26,4 +26,3 @@ - From 7b9e72e6c97fdcfa3428294c8b98df51e3f972f2 Mon Sep 17 00:00:00 2001 From: cror Date: Mon, 28 Jan 2019 18:58:59 +0100 Subject: [PATCH 322/441] BAEL-2702 fix: added SecuredResourceController to the test context --- .../src/main/resources/RedirectionWebSecurityConfig.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml b/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml index 0bb73d68ee..cdee8dab43 100644 --- a/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml +++ b/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml @@ -15,6 +15,7 @@ + From d5e875a3f04794af04544bff6f8cb18b8c7ea2e8 Mon Sep 17 00:00:00 2001 From: cror Date: Mon, 28 Jan 2019 19:11:36 +0100 Subject: [PATCH 323/441] BAEL-2702 fix: added a NoOpPasswordEncoder to the test context --- .../src/main/resources/RedirectionWebSecurityConfig.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml b/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml index cdee8dab43..659347f610 100644 --- a/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml +++ b/spring-security-mvc-login/src/main/resources/RedirectionWebSecurityConfig.xml @@ -16,6 +16,7 @@ + From 8f5f12519fc99f8f17848627c333f2f566fad25f Mon Sep 17 00:00:00 2001 From: eric-martin Date: Mon, 28 Jan 2019 20:37:45 -0600 Subject: [PATCH 324/441] BAEL-2328: Using isTrue() and isFalse() for assertions --- .../baeldung/string/MatchWordsUnitTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java b/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java index 1c2288068b..385aadaa5d 100644 --- a/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java +++ b/java-strings/src/test/java/com/baeldung/string/MatchWordsUnitTest.java @@ -13,54 +13,54 @@ public class MatchWordsUnitTest { @Test public void givenText_whenCallingStringContains_shouldMatchWords() { final boolean result = MatchWords.containsWords(inputString, words); - assertThat(result).isEqualTo(true); + assertThat(result).isTrue(); } @Test public void givenText_whenCallingJava8_shouldMatchWords() { final boolean result = MatchWords.containsWordsJava8(inputString, words); - assertThat(result).isEqualTo(true); + assertThat(result).isTrue(); } @Test public void givenText_whenCallingJava8_shouldNotMatchWords() { final boolean result = MatchWords.containsWordsJava8(wholeInput, words); - assertThat(result).isEqualTo(false); + assertThat(result).isFalse(); } @Test public void givenText_whenCallingPattern_shouldMatchWords() { final boolean result = MatchWords.containsWordsPatternMatch(inputString, words); - assertThat(result).isEqualTo(true); + assertThat(result).isTrue(); } @Test public void givenText_whenCallingAhoCorasick_shouldMatchWords() { final boolean result = MatchWords.containsWordsAhoCorasick(inputString, words); - assertThat(result).isEqualTo(true); + assertThat(result).isTrue(); } @Test public void givenText_whenCallingAhoCorasick_shouldNotMatchWords() { final boolean result = MatchWords.containsWordsAhoCorasick(wholeInput, words); - assertThat(result).isEqualTo(false); + assertThat(result).isFalse(); } @Test public void givenText_whenCallingIndexOf_shouldMatchWords() { final boolean result = MatchWords.containsWordsIndexOf(inputString, words); - assertThat(result).isEqualTo(true); + assertThat(result).isTrue(); } @Test public void givenText_whenCallingArrayList_shouldMatchWords() { final boolean result = MatchWords.containsWordsArray(inputString, words); - assertThat(result).isEqualTo(true); + assertThat(result).isTrue(); } @Test public void givenText_whenCallingArrayList_shouldNotMatchWords() { final boolean result = MatchWords.containsWordsArray(wholeInput, words); - assertThat(result).isEqualTo(false); + assertThat(result).isFalse(); } } From 1f4d1839f44232312c289e30b6869420dd558520 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Tue, 29 Jan 2019 17:27:52 +0200 Subject: [PATCH 325/441] BAEL-2659 - Reading a file in Groovy - added more examples and unit tests --- .../groovy/com/baeldung/file/ReadFile.groovy | 36 ++++++++++++++++++ core-groovy/src/main/resources/sample.png | Bin 0 -> 329 bytes .../src/main/resources/utf8Content.html | 5 +++ .../com/baeldung/file/ReadFileUnitTest.groovy | 12 +++++- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 core-groovy/src/main/resources/sample.png create mode 100644 core-groovy/src/main/resources/utf8Content.html diff --git a/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy index 73208a52c8..38bf189e63 100644 --- a/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy +++ b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy @@ -53,5 +53,41 @@ class ReadFile { return utf8Content } + /** + * reads content of binary file and returns byte array + * @param filePath + * @return + */ + byte[] readBinaryFile(String filePath) { + File file = new File(filePath) + byte[] binaryContent = file.bytes + return binaryContent + } + + /** + * More Examples of reading a file + * @return + */ + def moreExamples() { + def list = new File("src/main/resources/fileContent.txt").collect {it} + + def array = new File("src/main/resources/fileContent.txt") as String[] + + new File("src/main/resources/fileContent.txt").eachLine { line -> + println line + } + + def is = new File("src/main/resources/fileContent.txt").newInputStream() + is.eachLine { + println it + } + is.close() + + new File("src/main/resources/fileContent.txt").withInputStream { stream -> + stream.eachLine { line -> + println line + } + } + } } \ No newline at end of file diff --git a/core-groovy/src/main/resources/sample.png b/core-groovy/src/main/resources/sample.png new file mode 100644 index 0000000000000000000000000000000000000000..7d473430b7bec514f7de12f5769fe7c5859e8c5d GIT binary patch literal 329 zcmeAS@N?(olHy`uVBq!ia0vp^JRr;gBp8b2n5}^nQC}X^4DKU-G|w_t}fLBA)Suv#nrW z!^h2QnY_`l!BOq-UXEX{m2up>JTQkX)2m zTvF+fTUlI^nXH#utd~++ke^qgmzgTe~DWM4ffP81J literal 0 HcmV?d00001 diff --git a/core-groovy/src/main/resources/utf8Content.html b/core-groovy/src/main/resources/utf8Content.html new file mode 100644 index 0000000000..9d941200b1 --- /dev/null +++ b/core-groovy/src/main/resources/utf8Content.html @@ -0,0 +1,5 @@ +ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ +ᛋᚳᛖᚪᛚ᛫ᚦᛖᚪᚻ᛫ᛗᚪᚾᚾᚪ᛫ᚷᛖᚻᚹᛦᛚᚳ᛫ᛗᛁᚳᛚᚢᚾ᛫ᚻᛦᛏ᛫ᛞᚫᛚᚪᚾ +ᚷᛁᚠ᛫ᚻᛖ᛫ᚹᛁᛚᛖ᛫ᚠᚩᚱ᛫ᛞᚱᛁᚻᛏᚾᛖ᛫ᛞᚩᛗᛖᛋ᛫ᚻᛚᛇᛏᚪᚾ + +¥ · £ · € · $ · ¢ · ₡ · ₢ · ₣ · ₤ · ₥ · ₦ · ₧ · ₨ · ₩ · ₪ · ₫ · ₭ · ₮ · ₯ · ₹ \ No newline at end of file diff --git a/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy index 105a8e157f..5fc1409276 100644 --- a/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy @@ -48,11 +48,21 @@ Line 3 : String content""") def 'Should return UTF-8 encoded file content in string using ReadFile.readFileStringWithCharset given filePath' () { given: - def filePath = "src/main/resources/fileContent.txt" + def filePath = "src/main/resources/utf8Content.html" when: def noOfLines = readFile.readFileStringWithCharset(filePath) then: noOfLines noOfLines instanceof String } + + def 'Should return binary file content in byte arry using ReadFile.readBinaryFile given filePath' () { + given: + def filePath = "src/main/resources/sample.png" + when: + def noOfLines = readFile.readBinaryFile(filePath) + then: + noOfLines + noOfLines instanceof byte[] + } } \ No newline at end of file From 0b988db96d1fa03768402b81360722d0606114b8 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Tue, 29 Jan 2019 17:04:33 -0200 Subject: [PATCH 326/441] Moved Building REST API article related code from spring-rest-full to spring-boot-rest module --- spring-boot-rest/pom.xml | 2 - .../com/baeldung/persistence/IOperations.java | 13 +++++ .../service/common/AbstractService.java | 34 ++++++++++++- .../persistence/service/impl/FooService.java | 11 +++++ .../web/controller/FooController.java | 48 +++++++++++++++---- .../event/SingleResourceRetrievedEvent.java | 22 +++++++++ ...ourceRetrievedDiscoverabilityListener.java | 34 +++++++++++++ spring-rest-full/.attach_pid28499 | 0 .../org/baeldung/persistence/IOperations.java | 6 +-- .../service/common/AbstractService.java | 10 ---- .../persistence/service/impl/FooService.java | 12 ----- .../web/controller/FooController.java | 14 ------ 12 files changed, 153 insertions(+), 53 deletions(-) create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java create mode 100644 spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java delete mode 100644 spring-rest-full/.attach_pid28499 diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index cf4ac0371b..3c8c4d7486 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -51,7 +51,6 @@ net.sourceforge.htmlunit htmlunit - ${htmlunit.version} test @@ -67,7 +66,6 @@ com.baeldung.SpringBootRestApplication - 2.32 27.0.1-jre diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/IOperations.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/IOperations.java index d8996ca50d..1cc732ab08 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/persistence/IOperations.java +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/IOperations.java @@ -1,16 +1,29 @@ package com.baeldung.persistence; import java.io.Serializable; +import java.util.List; import org.springframework.data.domain.Page; public interface IOperations { + // read - one + + T findOne(final long id); + // read - all + List findAll(); + Page findPaginated(int page, int size); // write T create(final T entity); + + T update(final T entity); + + void delete(final T entity); + + void deleteById(final long entityId); } diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/service/common/AbstractService.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/common/AbstractService.java index 871f768895..5900c443b8 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/persistence/service/common/AbstractService.java +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/common/AbstractService.java @@ -1,6 +1,7 @@ package com.baeldung.persistence.service.common; import java.io.Serializable; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -8,23 +9,54 @@ import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.transaction.annotation.Transactional; import com.baeldung.persistence.IOperations; +import com.google.common.collect.Lists; @Transactional public abstract class AbstractService implements IOperations { + // read - one + + @Override + @Transactional(readOnly = true) + public T findOne(final long id) { + return getDao().findById(id) + .get(); + } + // read - all + @Override + @Transactional(readOnly = true) + public List findAll() { + return Lists.newArrayList(getDao().findAll()); + } + @Override public Page findPaginated(final int page, final int size) { return getDao().findAll(PageRequest.of(page, size)); } // write - + @Override public T create(final T entity) { return getDao().save(entity); } + + @Override + public T update(final T entity) { + return getDao().save(entity); + } + + @Override + public void delete(final T entity) { + getDao().delete(entity); + } + + @Override + public void deleteById(final long entityId) { + getDao().deleteById(entityId); + } protected abstract PagingAndSortingRepository getDao(); diff --git a/spring-boot-rest/src/main/java/com/baeldung/persistence/service/impl/FooService.java b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/impl/FooService.java index 9d705f51d3..299e5ec214 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/persistence/service/impl/FooService.java +++ b/spring-boot-rest/src/main/java/com/baeldung/persistence/service/impl/FooService.java @@ -1,5 +1,7 @@ package com.baeldung.persistence.service.impl; +import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -11,6 +13,7 @@ import com.baeldung.persistence.dao.IFooDao; import com.baeldung.persistence.model.Foo; import com.baeldung.persistence.service.IFooService; import com.baeldung.persistence.service.common.AbstractService; +import com.google.common.collect.Lists; @Service @Transactional @@ -36,5 +39,13 @@ public class FooService extends AbstractService implements IFooService { public Page findPaginated(Pageable pageable) { return dao.findAll(pageable); } + + // overridden to be secured + + @Override + @Transactional(readOnly = true) + public List findAll() { + return Lists.newArrayList(getDao().findAll()); + } } diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/controller/FooController.java b/spring-boot-rest/src/main/java/com/baeldung/web/controller/FooController.java index b35295cf99..59e33263db 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/web/controller/FooController.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/controller/FooController.java @@ -9,14 +9,16 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.util.UriComponentsBuilder; import com.baeldung.persistence.model.Foo; @@ -24,9 +26,11 @@ import com.baeldung.persistence.service.IFooService; import com.baeldung.web.exception.MyResourceNotFoundException; import com.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; import com.baeldung.web.hateoas.event.ResourceCreatedEvent; +import com.baeldung.web.hateoas.event.SingleResourceRetrievedEvent; +import com.baeldung.web.util.RestPreconditions; import com.google.common.base.Preconditions; -@Controller +@RestController @RequestMapping(value = "/auth/foos") public class FooController { @@ -42,10 +46,24 @@ public class FooController { // API + // read - one + + @GetMapping(value = "/{id}") + public Foo findById(@PathVariable("id") final Long id, final HttpServletResponse response) { + final Foo resourceById = RestPreconditions.checkFound(service.findOne(id)); + + eventPublisher.publishEvent(new SingleResourceRetrievedEvent(this, response)); + return resourceById; + } + // read - all - @RequestMapping(params = { "page", "size" }, method = RequestMethod.GET) - @ResponseBody + @GetMapping + public List findAll() { + return service.findAll(); + } + + @GetMapping(params = { "page", "size" }) public List findPaginated(@RequestParam("page") final int page, @RequestParam("size") final int size, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { final Page resultPage = service.findPaginated(page, size); @@ -59,7 +77,6 @@ public class FooController { } @GetMapping("/pageable") - @ResponseBody public List findPaginatedWithPageable(Pageable pageable, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { final Page resultPage = service.findPaginated(pageable); @@ -74,9 +91,8 @@ public class FooController { // write - @RequestMapping(method = RequestMethod.POST) + @PostMapping @ResponseStatus(HttpStatus.CREATED) - @ResponseBody public Foo create(@RequestBody final Foo resource, final HttpServletResponse response) { Preconditions.checkNotNull(resource); final Foo foo = service.create(resource); @@ -86,4 +102,18 @@ public class FooController { return foo; } + + @PutMapping(value = "/{id}") + @ResponseStatus(HttpStatus.OK) + public void update(@PathVariable("id") final Long id, @RequestBody final Foo resource) { + Preconditions.checkNotNull(resource); + RestPreconditions.checkFound(service.findOne(resource.getId())); + service.update(resource); + } + + @DeleteMapping(value = "/{id}") + @ResponseStatus(HttpStatus.OK) + public void delete(@PathVariable("id") final Long id) { + service.deleteById(id); + } } diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java new file mode 100644 index 0000000000..70face083c --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/event/SingleResourceRetrievedEvent.java @@ -0,0 +1,22 @@ +package com.baeldung.web.hateoas.event; + +import javax.servlet.http.HttpServletResponse; + +import org.springframework.context.ApplicationEvent; + +public class SingleResourceRetrievedEvent extends ApplicationEvent { + private final HttpServletResponse response; + + public SingleResourceRetrievedEvent(final Object source, final HttpServletResponse response) { + super(source); + + this.response = response; + } + + // API + + public HttpServletResponse getResponse() { + return response; + } + +} \ No newline at end of file diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java new file mode 100644 index 0000000000..d527c308b9 --- /dev/null +++ b/spring-boot-rest/src/main/java/com/baeldung/web/hateoas/listener/SingleResourceRetrievedDiscoverabilityListener.java @@ -0,0 +1,34 @@ +package com.baeldung.web.hateoas.listener; + +import javax.servlet.http.HttpServletResponse; + +import com.baeldung.web.hateoas.event.SingleResourceRetrievedEvent; +import com.baeldung.web.util.LinkUtil; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +import com.google.common.base.Preconditions; +import com.google.common.net.HttpHeaders; + +@Component +class SingleResourceRetrievedDiscoverabilityListener implements ApplicationListener { + + @Override + public void onApplicationEvent(final SingleResourceRetrievedEvent resourceRetrievedEvent) { + Preconditions.checkNotNull(resourceRetrievedEvent); + + final HttpServletResponse response = resourceRetrievedEvent.getResponse(); + addLinkHeaderOnSingleResourceRetrieval(response); + } + + void addLinkHeaderOnSingleResourceRetrieval(final HttpServletResponse response) { + final String requestURL = ServletUriComponentsBuilder.fromCurrentRequestUri().build().toUri().toASCIIString(); + final int positionOfLastSlash = requestURL.lastIndexOf("/"); + final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash); + + final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection"); + response.addHeader(HttpHeaders.LINK, linkHeaderValue); + } + +} \ No newline at end of file diff --git a/spring-rest-full/.attach_pid28499 b/spring-rest-full/.attach_pid28499 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-rest-full/src/main/java/org/baeldung/persistence/IOperations.java b/spring-rest-full/src/main/java/org/baeldung/persistence/IOperations.java index 8c5593c3e8..0b617bf7ab 100644 --- a/spring-rest-full/src/main/java/org/baeldung/persistence/IOperations.java +++ b/spring-rest-full/src/main/java/org/baeldung/persistence/IOperations.java @@ -16,11 +16,7 @@ public interface IOperations { // write T create(final T entity); - + T update(final T entity); - void delete(final T entity); - - void deleteById(final long entityId); - } diff --git a/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java b/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java index 59ccea8b12..059516eeba 100644 --- a/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java +++ b/spring-rest-full/src/main/java/org/baeldung/persistence/service/common/AbstractService.java @@ -40,16 +40,6 @@ public abstract class AbstractService implements IOperat return getDao().save(entity); } - @Override - public void delete(final T entity) { - getDao().delete(entity); - } - - @Override - public void deleteById(final long entityId) { - getDao().delete(entityId); - } - protected abstract PagingAndSortingRepository getDao(); } diff --git a/spring-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java index d46f1bfe90..32fe1bd7e0 100644 --- a/spring-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java +++ b/spring-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -1,7 +1,5 @@ package org.baeldung.persistence.service.impl; -import java.util.List; - import org.baeldung.persistence.dao.IFooDao; import org.baeldung.persistence.model.Foo; import org.baeldung.persistence.service.IFooService; @@ -11,8 +9,6 @@ import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.google.common.collect.Lists; - @Service @Transactional public class FooService extends AbstractService implements IFooService { @@ -38,12 +34,4 @@ public class FooService extends AbstractService implements IFooService { return dao.retrieveByName(name); } - // overridden to be secured - - @Override - @Transactional(readOnly = true) - public List findAll() { - return Lists.newArrayList(getDao().findAll()); - } - } diff --git a/spring-rest-full/src/main/java/org/baeldung/web/controller/FooController.java b/spring-rest-full/src/main/java/org/baeldung/web/controller/FooController.java index 443d0908ee..2e4dbcacc9 100644 --- a/spring-rest-full/src/main/java/org/baeldung/web/controller/FooController.java +++ b/spring-rest-full/src/main/java/org/baeldung/web/controller/FooController.java @@ -80,20 +80,6 @@ public class FooController { return foo; } - @RequestMapping(value = "/{id}", method = RequestMethod.PUT) - @ResponseStatus(HttpStatus.OK) - public void update(@PathVariable("id") final Long id, @RequestBody final Foo resource) { - Preconditions.checkNotNull(resource); - RestPreconditions.checkFound(service.findOne(resource.getId())); - service.update(resource); - } - - @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) - @ResponseStatus(HttpStatus.OK) - public void delete(@PathVariable("id") final Long id) { - service.deleteById(id); - } - @RequestMapping(method = RequestMethod.HEAD) @ResponseStatus(HttpStatus.OK) public void head(final HttpServletResponse resp) { From e51d996ec1fab6f0239cd436e0739fd8f5d22bba Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Tue, 29 Jan 2019 17:05:09 -0200 Subject: [PATCH 327/441] Added spring boot related tests for building Rest API article --- .../web/FooControllerAppIntegrationTest.java | 36 +++++++++++ .../FooControllerWebLayerIntegrationTest.java | 60 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 spring-boot-rest/src/test/java/com/baeldung/web/FooControllerAppIntegrationTest.java create mode 100644 spring-boot-rest/src/test/java/com/baeldung/web/FooControllerWebLayerIntegrationTest.java diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/FooControllerAppIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/FooControllerAppIntegrationTest.java new file mode 100644 index 0000000000..bd5b5eb58e --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/web/FooControllerAppIntegrationTest.java @@ -0,0 +1,36 @@ +package com.baeldung.web; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; + +/** + * + * We'll start the whole context, but not the server. We'll mock the REST calls instead. + * + */ +@RunWith(SpringRunner.class) +@SpringBootTest +@AutoConfigureMockMvc +public class FooControllerAppIntegrationTest { + + @Autowired + private MockMvc mockMvc; + + @Test + public void whenFindPaginatedRequest_thenEmptyResponse() throws Exception { + this.mockMvc.perform(get("/auth/foos").param("page", "0") + .param("size", "2")) + .andExpect(status().isOk()) + .andExpect(content().json("[]")); + } + +} diff --git a/spring-boot-rest/src/test/java/com/baeldung/web/FooControllerWebLayerIntegrationTest.java b/spring-boot-rest/src/test/java/com/baeldung/web/FooControllerWebLayerIntegrationTest.java new file mode 100644 index 0000000000..7e41cf6393 --- /dev/null +++ b/spring-boot-rest/src/test/java/com/baeldung/web/FooControllerWebLayerIntegrationTest.java @@ -0,0 +1,60 @@ +package com.baeldung.web; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.util.Collections; + +import org.hamcrest.Matchers; +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.ApplicationEventPublisher; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.service.IFooService; +import com.baeldung.web.controller.FooController; +import com.baeldung.web.hateoas.event.PaginatedResultsRetrievedEvent; + +/** + * + * We'll start only the web layer. + * + */ +@RunWith(SpringRunner.class) +@WebMvcTest(FooController.class) +public class FooControllerWebLayerIntegrationTest { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private IFooService service; + + @MockBean + private ApplicationEventPublisher publisher; + + @Test() + public void givenPresentFoo_whenFindPaginatedRequest_thenPageWithFooRetrieved() throws Exception { + Page page = new PageImpl<>(Collections.singletonList(new Foo("fooName"))); + when(service.findPaginated(0, 2)).thenReturn(page); + doNothing().when(publisher) + .publishEvent(any(PaginatedResultsRetrievedEvent.class)); + + this.mockMvc.perform(get("/auth/foos").param("page", "0") + .param("size", "2")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$",Matchers.hasSize(1))); + } + +} From 822b09baab5b1a4080bf8311c2e562f46397b2a0 Mon Sep 17 00:00:00 2001 From: ciro Date: Tue, 29 Jan 2019 11:31:15 -0800 Subject: [PATCH 328/441] BAEL-2466 moving request.xml --- spring-soap/src/{main => test}/resources/request.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spring-soap/src/{main => test}/resources/request.xml (100%) diff --git a/spring-soap/src/main/resources/request.xml b/spring-soap/src/test/resources/request.xml similarity index 100% rename from spring-soap/src/main/resources/request.xml rename to spring-soap/src/test/resources/request.xml From 281432707993500042df7f02f1fa3b2310d9d401 Mon Sep 17 00:00:00 2001 From: Ger Roza Date: Tue, 29 Jan 2019 19:17:01 -0200 Subject: [PATCH 329/441] Moved article from Readme files --- spring-boot-rest/README.md | 3 ++- spring-rest-full/README.md | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md index 2c89a64a00..ffc48126d3 100644 --- a/spring-boot-rest/README.md +++ b/spring-boot-rest/README.md @@ -2,4 +2,5 @@ Module for the articles that 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. [Error Handling for REST with Spring](http://www.baeldung.com/exception-handling-for-rest-with-spring) -3. [REST Pagination in Spring](http://www.baeldung.com/rest-api-pagination-in-spring) \ No newline at end of file +3. [REST Pagination in Spring](http://www.baeldung.com/rest-api-pagination-in-spring) +4. [Build a REST API with Spring and Java Config](http://www.baeldung.com/building-a-restful-web-service-with-spring-and-java-based-configuration) \ No newline at end of file diff --git a/spring-rest-full/README.md b/spring-rest-full/README.md index 2ef3a09e37..5140c4b270 100644 --- a/spring-rest-full/README.md +++ b/spring-rest-full/README.md @@ -16,7 +16,6 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com - [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) - [Bootstrap a Web Application with Spring 4](http://www.baeldung.com/bootstraping-a-web-application-with-spring-and-java-based-configuration) -- [Build a REST API with Spring and Java Config](http://www.baeldung.com/building-a-restful-web-service-with-spring-and-java-based-configuration) - [Spring Security Expressions - hasRole Example](https://www.baeldung.com/spring-security-expressions-basic) From 50a8870d4f95175e409b51972fc31ae014bb1a2f Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Wed, 30 Jan 2019 13:46:56 +0200 Subject: [PATCH 330/441] BAEL-2659 - Reading a file in Groovy - added more example --- .../src/main/groovy/com/baeldung/file/ReadFile.groovy | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy index 38bf189e63..828f702e82 100644 --- a/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy +++ b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy @@ -69,6 +69,14 @@ class ReadFile { * @return */ def moreExamples() { + + new File("src/main/resources/utf8Content.html").withReader('UTF-8') { reader -> + def line + while ((line = reader.readLine())!=null) { + println "${line}" + } + } + def list = new File("src/main/resources/fileContent.txt").collect {it} def array = new File("src/main/resources/fileContent.txt") as String[] From f1ea814185be1e0bf555bb49c737da27eed86b3f Mon Sep 17 00:00:00 2001 From: rodolforfq <31481067+rodolforfq@users.noreply.github.com> Date: Wed, 30 Jan 2019 11:40:24 -0400 Subject: [PATCH 331/441] New examples (#6242) Adding new examples. Improvement in existing method. --- .../baeldung/java8/lambda/methodreference/Bicycle.java | 5 +++++ .../methodreference/MethodReferenceExamples.java | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java index 760a24d7c2..26f9f8bc46 100644 --- a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java +++ b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/Bicycle.java @@ -5,6 +5,11 @@ public class Bicycle { private String brand; private Integer frameSize; + public Bicycle(String brand) { + this.brand = brand; + this.frameSize = 0; + } + public Bicycle(String brand, Integer frameSize) { this.brand = brand; this.frameSize = frameSize; diff --git a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceExamples.java b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceExamples.java index 3b9a5ec6ff..ede0ef9f70 100644 --- a/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceExamples.java +++ b/core-java-8/src/test/java/com/baeldung/java8/lambda/methodreference/MethodReferenceExamples.java @@ -52,10 +52,18 @@ public class MethodReferenceExamples { bikes.add(bikeCreatorMethodReference.apply("GT", 40)); } + @Test + public void referenceToConstructorSimpleExample() { + List bikeBrands = Arrays.asList("Giant", "Scott", "Trek", "GT"); + bikeBrands.stream() + .map(Bicycle::new) + .toArray(Bicycle[]::new); + } + @Test public void limitationsAndAdditionalExamples() { createBicyclesList().forEach(b -> System.out.printf("Bike brand is '%s' and frame size is '%d'%n", b.getBrand(), b.getFrameSize())); - createBicyclesList().forEach((o) -> this.doNothingAtAll(o)); + createBicyclesList().forEach((o) -> MethodReferenceExamples.doNothingAtAll(o)); } private List createBicyclesList() { From 499aec3490118b3e9d92264edcc4f8816c5f3abb Mon Sep 17 00:00:00 2001 From: amdegregorio Date: Wed, 30 Jan 2019 13:55:37 -0500 Subject: [PATCH 332/441] updates to simplify example --- .../java/com/baeldung/jar/Dimensioner.java | 27 ------------ .../java/com/baeldung/jar/JarExample.java | 24 +--------- .../main/java/com/baeldung/jar/Rectangle.java | 44 ------------------- 3 files changed, 1 insertion(+), 94 deletions(-) delete mode 100644 core-java/src/main/java/com/baeldung/jar/Dimensioner.java delete mode 100644 core-java/src/main/java/com/baeldung/jar/Rectangle.java diff --git a/core-java/src/main/java/com/baeldung/jar/Dimensioner.java b/core-java/src/main/java/com/baeldung/jar/Dimensioner.java deleted file mode 100644 index bc5cea4010..0000000000 --- a/core-java/src/main/java/com/baeldung/jar/Dimensioner.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.jar; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -public class Dimensioner { - - public List loadFromFile(String dimensionFile) throws FileNotFoundException, IOException { - List rectangles = new ArrayList(); - try (BufferedReader br = new BufferedReader(new InputStreamReader(Dimensioner.class.getResourceAsStream(dimensionFile)))) { - String line; - while ((line = br.readLine()) != null) { - String[] dimensions = line.split(","); - if (dimensions.length == 2) { - Rectangle rectangle = new Rectangle(Integer.valueOf(dimensions[0]), Integer.valueOf(dimensions[1])); - rectangles.add(rectangle); - } - } - } - return rectangles; - } - -} diff --git a/core-java/src/main/java/com/baeldung/jar/JarExample.java b/core-java/src/main/java/com/baeldung/jar/JarExample.java index daa44025d5..5f33188adf 100644 --- a/core-java/src/main/java/com/baeldung/jar/JarExample.java +++ b/core-java/src/main/java/com/baeldung/jar/JarExample.java @@ -1,31 +1,9 @@ package com.baeldung.jar; -import java.io.IOException; -import java.util.List; - public class JarExample { - private static final String DIMENSION_FILE = "/dimensions.txt"; public static void main(String[] args) { - String inputType = System.getProperty("input"); - if (inputType != null && inputType.equalsIgnoreCase("file")) { - Dimensioner dimensioner = new Dimensioner(); - try { - List rectangles = dimensioner.loadFromFile(DIMENSION_FILE); - rectangles.forEach(rectangle -> { - rectangle.printArea(); - rectangle.printPerimeter(); - }); - } catch (IOException e) { - System.err.println("Exception loading dimensions"); - } - } else if (args.length > 0) { - int length = Integer.valueOf(args[0]); - int width = (args.length > 1) ? Integer.valueOf(args[1]) : Integer.valueOf(args[0]); - Rectangle rectangle = new Rectangle(length, width); - rectangle.printArea(); - rectangle.printPerimeter(); - } + System.out.println("Hello Baeldung Reader!"); } } diff --git a/core-java/src/main/java/com/baeldung/jar/Rectangle.java b/core-java/src/main/java/com/baeldung/jar/Rectangle.java deleted file mode 100644 index f2a174c819..0000000000 --- a/core-java/src/main/java/com/baeldung/jar/Rectangle.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.jar; - -public class Rectangle { - private int length; - private int width; - - public Rectangle(int length, int width) { - this.length = length; - this.width = width; - } - - public int area() { - return length * width; - } - - public int perimeter() { - return (length * 2) + (width * 2); - } - - public void printArea() { - System.out.println("Area: " + area()); - } - - public void printPerimeter() { - System.out.println("Perimeter: " + perimeter()); - } - - public int getLength() { - return length; - } - - public void setLength(int length) { - this.length = length; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - -} From 4d1c8634facc2e9fb305c794c27e379bf7bb4aeb Mon Sep 17 00:00:00 2001 From: psevestre Date: Thu, 31 Jan 2019 00:16:26 -0200 Subject: [PATCH 333/441] Code for BAEL-1381 (#6214) * BAEL-1381 * [BAEL-1381] * [BAEL-1381] New module name * [BAEL-1381] software-security module --- pom.xml | 3 +- .../sql-injection-samples/.gitignore | 25 +++ .../sql-injection-samples/pom.xml | 61 +++++++ .../examples/security/sql/AccountDAO.java | 169 ++++++++++++++++++ .../examples/security/sql/AccountDTO.java | 16 ++ .../sql/SqlInjectionSamplesApplication.java | 14 ++ .../src/main/resources/application.properties | 0 .../resources/db/changelog/create-tables.xml | 19 ++ .../main/resources/db/master-changelog.xml | 8 + ...qlInjectionSamplesApplicationUnitTest.java | 60 +++++++ .../src/test/resources/application-test.yml | 6 + .../src/test/resources/data.sql | 4 + .../src/test/resources/schema.sql | 6 + 13 files changed, 390 insertions(+), 1 deletion(-) create mode 100644 software-security/sql-injection-samples/.gitignore create mode 100644 software-security/sql-injection-samples/pom.xml create mode 100644 software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDAO.java create mode 100644 software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDTO.java create mode 100644 software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplication.java create mode 100644 software-security/sql-injection-samples/src/main/resources/application.properties create mode 100644 software-security/sql-injection-samples/src/main/resources/db/changelog/create-tables.xml create mode 100644 software-security/sql-injection-samples/src/main/resources/db/master-changelog.xml create mode 100644 software-security/sql-injection-samples/src/test/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplicationUnitTest.java create mode 100644 software-security/sql-injection-samples/src/test/resources/application-test.yml create mode 100644 software-security/sql-injection-samples/src/test/resources/data.sql create mode 100644 software-security/sql-injection-samples/src/test/resources/schema.sql diff --git a/pom.xml b/pom.xml index 01cb86d103..787a03c2fb 100644 --- a/pom.xml +++ b/pom.xml @@ -567,7 +567,8 @@ rule-engines/rulebook rsocket rxjava - rxjava-2 + rxjava-2 + software-security/sql-injection-samples diff --git a/software-security/sql-injection-samples/.gitignore b/software-security/sql-injection-samples/.gitignore new file mode 100644 index 0000000000..82eca336e3 --- /dev/null +++ b/software-security/sql-injection-samples/.gitignore @@ -0,0 +1,25 @@ +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/build/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ \ No newline at end of file diff --git a/software-security/sql-injection-samples/pom.xml b/software-security/sql-injection-samples/pom.xml new file mode 100644 index 0000000000..d5e64db6b3 --- /dev/null +++ b/software-security/sql-injection-samples/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + com.baeldung + sql-injection-samples + 0.0.1-SNAPSHOT + sql-injection-samples + Sample SQL Injection tests + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-jdbc + + + + org.apache.derby + derby + runtime + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.projectlombok + lombok + provided + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDAO.java b/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDAO.java new file mode 100644 index 0000000000..447dcc456d --- /dev/null +++ b/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDAO.java @@ -0,0 +1,169 @@ +/** + * + */ +package com.baeldung.examples.security.sql; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.sql.DataSource; + +import org.springframework.stereotype.Component; + +/** + * @author Philippe + * + */ +@Component +public class AccountDAO { + + private final DataSource dataSource; + + public AccountDAO(DataSource dataSource) { + this.dataSource = dataSource; + } + + /** + * Return all accounts owned by a given customer,given his/her external id + * + * @param customerId + * @return + */ + public List unsafeFindAccountsByCustomerId(String customerId) { + + String sql = "select " + "customer_id,acc_number,branch_id,balance from Accounts where customer_id = '" + customerId + "'"; + + try (Connection c = dataSource.getConnection(); + ResultSet rs = c.createStatement() + .executeQuery(sql)) { + List accounts = new ArrayList<>(); + while (rs.next()) { + AccountDTO acc = AccountDTO.builder() + .customerId(rs.getString("customer_id")) + .branchId(rs.getString("branch_id")) + .accNumber(rs.getString("acc_number")) + .balance(rs.getBigDecimal("balance")) + .build(); + + accounts.add(acc); + } + + return accounts; + } catch (SQLException ex) { + throw new RuntimeException(ex); + } + } + + /** + * Return all accounts owned by a given customer,given his/her external id + * + * @param customerId + * @return + */ + public List safeFindAccountsByCustomerId(String customerId) { + + String sql = "select " + "customer_id,acc_number,branch_id,balance from Accounts where customer_id = ?"; + + try (Connection c = dataSource.getConnection(); PreparedStatement p = c.prepareStatement(sql)) { + p.setString(1, customerId); + ResultSet rs = p.executeQuery(); + List accounts = new ArrayList<>(); + while (rs.next()) { + AccountDTO acc = AccountDTO.builder() + .customerId(rs.getString("customerId")) + .branchId(rs.getString("branch_id")) + .accNumber(rs.getString("acc_number")) + .balance(rs.getBigDecimal("balance")) + .build(); + + accounts.add(acc); + } + return accounts; + } catch (SQLException ex) { + throw new RuntimeException(ex); + } + } + + private static final Set VALID_COLUMNS_FOR_ORDER_BY = Stream.of("acc_number", "branch_id", "balance") + .collect(Collectors.toCollection(HashSet::new)); + + /** + * Return all accounts owned by a given customer,given his/her external id + * + * @param customerId + * @return + */ + public List safeFindAccountsByCustomerId(String customerId, String orderBy) { + + String sql = "select " + "customer_id,acc_number,branch_id,balance from Accounts where customer_id = ? "; + + if (VALID_COLUMNS_FOR_ORDER_BY.contains(orderBy)) { + sql = sql + " order by " + orderBy; + } + else { + throw new IllegalArgumentException("Nice try!"); + } + + try (Connection c = dataSource.getConnection(); PreparedStatement p = c.prepareStatement(sql)) { + + p.setString(1, customerId); + ResultSet rs = p.executeQuery(); + List accounts = new ArrayList<>(); + while (rs.next()) { + AccountDTO acc = AccountDTO.builder() + .customerId(rs.getString("customerId")) + .branchId(rs.getString("branch_id")) + .accNumber(rs.getString("acc_number")) + .balance(rs.getBigDecimal("balance")) + .build(); + + accounts.add(acc); + } + + return accounts; + } catch (SQLException ex) { + throw new RuntimeException(ex); + } + } + + /** + * Invalid placeholder usage example + * + * @param tableName + * @return + */ + public List wrongCountRecordsByTableName(String tableName) { + + try (Connection c = dataSource.getConnection(); + PreparedStatement p = c.prepareStatement("select count(*) from ?")) { + + p.setString(1, tableName); + ResultSet rs = p.executeQuery(); + List accounts = new ArrayList<>(); + while (rs.next()) { + AccountDTO acc = AccountDTO.builder() + .customerId(rs.getString("customerId")) + .branchId(rs.getString("branch_id")) + .accNumber(rs.getString("acc_number")) + .balance(rs.getBigDecimal("balance")) + .build(); + + accounts.add(acc); + } + + return accounts; + } catch (SQLException ex) { + throw new RuntimeException(ex); + } + } + +} diff --git a/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDTO.java b/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDTO.java new file mode 100644 index 0000000000..2e6fa04af4 --- /dev/null +++ b/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/AccountDTO.java @@ -0,0 +1,16 @@ +package com.baeldung.examples.security.sql; + +import java.math.BigDecimal; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class AccountDTO { + + private String customerId; + private String accNumber; + private String branchId; + private BigDecimal balance; +} diff --git a/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplication.java b/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplication.java new file mode 100644 index 0000000000..c1083ae3de --- /dev/null +++ b/software-security/sql-injection-samples/src/main/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplication.java @@ -0,0 +1,14 @@ +package com.baeldung.examples.security.sql; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SqlInjectionSamplesApplication { + + public static void main(String[] args) { + SpringApplication.run(SqlInjectionSamplesApplication.class, args); + } + +} + diff --git a/software-security/sql-injection-samples/src/main/resources/application.properties b/software-security/sql-injection-samples/src/main/resources/application.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/software-security/sql-injection-samples/src/main/resources/db/changelog/create-tables.xml b/software-security/sql-injection-samples/src/main/resources/db/changelog/create-tables.xml new file mode 100644 index 0000000000..a405c02049 --- /dev/null +++ b/software-security/sql-injection-samples/src/main/resources/db/changelog/create-tables.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/software-security/sql-injection-samples/src/main/resources/db/master-changelog.xml b/software-security/sql-injection-samples/src/main/resources/db/master-changelog.xml new file mode 100644 index 0000000000..047ca2b314 --- /dev/null +++ b/software-security/sql-injection-samples/src/main/resources/db/master-changelog.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/software-security/sql-injection-samples/src/test/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplicationUnitTest.java b/software-security/sql-injection-samples/src/test/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplicationUnitTest.java new file mode 100644 index 0000000000..1f37ba04b6 --- /dev/null +++ b/software-security/sql-injection-samples/src/test/java/com/baeldung/examples/security/sql/SqlInjectionSamplesApplicationUnitTest.java @@ -0,0 +1,60 @@ +package com.baeldung.examples.security.sql; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.examples.security.sql.AccountDAO; +import com.baeldung.examples.security.sql.AccountDTO; + +@RunWith(SpringRunner.class) +@SpringBootTest +@ActiveProfiles({ "test" }) +public class SqlInjectionSamplesApplicationUnitTest { + + @Autowired + private AccountDAO target; + + @Test + public void givenAVulnerableMethod_whenValidCustomerId_thenReturnSingleAccount() { + + List accounts = target.unsafeFindAccountsByCustomerId("C1"); + assertThat(accounts).isNotNull(); + assertThat(accounts).isNotEmpty(); + assertThat(accounts).hasSize(1); + } + + @Test + public void givenAVulnerableMethod_whenHackedCustomerId_thenReturnAllAccounts() { + + List accounts = target.unsafeFindAccountsByCustomerId("C1' or '1'='1"); + assertThat(accounts).isNotNull(); + assertThat(accounts).isNotEmpty(); + assertThat(accounts).hasSize(3); + } + + @Test + public void givenASafeMethod_whenHackedCustomerId_thenReturnNoAccounts() { + + List accounts = target.safeFindAccountsByCustomerId("C1' or '1'='1"); + assertThat(accounts).isNotNull(); + assertThat(accounts).isEmpty(); + } + + @Test(expected = IllegalArgumentException.class) + public void givenASafeMethod_whenInvalidOrderBy_thenThroweException() { + target.safeFindAccountsByCustomerId("C1", "INVALID"); + } + + @Test(expected = RuntimeException.class) + public void givenWrongPlaceholderUsageMethod_whenNormalCall_thenThrowsException() { + target.wrongCountRecordsByTableName("Accounts"); + } +} diff --git a/software-security/sql-injection-samples/src/test/resources/application-test.yml b/software-security/sql-injection-samples/src/test/resources/application-test.yml new file mode 100644 index 0000000000..d07ee10aee --- /dev/null +++ b/software-security/sql-injection-samples/src/test/resources/application-test.yml @@ -0,0 +1,6 @@ +# +# Test profile configuration +# +spring: + datasource: + initialization-mode: always diff --git a/software-security/sql-injection-samples/src/test/resources/data.sql b/software-security/sql-injection-samples/src/test/resources/data.sql new file mode 100644 index 0000000000..586618a07f --- /dev/null +++ b/software-security/sql-injection-samples/src/test/resources/data.sql @@ -0,0 +1,4 @@ +insert into Accounts(customer_id,acc_number,branch_id,balance) values ('C1','0001',1,1000.00); +insert into Accounts(customer_id,acc_number,branch_id,balance) values ('C2','0002',1,500.00); +insert into Accounts(customer_id,acc_number,branch_id,balance) values ('C3','0003',1,501.00); + diff --git a/software-security/sql-injection-samples/src/test/resources/schema.sql b/software-security/sql-injection-samples/src/test/resources/schema.sql new file mode 100644 index 0000000000..bfb0ae8059 --- /dev/null +++ b/software-security/sql-injection-samples/src/test/resources/schema.sql @@ -0,0 +1,6 @@ +create table Accounts ( + customer_id varchar(16) not null, + acc_number varchar(16) not null, + branch_id decimal(8,0), + balance decimal(16,4) +); From b48f77cf6e61afb2990f52a9fe515813aa0f8f3a Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Thu, 31 Jan 2019 12:46:25 +0200 Subject: [PATCH 334/441] BAEL-2659 - Reading a file in Groovy - corrected variable names --- .../main/groovy/com/baeldung/file/ReadFile.groovy | 8 +++++++- core-groovy/src/main/resources/utf8Content.html | 4 +--- .../com/baeldung/file/ReadFileUnitTest.groovy | 14 ++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy index 828f702e82..4239fa534c 100644 --- a/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy +++ b/core-groovy/src/main/groovy/com/baeldung/file/ReadFile.groovy @@ -70,6 +70,7 @@ class ReadFile { */ def moreExamples() { + //with reader with utf-8 new File("src/main/resources/utf8Content.html").withReader('UTF-8') { reader -> def line while ((line = reader.readLine())!=null) { @@ -77,20 +78,25 @@ class ReadFile { } } + //collect api def list = new File("src/main/resources/fileContent.txt").collect {it} + //as operator def array = new File("src/main/resources/fileContent.txt") as String[] - + + //eachline new File("src/main/resources/fileContent.txt").eachLine { line -> println line } + //newInputStream with eachLine def is = new File("src/main/resources/fileContent.txt").newInputStream() is.eachLine { println it } is.close() + //withInputStream new File("src/main/resources/fileContent.txt").withInputStream { stream -> stream.eachLine { line -> println line diff --git a/core-groovy/src/main/resources/utf8Content.html b/core-groovy/src/main/resources/utf8Content.html index 9d941200b1..873a75b8d0 100644 --- a/core-groovy/src/main/resources/utf8Content.html +++ b/core-groovy/src/main/resources/utf8Content.html @@ -1,5 +1,3 @@ ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ ᛋᚳᛖᚪᛚ᛫ᚦᛖᚪᚻ᛫ᛗᚪᚾᚾᚪ᛫ᚷᛖᚻᚹᛦᛚᚳ᛫ᛗᛁᚳᛚᚢᚾ᛫ᚻᛦᛏ᛫ᛞᚫᛚᚪᚾ -ᚷᛁᚠ᛫ᚻᛖ᛫ᚹᛁᛚᛖ᛫ᚠᚩᚱ᛫ᛞᚱᛁᚻᛏᚾᛖ᛫ᛞᚩᛗᛖᛋ᛫ᚻᛚᛇᛏᚪᚾ - -¥ · £ · € · $ · ¢ · ₡ · ₢ · ₣ · ₤ · ₥ · ₦ · ₧ · ₨ · ₩ · ₪ · ₫ · ₭ · ₮ · ₯ · ₹ \ No newline at end of file +ᚷᛁᚠ᛫ᚻᛖ᛫ᚹᛁᛚᛖ᛫ᚠᚩᚱ᛫ᛞᚱᛁᚻᛏᚾᛖ᛫ᛞᚩᛗᛖᛋ᛫ᚻᛚᛇᛏᚪᚾ \ No newline at end of file diff --git a/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy index 5fc1409276..0d0e2aed1a 100644 --- a/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/file/ReadFileUnitTest.groovy @@ -50,19 +50,21 @@ Line 3 : String content""") given: def filePath = "src/main/resources/utf8Content.html" when: - def noOfLines = readFile.readFileStringWithCharset(filePath) + def encodedContent = readFile.readFileStringWithCharset(filePath) then: - noOfLines - noOfLines instanceof String + encodedContent + encodedContent instanceof String } def 'Should return binary file content in byte arry using ReadFile.readBinaryFile given filePath' () { given: def filePath = "src/main/resources/sample.png" when: - def noOfLines = readFile.readBinaryFile(filePath) + def binaryContent = readFile.readBinaryFile(filePath) then: - noOfLines - noOfLines instanceof byte[] + binaryContent + binaryContent instanceof byte[] + binaryContent.length == 329 } + } \ No newline at end of file From ca98fbb7062c13129ee3193b679a64ad9da63f84 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Thu, 31 Jan 2019 16:18:59 +0400 Subject: [PATCH 335/441] Added Stream Api --- .../list/primitive/PrimitiveCollections.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java index 50f372e9c9..01372763e9 100644 --- a/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java +++ b/core-java-collections-list/src/main/java/com/baeldung/list/primitive/PrimitiveCollections.java @@ -7,15 +7,20 @@ import it.unimi.dsi.fastutil.ints.IntArrayList; import java.util.Arrays; import java.util.List; +import java.util.OptionalDouble; +import java.util.function.IntPredicate; +import java.util.stream.IntStream; public class PrimitiveCollections { public static void main(String[] args) { - int[] primitives = new int[] {5, 10, 0, 2}; + int[] primitives = new int[] {5, 10, 0, 2, -8}; guavaPrimitives(primitives); + intStream(primitives); + TIntArrayList tList = new TIntArrayList(primitives); cern.colt.list.IntArrayList coltList = new cern.colt.list.IntArrayList(primitives); @@ -29,6 +34,15 @@ public class PrimitiveCollections { System.out.println(fastUtilList); } + private static void intStream(int[] primitives) { + + IntStream stream = IntStream.of(5, 10, 0, 2, -8); + + IntStream newStream = IntStream.of(primitives); + + OptionalDouble average = stream.filter(i -> i > 0).average(); + } + private static void guavaPrimitives(int[] primitives) { From 56a832273e35c82da8d6de1b041ed518f11b53ce Mon Sep 17 00:00:00 2001 From: Dave Crane Date: Thu, 31 Jan 2019 12:48:35 +0000 Subject: [PATCH 336/441] Lombok SuperBuilder Issue: BAEL-2561 --- .../buildermethodname}/Child.java | 2 +- .../buildermethodname}/Parent.java | 2 +- .../buildermethodname/Student.java | 16 ++++ .../inheritance/superbuilder/Child.java | 11 +++ .../inheritance/superbuilder/Parent.java | 11 +++ .../inheritance/superbuilder/Student.java | 10 ++ .../lombok/builder/BuilderUnitTest.java | 16 ---- ...derInheritanceUsingMethodNameUnitTest.java | 40 ++++++++ ...rInheritanceUsingSuperBuilderUnitTest.java | 96 +++++++++++++++++++ 9 files changed, 186 insertions(+), 18 deletions(-) rename lombok/src/main/java/com/baeldung/lombok/builder/{ => inheritance/buildermethodname}/Child.java (86%) rename lombok/src/main/java/com/baeldung/lombok/builder/{ => inheritance/buildermethodname}/Parent.java (70%) create mode 100644 lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Student.java create mode 100644 lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Child.java create mode 100644 lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Parent.java create mode 100644 lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Student.java create mode 100644 lombok/src/test/java/com/baeldung/lombok/builder/inheritance/buildermethodname/BuilderInheritanceUsingMethodNameUnitTest.java create mode 100644 lombok/src/test/java/com/baeldung/lombok/builder/inheritance/superbuilder/BuilderInheritanceUsingSuperBuilderUnitTest.java diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/Child.java b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Child.java similarity index 86% rename from lombok/src/main/java/com/baeldung/lombok/builder/Child.java rename to lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Child.java index 70f6d9c46e..4cfcc22fb2 100644 --- a/lombok/src/main/java/com/baeldung/lombok/builder/Child.java +++ b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Child.java @@ -1,4 +1,4 @@ -package com.baeldung.lombok.builder; +package com.baeldung.lombok.builder.inheritance.buildermethodname; import lombok.Builder; import lombok.Getter; diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/Parent.java b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Parent.java similarity index 70% rename from lombok/src/main/java/com/baeldung/lombok/builder/Parent.java rename to lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Parent.java index 0cf76d4b00..93e48ee44e 100644 --- a/lombok/src/main/java/com/baeldung/lombok/builder/Parent.java +++ b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Parent.java @@ -1,4 +1,4 @@ -package com.baeldung.lombok.builder; +package com.baeldung.lombok.builder.inheritance.buildermethodname; import lombok.Builder; import lombok.Getter; diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Student.java b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Student.java new file mode 100644 index 0000000000..c8eea84b97 --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/buildermethodname/Student.java @@ -0,0 +1,16 @@ +package com.baeldung.lombok.builder.inheritance.buildermethodname; + +import lombok.Builder; +import lombok.Getter; + +@Getter +public class Student extends Child { + + private final String schoolName; + + @Builder(builderMethodName = "studentBuilder") + public Student(String parentName, int parentAge, String childName, int childAge, String schoolName) { + super(parentName, parentAge, childName, childAge); + this.schoolName = schoolName; + } +} diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Child.java b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Child.java new file mode 100644 index 0000000000..92285ebdc3 --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Child.java @@ -0,0 +1,11 @@ +package com.baeldung.lombok.builder.inheritance.superbuilder; + +import lombok.Getter; +import lombok.experimental.SuperBuilder; + +@Getter +@SuperBuilder(toBuilder = true) +public class Child extends Parent { + private final String childName; + private final int childAge; +} diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Parent.java b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Parent.java new file mode 100644 index 0000000000..b8e0934520 --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Parent.java @@ -0,0 +1,11 @@ +package com.baeldung.lombok.builder.inheritance.superbuilder; + +import lombok.Getter; +import lombok.experimental.SuperBuilder; + +@Getter +@SuperBuilder(toBuilder = true) +public class Parent { + private final String parentName; + private final int parentAge; +} diff --git a/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Student.java b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Student.java new file mode 100644 index 0000000000..db43bacafa --- /dev/null +++ b/lombok/src/main/java/com/baeldung/lombok/builder/inheritance/superbuilder/Student.java @@ -0,0 +1,10 @@ +package com.baeldung.lombok.builder.inheritance.superbuilder; + +import lombok.Getter; +import lombok.experimental.SuperBuilder; + +@Getter +@SuperBuilder(toBuilder = true) +public class Student extends Child { + private final String schoolName; +} diff --git a/lombok/src/test/java/com/baeldung/lombok/builder/BuilderUnitTest.java b/lombok/src/test/java/com/baeldung/lombok/builder/BuilderUnitTest.java index 56a380569d..546c38f140 100644 --- a/lombok/src/test/java/com/baeldung/lombok/builder/BuilderUnitTest.java +++ b/lombok/src/test/java/com/baeldung/lombok/builder/BuilderUnitTest.java @@ -40,20 +40,4 @@ public class BuilderUnitTest { assertThat(testImmutableClient.getName()).isEqualTo("foo"); assertThat(testImmutableClient.getId()).isEqualTo(1); } - - @Test - public void givenBuilderAtMethodLevel_ChildInheritingParentIsBuilt() { - Child child = Child.childBuilder() - .parentName("Andrea") - .parentAge(38) - .childName("Emma") - .childAge(6) - .build(); - - assertThat(child.getChildName()).isEqualTo("Emma"); - assertThat(child.getChildAge()).isEqualTo(6); - assertThat(child.getParentName()).isEqualTo("Andrea"); - assertThat(child.getParentAge()).isEqualTo(38); - } - } diff --git a/lombok/src/test/java/com/baeldung/lombok/builder/inheritance/buildermethodname/BuilderInheritanceUsingMethodNameUnitTest.java b/lombok/src/test/java/com/baeldung/lombok/builder/inheritance/buildermethodname/BuilderInheritanceUsingMethodNameUnitTest.java new file mode 100644 index 0000000000..cf50b2577b --- /dev/null +++ b/lombok/src/test/java/com/baeldung/lombok/builder/inheritance/buildermethodname/BuilderInheritanceUsingMethodNameUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.lombok.builder.inheritance.buildermethodname; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +public class BuilderInheritanceUsingMethodNameUnitTest { + + @Test + public void givenBuilderAtMethodLevel_ChildInheritingParentIsBuilt() { + Child child = Child.childBuilder() + .parentName("Andrea") + .parentAge(38) + .childName("Emma") + .childAge(6) + .build(); + + assertThat(child.getChildName()).isEqualTo("Emma"); + assertThat(child.getChildAge()).isEqualTo(6); + assertThat(child.getParentName()).isEqualTo("Andrea"); + assertThat(child.getParentAge()).isEqualTo(38); + } + + @Test + public void givenSuperBuilderOnAllThreeLevels_StudentInheritingChildAndParentIsBuilt() { + Student student = Student.studentBuilder() + .parentName("Andrea") + .parentAge(38) + .childName("Emma") + .childAge(6) + .schoolName("Baeldung High School") + .build(); + + assertThat(student.getChildName()).isEqualTo("Emma"); + assertThat(student.getChildAge()).isEqualTo(6); + assertThat(student.getParentName()).isEqualTo("Andrea"); + assertThat(student.getParentAge()).isEqualTo(38); + assertThat(student.getSchoolName()).isEqualTo("Baeldung High School"); + } +} diff --git a/lombok/src/test/java/com/baeldung/lombok/builder/inheritance/superbuilder/BuilderInheritanceUsingSuperBuilderUnitTest.java b/lombok/src/test/java/com/baeldung/lombok/builder/inheritance/superbuilder/BuilderInheritanceUsingSuperBuilderUnitTest.java new file mode 100644 index 0000000000..72bfa6567b --- /dev/null +++ b/lombok/src/test/java/com/baeldung/lombok/builder/inheritance/superbuilder/BuilderInheritanceUsingSuperBuilderUnitTest.java @@ -0,0 +1,96 @@ +package com.baeldung.lombok.builder.inheritance.superbuilder; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +public class BuilderInheritanceUsingSuperBuilderUnitTest { + + @Test + public void givenSuperBuilderOnParentAndOnChild_ChildInheritingParentIsBuilt() { + Child child = Child.builder() + .parentName("Andrea") + .parentAge(38) + .childName("Emma") + .childAge(6) + .build(); + + assertThat(child.getChildName()).isEqualTo("Emma"); + assertThat(child.getChildAge()).isEqualTo(6); + assertThat(child.getParentName()).isEqualTo("Andrea"); + assertThat(child.getParentAge()).isEqualTo(38); + } + + @Test + public void givenSuperBuilderOnParent_StandardBuilderIsBuilt() { + Parent parent = Parent.builder() + .parentName("Andrea") + .parentAge(38) + .build(); + + assertThat(parent.getParentName()).isEqualTo("Andrea"); + assertThat(parent.getParentAge()).isEqualTo(38); + } + + @Test + public void givenToBuilderIsSetToTrueOnParentAndChild_DeepCopyViaBuilderIsPossible() { + Child child1 = Child.builder() + .parentName("Andrea") + .parentAge(38) + .childName("Emma") + .childAge(6) + .build(); + + Child child2 = child1.toBuilder() + .childName("Anna") + .build(); + + assertThat(child2.getChildName()).isEqualTo("Anna"); + assertThat(child2.getChildAge()).isEqualTo(6); + assertThat(child2.getParentName()).isEqualTo("Andrea"); + assertThat(child2.getParentAge()).isEqualTo(38); + + } + + @Test + public void givenSuperBuilderOnAllThreeLevels_StudentInheritingChildAndParentIsBuilt() { + Student student = Student.builder() + .parentName("Andrea") + .parentAge(38) + .childName("Emma") + .childAge(6) + .schoolName("Baeldung High School") + .build(); + + assertThat(student.getChildName()).isEqualTo("Emma"); + assertThat(student.getChildAge()).isEqualTo(6); + assertThat(student.getParentName()).isEqualTo("Andrea"); + assertThat(student.getParentAge()).isEqualTo(38); + assertThat(student.getSchoolName()).isEqualTo("Baeldung High School"); + } + + @Test + public void givenToBuilderIsSetToTrueOnParentChildAndStudent_DeepCopyViaBuilderIsPossible() { + Student student1 = Student.builder() + .parentName("Andrea") + .parentAge(38) + .childName("Emma") + .childAge(6) + .schoolName("School 1") + .build(); + + Student student2 = student1.toBuilder() + .childName("Anna") + .schoolName("School 2") + .build(); + + assertThat(student2.getChildName()).isEqualTo("Anna"); + assertThat(student2.getChildAge()).isEqualTo(6); + assertThat(student2.getParentName()).isEqualTo("Andrea"); + assertThat(student2.getParentAge()).isEqualTo(38); + assertThat(student2.getSchoolName()).isEqualTo("School 2"); + + } + + +} From bd166ed82f02a49b7c1eadec210b0c1459745c33 Mon Sep 17 00:00:00 2001 From: Andrey Shcherbakov Date: Thu, 31 Jan 2019 22:18:07 +0100 Subject: [PATCH 337/441] Fix the integration test in module spring-4 --- .../org/baeldung/SpringContextIntegrationTest.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spring-4/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-4/src/test/java/org/baeldung/SpringContextIntegrationTest.java index 9dfac2bd9e..d646e22511 100644 --- a/spring-4/src/test/java/org/baeldung/SpringContextIntegrationTest.java +++ b/spring-4/src/test/java/org/baeldung/SpringContextIntegrationTest.java @@ -2,13 +2,16 @@ package org.baeldung; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; import com.baeldung.flips.ApplicationConfig; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = ApplicationConfig.class) + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = ApplicationConfig.class) +@WebAppConfiguration public class SpringContextIntegrationTest { @Test From 1c556fe4fc9192eef90e0c60e084b202fd004a9e Mon Sep 17 00:00:00 2001 From: Andrey Shcherbakov Date: Thu, 31 Jan 2019 22:28:46 +0100 Subject: [PATCH 338/441] Fix the integration test in module springboot-autoconfiguration This test requires that MySQL engine is up. --- .../SpringContextIntegrationTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spring-boot-autoconfiguration/src/test/java/com/baeldung/SpringContextIntegrationTest.java diff --git a/spring-boot-autoconfiguration/src/test/java/com/baeldung/SpringContextIntegrationTest.java b/spring-boot-autoconfiguration/src/test/java/com/baeldung/SpringContextIntegrationTest.java new file mode 100644 index 0000000000..a0138bec8d --- /dev/null +++ b/spring-boot-autoconfiguration/src/test/java/com/baeldung/SpringContextIntegrationTest.java @@ -0,0 +1,19 @@ +package com.baeldung; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; + +import com.baeldung.autoconfiguration.MySQLAutoconfiguration; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = MySQLAutoconfiguration.class) +@WebAppConfiguration +public class SpringContextIntegrationTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} \ No newline at end of file From 191039ffc60afc3b39ef09be79a54887a8e9d164 Mon Sep 17 00:00:00 2001 From: Andrey Shcherbakov Date: Fri, 1 Feb 2019 07:19:07 +0100 Subject: [PATCH 339/441] Add code for issue BAEL-2574 (#6249) * Add code for issue BAEL-2574 This is a code for article "Access Spring MVC Model object in JS" Set up the project Add a test * Rename the test class --- spring-boot-mvc/pom.xml | 10 ++++++ .../java/com/baeldung/accessparamsjs/App.java | 13 ++++++++ .../baeldung/accessparamsjs/Controller.java | 32 +++++++++++++++++++ .../src/main/resources/application.properties | 4 ++- .../src/main/webapp/WEB-INF/jsp/index.jsp | 27 ++++++++++++++++ spring-boot-mvc/src/main/webapp/js/jquery.js | 2 ++ .../src/main/webapp/js/script-async-jquery.js | 6 ++++ .../src/main/webapp/js/script-async.js | 6 ++++ spring-boot-mvc/src/main/webapp/js/script.js | 4 +++ .../accessparamsjs/ControllerUnitTest.java | 28 ++++++++++++++++ 10 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java create mode 100644 spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java create mode 100644 spring-boot-mvc/src/main/webapp/WEB-INF/jsp/index.jsp create mode 100644 spring-boot-mvc/src/main/webapp/js/jquery.js create mode 100644 spring-boot-mvc/src/main/webapp/js/script-async-jquery.js create mode 100644 spring-boot-mvc/src/main/webapp/js/script-async.js create mode 100644 spring-boot-mvc/src/main/webapp/js/script.js create mode 100644 spring-boot-mvc/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java diff --git a/spring-boot-mvc/pom.xml b/spring-boot-mvc/pom.xml index b219e53431..bb3e6312ab 100644 --- a/spring-boot-mvc/pom.xml +++ b/spring-boot-mvc/pom.xml @@ -72,6 +72,16 @@ ${spring.fox.version} + + org.apache.tomcat.embed + tomcat-embed-jasper + provided + + + javax.servlet + jstl + + diff --git a/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java b/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java new file mode 100644 index 0000000000..2ffbb354c3 --- /dev/null +++ b/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/App.java @@ -0,0 +1,13 @@ +package com.baeldung.accessparamsjs; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class App { + + public static void main(String[] args) { + SpringApplication.run(App.class, args); + } + +} diff --git a/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java b/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java new file mode 100644 index 0000000000..cc838eb6a5 --- /dev/null +++ b/spring-boot-mvc/src/main/java/com/baeldung/accessparamsjs/Controller.java @@ -0,0 +1,32 @@ +package com.baeldung.accessparamsjs; + +import java.util.Map; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +/** + * Sample rest controller for the tutorial article + * "Access Spring MVC Model object in JavaScript". + * + * @author Andrew Shcherbakov + * + */ +@RestController +public class Controller { + + /** + * Define two model objects (one integer and one string) and pass them to the view. + * + * @param model + * @return + */ + @RequestMapping("/index") + public ModelAndView index(Map model) { + model.put("number", 1234); + model.put("message", "Hello from Spring MVC"); + return new ModelAndView("/index"); + } + +} diff --git a/spring-boot-mvc/src/main/resources/application.properties b/spring-boot-mvc/src/main/resources/application.properties index 709574239b..00362e2588 100644 --- a/spring-boot-mvc/src/main/resources/application.properties +++ b/spring-boot-mvc/src/main/resources/application.properties @@ -1 +1,3 @@ -spring.main.allow-bean-definition-overriding=true \ No newline at end of file +spring.main.allow-bean-definition-overriding=true +spring.mvc.view.prefix=/WEB-INF/jsp/ +spring.mvc.view.suffix=.jsp \ No newline at end of file diff --git a/spring-boot-mvc/src/main/webapp/WEB-INF/jsp/index.jsp b/spring-boot-mvc/src/main/webapp/WEB-INF/jsp/index.jsp new file mode 100644 index 0000000000..d9f3966e82 --- /dev/null +++ b/spring-boot-mvc/src/main/webapp/WEB-INF/jsp/index.jsp @@ -0,0 +1,27 @@ + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + +Access Spring MVC params + + + + + + +

Data from the external JS file (due to loading order)

+
+
+

Asynchronous loading from external JS file (plain JS)

+
+
+

Asynchronous loading from external JS file (jQuery)

+
+
+ + + + \ No newline at end of file diff --git a/spring-boot-mvc/src/main/webapp/js/jquery.js b/spring-boot-mvc/src/main/webapp/js/jquery.js new file mode 100644 index 0000000000..4d9b3a2587 --- /dev/null +++ b/spring-boot-mvc/src/main/webapp/js/jquery.js @@ -0,0 +1,2 @@ +/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+" "]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("object"!==t.nodeName.toLowerCase()){(c=t.getAttribute("id"))?c=c.replace(te,ne):t.setAttribute("id",c=b),s=(h=a(e)).length;while(s--)h[s]="#"+c+" "+ve(h[s]);v=h.join(","),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace(B,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function de(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-]").length||y.push("~="),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||y.push(".#.+[+~]")}),ue(function(e){e.innerHTML="";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(n.matchesSelector=Q.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),v.push("!=",W)}),y=y.length&&new RegExp(y.join("|")),v=v.length&&new RegExp(v.join("|")),t=Q.test(h.compareDocumentPosition),x=t||Q.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===d||e.ownerDocument===w&&x(w,e)?-1:t===d||t.ownerDocument===w&&x(w,t)?1:c?O(c,e)-O(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===d?-1:t===d?1:i?-1:o?1:c?O(c,e)-O(c,t):0;if(i===o)return ce(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?ce(a[r],s[r]):a[r]===w?-1:s[r]===w?1:0},d):d},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&p(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!y||!y.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,d,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==d&&p(e),x(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==d&&p(e);var i=r.attrHandle[t.toLowerCase()],o=i&&N.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(D),f){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return c=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return V.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace($," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase(),m=!u&&!s,x=!1;if(y){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===v:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&m){x=(d=(l=(c=(f=(p=y)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1])&&l[2],p=d&&y.childNodes[d];while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if(1===p.nodeType&&++x&&p===t){c[e]=[T,d,x];break}}else if(m&&(x=d=(l=(c=(f=(p=t)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1]),!1===x)while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===v:1===p.nodeType)&&++x&&(m&&((c=(f=p[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]=[T,x]),p===t))break;return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:de(!1),disabled:de(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return[0]}),last:he(function(e,t){return[t-1]}),eq:he(function(e,t,n){return[n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r-1&&(o[l]=!(a[l]=f))}}else v=we(v===a?v.splice(h,v.length):v),i?i(null,a,v,u):L.apply(a,v)})}function Ce(e){for(var t,n,i,o=e.length,a=r.relative[e[0].type],s=a||r.relative[" "],u=a?1:0,c=me(function(e){return e===t},s,!0),f=me(function(e){return O(t,e)>-1},s,!0),p=[function(e,n,r){var i=!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):f(e,n,r));return t=null,i}];u1&&xe(p),u>1&&ve(e.slice(0,u-1).concat({value:" "===e[u-2].type?"*":""})).replace(B,"$1"),n,u0,i=e.length>0,o=function(o,a,s,u,c){var f,h,y,v=0,m="0",x=o&&[],b=[],w=l,C=o||i&&r.find.TAG("*",c),E=T+=null==w?1:Math.random()||.1,k=C.length;for(c&&(l=a===d||a||c);m!==k&&null!=(f=C[m]);m++){if(i&&f){h=0,a||f.ownerDocument===d||(p(f),s=!g);while(y=e[h++])if(y(f,a||d,s)){u.push(f);break}c&&(T=E)}n&&((f=!y&&f)&&v--,o&&x.push(f))}if(v+=m,n&&m!==v){h=0;while(y=t[h++])y(x,b,a,s);if(o){if(v>0)while(m--)x[m]||b[m]||(b[m]=j.call(u));b=we(b)}L.apply(u,b),c&&!o&&b.length>0&&v+t.length>1&&oe.uniqueSort(u)}return c&&(T=E,l=w),x};return n?se(o):o}return s=oe.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=a(e)),n=t.length;while(n--)(o=Ce(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e}return o},u=oe.select=function(e,t,n,i){var o,u,l,c,f,p="function"==typeof e&&e,d=!i&&a(e=p.selector||e);if(n=n||[],1===d.length){if((u=d[0]=d[0].slice(0)).length>2&&"ID"===(l=u[0]).type&&9===t.nodeType&&g&&r.relative[u[1].type]){if(!(t=(r.find.ID(l.matches[0].replace(Z,ee),t)||[])[0]))return n;p&&(t=t.parentNode),e=e.slice(u.shift().value.length)}o=V.needsContext.test(e)?0:u.length;while(o--){if(l=u[o],r.relative[c=l.type])break;if((f=r.find[c])&&(i=f(l.matches[0].replace(Z,ee),K.test(u[0].type)&&ge(t.parentNode)||t))){if(u.splice(o,1),!(e=i.length&&ve(u)))return L.apply(n,i),n;break}}}return(p||s(e,d))(i,t,!g,n,!t||K.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(D).join("")===b,n.detectDuplicates=!!f,p(),n.sortDetached=ue(function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||le("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ue(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||le("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ue(function(e){return null==e.getAttribute("disabled")})||le(P,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),oe}(e);w.find=E,w.expr=E.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=E.uniqueSort,w.text=E.getText,w.isXMLDoc=E.isXML,w.contains=E.contains,w.escapeSelector=E.escape;var k=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&w(e).is(n))break;r.push(e)}return r},S=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},D=w.expr.match.needsContext;function N(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,t,n){return g(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return u.call(t,e)>-1!==n}):w.filter(t,e,n)}w.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?w.find.matchesSelector(r,e)?[r]:[]:w.find.matches(e,w.grep(t,function(e){return 1===e.nodeType}))},w.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(w(e).filter(function(){for(t=0;t1?w.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&D.test(e)?w(e):e||[],!1).length}});var q,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var i,o;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:r,!0)),A.test(i[1])&&w.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(o=r.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,q=w(r);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&w.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(w(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}w.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,n){return k(e,"parentNode",n)},next:function(e){return P(e,"nextSibling")},prev:function(e){return P(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,n){return k(e,"nextSibling",n)},prevUntil:function(e,t,n){return k(e,"previousSibling",n)},siblings:function(e){return S((e.parentNode||{}).firstChild,e)},children:function(e){return S(e.firstChild)},contents:function(e){return N(e,"iframe")?e.contentDocument:(N(e,"template")&&(e=e.content||e),w.merge([],e.childNodes))}},function(e,t){w.fn[e]=function(n,r){var i=w.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(O[e]||w.uniqueSort(i),H.test(e)&&i.reverse()),this.pushStack(i)}});var M=/[^\x20\t\r\n\f]+/g;function R(e){var t={};return w.each(e.match(M)||[],function(e,n){t[n]=!0}),t}w.Callbacks=function(e){e="string"==typeof e?R(e):w.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1){n=a.shift();while(++s-1)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?w.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=[e,(n=n||[]).slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l};function I(e){return e}function W(e){throw e}function $(e,t,n,r){var i;try{e&&g(i=e.promise)?i.call(e).done(t).fail(n):e&&g(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}w.extend({Deferred:function(t){var n=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},"catch":function(e){return i.then(null,e)},pipe:function(){var e=arguments;return w.Deferred(function(t){w.each(n,function(n,r){var i=g(e[r[4]])&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&g(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t=o&&(r!==W&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(w.Deferred.getStackHook&&(c.stackTrace=w.Deferred.getStackHook()),e.setTimeout(c))}}return w.Deferred(function(e){n[0][3].add(a(0,e,g(i)?i:I,e.notifyWith)),n[1][3].add(a(0,e,g(t)?t:I)),n[2][3].add(a(0,e,g(r)?r:W))}).promise()},promise:function(e){return null!=e?w.extend(e,i):i}},o={};return w.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),i=o.call(arguments),a=w.Deferred(),s=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?o.call(arguments):n,--t||a.resolveWith(r,i)}};if(t<=1&&($(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||g(i[n]&&i[n].then)))return a.then();while(n--)$(i[n],s(n),a.reject);return a.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&B.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},w.readyException=function(t){e.setTimeout(function(){throw t})};var F=w.Deferred();w.fn.ready=function(e){return F.then(e)["catch"](function(e){w.readyException(e)}),this},w.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==e&&--w.readyWait>0||F.resolveWith(r,[w]))}}),w.ready.then=F.then;function _(){r.removeEventListener("DOMContentLoaded",_),e.removeEventListener("load",_),w.ready()}"complete"===r.readyState||"loading"!==r.readyState&&!r.documentElement.doScroll?e.setTimeout(w.ready):(r.addEventListener("DOMContentLoaded",_),e.addEventListener("load",_));var z=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n)){i=!0;for(s in n)z(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,g(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(w(e),n)})),t))for(;s1,null,!0)},removeData:function(e){return this.each(function(){K.remove(this,e)})}}),w.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=J.get(e,t),n&&(!r||Array.isArray(n)?r=J.access(e,t,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=w.queue(e,t),r=n.length,i=n.shift(),o=w._queueHooks(e,t),a=function(){w.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:w.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),w.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}!function(){var e=r.createDocumentFragment().appendChild(r.createElement("div")),t=r.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),h.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w("