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:edu.samplu.common.WebDriverLegacyITBase.java

protected void testLocationStateBlanketApprove() throws Exception {
    selectFrameIframePortlet();/*from  ww  w  . ja  v a2 s .c  om*/
    waitAndCreateNew();
    String docId = waitForDocId();
    waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test State");
    assertBlanketApproveButtonsPresent();

    //jiraAwareWaitAndClick("methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + getBaseUrlString() + "/kr/lookup.do;::::).anchor4");
    String countryLookUp = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;"
            + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']";
    waitAndClickByXpath(countryLookUp);
    waitAndClickSearch();
    waitAndClickReturnValue();
    String code = RandomStringUtils.randomAlphabetic(2).toUpperCase();
    waitAndTypeByXpath(DOC_CODE_XPATH, code);
    String state = "Validation Test State " + code;
    waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", state);
    waitAndClickByXpath("//input[@id='document.newMaintainableObject.active']");
    blanketApproveTest();
    assertDocFinal(docId);
}

From source file:edu.samplu.common.WebDriverLegacyITBase.java

protected void testReferenceCampusTypeBlanketApprove() throws Exception {
    selectFrameIframePortlet();//from   w w  w.j  a  v a  2 s .  c om
    waitAndCreateNew();
    String docId = waitForDocId();
    assertBlanketApproveButtonsPresent();
    String dtsTwo = ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits();
    waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Validation Test Campus Type " + dtsTwo);
    waitAndTypeByXpath(DOC_CODE_XPATH, RandomStringUtils.randomAlphabetic(1));
    waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", "Indianapolis" + dtsTwo);
    int attemptCount = 1;
    blanketApproveCheck();
    while (hasDocError("same primary key already exists") && attemptCount < 25) {
        clearTextByXpath(DOC_CODE_XPATH);
        waitAndTypeByXpath(DOC_CODE_XPATH, Character.toString((char) ('A' + attemptCount++)));
        blanketApproveCheck();
    }
    blanketApproveAssert();
    assertDocFinal(docId);
}

From source file:nl.b3p.viewer.util.TestUtil.java

/**
 * initialisatie van EntityManager {@link #entityManager} en starten
 * transactie.//  ww  w .j  a  va2 s  . c  om
 *
 * @throws Exception if any
 *
 * @see #entityManager
 */
@Before
public void setUp() throws Exception {
    final String persistenceUnit = System.getProperty("test.persistence.unit");
    Map config = new HashMap();
    String testname = testName.getMethodName();
    testname = testname.replaceAll(":", "-");
    testname = testname.replaceAll(" ", "");
    String randomizer = RandomStringUtils.randomAlphabetic(8);
    config.put("javax.persistence.jdbc.url",
            "jdbc:hsqldb:file:./target/unittest-hsqldb_" + testname + "_" + randomizer + "/db;shutdown=true");
    entityManager = Persistence.createEntityManagerFactory(persistenceUnit, config).createEntityManager();
    if (!entityManager.getTransaction().isActive()) {
        entityManager.getTransaction().begin();
    }
    loadTestData();

    if (!entityManager.getTransaction().isActive()) {
        entityManager.getTransaction().begin();
    }
}

From source file:org.alfresco.repo.web.scripts.invite.InviteServiceTest.java

@Test
public void testDontOwerrideModeratedSitePermissions() throws Exception {
    final String MODERATED_SITE_NAME = RandomStringUtils.randomAlphabetic(6);
    final String siteManager = RandomStringUtils.randomAlphabetic(6);
    final String secondUser = RandomStringUtils.randomAlphabetic(6);

    // Create two users
    AuthenticationUtil.runAs(new RunAsWork<Object>() {
        public Object doWork() throws Exception {
            createPerson(siteManager, siteManager, siteManager, "");
            createPerson(secondUser, secondUser, secondUser, "");
            return null;
        }/*from  w  w w.ja v a2  s .c  o  m*/

    }, AuthenticationUtil.getSystemUserName());

    // Create moderated site
    SiteInfo siteInfo = InviteServiceTest.this.siteService.getSite(MODERATED_SITE_NAME);
    if (siteInfo == null) {
        siteService.createSite("InviteSitePreset", MODERATED_SITE_NAME, MODERATED_SITE_NAME,
                MODERATED_SITE_NAME, SiteVisibility.MODERATED);
    }
    siteService.setMembership(MODERATED_SITE_NAME, siteManager, SiteModel.SITE_MANAGER);
    String role = siteService.getMembersRole(MODERATED_SITE_NAME, siteManager);
    assertEquals(SiteModel.SITE_MANAGER, role);

    // Create request to join to site
    String inviteId = createModeratedInvitation(MODERATED_SITE_NAME, "", secondUser, SiteModel.SITE_CONSUMER);

    // Set second user to Collaborator
    siteService.setMembership(MODERATED_SITE_NAME, secondUser, SiteModel.SITE_COLLABORATOR);
    role = siteService.getMembersRole(MODERATED_SITE_NAME, secondUser);
    assertEquals(SiteModel.SITE_COLLABORATOR, role);

    final String taskId = getTaskId(inviteId);
    assertNotNull("Cannot find taskId", taskId);

    // Accept invitation
    String oldUser = AuthenticationUtil.getFullyAuthenticatedUser();
    AuthenticationUtil.setFullyAuthenticatedUser(siteManager);
    workflowService.endTask(taskId, "approve");
    AuthenticationUtil.setFullyAuthenticatedUser(oldUser);

    // Check the role
    role = siteService.getMembersRole(MODERATED_SITE_NAME, secondUser);
    assertEquals(SiteModel.SITE_COLLABORATOR, role);
}

