gauravpaliwal

Untitled

Jul 25th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 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 java.lang.String;
  18. import java.util.HashMap;
  19. import java.util.Iterator;
  20. import java.util.List;
  21. import java.util.Map;
  22.  
  23. import javax.servlet.http.HttpServletRequest;
  24. import javax.servlet.http.HttpServletResponse;
  25. import junit.framework.Assert;
  26.  
  27. import org.springframework.mock.web.MockHttpSession;
  28. import org.springframework.web.servlet.ModelAndView;
  29. import org.openmrs.module.feedback.PredefinedSubject;
  30. import org.springframework.mock.web.MockHttpServletResponse;
  31. import org.springframework.mock.web.MockHttpServletRequest;
  32.  
  33. import org.openmrs.module.feedback.FeedbackService;
  34. import org.openmrs.web.test.BaseModuleWebContextSensitiveTest ;
  35. import org.openmrs.api.context.Context;
  36.  
  37. import org.junit.After;
  38. import org.junit.AfterClass;
  39. import org.junit.Before;
  40. import org.junit.BeforeClass;
  41. import org.junit.Test;
  42.  
  43. import org.junit.Assert.* ;
  44.  
  45. public class PredefinedSubjectFormControllerTest extends BaseModuleWebContextSensitiveTest {
  46.  
  47. private FeedbackService service;
  48. private FeedbackListController controller;
  49. private MockHttpServletRequest request;
  50. private MockHttpServletResponse response;
  51. private Boolean expResult = false ;
  52. private Boolean result = true ;
  53.  
  54. public PredefinedSubjectFormControllerTest() {
  55. }
  56.  
  57. @BeforeClass
  58. public static void setUpClass() throws Exception {
  59. }
  60.  
  61. @AfterClass
  62. public static void tearDownClass() throws Exception {
  63. }
  64.  
  65. @Before
  66. public void setUp() throws Exception {
  67.  
  68. /*executed before the test is run*/
  69. this.service = Context.getService(FeedbackService.class);
  70. this.controller = new FeedbackListController();
  71. this.request = new MockHttpServletRequest();
  72. this.response = new MockHttpServletResponse();
  73. /*this file is in the same folder of test resources where the hibernate mapping file is located*/
  74. initializeInMemoryDatabase() ;
  75. executeDataSet("PredefinedSubjectDataset.xml");
  76. /*Sample data is loaded into the system*/
  77. authenticate() ;
  78. }
  79.  
  80. @After
  81. public void tearDown() {
  82. }
  83.  
  84. /**
  85. * Test of formBackingObject method, of class PredefinedSubjectFormController.
  86. */
  87. @Test
  88. public void testFormBackingObject() throws Exception {
  89. HttpServletRequest req = null;
  90. authenticate() ;
  91. AddPredefinedSubjectFormController instance = new AddPredefinedSubjectFormController();
  92. System.out.println("formBackingObject");
  93.  
  94. /*Trying to delete a element with the existing id*/
  95. this.request = new MockHttpServletRequest();
  96. ModelAndView mv = new ModelAndView();
  97. instance.setSuccessView("someValue") ;
  98. System.out.println(service.getPredefinedSubject(1).getSubject()) ;
  99. request.setSession(new MockHttpSession(null));
  100. request.setMethod("POST") ;
  101. Map<String,String> map = new HashMap<String,String>() ;
  102. map.put("predefinedsubjectid", "1");
  103. map.put("predefinedsubject", "testing");
  104. map.put("save","1") ;
  105. request.addParameters(map) ;
  106. mv = instance.handleRequest(request, response) ;
  107. System.out.println(service.getPredefinedSubject(1).getSubject()) ;
  108. System.out.println("Tholla") ;
  109.  
  110.  
  111. }
  112.  
  113. /**
  114. * Test of referenceData method, of class PredefinedSubjectFormController.
  115.  
  116. @Test
  117. public void testReferenceData() throws Exception {
  118. System.out.println("referenceData");
  119. HttpServletRequest req = null;
  120. PredefinedSubjectFormController instance = new PredefinedSubjectFormController();
  121. Map expResult = null;
  122. Map result = instance.referenceData(req);
  123. assertEquals(expResult, result);
  124. // TODO review the generated test code and remove the default call to fail.
  125. fail("The test case is a prototype.");
  126. }
  127. * */
  128. }
Advertisement
Add Comment
Please, Sign In to add comment