當前位置: 首頁>>代碼示例>>Java>>正文


Java RandomStringUtils.randomAlphanumeric方法代碼示例

本文整理匯總了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;
    }
 
開發者ID:lmartire,項目名稱:DoApp,代碼行數:21,代碼來源:GenericPathPortURIGenerator.java

示例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;
    }
 
開發者ID:lmartire,項目名稱:DoApp,代碼行數:20,代碼來源:GenericPathPrefixPortURIGenerator.java

示例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();
    }
}
 
開發者ID:orshachar,項目名稱:known-issue,代碼行數:17,代碼來源:ExecutableMethodBuilder.java

示例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);
}
 
開發者ID:PatternFM,項目名稱:tokamak,代碼行數:8,代碼來源:AccountValidationTest.java

示例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;
    }
 
開發者ID:lmartire,項目名稱:DoApp,代碼行數:13,代碼來源:GenericPortURIGenerator.java

示例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();
}
 
開發者ID:amvnetworks,項目名稱:amv-access-api-poc,代碼行數:9,代碼來源:ErrorResponseDtoObjectMother.java

示例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);
}
 
開發者ID:conf4j,項目名稱:conf4j,代碼行數:9,代碼來源:EtcdFileConfigurationSourceTest.java

示例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;
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:14,代碼來源:TemplateUtils.java

示例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);
}
 
開發者ID:conf4j,項目名稱:conf4j,代碼行數:9,代碼來源:ConsulFileConfigurationSourceTest.java

示例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)));
}
 
開發者ID:amvnetworks,項目名稱:amv-highmobility-cryptotool-wrapper,代碼行數:14,代碼來源:CryptotoolUtilsTest.java

示例12: generateRandomString

import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
private static String generateRandomString() {
    return RandomStringUtils.randomAlphanumeric(20);
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:4,代碼來源:ExternalResourceAttributeReaderTest.java

示例13: aktorId

import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
protected String aktorId() {
    return RandomStringUtils.randomAlphanumeric(10);
}
 
開發者ID:navikt,項目名稱:fo-veilarbjobbsokerkompetanse,代碼行數:4,代碼來源:IntegrasjonsTest.java

示例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);
}
 
開發者ID:xm-online,項目名稱:xm-uaa,代碼行數:9,代碼來源:RandomUtil.java

示例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);
}
 
開發者ID:Microsoft,項目名稱:MTC_Labrat,代碼行數:10,代碼來源:RandomUtil.java


注:本文中的org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。