Search in sources :

Example 1 with Employee

use of org.springframework.tests.sample.beans.Employee in project spring-framework by spring-projects.

the class ParameterizedDependencyInjectionTests method verifyPetAndEmployee.

@Test
public final void verifyPetAndEmployee() {
    invocationCount.incrementAndGet();
    // Verifying dependency injection:
    assertNotNull("The pet field should have been autowired.", this.pet);
    // Verifying 'parameterized' support:
    Employee employee = this.applicationContext.getBean(this.employeeBeanName, Employee.class);
    assertEquals("Name of the employee configured as bean [" + this.employeeBeanName + "].", this.employeeName, employee.getName());
}
Also used : Employee(org.springframework.tests.sample.beans.Employee) Test(org.junit.Test)

Example 2 with Employee

use of org.springframework.tests.sample.beans.Employee in project spring-framework by spring-projects.

the class ConcreteTransactionalTestNGSpringContextTests method verifyApplicationContextSet.

@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
void verifyApplicationContextSet() {
    assertInTransaction(false);
    assertNotNull(super.applicationContext, "The application context should have been set due to ApplicationContextAware semantics.");
    Employee employeeBean = (Employee) super.applicationContext.getBean("employee");
    assertEquals(employeeBean.getName(), "John Smith", "employee's name.");
}
Also used : Employee(org.springframework.tests.sample.beans.Employee) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Employee

use of org.springframework.tests.sample.beans.Employee in project spring-framework by spring-projects.

the class DevProfileConfig method employee.

@Bean
public Employee employee() {
    Employee employee = new Employee();
    employee.setName("John Smith");
    employee.setAge(42);
    employee.setCompany("Acme Widgets, Inc.");
    return employee;
}
Also used : Employee(org.springframework.tests.sample.beans.Employee) Bean(org.springframework.context.annotation.Bean)

Example 4 with Employee

use of org.springframework.tests.sample.beans.Employee in project spring-framework by spring-projects.

the class ParameterizedSpringRuleTests method verifyPetAndEmployee.

@Test
public final void verifyPetAndEmployee() {
    invocationCount.incrementAndGet();
    // Verifying dependency injection:
    assertNotNull("The pet field should have been autowired.", this.pet);
    // Verifying 'parameterized' support:
    Employee employee = this.applicationContext.getBean(this.employeeBeanName, Employee.class);
    assertEquals("Name of the employee configured as bean [" + this.employeeBeanName + "].", this.employeeName, employee.getName());
}
Also used : Employee(org.springframework.tests.sample.beans.Employee) Test(org.junit.Test)

Example 5 with Employee

use of org.springframework.tests.sample.beans.Employee in project spring-framework by spring-projects.

the class PojoAndStringConfig method employee.

@Bean
public Employee employee() {
    Employee employee = new Employee();
    employee.setName("John Smith");
    employee.setAge(42);
    employee.setCompany("Acme Widgets, Inc.");
    return employee;
}
Also used : Employee(org.springframework.tests.sample.beans.Employee) Bean(org.springframework.context.annotation.Bean)

Aggregations

Employee (org.springframework.tests.sample.beans.Employee)6 Test (org.junit.Test)3 Bean (org.springframework.context.annotation.Bean)2 ApplicationContext (org.springframework.context.ApplicationContext)1 GenericGroovyApplicationContext (org.springframework.context.support.GenericGroovyApplicationContext)1 Pet (org.springframework.tests.sample.beans.Pet)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Test (org.testng.annotations.Test)1