类org.springframework.test.context.junit.jupiter.comics.Person源码实例Demo

下面列出了怎么用org.springframework.test.context.junit.jupiter.comics.Person的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spring-analysis-note   文件: PersonController.java
@GetMapping("/person/{id}")
Person getPerson(@PathVariable long id) {
	if (id == 42) {
		return new Person("Dilbert");
	}
	return new Person("Wally");
}
 
@Autowired
SpringJUnitJupiterAutowiredConstructorInjectionTests(ApplicationContext applicationContext, Person dilbert, Dog dog,
		@Value("${enigma}") Integer enigma) {

	this.applicationContext = applicationContext;
	this.dilbert = dilbert;
	this.dog = dog;
	this.enigma = enigma;
}
 
TestConstructorAnnotationIntegrationTests(ApplicationContext applicationContext, Person dilbert, Dog dog,
		@Value("${enigma}") Integer enigma) {

	this.applicationContext = applicationContext;
	this.dilbert = dilbert;
	this.dog = dog;
	this.enigma = enigma;
}
 
@Test
void genericApplicationContextInjectedIntoMethod(
		GenericApplicationContext applicationContext) {
	assertNotNull(applicationContext,
			"GenericApplicationContext should have been injected by Spring");
	assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}
 
/**
 * NOTE: Test code must be compiled with "-g" (debug symbols) or "-parameters" in
 * order for the parameter name to be used as the qualifier; otherwise, use
 * {@code @Qualifier("wally")}.
 */
@Test
void autowiredParameterWithImplicitQualifierBasedOnParameterName(
		@Autowired Person wally) {
	assertNotNull(wally, "Wally should have been @Autowired by Spring");
	assertEquals("Wally", wally.getName(), "Person's name");
}
 
SpringJUnitJupiterConstructorInjectionTests(ApplicationContext applicationContext, @Autowired Person dilbert,
		@Autowired Dog dog, @Value("${enigma}") Integer enigma, TestInfo testInfo) {

	this.applicationContext = applicationContext;
	this.dilbert = dilbert;
	this.dog = dog;
	this.enigma = enigma;
	this.testInfo = testInfo;
}
 
源代码7 项目: java-technology-stack   文件: PersonController.java
@GetMapping("/person/{id}")
Person getPerson(@PathVariable long id) {
	if (id == 42) {
		return new Person("Dilbert");
	}
	return new Person("Wally");
}
 
@Autowired
SpringJUnitJupiterAutowiredConstructorInjectionTests(ApplicationContext applicationContext, Person dilbert, Dog dog,
		@Value("${enigma}") Integer enigma) {

	this.applicationContext = applicationContext;
	this.dilbert = dilbert;
	this.dog = dog;
	this.enigma = enigma;
}
 
@Test
void genericApplicationContextInjectedIntoMethod(
		GenericApplicationContext applicationContext) {
	assertNotNull(applicationContext,
			"GenericApplicationContext should have been injected by Spring");
	assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}
 
/**
 * NOTE: Test code must be compiled with "-g" (debug symbols) or "-parameters" in
 * order for the parameter name to be used as the qualifier; otherwise, use
 * {@code @Qualifier("wally")}.
 */
@Test
void autowiredParameterWithImplicitQualifierBasedOnParameterName(
		@Autowired Person wally) {
	assertNotNull(wally, "Wally should have been @Autowired by Spring");
	assertEquals("Wally", wally.getName(), "Person's name");
}
 
SpringJUnitJupiterConstructorInjectionTests(ApplicationContext applicationContext, @Autowired Person dilbert,
		@Autowired Dog dog, @Value("${enigma}") Integer enigma, TestInfo testInfo) {

	this.applicationContext = applicationContext;
	this.dilbert = dilbert;
	this.dog = dog;
	this.enigma = enigma;
	this.testInfo = testInfo;
}
 
源代码12 项目: spring-test-junit5   文件: PersonController.java
@GetMapping("/person/{id}")
Person getPerson(@PathVariable long id) {
	if (id == 42) {
		return new Person("Dilbert");
	}
	return new Person("Wally");
}
 
