From dd91ef722bf3b1a8968a1ad719f2bd4b29f4818e Mon Sep 17 00:00:00 2001 From: Ahmad Alsanie Date: Mon, 20 Nov 2017 21:08:41 +0200 Subject: [PATCH] BAEL-1308 DI related code removed and included original text file --- core-java/src/test/resources/original | 2 ++ .../baeldung/ditypes/RegisterarConfig.java | 14 --------- .../java/com/baeldung/ditypes/Registrar.java | 18 ------------ .../main/java/com/baeldung/ditypes/User.java | 20 ------------- .../com/baeldung/ditypes/RegisterarTest.java | 29 ------------------- 5 files changed, 2 insertions(+), 81 deletions(-) create mode 100644 core-java/src/test/resources/original delete mode 100644 spring-core/src/main/java/com/baeldung/ditypes/RegisterarConfig.java delete mode 100644 spring-core/src/main/java/com/baeldung/ditypes/Registrar.java delete mode 100644 spring-core/src/main/java/com/baeldung/ditypes/User.java delete mode 100644 spring-core/src/test/java/com/baeldung/ditypes/RegisterarTest.java diff --git a/core-java/src/test/resources/original b/core-java/src/test/resources/original new file mode 100644 index 0000000000..cf8c89d389 --- /dev/null +++ b/core-java/src/test/resources/original @@ -0,0 +1,2 @@ +#Copy a File with Java (www.Baeldung.com) +Copying Files with Java is Fun! \ No newline at end of file diff --git a/spring-core/src/main/java/com/baeldung/ditypes/RegisterarConfig.java b/spring-core/src/main/java/com/baeldung/ditypes/RegisterarConfig.java deleted file mode 100644 index c1df1466f3..0000000000 --- a/spring-core/src/main/java/com/baeldung/ditypes/RegisterarConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.ditypes; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("com.baeldung.ditypes") -public class RegisterarConfig { - @Bean - public User user() { - return new User("Alice", 1); - } -} diff --git a/spring-core/src/main/java/com/baeldung/ditypes/Registrar.java b/spring-core/src/main/java/com/baeldung/ditypes/Registrar.java deleted file mode 100644 index 4406151c1b..0000000000 --- a/spring-core/src/main/java/com/baeldung/ditypes/Registrar.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.ditypes; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class Registrar { - private User user; - - @Autowired - public Registrar(User user) { - this.user = user; - } - - public String register() { - return user.register(); - } -} diff --git a/spring-core/src/main/java/com/baeldung/ditypes/User.java b/spring-core/src/main/java/com/baeldung/ditypes/User.java deleted file mode 100644 index b0120c7711..0000000000 --- a/spring-core/src/main/java/com/baeldung/ditypes/User.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.ditypes; - -import org.springframework.stereotype.Component; - -@Component -public class User { - - private String name; - private int id; - - public User(String name, int id) { - this.id = id; - this.name = name; - } - - public String register() { - return "User" + id + ": " + name + " is registered"; - } - -} diff --git a/spring-core/src/test/java/com/baeldung/ditypes/RegisterarTest.java b/spring-core/src/test/java/com/baeldung/ditypes/RegisterarTest.java deleted file mode 100644 index a0aea95a2b..0000000000 --- a/spring-core/src/test/java/com/baeldung/ditypes/RegisterarTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.ditypes; - -import static org.junit.Assert.*; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = RegisterarConfig.class) -public class RegisterarTest { - - @Autowired - private Registrar reg; - - @Autowired - private User user; - - @Test - public void givenAutowiredAnnotation_whenSetOnField_thenRegistrarIsInjected() { - assertNotNull(reg); - } - - @Test - public void givenAutowiredAnnotation_whenSetOnField_thenUserIsInjected() { - assertEquals("User1: Alice is registered", user.register()); - } -}