BAEL-3744: Corrected unit test class names; split unit tests into two
classes.
This commit is contained in:
parent
53183ba166
commit
7b47b484e9
|
@ -0,0 +1,36 @@
|
|||
package com.baeldung.spring.patterns.factory;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
public class AnnotationConfigApplicationContextUnitTest {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void whenGetSimpleBean_thenReturnConstructedBean() {
|
||||
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
|
||||
|
||||
Foo foo = context.getBean(Foo.class);
|
||||
|
||||
assertNotNull(foo);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void whenGetPrototypeBean_thenReturnConstructedBean() {
|
||||
|
||||
String expectedName = "Some name";
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
|
||||
|
||||
Bar bar = context.getBean(Bar.class, expectedName);
|
||||
|
||||
assertNotNull(bar);
|
||||
assertThat(bar.getName(), is(expectedName));
|
||||
}
|
||||
}
|
|
@ -6,34 +6,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
public class AnnotationConfigApplicationContextTest {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void whenGetSimpleBean_thenReturnConstructedBean() {
|
||||
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
|
||||
|
||||
Foo foo = context.getBean(Foo.class);
|
||||
|
||||
assertNotNull(foo);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void whenGetPrototypeBean_thenReturnConstructedBean() {
|
||||
|
||||
String expectedName = "Some name";
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
|
||||
|
||||
Bar bar = context.getBean(Bar.class, expectedName);
|
||||
|
||||
assertNotNull(bar);
|
||||
assertThat(bar.getName(), is(expectedName));
|
||||
}
|
||||
public class ClassPathXmlApplicationContextUnitTest {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
Loading…
Reference in New Issue