@Autowired
SpringJUnit5AutowiredConstructorInjectionTests(ApplicationContext applicationContext, Person dilbert, Dog dog,
		@Value("${enigma}") Integer enigma) {

	this.applicationContext = applicationContext;
	this.dilbert = dilbert;
	this.dog = dog;
	this.enigma = enigma;
}
 
SpringJUnit5ConstructorInjectionTests(ApplicationContext applicationContext, @Autowired Person dilbert,
		@Autowired Dog dog, @Value("${enigma}") Integer enigma, TestInfo testInfo) {

	this.applicationContext = applicationContext;
	this.dilbert = dilbert;
	this.dog = dog;
	this.enigma = enigma;
	this.testInfo = testInfo;
}
 
源代码15 项目: spring-analysis-note   文件: TestConfig.java
@Bean
Person dilbert() {
	return new Person("Dilbert");
}
 
源代码16 项目: spring-analysis-note   文件: TestConfig.java
@Bean
Person wally() {
	return new Person("Wally");
}
 
@Test
void applicationContextInjectedIntoMethod(ApplicationContext applicationContext) {
	assertNotNull(applicationContext, "ApplicationContext should have been injected by Spring");
	assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}
 
@Test
void genericApplicationContextInjectedIntoMethod(GenericApplicationContext applicationContext) {
	assertNotNull(applicationContext, "GenericApplicationContext should have been injected by Spring");
	assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}
 
@Test
void autowiredParameterWithExplicitQualifier(@Qualifier("wally") Person person) {
	assertNotNull(person, "Wally should have been @Autowired by Spring");
	assertEquals("Wally", person.getName(), "Person's name");
}
 
/**
 * NOTE: Test code must be compiled with "-g" (debug symbols) or "-parameters" in order
 * for the parameter name to be used as the qualifier; otherwise, use
 * {@code @Qualifier("wally")}.
 */
@Test
void autowiredParameterWithImplicitQualifierBasedOnParameterName(@Autowired Person wally) {
	assertNotNull(wally, "Wally should have been @Autowired by Spring");
	assertEquals("Wally", wally.getName(), "Person's name");
}
 
@Test
void autowiredParameterOfList(@Autowired List<Person> peopleParam) {
	assertNotNull(peopleParam, "list of people should have been @Autowired by Spring");
	assertEquals(2, peopleParam.size(), "Number of people in context");
}
 
@Test
@DisplayName("ApplicationContext injected into method")
void applicationContextInjected(ApplicationContext applicationContext) {
	assertNotNull(applicationContext, "ApplicationContext should have been injected into method by Spring");
	assertEquals(dilbert, applicationContext.getBean("dilbert", Person.class));
}
 
@Test
void applicationContextInjected() {
	assertNotNull(applicationContext, "ApplicationContext should have been injected by Spring");
	assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}
 
@Test
void applicationContextInjected() {
	assertNotNull(applicationContext, "ApplicationContext should have been injected by Spring");
	assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}
 
@Test
void applicationContextInjectedIntoMethod(ApplicationContext applicationContext) {
	assertNotNull(applicationContext,
			"ApplicationContext should have been injected by Spring");
	assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}
 
@Test
void autowiredParameterWithExplicitQualifier(@Qualifier("wally") Person person) {
	assertNotNull(person, "Wally should have been @Autowired by Spring");
	assertEquals("Wally", person.getName(), "Person's name");
}
 
@Test
void autowiredParameterOfList(@Autowired List<Person> peopleParam) {
	assertNotNull(peopleParam,
			"list of people should have been @Autowired by Spring");
	assertEquals(2, peopleParam.size(), "Number of people in context");
}
 
@Test
void applicationContextInjected() {
	assertNotNull(applicationContext, "ApplicationContext should have been injected by Spring");
	assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}
 
源代码29 项目: java-technology-stack   文件: TestConfig.java
@Bean
Person dilbert() {
	return new Person("Dilbert");
}
 
源代码30 项目: java-technology-stack   文件: TestConfig.java
@Bean
Person wally() {
	return new Person("Wally");
}
 
 同包方法