From 58b01b624a25cb858a46a32d2b857aaf9c4af270 Mon Sep 17 00:00:00 2001 From: sharifi Date: Sun, 5 Dec 2021 13:58:51 +0330 Subject: [PATCH] bael-4197: add test class --- ...loyeeServiceAppContextIntegrationTest.java | 21 ++++++++++++++++ ...oyeeServiceTestContextIntegrationTest.java | 25 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java new file mode 100644 index 0000000000..7a63abf1a3 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceAppContextIntegrationTest.java @@ -0,0 +1,21 @@ +package com.baeldung.xmlapplicationcontext; + +import com.baeldung.xmlapplicationcontext.service.EmployeeService; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest(classes = XmlBeanApplication.class) +public class EmployeeServiceAppContextIntegrationTest { + + @Autowired + private EmployeeService service; + + @Test + public void whenContextLoads_thenServiceISNotNull() { + assertThat(service).isNotNull(); + } + +} diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java new file mode 100644 index 0000000000..9880c7c567 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/xmlapplicationcontext/EmployeeServiceTestContextIntegrationTest.java @@ -0,0 +1,25 @@ +package com.baeldung.xmlapplicationcontext; + +import com.baeldung.xmlapplicationcontext.service.EmployeeService; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest +@ContextConfiguration(locations = "/test-context.xml") +public class EmployeeServiceTestContextIntegrationTest { + + @Autowired + @Qualifier("employeeServiceTestImpl") + private EmployeeService serviceTest; + + @Test + public void whenTestContextLoads_thenServiceTestISNotNull() { + assertThat(serviceTest).isNotNull(); + } + +}