diff --git a/spring-core/src/main/java/com/baeldung/configuration/ConstructorConfig.java b/spring-core/src/main/java/com/baeldung/configuration/ConstructorConfig.java deleted file mode 100644 index e1ebdcedca..0000000000 --- a/spring-core/src/main/java/com/baeldung/configuration/ConstructorConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.configuration; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.baeldung.model.College; -import com.baeldung.model.Student; - -@Configuration -public class ConstructorConfig { - - @Bean - public Student student() { - return new Student(1, "John", college()); - } - - @Bean - public College college() { - return new College(1, "New York"); - } -} diff --git a/spring-core/src/main/java/com/baeldung/configuration/SetterConfig.java b/spring-core/src/main/java/com/baeldung/configuration/SetterConfig.java deleted file mode 100644 index caaa70ee46..0000000000 --- a/spring-core/src/main/java/com/baeldung/configuration/SetterConfig.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.configuration; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.baeldung.model.College; -import com.baeldung.model.Student; - -@Configuration -public class SetterConfig { - - @Bean - public Student student() { - Student student = new Student(); - student.setId(2); - student.setName("Tom"); - student.setCollege(college()); - return student; - } - - @Bean - public College college() { - College college = new College(); - college.setId(2); - college.setName("Pittsburgh"); - return college; - } -} diff --git a/spring-core/src/main/java/com/baeldung/model/College.java b/spring-core/src/main/java/com/baeldung/model/College.java deleted file mode 100644 index 0e55561fe7..0000000000 --- a/spring-core/src/main/java/com/baeldung/model/College.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.model; - -public class College { - - private int id; - private String name; - - public College() { - } - - public College(int id, String name) { - this.id = id; - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/model/Student.java b/spring-core/src/main/java/com/baeldung/model/Student.java deleted file mode 100644 index 46f01cd32d..0000000000 --- a/spring-core/src/main/java/com/baeldung/model/Student.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baeldung.model; - -public class Student { - - private int id; - private String name; - private College college; - - public Student() { - } - - public Student(int id, String name, College college) { - this.id = id; - this.name = name; - this.college = college; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public College getCollege() { - return college; - } - - public void setCollege(College college) { - this.college = college; - } - - public void introduceMyself() { - System.out.println("My ID is " + id + " and my name is " + name + ". I am a student at " + college.getName() + " College."); - } - -} diff --git a/spring-core/src/test/java/com/baeldung/configuration/ConstructorConfigTest.java b/spring-core/src/test/java/com/baeldung/configuration/ConstructorConfigTest.java deleted file mode 100644 index 5a80b8266b..0000000000 --- a/spring-core/src/test/java/com/baeldung/configuration/ConstructorConfigTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.configuration; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.model.Student; - -public class ConstructorConfigTest { - - @Test - public void whenContextLoaded_thenDependencyInjected() { - ApplicationContext context = new AnnotationConfigApplicationContext(ConstructorConfig.class); - Student student = context.getBean(Student.class); - assertEquals(1, student.getId()); - assertEquals("John", student.getName()); - assertEquals(1, student.getCollege().getId()); - assertEquals("New York", student.getCollege().getName()); - } -} diff --git a/spring-core/src/test/java/com/baeldung/configuration/SetterConfigTest.java b/spring-core/src/test/java/com/baeldung/configuration/SetterConfigTest.java deleted file mode 100644 index 3d11c42e50..0000000000 --- a/spring-core/src/test/java/com/baeldung/configuration/SetterConfigTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.configuration; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -import com.baeldung.model.Student; - -public class SetterConfigTest { - - @Test - public void whenContextLoaded_thenDependencyInjected() { - ApplicationContext context = new AnnotationConfigApplicationContext(SetterConfig.class); - Student student = context.getBean(Student.class); - assertEquals(2, student.getId()); - assertEquals("Tom", student.getName()); - assertEquals(2, student.getCollege().getId()); - assertEquals("Pittsburgh", student.getCollege().getName()); - } -}