当前位置: 首页>>代码示例>>Java>>正文


Java RandomStringUtils.randomNumeric方法代码示例

本文整理汇总了Java中org.apache.commons.lang.RandomStringUtils.randomNumeric方法的典型用法代码示例。如果您正苦于以下问题:Java RandomStringUtils.randomNumeric方法的具体用法?Java RandomStringUtils.randomNumeric怎么用?Java RandomStringUtils.randomNumeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.RandomStringUtils的用法示例。


在下文中一共展示了RandomStringUtils.randomNumeric方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findListIndividuLdapDemo

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
/**
 * @return une liste de peopleLdap anonyme pour la recherche Ldap
 */
public List<PeopleLdap> findListIndividuLdapDemo(){
	List<PeopleLdap> liste = new ArrayList<PeopleLdap>();
	for (int i = 0;i<6;i++){
		String login = RandomStringUtils.randomAlphabetic(8).toLowerCase()+RandomStringUtils.randomNumeric(1);
		PeopleLdap people = new PeopleLdap(login,"displayName-"+login,"sn-"+login, "cn-"+login,
				"mail-"+login, null,"M.", "givenName-"+login);
		liste.add(people);
	}
	return liste;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:14,代码来源:DemoController.java

示例2: testUpdatePerson

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public void testUpdatePerson() throws Exception
{
    // Create a new person
    String userName  = RandomStringUtils.randomNumeric(6);                
    createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
                            "myJobTitle", "[email protected]", "myBio", "images/avatar.jpg", 0,
                            Status.STATUS_OK);
    
    // Update the person's details
    JSONObject result = updatePerson(userName, "updatedTitle", "updatedFirstName", "updatedLastName",
            "updatedOrganisation", "updatedJobTitle", "[email protected]", "updatedBio",
            "images/updatedAvatar.jpg", Status.STATUS_OK);

    assertEquals(userName, result.get("userName"));
    assertEquals("updatedFirstName", result.get("firstName"));
    assertEquals("updatedLastName", result.get("lastName"));
    assertEquals("updatedOrganisation", result.get("organization"));
    assertEquals("updatedJobTitle", result.get("jobtitle"));
    assertEquals("[email protected]", result.get("email"));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:PersonServiceTest.java

示例3: testCreatePerson

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public void testCreatePerson() throws Exception
{
    String userName  = RandomStringUtils.randomNumeric(6);
            
    // Create a new person
    JSONObject result = createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
                            "myJobTitle", "[email protected]", "myBio", "images/avatar.jpg", 0,
                            Status.STATUS_OK);        
    assertEquals(userName, result.get("userName"));
    assertEquals("myFirstName", result.get("firstName"));
    assertEquals("myLastName", result.get("lastName"));
    assertEquals("myOrganisation", result.get("organization"));
    assertEquals("myJobTitle", result.get("jobtitle"));
    assertEquals("[email protected]", result.get("email"));
    
    // Check for duplicate names
    createPerson(userName, "myTitle", "myFirstName", "mylastName", "myOrganisation",
            "myJobTitle", "myEmail", "myBio", "images/avatar.jpg", 0, 409);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:20,代码来源:PersonServiceTest.java

示例4: generateUserName

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
/**
 * Returns a generated user name
 * 
 * @return the generated user name
 */
public String generateUserName(String firstName, String lastName, String emailAddress, int seed)
{
	String userName;
	
 	String pattern = namePattern;
 	
 	String initial = firstName.toLowerCase().substring(0,1);
		
	userName = pattern
		.replace("%i%", initial)
		.replace("%firstName%", cleanseName(firstName))
		.replace("%lastName%", cleanseName(lastName))
		.replace("%emailAddress%", emailAddress.toLowerCase());
	
	if(seed > 0)
	{
		if (userName.length() < userNameLength + 3)
		{
		     userName = userName + RandomStringUtils.randomNumeric(3);	
		}
		else
		{
			// truncate the user name and slap on 3 random characters
			userName = userName.substring(0, userNameLength -3) + RandomStringUtils.randomNumeric(3);
		}
	}
	
    return userName;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:35,代码来源:NameBasedUserNameGenerator.java

示例5: testGetPerson

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public void testGetPerson() throws Exception
{
    // Get a person that doesn't exist
    Response response = sendRequest(new GetRequest(URL_PEOPLE + "/" + "nonExistantUser"), 404);
    
    // Create a person and get him/her
    String userName  = RandomStringUtils.randomNumeric(6);
    JSONObject result = createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
                            "myJobTitle", "myEmailAddress", "myBio", "images/avatar.jpg", 0, 200);
    response = sendRequest(new GetRequest(URL_PEOPLE + "/" + userName), 200);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:13,代码来源:PersonServiceTest.java

示例6: testDeletePerson

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public void testDeletePerson() throws Exception
{
    // Create a new person
    String userName  = RandomStringUtils.randomNumeric(6);                
    createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
                            "myJobTitle", "[email protected]", "myBio", "images/avatar.jpg", 0,
                            Status.STATUS_OK);
    
    // Delete the person
    deletePerson(userName, Status.STATUS_OK);
    
    // Make sure that the person has been deleted and no longer exists
    deletePerson(userName, Status.STATUS_NOT_FOUND);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:15,代码来源:PersonServiceTest.java

示例7: testCreatePersonMissingFirstName

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public void testCreatePersonMissingFirstName() throws Exception
{
    String userName  = RandomStringUtils.randomNumeric(6);
            
    // Create a new person with firstName == null (first name missing)
    createPerson(userName, "myTitle", null, "myLastName", "myOrganisation",
                    "myJobTitle", "[email protected]", "myBio", "images/avatar.jpg", 0,
                    Status.STATUS_BAD_REQUEST);        
    
    // Create a new person with firstName == "" (first name is blank)
    createPerson(userName, "myTitle", "", "myLastName", "myOrganisation",
                    "myJobTitle", "[email protected]", "myBio", "images/avatar.jpg", 0,
                    Status.STATUS_BAD_REQUEST);        
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:15,代码来源:PersonServiceTest.java

示例8: testDisableEnablePerson

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public void testDisableEnablePerson() throws Exception
{
    String userName = RandomStringUtils.randomNumeric(6);

    // Create a new person
    createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation", "myJobTitle", "[email protected]", "myBio",
            "images/avatar.jpg", 0, Status.STATUS_OK);

    String currentUser = this.authenticationComponent.getCurrentUserName();
    String adminUser = this.authenticationComponent.getSystemUserName();
    this.authenticationComponent.setCurrentUser(adminUser);

    // Check if user is enabled
    assertTrue("User isn't enabled", personService.isEnabled(userName));

    this.authenticationComponent.setCurrentUser(adminUser);
    // Disable user
    authenticationService.setAuthenticationEnabled(userName, false);

    this.authenticationComponent.setCurrentUser(adminUser);
    // Check user status
    assertFalse("User must be disabled", personService.isEnabled(userName));

    // Delete the person
    deletePerson(userName, Status.STATUS_OK);

    this.authenticationComponent.setCurrentUser(currentUser);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:29,代码来源:PersonServiceTest.java

示例9: createWALFactory

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
static WALFactory createWALFactory(Configuration conf, Path rootDir) throws IOException {
  Configuration confForWAL = new Configuration(conf);
  confForWAL.set(HConstants.HBASE_DIR, rootDir.toString());
  return new WALFactory(confForWAL,
      Collections.<WALActionsListener>singletonList(new MetricsWAL()),
      "hregion-" + RandomStringUtils.randomNumeric(8));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:TestHRegion.java

示例10: createRuleWithTwoRandomConditions

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public static Rule createRuleWithTwoRandomConditions(ConditionOperators ruleConditionsOperator, Operators conditionsOperator) {
    String conditionValue = RandomStringUtils.randomNumeric(2);
    Map conditions = ImmutableMap.of(conditionsOperator, Arrays.asList(conditionValue));
    return new RuleCreator(ruleConditionsOperator).createBasicRule
            (ImmutableMap.of(IdGenerator.generateId(), conditions,
                    IdGenerator.generateId(), conditions));
}
 
开发者ID:enableiot,项目名称:iotanalytics-gearpump-rule-engine,代码行数:8,代码来源:RuleCreator.java

示例11: generateVerificationCodeAndSet2Cache

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public String generateVerificationCodeAndSet2Cache() {
    String verificationCode = RandomStringUtils.randomNumeric(VERIFICATION_CODE_LENGTH);
    if (BooleanUtils.isTrue(tcConfig.isFixedVerificationCode())) {
        verificationCode = FIXED_VERIFICATION_CODE;
    }

    String sessionId = SecurityUtils.getSubject().getSession().getId().toString();
    String verificationCacheKey =
            tcCacheService.buildLogicKey(LOGIN_VERIFICATION_CODE_EXPIRE_TIME_COUNTER_GROUP, sessionId);
    tcCacheService.set(verificationCacheKey, verificationCode, LOGIN_VERIFICATION_CODE_EXPIRE_TIME_IN_MS);

    log.info("session id -> [{}] verification code -> [{}]", sessionId, verificationCode);
    return verificationCode;
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:15,代码来源:TcAuthenticationService.java

示例12: generateId

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
@Override
public Serializable generateId(Session session) {
    String id = UUID.randomUUID().toString() + RandomStringUtils.randomNumeric(16);
    if (log.isDebugEnabled()) {
        log.debug("tc cluster session id generator generate session id [{}]", id);
    }
    return id;
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:9,代码来源:TcClusterSessionIdGenerator.java

示例13: generateBillNo

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public static String generateBillNo(String prefix) {
	return prefix + DateFormatUtils.format(Calendar.getInstance(), "yyyyMMddHHmmssSSS") + RandomStringUtils.randomNumeric(5);
}
 
开发者ID:onsoul,项目名称:os,代码行数:4,代码来源:BillNoUtils.java

示例14: generateSalt

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public static String generateSalt() {
	return RandomStringUtils.randomNumeric(6);
}
 
开发者ID:onsoul,项目名称:os,代码行数:4,代码来源:PasswordUtils.java

示例15: generateUserName

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
/**
 * Returns a generated user name
 * 
 * @return the generated user name
 */
public String generateUserName(String firstName, String lastName, String emailAddress, int seed)
{
    String userName = RandomStringUtils.randomNumeric(getUserNameLength());
    return userName;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:RandomUserNameGenerator.java


注:本文中的org.apache.commons.lang.RandomStringUtils.randomNumeric方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。