當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。