From 72c39bab4c63f01da9703b079d0f099f67ef0d17 Mon Sep 17 00:00:00 2001 From: Ariel Papuga Date: Mon, 24 Jun 2019 23:09:44 +0200 Subject: [PATCH] BAEL-2921 Review: creation of spring-core-2 module --- pom.xml | 1 + spring-core-2/pom.xml | 60 +++++++++++++++++++ .../baeldung/getbean/AnnotationConfig.java | 0 .../main/java/com/baeldung/getbean/Lion.java | 0 .../main/java/com/baeldung/getbean/Tiger.java | 0 .../getbean/GetBeanByNameAndTypeUnitTest.java | 0 .../getbean/GetBeanByNameUnitTest.java | 4 +- ...NameWithConstructorParametersUnitTest.java | 18 ++++-- .../getbean/GetBeanByTypeUnitTest.java | 0 ...TypeWithConstructorParametersUnitTest.java | 0 10 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 spring-core-2/pom.xml rename {spring-core => spring-core-2}/src/main/java/com/baeldung/getbean/AnnotationConfig.java (100%) rename {spring-core => spring-core-2}/src/main/java/com/baeldung/getbean/Lion.java (100%) rename {spring-core => spring-core-2}/src/main/java/com/baeldung/getbean/Tiger.java (100%) rename {spring-core => spring-core-2}/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java (100%) rename {spring-core => spring-core-2}/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java (91%) rename {spring-core => spring-core-2}/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java (70%) rename {spring-core => spring-core-2}/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java (100%) rename {spring-core => spring-core-2}/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java (100%) diff --git a/pom.xml b/pom.xml index 9760e06bc1..aae8f500bb 100644 --- a/pom.xml +++ b/pom.xml @@ -659,6 +659,7 @@ spring-cloud-data-flow spring-core + spring-core-2 spring-cucumber spring-data-rest diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml new file mode 100644 index 0000000000..8e4c539e3b --- /dev/null +++ b/spring-core-2/pom.xml @@ -0,0 +1,60 @@ + + + + com.baeldung + parent-spring-5 + 0.0.1-SNAPSHOT + ../parent-spring-5 + + 4.0.0 + + spring-core-2 + + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-core + ${spring.version} + + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.1 + + + + + + 5.1.4.RELEASE + 5.0.2 + + + \ No newline at end of file diff --git a/spring-core/src/main/java/com/baeldung/getbean/AnnotationConfig.java b/spring-core-2/src/main/java/com/baeldung/getbean/AnnotationConfig.java similarity index 100% rename from spring-core/src/main/java/com/baeldung/getbean/AnnotationConfig.java rename to spring-core-2/src/main/java/com/baeldung/getbean/AnnotationConfig.java diff --git a/spring-core/src/main/java/com/baeldung/getbean/Lion.java b/spring-core-2/src/main/java/com/baeldung/getbean/Lion.java similarity index 100% rename from spring-core/src/main/java/com/baeldung/getbean/Lion.java rename to spring-core-2/src/main/java/com/baeldung/getbean/Lion.java diff --git a/spring-core/src/main/java/com/baeldung/getbean/Tiger.java b/spring-core-2/src/main/java/com/baeldung/getbean/Tiger.java similarity index 100% rename from spring-core/src/main/java/com/baeldung/getbean/Tiger.java rename to spring-core-2/src/main/java/com/baeldung/getbean/Tiger.java diff --git a/spring-core/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java similarity index 100% rename from spring-core/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java rename to spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java diff --git a/spring-core/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java similarity index 91% rename from spring-core/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java rename to spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java index 70a135b314..4d6d77e39d 100644 --- a/spring-core/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java +++ b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java @@ -21,9 +21,9 @@ class GetBeanByNameUnitTest { @Test void whenGivenExistingBeanName_shouldReturnThatBean() { - Object requestedBean = context.getBean("lion"); + Object lion = context.getBean("lion"); - assertEquals(requestedBean.getClass(), Lion.class); + assertEquals(lion.getClass(), Lion.class); } @Test diff --git a/spring-core/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java similarity index 70% rename from spring-core/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java rename to spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java index 4ac8c1ac13..32d37e4ff2 100644 --- a/spring-core/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java +++ b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java @@ -19,14 +19,20 @@ class GetBeanByNameWithConstructorParametersUnitTest { context = new AnnotationConfigApplicationContext(AnnotationConfig.class); } + @Test + void whenGivenCorrectName_thenShouldReturnBeanWithSpecifiedName() { + Tiger tiger = (Tiger) context.getBean("tiger", "Siberian"); + + assertEquals("Siberian", tiger.getName()); + } + @Test void whenGivenCorrectNameOrAlias_shouldReturnBeanWithSpecifiedName() { - Tiger tiger = (Tiger) context.getBean("tiger", "Cutie"); - Tiger tigerSecond = (Tiger) context.getBean("tiger", "Striped"); - Tiger tigerViaAlias = (Tiger) context.getBean("kitty", "Siberian"); - assertEquals("Cutie", tiger.getName()); - assertEquals("Striped", tigerSecond.getName()); - assertEquals("Siberian", tigerViaAlias.getName()); + Tiger tiger = (Tiger) context.getBean("tiger", "Siberian"); + Tiger secondTiger = (Tiger) context.getBean("tiger", "Striped"); + + assertEquals("Siberian", tiger.getName()); + assertEquals("Striped", secondTiger.getName()); } @Test diff --git a/spring-core/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java similarity index 100% rename from spring-core/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java rename to spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java diff --git a/spring-core/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java similarity index 100% rename from spring-core/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java rename to spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java