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

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

Introduction

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

Prototype

public static String randomAlphabetic(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 alphabetic characters.

Usage

From source file:com.haulmont.restapi.service.filter.RestFilterParserTest.java

@Test
public void testEntityCondition() throws Exception {
    new StrictExpectations() {
        {//from   w  w  w. j a v  a 2 s . c o  m
            RandomStringUtils.randomAlphabetic(anyInt);
            result = "paramName1";
        }
    };

    String data = readDataFromFile("data/restFilter2.json");
    MetaClass metaClass = metadata.getClass("test$TestEntity");
    RestFilterParseResult parseResult = restFilterParser.parse(data, metaClass);

    String expectedJpqlWhere = "({E}.linkedTestEntity.id = :paramName1)";
    assertEquals(expectedJpqlWhere, parseResult.getJpqlWhere());

    Map<String, Object> queryParameters = parseResult.getQueryParameters();
    assertEquals(UUID.fromString("2de6a78f-7bef-89a7-eb5e-b725582f23af"), queryParameters.get("paramName1"));
}

From source file:gobblin.data.management.copy.writer.TarArchiveInputStreamDataWriterTest.java

@Test(dataProvider = "testFileDataProvider")
public void testWrite(final String filePath, final String newFileName, final String expectedText)
        throws Exception {

    String expectedFileContents = "text";
    String fileNameInArchive = "text.txt";

    WorkUnitState state = TestUtils.createTestWorkUnitState();
    state.setProp(ConfigurationKeys.WRITER_STAGING_DIR, new Path(testTempPath, "staging").toString());
    state.setProp(ConfigurationKeys.WRITER_OUTPUT_DIR, new Path(testTempPath, "output").toString());
    state.setProp(ConfigurationKeys.WRITER_FILE_PATH,
            "writer_file_path_" + RandomStringUtils.randomAlphabetic(5));
    CopyableDatasetMetadata metadata = new CopyableDatasetMetadata(
            new TestCopyableDataset(new Path("/source")));
    CopySource.serializeCopyableDataset(state, metadata);

    FileAwareInputStream fileAwareInputStream = getCompressedInputStream(filePath, newFileName);
    CopySource.serializeCopyEntity(state, fileAwareInputStream.getFile());

    TarArchiveInputStreamDataWriter dataWriter = new TarArchiveInputStreamDataWriter(state, 1, 0);
    dataWriter.write(fileAwareInputStream);
    dataWriter.commit();// w ww  .  ja v a 2s  . c o  m

    // the archive file contains file test.txt
    Path unArchivedFilePath = new Path(fileAwareInputStream.getFile().getDestination(), fileNameInArchive);

    // Path at which the writer writes text.txt
    Path taskOutputFilePath = new Path(
            new Path(state.getProp(ConfigurationKeys.WRITER_OUTPUT_DIR),
                    fileAwareInputStream.getFile().getDatasetAndPartition(metadata).identifier()),
            PathUtils.withoutLeadingSeparator(unArchivedFilePath));

    Assert.assertEquals(IOUtils.toString(new FileInputStream(taskOutputFilePath.toString())).trim(),
            expectedFileContents);
}

From source file:com.linkedin.pinot.index.readerwriter.FixedByteSingleValueMultiColumnReaderWriterTest.java

private void testMutability() {
    for (int i = 0; i < NUM_ROWS; i++) {
        int row = _random.nextInt(NUM_ROWS);

        int intValue = _random.nextInt();
        _readerWriter.setInt(row, 0, intValue);
        Assert.assertEquals(_readerWriter.getInt(row, 0), intValue);

        long longValue = _random.nextLong();
        _readerWriter.setLong(row, 1, longValue);
        Assert.assertEquals(_readerWriter.getLong(row, 1), longValue);

        float floatValue = _random.nextFloat();
        _readerWriter.setFloat(row, 2, floatValue);
        Assert.assertEquals(_readerWriter.getFloat(row, 2), floatValue);

        double doubleValue = _random.nextDouble();
        _readerWriter.setDouble(row, 3, doubleValue);
        Assert.assertEquals(_readerWriter.getDouble(row, 3), doubleValue);

        String stringValue = RandomStringUtils.randomAlphabetic(STRING_LENGTH);
        _readerWriter.setString(row, 4, stringValue);
        Assert.assertEquals(_readerWriter.getString(row, 4), stringValue);
    }/*from   w  w  w .  j av  a2 s .c  om*/
}

From source file:edu.sampleu.admin.DetailedDocSearchAft.java

private void createGroupDocument() throws Exception {
    waitAndClickAdministration();//ww  w  .  ja v  a 2 s  .  c o  m
    selectFrameIframePortlet();
    waitAndClickByLinkText("Group");
    selectFrameIframePortlet();
    waitAndClickByXpath("//a[@title='Create a new record']");
    selectFrameIframePortlet();
    String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
    waitAndSelectByName("document.groupNamespace", "KR-BUS - Service Bus");
    waitAndTypeByName("document.documentHeader.documentDescription", "Group");
    waitAndTypeByName("document.groupName", "Group 1" + randomCode);
    groupId = waitForElementPresentByXpath(
            "//div[@id='tab-Overview-div']/div[@class='tab-container']/table/tbody/tr/td").getText();
    waitAndClickByXpath("//input[@name='methodToCall.route']");
}

From source file:de.hybris.platform.jobs.MediaMigrationStrategyIntegrationTest.java

private List<MediaModel> createAndAddMediaToFolder(final int numOfMedia, final MediaFolderModel folder) {
    final List<MediaModel> result = new ArrayList<MediaModel>();

    for (int i = 0; i < numOfMedia; i++) {
        final String code = RandomStringUtils.randomAlphabetic(5);
        final MediaModel media = createEmptyMediaModelInFolder(code, folder);
        mediaService.setStreamForMedia(media, new DataInputStream(new ByteArrayInputStream(code.getBytes())));
        modelService.save(media);/* w  w  w . j  a v a2  s.c om*/
        assertThat(media.getDataPK())
                .overridingErrorMessage("media PK: " + media.getPk() + ", index: " + i + " has no dataPK")
                .isNotNull();
        MediaDataAssert.assertThat(media).hasDirDepthEqualTo(Integer.valueOf(0));
        result.add(media);
    }
    return result;
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.api.user.MMXUsersResourceTest.java

private static TestUserDao.UserEntity createRandomUser(AppEntity appEntity, int index) throws Exception {
    TestUserDao.UserEntity ue = new TestUserDao.UserEntity();
    ue.setEmail(RandomStringUtils.randomAlphabetic(5) + "@" + RandomStringUtils.randomAlphabetic(8) + ".com");
    ue.setName(RandomStringUtils.randomAlphabetic(5) + " " + RandomStringUtils.randomAlphabetic(5));
    ue.setPlainPassword(RandomStringUtils.randomAlphabetic(10));
    ue.setEncryptedPassword(RandomStringUtils.randomAlphabetic(80));
    ue.setCreationDate(org.jivesoftware.util.StringUtils.dateToMillis(new Date()));
    ue.setModificationDate(org.jivesoftware.util.StringUtils.dateToMillis(new Date()));
    ue.setUsername("MMXUsersResourceTestUser" + "_" + index + "%" + appEntity.getAppId());
    ue.setUsernameNoAppId("MMXUsersResourceTestUser" + "_" + index);
    DBTestUtil.getTestUserDao().persist(ue);
    return ue;//  w w w.j av  a  2s  . com
}

From source file:com.b2international.index.SortIndexTest.java

@Test
public void sortAnalyzedField() throws Exception {
    final TreeSet<String> orderedItems = newTreeSet();
    final Map<String, Data> documents = newHashMap();

    for (int i = 0; i < NUM_DOCS; i++) {
        String item = null;//from   w w  w. jav a  2 s  . c om
        while (item == null || orderedItems.contains(item)) {
            item = RandomStringUtils.randomAlphabetic(10);
        }
        orderedItems.add(item);

        final Data data = new Data();
        data.setAnalyzedField(item);
        documents.put(Integer.toString(i), data);
    }

    indexDocuments(documents);

    final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("analyzedField.exact", Order.ASC)).build();

    checkDocumentOrder(ascendingQuery, data -> data.getAnalyzedField(), orderedItems, String.class);

    final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS)
            .sortBy(SortBy.field("analyzedField.exact", Order.DESC)).build();

    checkDocumentOrder(descendingQuery, data -> data.getAnalyzedField(), orderedItems.descendingSet(),
            String.class);
}

