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.google.cloud.bigtable.hbase.TestBufferedMutator.java

@Test
@Ignore(value = "We need a better test now that BigtableBufferedMutator has different logic")
public void testBufferSizeFlush() throws Exception {
    int maxSize = 1024;
    BufferedMutatorParams params = new BufferedMutatorParams(TABLE_NAME).writeBufferSize(maxSize);
    try (BufferedMutator mutator = getConnection().getBufferedMutator(params)) {
        // HBase 1.0.0 has a bug in it. It returns maxSize instead of the buffer size for
        // getWriteBufferSize.  https://issues.apache.org/jira/browse/HBASE-13113
        Assert.assertTrue(0 == mutator.getWriteBufferSize() || maxSize == mutator.getWriteBufferSize());

        Put put = getPut();/*  ww  w .j  a va 2  s.  c  om*/
        mutator.mutate(put);
        Assert.assertTrue(mutator.getWriteBufferSize() > 0);

        Put largePut = new Put(dataHelper.randomData("testrow-"));
        largePut.addColumn(COLUMN_FAMILY, qualifier,
                Bytes.toBytes(RandomStringUtils.randomAlphanumeric(maxSize * 2)));
        long heapSize = largePut.heapSize();
        Assert.assertTrue("largePut heapsize is : " + heapSize, heapSize > maxSize);
        mutator.mutate(largePut);

        // HBase 1.0.0 has a bug in it. It returns maxSize instead of the buffer size for
        // getWriteBufferSize.  https://issues.apache.org/jira/browse/HBASE-13113
        Assert.assertTrue(0 == mutator.getWriteBufferSize() || maxSize == mutator.getWriteBufferSize());
    }
}

From source file:jef.database.DefaultSqlProcessor.java

public static final String wrapCount(String sql) {
    return StringUtils.concat("select count(*) from (", sql, ") t", RandomStringUtils.randomAlphanumeric(3));
}

From source file:com.genericconf.bbbgateway.domain.Meeting.java

public String getMeetingID() {
    if (meetingID == null) {
        this.meetingID = RandomStringUtils.randomAlphanumeric(8);
    }
    return meetingID;
}

From source file:com.kixeye.chassis.scala.transport.serde.ScalaCaseClassTest.java

@Test
public void testProtobufSerDe() throws Exception {
    final ProtobufMessageSerDe serDe = new ProtobufMessageSerDe();

    final TestObject obj = new TestObject(RandomStringUtils.randomAlphanumeric(64),
            new SomeOtherObject(RandomStringUtils.randomAlphanumeric(64)));

    final byte[] serializedObj = serDe.serialize(obj);

    dumpToLog(serDe, serializedObj);//from   www. ja v  a  2  s  .c  om

    final TestObject deserializedObj = serDe.deserialize(serializedObj, 0, serializedObj.length,
            TestObject.class);

    Assert.assertEquals(obj, deserializedObj);
}

From source file:com.impetus.ankush.common.utils.UploadHandler.java

/**
 * Gets the hash.
 * 
 * @return the hash
 */
private String getHash() {
    return RandomStringUtils.randomAlphanumeric(20) + System.currentTimeMillis();
}

From source file:net.nelz.simplesm.aop.CacheBaseTest.java

@Test
public void testBuildCacheKey() {
    try {//  www .j av  a  2s  .  c om
        cut.buildCacheKey(null, (AnnotationData) null);
        fail("Expected exception.");
    } catch (InvalidParameterException ex) {
        assertTrue(ex.getMessage().indexOf("at least 1 character") != -1);
        System.out.println(ex.getMessage());
    }

    try {
        cut.buildCacheKey("", (AnnotationData) null);
        fail("Expected exception.");
    } catch (InvalidParameterException ex) {
        assertTrue(ex.getMessage().indexOf("at least 1 character") != -1);
        System.out.println(ex.getMessage());
    }

    final String objectId = RandomStringUtils.randomAlphanumeric(20);
    final AnnotationData annotationData = new AnnotationData();
    final String namespace = RandomStringUtils.randomAlphanumeric(12);
    annotationData.setNamespace(namespace);

    final String result = cut.buildCacheKey(objectId, annotationData);

    assertTrue(result.indexOf(objectId) != -1);
    assertTrue(result.indexOf(namespace) != -1);
}

From source file:de.thorstenberger.examServer.pdf.PDFExporter.java

/**
 * Render pdf outside of a running web session. This relies on a hack: It uses a random mock sessionId as identifier
 * for {@link TaskModelViewDelegate}. This works for taskmodel-core-view's ShowSolutionAction.java only!
 *
 * @param um//from   ww w.  j  a  v  a 2s.  c om
 * @param tm
 */
public PDFExporter(final UserManager um, final TaskManager tm) {
    this(RandomStringUtils.randomAlphanumeric(40), um, tm);
    this.mockSession = true;
}

From source file:fr.xebia.cocktail.CocktailRepository.java

public void insert(Cocktail cocktail) {
    Preconditions.checkArgument(cocktail.getId() == null, "Given id must be null in %s", cocktail);

    cocktail.setId(RandomStringUtils.randomAlphanumeric(5));

    cocktails.put(cocktail.getId(), cocktail);
}

From source file:fr.fg.server.data.Report.java

public void save() {
    // Gnre un code de hash unique
    String hash;//from   w  ww.  j  a va 2 s.  c om
    do {
        hash = RandomStringUtils.randomAlphanumeric(16);
    } while (DataAccess.getReportByHash(hash) != null || Badwords.containsBadwords(hash));
    setHash(hash);

    super.save();

    for (ReportSlot reportSlot : reportSlots) {
        reportSlot.setIdReport(getId());
        reportSlot.save();
    }
    reportSlots = null;

    if (reportActions != null) {
        for (ReportAction reportAction : reportActions) {
            reportAction.setIdReport(getId());
            reportAction.save();
        }
    }
    reportActions = null;
}

From source file:com.spotify.docker.client.messages.RegistryAuthTest.java

@Test
public void testFromDockerConfig_MissingConfigFile() throws Exception {
    final Path randomPath = Paths.get(RandomStringUtils.randomAlphanumeric(16) + ".json");
    expectedException.expect(FileNotFoundException.class);
    RegistryAuth.fromDockerConfig(randomPath).build();
}