3
3
import org .junit .Before ;
4
4
import org .junit .Test ;
5
5
import org .junit .runner .RunWith ;
6
- import org .mockito .InjectMocks ;
7
6
import org .mockito .Mock ;
8
7
import org .mockito .MockitoAnnotations ;
9
8
import org .springframework .beans .factory .annotation .Autowired ;
10
- import org .springframework .beans .factory .annotation .Qualifier ;
11
9
import org .springframework .boot .test .context .SpringBootTest ;
12
10
import org .springframework .context .annotation .Bean ;
13
11
import org .springframework .context .annotation .Configuration ;
14
12
import org .springframework .context .annotation .Primary ;
15
13
import org .springframework .context .support .ClassPathXmlApplicationContext ;
16
- import org .springframework .dao .support .DaoSupport ;
17
- import org .springframework .test .context .ActiveProfiles ;
18
14
import org .springframework .test .context .ContextConfiguration ;
19
15
import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
20
- import org .springframework .test .context .junit4 .SpringRunner ;
21
-
22
16
import com .Polodz .View .MainWindow ;
23
17
import com .Polodz .controller .Controller ;
24
18
import com .Polodz .controller .IController ;
25
19
import com .Polodz .controller .MainController ;
26
- import com .Polodz .model .MembersBeanFactory ;
27
20
import com .Polodz .model .MembersDAO ;
28
21
29
- import junit . framework .Assert ;
22
+ import org . junit .Assert ;
30
23
import static org .mockito .Mockito .*;
31
24
32
- import org .mockito .runners .MockitoJUnitRunner ;
33
-
34
- @ SuppressWarnings ("deprecation" )
35
- //@RunWith(MockitoJUnitRunner.class)
36
-
37
- @ RunWith (SpringJUnit4ClassRunner .class )//(SpringJUnit4ClassRunner.class)//(SpringRunner.class)
25
+ @ RunWith (SpringJUnit4ClassRunner .class )
38
26
@ ContextConfiguration (locations ={"file:src/test/resources/Grown-mainContext.xml" }, loader =CustomSpringApplicationContextLoader .class )
39
27
@ SpringBootTest
40
- //@ActiveProfiles("test")
41
- //@ContextConfiguration(locations = {"classpath*:spring/mocksContext.xml"})
42
- //@ContextConfiguration
43
- //@ActiveProfiles("test")
44
28
@ Configuration
29
+ //@ActiveProfiles("test")
45
30
public class GrownApplicationTests {
46
31
private ClassPathXmlApplicationContext context ;
47
- //@InjectMocks
32
+
48
33
@ Autowired
49
34
private MainController mainControler ;
50
- //@InjectMocks
35
+
51
36
@ Autowired
52
37
private MembersDAO mtcDAO ;
53
- // private BtcsBeanFactory btcsBeanFactory ;
38
+ // private BeanFactory BeanFactory ;
54
39
@ Mock
55
40
private IController IController ;
56
41
@@ -59,26 +44,19 @@ public class GrownApplicationTests {
59
44
60
45
@ Before
61
46
public void setup (){
62
- MockitoAnnotations .initMocks (this ); //@RunWith(MockitoJUnitRunner.class).
63
- //context= new ClassPathXmlApplicationContext("file:src/EasyMTC-contextTestBF.xml");//file:classpath*
64
- //mtcDAO= context.getBean("mtcDAOF",MtcDAO.class);
65
- //mainControler= context.getBean("mainController",MainController.class);
66
- //mtcDAO= (MtcDAO)context.getBean("mtcDAO");
67
-
47
+ MockitoAnnotations .initMocks (this );
68
48
when (IController .execute ("list" )).thenReturn ("test\n test\n test\n test\n test\n test" );
69
49
when (IController .execute ("test items" )).thenReturn ("mtest\n mtest\n mtest\n mtest\n mtest\n mtest" );
70
50
reset (IController );
71
- //btcsBeanFactory = context.getBean(BtcsBeanFactory .class);
51
+ //BeanFactory = context.getBean(BeanFactory .class);
72
52
}
73
- @ SuppressWarnings ( "deprecation" )
53
+
74
54
@ Test
75
55
public void contextLoads () {
76
56
Assert .assertEquals (mainControler .listAll ().size (), 6 );
77
57
Assert .assertEquals (mainControler .listAll ().get (1 ).getName (), "test" );
78
58
Assert .assertEquals (mainControler .getMtcResponse ("list" ), "test\n test\n test\n test\n test\n test" );
79
- //Assert.assertEquals(mtcDAO.getALL().length, 86);
80
- //Assert.assertEquals(mtcDAO.getALL()[85].getName(), "bsc183"); //Aware of spaces!
81
- //Assert.assertEquals(btcsBeanFactory.getObjectType(), MtcDAO.class);
59
+ //Assert.assertEquals(BeanFactory.getObjectType(), DAO.class);
82
60
}
83
61
84
62
@ Bean
@@ -88,9 +66,7 @@ public IController iController() {
88
66
IController =mock (Controller .class );
89
67
when (IController .execute ("list" )).thenReturn ("test\n test\n test\n test\n test\n test"
90
68
+ "" );
91
-
92
69
}
93
-
94
70
return IController ;
95
71
}
96
72
0 commit comments