From source file:edu.sampleu.main.TermMaintenanceEditCopyAft.java

protected void copyExistingTermWithParameter() throws InterruptedException {
    selectFrameIframePortlet();//from ww w.  j  a v  a2  s.  c o m
    waitAndTypeByName("lookupCriteria[id]", "T1000");
    waitAndClickByXpath("//button[contains(text(),'Search')]");
    waitAndClickCopy();
    waitForTextPresent("BL");
    String newRandomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
    clearTextByName("document.newMaintainableObject.dataObject.description");
    waitAndTypeByName("document.newMaintainableObject.dataObject.description",
            "Copy Term - Short ID " + StringUtils.substring(newRandomCode, 0, 4));
    clearTextByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]");
    waitAndTypeByName("document.newMaintainableObject.dataObject.parametersMap[Campus Code]", newRandomCode);
    submitSuccessfully();
    waitForTextPresent(newRandomCode);
}

From source file:gobblin.data.management.copy.writer.FileAwareInputStreamDataWriterTest.java

@Test
public void testWrite() throws Exception {
    String streamString = "testContents";

    FileStatus status = fs.getFileStatus(testTempPath);
    OwnerAndPermission ownerAndPermission = new OwnerAndPermission(status.getOwner(), status.getGroup(),
            new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
    CopyableFile cf = CopyableFileUtils.getTestCopyableFile(ownerAndPermission);

    CopyableDatasetMetadata metadata = new CopyableDatasetMetadata(
            new TestCopyableDataset(new Path("/source")));

    WorkUnitState state = TestUtils.createTestWorkUnitState();
    state.setProp(ConfigurationKeys.WRITER_STAGING_DIR, new Path(testTempPath, "staging").toString());
    state.setProp(ConfigurationKeys.WRITER_OUTPUT_DIR, new Path(testTempPath, "output").toString());
    state.setProp(ConfigurationKeys.WRITER_FILE_PATH, RandomStringUtils.randomAlphabetic(5));
    CopySource.serializeCopyEntity(state, cf);
    CopySource.serializeCopyableDataset(state, metadata);

    FileAwareInputStreamDataWriter dataWriter = new FileAwareInputStreamDataWriter(state, 1, 0);

    FileAwareInputStream fileAwareInputStream = new FileAwareInputStream(cf,
            StreamUtils.convertStream(IOUtils.toInputStream(streamString)));
    dataWriter.write(fileAwareInputStream);
    dataWriter.commit();/*w ww . j  a  va 2  s.  c  o m*/
    Path writtenFilePath = new Path(new Path(state.getProp(ConfigurationKeys.WRITER_OUTPUT_DIR),
            cf.getDatasetAndPartition(metadata).identifier()), cf.getDestination());
    Assert.assertEquals(IOUtils.toString(new FileInputStream(writtenFilePath.toString())), streamString);
}

From source file:com.thebodgeitstore.selenium.tests.FunctionalTest.java

public void tstRegisterUser() {
    // Create random username so we can rerun test
    String randomUser = RandomStringUtils.randomAlphabetic(10) + "@test.com";
    this.registerUser(randomUser, "password");
    assertTrue(driver.getPageSource().indexOf("You have successfully registered with The BodgeIt Store.") > 0);
}