The SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring

This commit is contained in:
michaelin007 2023-12-26 15:17:28 +00:00
parent f36e38d1f1
commit 922b77106c
3 changed files with 0 additions and 67 deletions

View File

@ -1,33 +0,0 @@
package com.baeldung.jupiter;
import static org.junit.Assert.assertNotNull;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* @SpringJUnitConfig(SpringJUnitConfigTest.Config.class) is equivalent to:
*
* @ExtendWith(SpringExtension.class)
* @ContextConfiguration(classes = SpringJUnitConfigTest.Config.class )
*
*/
@SpringJUnitConfig(SpringJUnitConfigIntegrationTest.Config.class)
public class SpringJUnitConfigIntegrationTest {
@Configuration
static class Config {
}
@Autowired
private ApplicationContext applicationContext;
@Test
void givenAppContext_WhenInjected_ThenItShouldNotBeNull() {
assertNotNull(applicationContext);
}
}

View File

@ -1,34 +0,0 @@
package com.baeldung.jupiter;
import static org.junit.Assert.assertNotNull;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
import org.springframework.web.context.WebApplicationContext;
/**
* @SpringJUnitWebConfig(SpringJUnitWebConfigTest.Config.class) is equivalent to:
*
* @ExtendWith(SpringExtension.class)
* @WebAppConfiguration
* @ContextConfiguration(classes = SpringJUnitWebConfigTest.Config.class )
*
*/
@SpringJUnitWebConfig(SpringJUnitWebConfigIntegrationTest.Config.class)
public class SpringJUnitWebConfigIntegrationTest {
@Configuration
static class Config {
}
@Autowired
private WebApplicationContext webAppContext;
@Test
void givenWebAppContext_WhenInjected_ThenItShouldNotBeNull() {
assertNotNull(webAppContext);
}
}