Skip to content

Instantly share code, notes, and snippets.

@bholagabbar
Created January 14, 2016 13:27
Show Gist options
  • Save bholagabbar/9ef0d06dadf483cb45dc to your computer and use it in GitHub Desktop.
Save bholagabbar/9ef0d06dadf483cb45dc to your computer and use it in GitHub Desktop.
LUI 45 test
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.web.controller;
import org.openmrs.User;
import org.openmrs.api.ConceptService;
import org.openmrs.test.BaseContextSensitiveTest;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;
import org.openmrs.web.test.BaseWebContextSensitiveTest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openmrs.api.context.Context;
import org.openmrs.web.controller.ForgotPasswordFormController;
import org.openmrs.web.test.BaseWebContextSensitiveTest;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import java.net.BindException;
/**
* Test the different aspects of
* {@link org.openmrs.web.controller.ForgotPasswordFormController}
*/
public class ForgotPasswordFormControllerTest extends BaseModuleWebContextSensitiveTest {
protected static final String TEST_DATA= "org/openmrs/web/controller/include/ForgotPasswordFormControllerTest.xml";
@Before
public void updateSearchIndex() {
super.updateSearchIndex();
}
/**
* Check to see if the admin's secret question comes back
*
* @throws Exception
*/
@Test
public void shouldNotNotFailOnNotFoundUsernameTEST() throws Exception {
executeDataSet(TEST_DATA);
ForgotPasswordFormController controller = (ForgotPasswordFormController) applicationContext.getBean("forgotPasswordForm");
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
request.setParameter("uname", "bruno");
request.setParameter("secretAnswer", "valid secret answer");
request.setMethod("POST");
controller.handleRequest(request, response);
Assert.assertEquals("what is your name bruno?", request.getParameter("secretQuestion"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment