@Before public void setUp() throws Exception { // mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) // .build(); message = new Message(); event = new Event(); message.setMessageString("data successfully inserted!!!"); event.setEventTitle("test event"); event.setEventDate(Date.valueOf("2011-02-02")); event.setEventDesc("this is test event description"); Image photo = new Image(); /*MockMultipartFile file = new MockMultipartFile("image", "FooBar".getBytes());*/ /* FileInputStream test = new FileInputStream("EventManagment/Event_Image/Desert.png"); System.out.println("test image:"+test); MockMultipartFile file = new MockMultipartFile( "eventPhoto", test);*/ // multiPartRequest.addFile(new MockMultipartFile("dummyImage", "Desert.jpg","image/jpeg", new // byte[20971524] )); // System.out.println("test image file:"+file); // photo.setEventPhoto(file); event.setPhoto(photo); }
@Test @Override public void testInsert() { String actualMessage = "test fail"; try { EventVO eventVO = eventManager.craeteVOFromEvent(event); actualMessage = eventController.insert(eventVO, null).getMessageString(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(message.getMessageString(), actualMessage); }