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:
+35
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user