Skip to content

Commit aaff507

Browse files
tomeqtomeq
authored andcommitted
Main Test Clarify
1 parent 48ba637 commit aaff507

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed

src/test/java/com/Polodz/GrownApplicationTests.java

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,39 @@
33
import org.junit.Before;
44
import org.junit.Test;
55
import org.junit.runner.RunWith;
6-
import org.mockito.InjectMocks;
76
import org.mockito.Mock;
87
import org.mockito.MockitoAnnotations;
98
import org.springframework.beans.factory.annotation.Autowired;
10-
import org.springframework.beans.factory.annotation.Qualifier;
119
import org.springframework.boot.test.context.SpringBootTest;
1210
import org.springframework.context.annotation.Bean;
1311
import org.springframework.context.annotation.Configuration;
1412
import org.springframework.context.annotation.Primary;
1513
import org.springframework.context.support.ClassPathXmlApplicationContext;
16-
import org.springframework.dao.support.DaoSupport;
17-
import org.springframework.test.context.ActiveProfiles;
1814
import org.springframework.test.context.ContextConfiguration;
1915
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
20-
import org.springframework.test.context.junit4.SpringRunner;
21-
2216
import com.Polodz.View.MainWindow;
2317
import com.Polodz.controller.Controller;
2418
import com.Polodz.controller.IController;
2519
import com.Polodz.controller.MainController;
26-
import com.Polodz.model.MembersBeanFactory;
2720
import com.Polodz.model.MembersDAO;
2821

29-
import junit.framework.Assert;
22+
import org.junit.Assert;
3023
import static org.mockito.Mockito.*;
3124

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)
3826
@ContextConfiguration(locations={"file:src/test/resources/Grown-mainContext.xml"}, loader=CustomSpringApplicationContextLoader.class)
3927
@SpringBootTest
40-
//@ActiveProfiles("test")
41-
//@ContextConfiguration(locations = {"classpath*:spring/mocksContext.xml"})
42-
//@ContextConfiguration
43-
//@ActiveProfiles("test")
4428
@Configuration
29+
//@ActiveProfiles("test")
4530
public class GrownApplicationTests {
4631
private ClassPathXmlApplicationContext context;
47-
//@InjectMocks
32+
4833
@Autowired
4934
private MainController mainControler;
50-
//@InjectMocks
35+
5136
@Autowired
5237
private MembersDAO mtcDAO;
53-
// private BtcsBeanFactory btcsBeanFactory;
38+
// private BeanFactory BeanFactory;
5439
@Mock
5540
private IController IController;
5641

@@ -59,26 +44,19 @@ public class GrownApplicationTests {
5944

6045
@Before
6146
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);
6848
when(IController.execute("list")).thenReturn("test\ntest\ntest\ntest\ntest\ntest");
6949
when(IController.execute("test items")).thenReturn("mtest\nmtest\nmtest\nmtest\nmtest\nmtest");
7050
reset(IController);
71-
//btcsBeanFactory= context.getBean(BtcsBeanFactory.class);
51+
//BeanFactory= context.getBean(BeanFactory.class);
7252
}
73-
@SuppressWarnings("deprecation")
53+
7454
@Test
7555
public void contextLoads() {
7656
Assert.assertEquals(mainControler.listAll().size(), 6);
7757
Assert.assertEquals(mainControler.listAll().get(1).getName(), "test");
7858
Assert.assertEquals(mainControler.getMtcResponse("list"), "test\ntest\ntest\ntest\ntest\ntest");
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);
8260
}
8361

8462
@Bean
@@ -88,9 +66,7 @@ public IController iController() {
8866
IController=mock(Controller.class);
8967
when(IController.execute("list")).thenReturn("test\ntest\ntest\ntest\ntest\ntest"
9068
+ "");
91-
9269
}
93-
9470
return IController;
9571
}
9672

0 commit comments

Comments
 (0)