Radu/bael 1265 junit updates (#2965)

* Code for test article: Different Types of Bean Injection in Spring

* Adding jUnits for test article: Different Types of Bean Injection in Spring

* BAEL-1265: Adding jUnit for article

* BAEL-1265: Closing ExecutorService in jUnit

* BAEL-1265: Adding jUnit for CountDownLatch and example for ExecutorService.awaitTermination
This commit is contained in:
tamasradu
2017-11-06 03:46:29 +02:00
committed by maibin
parent 2e7d254adb
commit 90c2739563
8 changed files with 211 additions and 10 deletions
@@ -0,0 +1,35 @@
package com.baeldung.dependencyinjectiontypes;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class DependencyInjectionTest {
@Test
public void givenAutowiredAnnotation_WhenSetOnSetter_ThenDependencyValid() {
ApplicationContext context = new ClassPathXmlApplicationContext("dependencyinjectiontypes-context.xml");
ArticleWithSetterInjection article = (ArticleWithSetterInjection) context.getBean("articleWithSetterInjectionBean");
String originalText = "This is a text !";
String formattedArticle = article.format(originalText);
assertTrue(originalText.toUpperCase().equals(formattedArticle));
}
@Test
public void givenAutowiredAnnotation_WhenSetOnConstructor_ThenDependencyValid() {
ApplicationContext context = new ClassPathXmlApplicationContext("dependencyinjectiontypes-context.xml");
ArticleWithConstructorInjection article = (ArticleWithConstructorInjection) context.getBean("articleWithConstructorInjectionBean");
String originalText = "This is a text !";
String formattedArticle = article.format(originalText);
assertTrue(originalText.toUpperCase().equals(formattedArticle));
}
}