Clean my test article

This commit is contained in:
Dassi Orleando
2017-08-25 12:36:28 +01:00
parent 114c10c09f
commit 4f827b93ed
10 changed files with 0 additions and 264 deletions
-1
View File
@@ -212,7 +212,6 @@
<module>spring-spel</module>
<module>spring-state-machine</module>
<module>spring-thymeleaf</module>
<module>spring-types-bean-injection</module>
<module>spring-userservice</module>
<module>spring-zuul</module>
<module>spring-reactor</module>
-3
View File
@@ -1,3 +0,0 @@
## Relevant articles:
- [Constructor Dependency Injection in Spring](http://www.baeldung.com/constructor-injection-in-spring)
-81
View File
@@ -1,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>spring-types-bean-injection</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-types-bean-injection</name>
<description>Types of bean injection in spring</description>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludes>
<exclude>**/*LiveTest.java</exclude>
</excludes>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<test.mime>json</test.mime>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<java.version>1.8</java.version>
<spring.version>4.3.10.RELEASE</spring.version>
<junit.version>4.12</junit.version>
</properties>
</project>
@@ -1,25 +0,0 @@
package com.baeldung.config;
import com.baeldung.service.MegaTestService;
import com.baeldung.service.SuperTestService;
import com.baeldung.service.TestService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AppConfig {
@Bean
public TestService TestService() {
return new TestService();
}
@Bean
public SuperTestService SuperTestService() {
return new SuperTestService(new TestService());
}
@Bean
public MegaTestService MegaTestService() {
return new MegaTestService();
}
}
@@ -1,22 +0,0 @@
package com.baeldung.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class MegaTestService {
private TestService testService;
@Autowired
public void setTestService(TestService testService) {
this.testService = testService;
}
public String getMegaTestOne() {
return "Mega" + testService.getTestOne();
}
public String getMegaTestTwo() {
return "Mega" + testService.getTestTwo();
}
}
@@ -1,22 +0,0 @@
package com.baeldung.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class SuperTestService {
private TestService testService;
@Autowired
public SuperTestService(TestService testService) {
this.testService = testService;
}
public String getSuperTestOne() {
return "Super" + testService.getTestOne();
}
public String getSuperTestTwo() {
return "Super" + testService.getTestTwo();
}
}
@@ -1,14 +0,0 @@
package com.baeldung.service;
import org.springframework.stereotype.Service;
@Service
public class TestService {
public String getTestOne() {
return "TestOne";
}
public String getTestTwo() {
return "TestTwo";
}
}
@@ -1,32 +0,0 @@
package com.baeldung.service;
import com.baeldung.config.AppConfig;
import 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.SpringRunner;
import static org.hamcrest.CoreMatchers.is;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {AppConfig.class})
public class MegaTestServiceIntegrationTest {
@Autowired
MegaTestService megaTestService;
@Test
public void whenCallingGetMegaTestOne_thenWeGetMegaTestOneString() {
String resultOne = megaTestService.getMegaTestOne();
Assert.assertThat(resultOne, is("MegaTestOne"));
}
@Test
public void whenCallingGetMegaTestTwo_thenWeGetMegaTestTwoString() {
String resultTwo = megaTestService.getMegaTestTwo();
Assert.assertThat(resultTwo, is("MegaTestTwo"));
}
}
@@ -1,32 +0,0 @@
package com.baeldung.service;
import com.baeldung.config.AppConfig;
import 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.SpringRunner;
import static org.hamcrest.CoreMatchers.is;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {AppConfig.class})
public class SuperTestServiceIntegrationTest {
@Autowired
SuperTestService superTestService;
@Test
public void whenCallingGetSuperTestOne_thenWeGetSuperTestOneString() {
String resultOne = superTestService.getSuperTestOne();
Assert.assertThat(resultOne, is("SuperTestOne"));
}
@Test
public void whenCallingGetSuperTestTwo_thenWeGetSuperTestTwoString() {
String resultTwo = superTestService.getSuperTestTwo();
Assert.assertThat(resultTwo, is("SuperTestTwo"));
}
}
@@ -1,32 +0,0 @@
package com.baeldung.service;
import com.baeldung.config.AppConfig;
import 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.SpringRunner;
import static org.hamcrest.CoreMatchers.is;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = { AppConfig.class })
public class TestServiceIntegrationTest {
@Autowired
TestService testService;
@Test
public void whenCallingGetTestOne_thenWeGetTestOneString() {
String resultOne = testService.getTestOne();
Assert.assertThat(resultOne, is("TestOne"));
}
@Test
public void whenCallingGetTestTwo_thenWeGetTestTwoString() {
String resultTwo = testService.getTestTwo();
Assert.assertThat(resultTwo, is("TestTwo"));
}
}