From ae47827879d0e9396ad5de5f979f495629a35838 Mon Sep 17 00:00:00 2001 From: alv21 Date: Thu, 8 Feb 2018 19:15:56 +0100 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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 931dc2ae18577e9189ba83e44f2344b087c1563f Mon Sep 17 00:00:00 2001 From: alv21 Date: Fri, 25 Jan 2019 21:15:59 -0800 Subject: [PATCH 05/10] 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 4c1c93e1f698c06137de54737fb11fc828b27857 Mon Sep 17 00:00:00 2001 From: alv21 Date: Sat, 26 Jan 2019 09:14:27 -0800 Subject: [PATCH 06/10] 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 822b09baab5b1a4080bf8311c2e562f46397b2a0 Mon Sep 17 00:00:00 2001 From: ciro Date: Tue, 29 Jan 2019 11:31:15 -0800 Subject: [PATCH 07/10] 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 7c5da0c07c4b8ac053899abf1b00c0c2c557e686 Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Sat, 9 Feb 2019 11:18:47 -0800 Subject: [PATCH 08/10] Update spring-soap/pom.xml Co-Authored-By: alv21 --- spring-soap/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-soap/pom.xml b/spring-soap/pom.xml index 54a1d86038..68ea7711fc 100644 --- a/spring-soap/pom.xml +++ b/spring-soap/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework + com.baeldung spring-soap 1.0.0 From 31f858f3baaa46d1e6d459b42a18166d60ecfa1d Mon Sep 17 00:00:00 2001 From: ciro Date: Sun, 10 Feb 2019 17:12:04 -0800 Subject: [PATCH 09/10] review changes --- spring-soap/pom.xml | 2 +- .../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 -- .../ApplicationIntegrationTest.java | 1 - 8 files changed, 1 insertion(+), 407 deletions(-) delete mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/Country.java delete mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/Currency.java delete mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryRequest.java delete mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryResponse.java delete mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/ObjectFactory.java delete mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/gen/package-info.java diff --git a/spring-soap/pom.xml b/spring-soap/pom.xml index 68ea7711fc..2865a4c3bc 100644 --- a/spring-soap/pom.xml +++ b/spring-soap/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.5.RELEASE + 2.1.2.RELEASE 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 deleted file mode 100644 index e3eb686d6b..0000000000 --- a/spring-soap/src/main/java/com/baeldung/springsoap/gen/Country.java +++ /dev/null @@ -1,144 +0,0 @@ -// -// 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 deleted file mode 100644 index 9b0660466f..0000000000 --- a/spring-soap/src/main/java/com/baeldung/springsoap/gen/Currency.java +++ /dev/null @@ -1,47 +0,0 @@ -// -// 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 deleted file mode 100644 index 7e1f151929..0000000000 --- a/spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryRequest.java +++ /dev/null @@ -1,71 +0,0 @@ -// -// 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 deleted file mode 100644 index 38c49193b4..0000000000 --- a/spring-soap/src/main/java/com/baeldung/springsoap/gen/GetCountryResponse.java +++ /dev/null @@ -1,71 +0,0 @@ -// -// 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 deleted file mode 100644 index 6b9691efc0..0000000000 --- a/spring-soap/src/main/java/com/baeldung/springsoap/gen/ObjectFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -// -// 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 deleted file mode 100644 index 9638be3d94..0000000000 --- a/spring-soap/src/main/java/com/baeldung/springsoap/gen/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -// -// 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/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java b/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java index 18c8a96576..0bde6f94aa 100644 --- a/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java +++ b/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java @@ -1,6 +1,5 @@ package com.baeldung.springsoap; -import com.baeldung.springsoap.gen.GetCountryRequest; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; From 29e492342e9d0479a2a7b81803a7a1d25e079514 Mon Sep 17 00:00:00 2001 From: Ciro Alvino Date: Sun, 10 Feb 2019 17:13:27 -0800 Subject: [PATCH 10/10] Update ApplicationIntegrationTest.java --- .../com/baeldung/springsoap/ApplicationIntegrationTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java b/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java index 0bde6f94aa..3b071c286f 100644 --- a/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java +++ b/spring-soap/src/test/java/com/baeldung/springsoap/ApplicationIntegrationTest.java @@ -1,5 +1,6 @@ package com.baeldung.springsoap; +import com.baeldung.springsoap.gen.GetCountryRequest; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -35,4 +36,4 @@ public class ApplicationIntegrationTest { assertThat(ws.marshalSendAndReceive("http://localhost:" + port + "/ws", request)).isNotNull(); } -} \ No newline at end of file +}