/
GuestListTests.java
39 lines (31 loc) · 1.03 KB
/
GuestListTests.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.af.springtests;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.af.flexonspring.chapter5.beanfactory.services.GuestListService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "applicationContext.xml")
public class GuestListTests implements ApplicationContextAware
{
private GuestListService guestListService;
private ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext applicationContext)
{
this.applicationContext = applicationContext;
}
@Before
public void init()
{
guestListService =
(GuestListService) applicationContext.getBean("guestListService");
}
@Test
public void testPrintGuestList()
{
guestListService.printGuestList();
}
}