<commit_before>package edu.columbia.gemma.controller.common.auditAndSecurity;

import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.ResourceBundle;

import javax.servlet.ServletConfig;

import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
import org.springframework.validation.BindException;
import org.springframework.web.context.support.StaticWebApplicationContext;
import org.springframework.web.servlet.ModelAndView;

import edu.columbia.gemma.BaseControllerTestCase;
import edu.columbia.gemma.common.auditAndSecurity.User;
import edu.columbia.gemma.common.auditAndSecurity.UserRole;
import edu.columbia.gemma.common.auditAndSecurity.UserService;
import edu.columbia.gemma.web.controller.common.auditAndSecurity.SignupController;

/**
 * 
 * 
 *
 * <hr>
 * <p>Copyright (c) 2004 - 2005 Columbia University
 * @author keshav
 * @version $Id$
 */
public class SignupControllerTest extends BaseControllerTestCase{
    
    private MockServletContext mockCtx;
    private MockHttpServletRequest request;
    private MockHttpServletResponse response;

    SignupController signupController;
    
    User testUser;
    UserRole ur;
    UserService userService;

    public void setUp() throws Exception {
        
        mockCtx = new MockServletContext();
        
        request = new MockHttpServletRequest();
        response = new MockHttpServletResponse();
        
        signupController = ( SignupController ) ctx.getBean( "signupController" );
        
        testUser = User.Factory.newInstance();
        ur = UserRole.Factory.newInstance();
        userService = ( UserService ) ctx.getBean( "userService" );
        
    }

    public void tearDown() {
        signupController = null;
    }

    public void testOnSubmit() throws Exception {

        request.setContextPath( "/Gemma" );
        request.setServletPath("/test.signup.html");
        request.setLocalName("en_US");
        
        String rand = ( new Date() ).toString();

        String adminName = "admin";
        String userName = "user";
        User checkUser = userService.getUser( adminName );

        if ( ( checkUser == null ) ) {
            testUser.setUserName( adminName );
            ur.setUserName( adminName );
            ur.setName( adminName );
            
        } else {
            testUser.setUserName( rand );
            ur.setUserName( rand );
            ur.setName( userName );
        }

        Collection set = new HashSet();
        testUser.setUserRoles( set );

        testUser.setPassword( "<PASSWORD>" );
        testUser.setConfirmPassword( "root" );
        testUser.setPasswordHint( "<PASSWORD>" );

        testUser.getUserRoles().add( ur );

        
        
        ModelAndView mav = signupController.onSubmit( request, response, testUser, (BindException) null);

        //assertEquals( "pubMedList", mav.getViewName() );
        assertEquals( null, null );

    }
    
    protected String[] getConfigLocations() {

        ResourceBundle db = ResourceBundle.getBundle( "testResources" );
        String daoType = db.getString( "dao.type" );
        String servletContext = db.getString( "servlet.name.0" );
        // Make sure you have the /web on the junit classpath.
        String[] paths = { "applicationContext-dataSource.xml", "applicationContext-" + daoType + ".xml",
                servletContext + "-servlet.xml" };

        return paths;
    }

}<commit_msg>changed collection to list<commit_after>package edu.columbia.gemma.controller.common.auditAndSecurity;

import java.util.Date;
import java.util.HashSet;
import java.util.ResourceBundle;
import java.util.Set;

import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;

import edu.columbia.gemma.BaseControllerTestCase;
import edu.columbia.gemma.common.auditAndSecurity.User;
import edu.columbia.gemma.common.auditAndSecurity.UserRole;
import edu.columbia.gemma.common.auditAndSecurity.UserService;
import edu.columbia.gemma.web.controller.common.auditAndSecurity.SignupController;

/**
 * 
 * 
 *
 * <hr>
 * <p>Copyright (c) 2004 - 2005 Columbia University
 * @author keshav
 * @version $Id$
 */
public class SignupControllerTest extends BaseControllerTestCase{
    
    private MockServletContext mockCtx;
    private MockHttpServletRequest request;
    private MockHttpServletResponse response;

    SignupController signupController;
    
    User testUser;
    UserRole ur;
    UserService userService;

    public void setUp() throws Exception {
        
        mockCtx = new MockServletContext();
        
        request = new MockHttpServletRequest();
        response = new MockHttpServletResponse();
        
        signupController = ( SignupController ) ctx.getBean( "signupController" );
        
        testUser = User.Factory.newInstance();
        ur = UserRole.Factory.newInstance();
        userService = ( UserService ) ctx.getBean( "userService" );
        
    }

    public void tearDown() {
        signupController = null;
    }

    public void testOnSubmit() throws Exception {

        request.setContextPath( "/Gemma" );
        request.setServletPath("/test.signup.html");
        request.setLocalName("en_US");
        
        String rand = ( new Date() ).toString();

        String adminName = "admin";
        String userName = "user";
        User checkUser = userService.getUser( adminName );

        if ( ( checkUser == null ) ) {
            testUser.setUserName( adminName );
            ur.setUserName( adminName );
            ur.setName( adminName );
            
        } else {
            testUser.setUserName( rand );
            ur.setUserName( rand );
            ur.setName( userName );
        }

        Set set = new HashSet();
        testUser.setUserRoles( set );

        testUser.setPassword( "<PASSWORD>" );
        testUser.setConfirmPassword( "root" );
        testUser.setPasswordHint( "<PASSWORD>" );

        testUser.getUserRoles().add( ur );

        
        
        ModelAndView mav = signupController.onSubmit( request, response, testUser, (BindException) null);

        //assertEquals( "pubMedList", mav.getViewName() );
        assertEquals( null, null );

    }
    
    protected String[] getConfigLocations() {

        ResourceBundle db = ResourceBundle.getBundle( "testResources" );
        String daoType = db.getString( "dao.type" );
        String servletContext = db.getString( "servlet.name.0" );
        // Make sure you have the /web on the junit classpath.
        String[] paths = { "applicationContext-dataSource.xml", "applicationContext-" + daoType + ".xml",
                servletContext + "-servlet.xml" };

        return paths;
    }

}
{'fraction_non_alphanumeric': 0.10469059056230573, 'fraction_numerical': 0.002543091268719977, 'mean_word_length': 2.7896145610278373, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4445466', 'n_tokens_mistral': 1987, 'n_tokens_neox': 1948, 'n_words': 405}