本文整理汇总了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);
}