gauravpaliwal

servlet

Jul 20th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. /**
  2. * The contents of this file are subject to the OpenMRS Public License
  3. * Version 1.0 (the "License"); you may not use this file except in
  4. * compliance with the License. You may obtain a copy of the License at
  5. * http://license.openmrs.org
  6. *
  7. * Software distributed under the License is distributed on an "AS IS"
  8. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  9. * License for the specific language governing rights and limitations
  10. * under the License.
  11. *
  12. * Copyright (C) OpenMRS, LLC. All Rights Reserved.
  13. */
  14.  
  15. package org.openmrs.module.feedback.web;
  16.  
  17. import org.openmrs.module.feedback.PredefinedSubject;
  18. import org.springframework.mock.web.MockHttpServletResponse;
  19. import org.springframework.mock.web.MockHttpServletRequest;
  20.  
  21. import javax.servlet.http.HttpServletResponse;
  22.  
  23. import org.openmrs.module.feedback.FeedbackService;
  24. import org.openmrs.web.test.BaseModuleWebContextSensitiveTest ;
  25. import org.openmrs.api.context.Context;
  26.  
  27. import java.util.Map;
  28. import javax.servlet.http.HttpServletRequest;
  29. import junit.framework.Assert;
  30.  
  31. import org.junit.After;
  32. import org.junit.AfterClass;
  33. import org.junit.Before;
  34. import org.junit.BeforeClass;
  35. import org.junit.Test;
  36.  
  37. import static org.junit.Assert.*;
  38.  
  39.  
  40. public class AddPredefinedSubjectFormControllerTest extends BaseModuleWebContextSensitiveTest {
  41.  
  42. private FeedbackService service;
  43. private FeedbackListController controller;
  44. private MockHttpServletRequest request;
  45. private HttpServletResponse response;
  46.  
  47. public AddPredefinedSubjectFormControllerTest() {
  48. }
  49.  
  50. @BeforeClass
  51. public static void setUpClass() throws Exception {
  52. }
  53.  
  54. @AfterClass
  55. public static void tearDownClass() throws Exception {
  56. }
  57.  
  58. @Before
  59. public void setUp() throws Exception {
  60. /*executed before the test is run*/
  61. this.service = Context.getService(FeedbackService.class);
  62. this.controller = new FeedbackListController();
  63. this.request = new MockHttpServletRequest();
  64. this.response = new MockHttpServletResponse();
  65. /*this file is in the same folder of test resources where the hibernate mapping file is located*/
  66. executeDataSet("PredefinedSubjectDataset.xml");
  67. /*Sample data is loaded into the system*/
  68. authenticate() ;
  69. }
  70.  
  71. @After
  72. public void tearDown() {
  73. }
  74.  
  75. /**
  76. * Test of formBackingObject method, of class AddPredefinedSubjectFormController.
  77. */
  78. @Test
  79. public void testFormBackingObject() throws Exception {
  80. System.out.println("formBackingObject");
  81. PredefinedSubject test = new PredefinedSubject() ;
  82.  
  83. /*This is to test that the exactly varchar(50) is allowed*/
  84. Assert.assertEquals("Test Sucessfull with dataset feedbackSeverityId : 3", service.getPredefinedSubject(3).getSubject() , "to_test_if_it_is_possible_to_enter_exactly_fifty_" ) ;
  85. }
  86.  
  87. /**
  88. * Test of referenceData method, of class AddPredefinedSubjectFormController.
  89. */
  90. @Test
  91. public void testReferenceData() throws Exception {
  92. System.out.println("referenceData");
  93. HttpServletRequest req = null;
  94. AddPredefinedSubjectFormController instance = new AddPredefinedSubjectFormController();
  95. Map expResult = null;
  96. Map result = instance.referenceData(req);
  97. // TODO review the generated test code and remove the default call to fail.
  98. fail("The test case is a prototype.");
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment