本文整理匯總了Java中org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric方法的典型用法代碼示例。如果您正苦於以下問題:Java RandomStringUtils.randomAlphanumeric方法的具體用法?Java RandomStringUtils.randomAlphanumeric怎麽用?Java RandomStringUtils.randomAlphanumeric使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.RandomStringUtils
的用法示例。
在下文中一共展示了RandomStringUtils.randomAlphanumeric方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSemivalidSchemeHostPortPathURIMalIntent
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public static MalIntent getSemivalidSchemeHostPortPathURIMalIntent(IntentDataInfo datafield) {
MalIntent mal = new MalIntent(datafield);
String scheme = datafield.scheme;
String host = datafield.host;
host = host.replace("*", RandomStringUtils.randomAlphanumeric(10));
String port = datafield.port;
String path = datafield.path;
String semiValidPath;
if (path.charAt(0) == '/')
semiValidPath = path + "/" + RandomStringUtils.randomAlphanumeric(10);
else
semiValidPath = "/" + path + "/" + RandomStringUtils.randomAlphanumeric(10);
mal.setData(Uri.parse(scheme + "://" + host + ":" + port + semiValidPath));
return mal;
}
示例2: getSemivalidSchemeHostPortPathPrefixURIMalIntent
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public static MalIntent getSemivalidSchemeHostPortPathPrefixURIMalIntent(IntentDataInfo datafield) {
MalIntent mal = new MalIntent(datafield);
String scheme = datafield.scheme;
String host = datafield.host;
host = host.replace("*", RandomStringUtils.randomAlphanumeric(10));
String port = datafield.port;
String pathPrefix = datafield.pathPrefix;
String semivalidPathPrefix;
if (pathPrefix.charAt(pathPrefix.length() - 1) != '/')
semivalidPathPrefix = pathPrefix + "/" + RandomStringUtils.randomAlphanumeric(10);
else
semivalidPathPrefix = pathPrefix + RandomStringUtils.randomAlphanumeric(10);
mal.setData(Uri.parse(scheme + "://" + host + ":" + port + semivalidPathPrefix));
return mal;
}
示例3: downloadFile
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
private File downloadFile(HttpResponse response) {
File dir = new File("downloadedFiles");
if (!dir.exists()) {
dir.mkdir();
}
File outputFile = new File("downloadedFiles/temp" + RandomStringUtils.randomAlphanumeric(3));
try {
IOUtils.copyLarge(response.getEntity().getContent(), new FileOutputStream(outputFile));
return outputFile;
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
request.releaseConnection();
}
}
示例4: shouldNotBeAbleToCreateAnAccountIfTheUsernameIsAlreadyInUse
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Test
public void shouldNotBeAbleToCreateAnAccountIfTheUsernameIsAlreadyInUse() {
String username = RandomStringUtils.randomAlphanumeric(15);
account().withUsername(username).save();
onCreate(account().withUsername(username).build()).rejected().withError("ACC-0003", "This account username is already in use.", ResourceConflictException.class);
}
示例5: getSemivalidSchemeHostPortURIMalIntent
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public static MalIntent getSemivalidSchemeHostPortURIMalIntent(IntentDataInfo datafield){
MalIntent mal = new MalIntent(datafield);
String scheme = datafield.scheme;
String host = datafield.host;
host = host.replace("*", RandomStringUtils.randomAlphanumeric(10));
String semivalidPort = datafield.port+"/"+RandomStringUtils.randomAlphanumeric(10);
mal.setData(Uri.parse(scheme+ "://" + host + ":" + semivalidPort ));
return mal;
}
示例6: randomErrorInfo
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
private static ErrorResponseDto.ErrorInfoDto randomErrorInfo() {
String randomString = RandomStringUtils.randomAlphanumeric(5);
return ErrorResponseDto.ErrorInfoDto.builder()
.title("test title " + randomString)
.detail("test detail " + randomString)
.source("test source " + randomString)
.build();
}
示例7: testConfigLoadedWithJsonFile
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Test
public void testConfigLoadedWithJsonFile() throws Exception {
String filePath = "test.json";
String expectedMessage = RandomStringUtils.randomAlphanumeric(12);
putFileInEtcd(filePath, String.format("{\"message\":\"%s\"}", expectedMessage));
testConfigLoaded(filePath, expectedMessage);
}
示例8: processTemplate
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public static File processTemplate(File template) throws IOException, TemplateException {
Configuration config = new Configuration();
config.setDirectoryForTemplateLoading(template.getParentFile());
config.setObjectWrapper(new DefaultObjectWrapper());
config.setDefaultEncoding("UTF-8");
Template temp = config.getTemplate(template.getName());
String child = template.getName() + RandomStringUtils.randomAlphanumeric(8);
File fileOutput = new File(template.getParentFile(), child);
Writer fileWriter = new FileWriter(fileOutput);
Map<Object, Object> currentSession = Thucydides.getCurrentSession();
temp.process(currentSession, fileWriter);
return fileOutput;
}
示例9: testConfigLoadedWithHoconFile
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Test
public void testConfigLoadedWithHoconFile() throws Exception {
String filePath = "test.conf";
String expectedMessage = RandomStringUtils.randomAlphanumeric(12);
putFileInConsul(filePath, String.format("message:%s", expectedMessage));
testConfigLoaded(filePath, expectedMessage);
}
示例10: exception
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@ExceptionHandler(Exception.class)
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public XAPIErrorInfo exception(final HttpServletRequest request, Exception e) throws Exception {
final String logMessageReferenceId = RandomStringUtils.randomAlphanumeric(8);
final XAPIErrorInfo result = new XAPIErrorInfo(HttpStatus.INTERNAL_SERVER_ERROR, request, "Unexpected error [reference ID: " + logMessageReferenceId + "].");
logger.debug("Unexpected XAPI exception [refId: {}]: {}", logMessageReferenceId, e);
this.logError(result);
return result;
}
開發者ID:Apereo-Learning-Analytics-Initiative,項目名稱:OpenLRW,代碼行數:11,代碼來源:XAPIExceptionHandlerAdvice.java
示例11: decodingAndEncodingFromAndToHexShouldBeTheSame
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Test
public void decodingAndEncodingFromAndToHexShouldBeTheSame() {
String value = RandomStringUtils.randomAlphanumeric(1000);
String valueBase64 = Base64.getEncoder().encodeToString(value.getBytes(Charsets.UTF_8));
String valueHex = CryptotoolUtils.decodeBase64AsHex(valueBase64);
String valueBase64Again = CryptotoolUtils.encodeHexAsBase64(valueHex);
assertThat(valueBase64Again, is(equalTo(valueBase64)));
String valueAgain = new String(Base64.getDecoder().decode(valueBase64Again.getBytes(Charsets.UTF_8)), Charsets.UTF_8);
assertThat(valueAgain, is(equalTo(value)));
}
示例12: generateRandomString
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
private static String generateRandomString() {
return RandomStringUtils.randomAlphanumeric(20);
}
示例13: aktorId
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
protected String aktorId() {
return RandomStringUtils.randomAlphanumeric(10);
}
示例14: generatePassword
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
/**
* Generate a password.
*
* @return the generated password
*/
public static String generatePassword() {
return RandomStringUtils.randomAlphanumeric(DEF_COUNT);
}
示例15: generateSeriesData
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
/**
* Generate a unique series to validate a persistent token, used in the
* authentication remember-me mechanism.
*
* @return the generated series data
*/
public static String generateSeriesData() {
return RandomStringUtils.randomAlphanumeric(DEF_COUNT);
}