Example usage for org.apache.commons.lang RandomStringUtils randomAlphanumeric

List of usage examples for org.apache.commons.lang RandomStringUtils randomAlphanumeric

Introduction

In this page you can find the example usage for org.apache.commons.lang RandomStringUtils randomAlphanumeric.

Prototype

public static String randomAlphanumeric(int count) 

Source Link

Document

Creates a random string whose length is the number of characters specified.

Characters will be chosen from the set of alpha-numeric characters.

Usage

From source file:com.boyuanitsm.fort.service.util.RandomUtil.java

/**
 * Generates a app secret.//from   w w w.ja v a2  s.  c o  m
 *
 * @return the generated app secret
 */
public static String generateAppSecret() {
    return RandomStringUtils.randomAlphanumeric(APP_SECRET_COUNT).toLowerCase();
}

From source file:com.watchrabbit.scanner.generator.strategy.BasicPasswordGenerator.java

@Override
public FieldValue generate(List<String> descriptions, List<String> words) {
    return new FieldValue.Builder().withFormality(Formality.AVERAGE)
            .withValue(RandomStringUtils.randomAlphanumeric(6) + "a5").build();
}

From source file:com.redhat.rhn.taskomatic.task.test.ErrataQueueTest.java

public void testErrataQueue() throws Exception {

    ErrataQueue eq = new ErrataQueue();
    String suffix = RandomStringUtils.randomAlphanumeric(5);
    TaskoBunch bunch = new TaskoBunch();
    TaskoTemplate template = new TaskoTemplate();
    TaskoTask task = new TaskoTask();
    bunch.setName("testBunchName_" + suffix);
    task.setName("testTaskName_" + suffix);
    task.setTaskClass(ErrataQueue.class.toString());
    template.setTask(task);/* www  .j a va2 s  .  c  o m*/
    template.setOrdering(0L);
    template.setBunch(bunch);
    TaskoFactory.save(template.getBunch());
    TaskoFactory.save(template.getTask());
    TaskoFactory.save(template);
    TaskoRun run = new TaskoRun(null, template, new Long(1));
    eq.execute(null, run);
    // Just a simple test to make sure we get here without
    // exceptions.  Better than nothin'
    assertTrue(true);
    TaskoFactory.delete(run);
    TaskoFactory.delete(template);
    TaskoFactory.delete(template.getBunch());
    TaskoFactory.delete(template.getTask());
    commitAndCloseSession();
    commitHappened();
}

From source file:com.xtructure.xutil.test.UTestAbstractXmlTest_Wrapper.java

public void replaceHookReturnsAsExpected() {
    String format = RandomStringUtils.randomAlphanumeric(10) + "%s" + RandomStringUtils.randomAlphanumeric(10);
    String replacement = RandomStringUtils.randomAlphanumeric(10);
    String hook = String.format(format, Wrapper.ELEMENT_HOOK_NAME);
    String replace = String.format(format, replacement);
    assertThat("", //
            Wrapper.replaceHook(hook, replacement), isEqualTo(replace));
}

From source file:com.xtructure.xutil.valid.comp.UTestAbstractComparisonCondition.java

License:asdf

public void isSatisfiedByBehavesAsExpected() {
    boolean valid = RandomUtil.nextBoolean();
    String value = RandomStringUtils.randomAlphanumeric(10);
    String object = RandomStringUtils.randomAlphanumeric(10);
    DummyComparisonCondition predicate = new DummyComparisonCondition(value);
    predicate.setrVal(valid);/*from   ww  w. j  ava 2s  .co  m*/
    if (valid != predicate.isSatisfiedBy(object) || predicate.getCall() != 1
            || !predicate.getLast().equals(object)) {
        throw new AssertionError();
    }
    if (predicate.isSatisfiedBy(new Object())) {
        throw new AssertionError();
    }
}

From source file:fi.csc.mobileauth.comm.CommonsEventIdGenerator.java

public String generateEventId(String prefix) {
    String eventId = prefix.toUpperCase();
    String randomPart = RandomStringUtils.randomAlphanumeric(idLength - prefix.length()).toUpperCase();
    return eventId.concat(randomPart);
}

From source file:com.falcon.orca.data.generators.impl.StringGenerator.java

@Override
public String next() {
    if (StringUtils.isBlank(characters)) {
        if (letters && numbers) {
            return RandomStringUtils.randomAlphanumeric(length);
        } else {/*from  w  w  w.j  a  va  2  s.  c o m*/
            if (letters) {
                return RandomStringUtils.randomAlphabetic(length);
            } else if (numbers) {
                return RandomStringUtils.randomAlphanumeric(length);
            }
        }
    } else {
        return RandomStringUtils.random(length, 0, characters.length(), letters, numbers,
                characters.toCharArray());
    }
    return "";
}

From source file:net.sf.ipsedixit.core.impl.DefaultDataProvider.java

/**
 * {@inheritDoc}//ww  w . ja  va  2s  .  c o  m
 */
public String randomString(StringType stringType, int length) {
    if (stringType == StringType.ALPHANUMERIC) {
        return RandomStringUtils.randomAlphanumeric(length);
    } else if (stringType == StringType.ALPHA) {
        return RandomStringUtils.randomAlphabetic(length);
    } else if (stringType == StringType.NUMERIC) {
        return RandomStringUtils.randomNumeric(length);
    }
    return RandomStringUtils.randomAscii(length);
}

From source file:com.merrill.examples.framework.lang.text.impl.CommonsRandomTextGenerator.java

public String randomAlphaNumeric(int count) {

    return RandomStringUtils.randomAlphanumeric(count);
}

From source file:net.nelz.simplesm.config.MemcachedConnectionBeanTest.java

@Test
public void testInAndOut() {
    final boolean consistent = RandomUtils.nextBoolean();
    final String addresses = RandomStringUtils.randomAlphanumeric(12);

    final MemcachedConnectionBean bean = new MemcachedConnectionBean();
    bean.setConsistentHashing(consistent);
    bean.setNodeList(addresses);//from w w w  .  j a  v a 2  s .  c  om

    assertEquals(consistent, bean.isConsistentHashing());
    assertEquals(addresses, bean.getNodeList());
}