Java tutorial
/** * The contents of this file are subject to the OpenMRS Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://license.openmrs.org * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Copyright (C) OpenMRS, LLC. All Rights Reserved. */ package org.openmrs.module.feedback.web; //~--- non-JDK imports -------------------------------------------------------- import junit.framework.Assert; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.openmrs.api.context.Context; import org.openmrs.module.feedback.FeedbackService; import org.openmrs.module.feedback.Severity; import org.openmrs.web.test.BaseModuleWebContextSensitiveTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpSession; import org.springframework.web.servlet.ModelAndView; //~--- JDK imports ------------------------------------------------------------ import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class FeedbackListControllerTest extends BaseModuleWebContextSensitiveTest { private Boolean expResult = false; private Boolean result = true; private FeedbackAdminListController controller; private MockHttpServletRequest request; private HttpServletResponse response; private FeedbackService service; public FeedbackListControllerTest() { } @BeforeClass public static void setUpClass() throws Exception { } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() throws Exception { /* executed before the test is run */ this.service = Context.getService(FeedbackService.class); this.controller = new FeedbackAdminListController(); this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); /* this file is in the same folder of test resources where the hibernate mapping file is located */ initializeInMemoryDatabase(); executeDataSet("FeedbackDataset.xml"); /* Sample data is loaded into the system */ authenticate(); } @After public void tearDown() { } /** * Nothing to test this method do nothing * Test of formBackingObject method, of class FeedbackListController. * * @Test * public void testFormBackingObject() throws Exception { * System.out.println("formBackingObject"); * HttpServletRequest request = null; * FeedbackListController instance = new FeedbackListController(); * String expResult = ""; * String result = instance.formBackingObject(request); * Assert.assertEquals(expResult, result); * // TODO review the generated test code and remove the default call to fail. * Assert.fail("The test case is a prototype."); * } * * */ /** * Test of referenceData method, of class FeedbackListController. */ @Test public void testReferenceData() throws Exception { System.out.println("referenceData"); HttpServletRequest req = null; FeedbackAdminListController instance = new FeedbackAdminListController(); Map expResult = null; Map result = instance.referenceData(req); /* to checl wheather the data is sent or not binded into the key feedback */ if (!result.containsKey("feedbacks")) { Assert.fail("Do not contain the object feedbacks"); } } } //~ Formatted by Jindent --- http://www.jindent.com