BAEL-865 - updated example code (#2029)
* added project files for evaluation article by smatt382@gmail.com * added project files for evaluation article by smatt382@gmail.com * added class com.baeldung.string.StringToCharStream by smatt382@gmail.com * updated the example codes. Use assert statements * updated example codes * fixed conflict in pom.xml * remove redundant files' * added unit test
This commit is contained in:
committed by
Zeger Hendrikse
parent
f18c993d71
commit
920167f5b7
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.beaninjection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class BeanInjectionApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.baeldung.beaninjection;
|
||||
|
||||
import com.baeldung.beaninjection.service.FileSystemStorageService;
|
||||
import com.baeldung.beaninjection.service.NetworkStorageService;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Created by smatt on 13/05/2017.
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class BeanInjectionUnitTests {
|
||||
|
||||
@Autowired
|
||||
NetworkStorageService networkStorageService;
|
||||
|
||||
@Autowired
|
||||
FileSystemStorageService fileSystemStorageService;
|
||||
|
||||
Logger logger = Logger.getLogger(BeanInjectionApplicationTests.class);
|
||||
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAutowiredOnClassConstructor_whenInstantiatingAndCallingGetter_thenDependencyShouldResolve() {
|
||||
Assert.assertNotNull("FileSystemStorageService not autowired in test class", fileSystemStorageService);
|
||||
Assert.assertNotNull("StorageProperties not autowired in FileSystemStorageService", fileSystemStorageService.getStorageProperties());
|
||||
logger.info(fileSystemStorageService.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAutowiredOnClassSetter_whenInstantiatingAndCallingGetter_thenDependencyShouldResolve() {
|
||||
Assert.assertNotNull("NetworkStorageService not autowired in test class", networkStorageService);
|
||||
Assert.assertNotNull("StorageProperties not autowired in NetworkStorageService", networkStorageService.getStorageProperties());
|
||||
logger.info(networkStorageService.toString());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user