本文整理汇总了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;
}
示例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"));
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
示例14: generateSalt
import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public static String generateSalt() {
return RandomStringUtils.randomNumeric(6);
}
示例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;
}