From source file:org.apache.activemq.artemis.tests.integration.stomp.StompWebSocketMaxFrameTest.java

@Test
public void testStompSendReceiveWithMaxFramePayloadLength() throws Exception {
    // Assert that sending message > default 64kb fails
    int size = 65536;
    String largeString1 = RandomStringUtils.randomAlphabetic(size);
    String largeString2 = RandomStringUtils.randomAlphabetic(size);

    StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri, false);
    conn.getTransport().setMaxFrameSize(stompWSMaxFrameSize);
    conn.getTransport().connect();//w  w  w . j  av a2  s  .c  o  m

    StompClientConnection conn2 = StompClientConnectionFactory.createClientConnection(wsURI, false);
    conn2.getTransport().setMaxFrameSize(stompWSMaxFrameSize);
    conn2.getTransport().connect();

    Wait.waitFor(() -> conn2.getTransport().isConnected() && conn.getTransport().isConnected(), 10000);
    conn.connect();
    conn2.connect();

    subscribeQueue(conn2, "sub1", getQueuePrefix() + getQueueName());

    try {
        // Client is kicked when sending frame > largest frame size.
        send(conn, getQueuePrefix() + getQueueName(), "text/plain", largeString1, false);
        Wait.waitFor(() -> !conn.getTransport().isConnected(), 2000);
        assertFalse(conn.getTransport().isConnected());

        send(conn2, getQueuePrefix() + getQueueName(), "text/plain", largeString2, false);
        Wait.waitFor(() -> !conn2.getTransport().isConnected(), 2000);
        assertTrue(conn2.getTransport().isConnected());

        ClientStompFrame frame = conn2.receiveFrame();
        assertNotNull(frame);
        assertEquals(largeString2, frame.getBody());

    } finally {
        conn2.closeTransport();
        conn.closeTransport();
    }
}

From source file:org.apache.ambari.server.security.CertGenerationTest.java

protected static Properties buildTestProperties() {
    try {/*from  w  w  w  . j  a  v  a  2  s. c  om*/
        temp.create();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Properties properties = new Properties();
    properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, temp.getRoot().getAbsolutePath());
    passLen = (int) Math.abs((new Random().nextFloat() * MAX_PASS_LEN));

    properties.setProperty(Configuration.SRVR_CRT_PASS_LEN_KEY, String.valueOf(passLen));

    passFileName = RandomStringUtils.randomAlphabetic(PASS_FILE_NAME_LEN);
    properties.setProperty(Configuration.SRVR_CRT_PASS_FILE_KEY, passFileName);

    return properties;
}

From source file:org.apache.ambari.server.security.TestPassFileGeneration.java

protected Properties buildTestProperties() {
    try {/*w ww  . java 2 s.  c  om*/
        temp.create();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Properties properties = new Properties();
    properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, temp.getRoot().getAbsolutePath());

    passLen = (int) Math.abs((new Random().nextFloat() * MAX_PASS_LEN));

    properties.setProperty(Configuration.SRVR_CRT_PASS_LEN_KEY, String.valueOf(passLen));

    passFileName = RandomStringUtils.randomAlphabetic(PASS_FILE_NAME_LEN);
    properties.setProperty(Configuration.SRVR_CRT_PASS_FILE_KEY, passFileName);

    return properties;
}

From source file:org.apache.atlas.utils.LruCacheTest.java

/**
 * Create a mock IInternalQuery.//from w  ww .  jav  a2 s.  c o m
 *
 * @return a mock IInternalQuery.
 * @throws QueryException
 */
private String createQuery() {
    return RandomStringUtils.randomAlphabetic(10);
}

From source file:org.apache.atlas.web.integration.BaseResourceIT.java

protected String randomString() {
    //names cannot start with a digit
    return RandomStringUtils.randomAlphabetic(1) + RandomStringUtils.randomAlphanumeric(9);
}

From source file:org.apache.beam.sdk.io.kinesis.KinesisReaderIT.java

private List<String> prepareTestData(int count) {
    List<String> data = newArrayList();
    for (int i = 0; i < count; ++i) {
        data.add(RandomStringUtils.randomAlphabetic(32));
    }//  w  ww  .ja v a 2  s .co  m
    return data;
}