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.linkedin.paldb.impl.GenerateTestData.java

public static String generateStringData(int letters) {
    return RandomStringUtils.randomAlphabetic(letters);
}

From source file:edu.samplu.admin.test.ConfigComponentLookUpAndCopyAbstractSmokeTestBase.java

public void testConfigComponentLookUpAndCopy() throws Exception {
    selectFrameIframePortlet();/*from  ww  w  .  j  av a  2 s  .c o  m*/
    waitAndClickByXpath("(//input[@name='methodToCall.search'])[2]");
    waitAndClickByLinkText("copy");
    String fourLetters = RandomStringUtils.randomAlphabetic(4);
    waitAndTypeByName("document.documentHeader.documentDescription",
            "Test description of Component copy " + ITUtil.createUniqueDtsPlusTwoRandomCharsNot9Digits());
    selectByName("document.newMaintainableObject.namespaceCode", "KR-WKFLW - Workflow");
    waitAndTypeByName("document.newMaintainableObject.code", "ActionList2" + fourLetters);
    waitAndTypeByName("document.newMaintainableObject.name", fourLetters);
    waitAndTypeByName("document.newMaintainableObject.name", "Action List 2 " + fourLetters);
    waitAndClickByName("methodToCall.route");
    checkForDocError();
    waitAndClickByName("methodToCall.close");
    waitAndClickByName("methodToCall.processAnswer.button1");
}

From source file:energy.usef.environment.tool.security.VaultService.java

public VaultService(NodeConfig node) {
    this.node = node;
    String encryptionPassword = RandomStringUtils.randomAlphabetic(15);
    String connectionPassword = RandomStringUtils.randomAlphabetic(15);
    password = encryptionPassword + " " + connectionPassword;
}

From source file:de.hybris.platform.jalo.media.MediaIntegrationTest.java

private byte[] getRandomBytes() {
    return RandomStringUtils.randomAlphabetic(1024).getBytes();
}

From source file:com.datastax.example.PreparedVsNonPreparedStatement.java

public void test1() {

    Random rnd = new Random();

    final CsvReporter reporter = CsvReporter.forRegistry(metrics).formatFor(Locale.US)
            .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS)
            .build(new File("/Users/patrick/projects/"));

    logger.info("Beginning PreparedVsNonPreparedStatement:Test1");

    reporter.start(1, TimeUnit.SECONDS);

    //Insert 10000
    for (int i = 0; i < 1000000; i++) {

        String firstName = RandomStringUtils.randomAlphabetic(10);
        String lastName = RandomStringUtils.randomAlphabetic(10);
        String street = RandomStringUtils.randomAlphabetic(8);
        int post_code = rnd.nextInt(99999);
        int phone = rnd.nextInt(99999999);

        final Timer.Context context = test1.time();

        session.execute("insert into users (id, firstname, lastname, street, post_code, phone) VALUES (" + i
                + ", '" + firstName + "', '" + lastName + "', '" + street + "', " + post_code + ", " + phone
                + ");");

        context.stop();//w  w  w  . j av a 2s  .  c o m

    }

    logger.info("Completed PreparedVsNonPreparedStatement:Test1");

}

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

@Test
public void testParseSimpleFilter() throws Exception {
    new StrictExpectations() {
        {//from ww w  .  ja v a 2  s  .co m
            RandomStringUtils.randomAlphabetic(anyInt);
            result = "stringParamName";
            RandomStringUtils.randomAlphabetic(anyInt);
            result = "intParamName";
            RandomStringUtils.randomAlphabetic(anyInt);
            result = "booleanParamName";
        }
    };

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

    String expectedJpqlWhere = "({E}.stringField <> :stringParamName and " + "{E}.intField > :intParamName and "
            + "{E}.booleanField = :booleanParamName)";
    assertEquals(expectedJpqlWhere, parseResult.getJpqlWhere());

    Map<String, Object> queryParameters = parseResult.getQueryParameters();

    assertEquals("stringValue", queryParameters.get("stringParamName"));
    assertEquals(100, queryParameters.get("intParamName"));
    assertEquals(true, queryParameters.get("booleanParamName"));
}

From source file:com.redhat.rhn.frontend.xmlrpc.packages.provider.test.PackagesProviderHandlerTest.java

public void testAddKey() throws Exception {
    admin.addPermanentRole(RoleFactory.SAT_ADMIN);

    String provStr = RandomStringUtils.randomAlphabetic(5);
    String keyStr = RandomStringUtils.randomAlphabetic(5);

    handler.associateKey(admin, provStr, keyStr, "gpg");
    assertFalse(handler.listKeys(admin, provStr).isEmpty());

}

From source file:de.hybris.platform.servicelayer.media.impl.DefaultMediaDaoIntegrationTest.java

List<MediaModel> createTestMedias(final MediaFolderModel folder, final int count) {
    final List<MediaModel> result = new ArrayList<MediaModel>();
    for (int i = 0; i < count; i++) {
        final CatalogUnawareMediaModel media = modelService.create(CatalogUnawareMediaModel.class);
        media.setCode(RandomStringUtils.randomAlphabetic(5));
        media.setFolder(folder);/*w  ww  .j a v  a2 s. c o  m*/
        modelService.save(media);

        result.add(media);
    }
    return result;
}

From source file:josejamilena.pfc.servidor.chartserver.ClientHandler.java

/**
 * Hilo de ejecucin del navegado cliente. Genera un pgina web para el
 * explorador cliente segn los datos disponibles.
 * @param s socket/*w w w  .j  av  a  2 s .c o  m*/
 */
public ClientHandler(final Socket s) {
    try {
        nombreFichero = RandomStringUtils.randomAlphabetic(longitudNombre);
        nombreFichero = nombreFichero + ".html";
        logger.info("Conexion desde: " + s.getInetAddress().toString());
        logger.info("Fichero index creado: " + nombreFichero);
        miSocketServidor = s;
        PrintWriter pw;
        Grafico g = null;
        Connection conn = DriverManager.getConnection(
                Webserver.getConfigProperties().getProperty("josejamilena.pfc.servidor.chartserver.url"));
        List<GrupoConsulta> lgc = SQLUtils.listaGruposConsultas(conn);
        List<String> googleCharts = new LinkedList<String>();
        if (lgc.size() == numGrupos) {
            GrupoConsulta gcHostSgbd = lgc.get(0);
            GrupoConsulta gcHostClientes = lgc.get(1);
            GrupoConsulta gcHostTipo = lgc.get(2);
            String plantilla1 = "";
            for (String tmp : gcHostSgbd.getLista()) {
                g = SQLUtils.consultaSQL2Grafico(conn, tmp);
                String textoAlternativo1 = "dibujo";
                String datos1 = "";
                for (String i : g.getLista()) {
                    datos1 = datos1 + "," + i;
                }
                String media1 = "";
                int cantidad = g.getLista().size();
                double mediad = 0.0;
                for (String i : g.getLista()) {
                    mediad = mediad + Double.parseDouble(i);
                }
                mediad = mediad / cantidad;
                for (String i : g.getLista()) {
                    media1 = media1 + "," + Math.round(mediad);
                }
                String leyendaDatos1 = tmp.substring(tmp.indexOf("'") + 1, tmp.lastIndexOf("'"));
                String tituloGrafico1 = "Servidor de bases de datos " + leyendaDatos1;
                String leyendaMedia1 = "media";
                String graficaActual = "<img src=\"http://chart.apis." + "google.com/chart?chs=600x400&chd=t:"
                        + datos1 + "|" + media1 + "&cht=lc&chtt=" + tituloGrafico1 + "&chts=FF0000,20&chdl="
                        + leyendaDatos1 + "|" + leyendaMedia1 + "&chco=ff0000,0000ff&chxt=y"
                        + "&chxl=1:|0|10000&chds=10,30000\"" + "  alt=\"" + textoAlternativo1 + "\">";
                graficaActual = graficaActual.replace("chd=t:,", "chd=t:");
                graficaActual = graficaActual.replace("|,", "|");
                plantilla1 = plantilla1 + "<p>" + graficaActual;
            }
            googleCharts.add(plantilla1);
            String plantilla2 = "";
            for (String tmp : gcHostClientes.getLista()) {
                g = SQLUtils.consultaSQL2Grafico(conn, tmp);
                String textoAlternativo2 = "dibujo";
                String datos2 = "";
                for (String i : g.getLista()) {
                    datos2 = datos2 + "," + i;
                }
                String media2 = "";
                int cantidad = g.getLista().size();
                double mediad = 0.0;
                for (String i : g.getLista()) {
                    mediad = mediad + Double.parseDouble(i);
                }
                mediad = mediad / cantidad;
                for (String i : g.getLista()) {
                    media2 = media2 + "," + Math.round(mediad);
                }
                String leyendaDatos2 = tmp.substring(tmp.indexOf("'") + 1, tmp.lastIndexOf("'"));
                String tituloGrafico2 = "Cliente de bases de datos " + leyendaDatos2;
                String leyendaMedia2 = "media";
                String graficaActual = "<img src=\"http://chart.apis." + "google.com/chart?chs=600x400&chd=t:"
                        + datos2 + "|" + media2 + "&cht=lc&chtt=" + tituloGrafico2 + "&chts=FF0000,20&chdl="
                        + leyendaDatos2 + "|" + leyendaMedia2 + "&chco=00FF00,0000ff&chxt=y"
                        + "&chxl=1:|0|10000&chds=10,30000\"" + "  alt=\"" + textoAlternativo2 + "\">";
                graficaActual = graficaActual.replace("chd=t:,", "chd=t:");
                graficaActual = graficaActual.replace("|,", "|");
                plantilla2 = plantilla2 + "<p>" + graficaActual;
            }
            googleCharts.add(plantilla2);
            String plantilla3 = "";
            for (String tmp : gcHostTipo.getLista()) {
                g = SQLUtils.consultaSQL2Grafico(conn, tmp);
                String textoAlternativo3 = "dibujo";
                String datos3 = "";
                for (String i : g.getLista()) {
                    datos3 = datos3 + "," + i;
                }
                String media3 = "";
                int cantidad = g.getLista().size();
                double mediad = 0.0;
                for (String i : g.getLista()) {
                    mediad = mediad + Double.parseDouble(i);
                }
                mediad = mediad / cantidad;
                for (String i : g.getLista()) {
                    media3 = media3 + "," + Math.round(mediad);
                }
                String leyendaDatos3 = tmp.substring(tmp.indexOf("'") + 1, tmp.lastIndexOf("'"));
                String tituloGrafico3 = "Script " + leyendaDatos3;
                String leyendaMedia3 = "media";
                String graficaActual = "<img src=\"http://chart.apis." + "google.com/chart?chs=600x400&chd=t:"
                        + datos3 + "|" + media3 + "&cht=lc&chtt=" + tituloGrafico3 + "&chts=FF0000,20&chdl="
                        + leyendaDatos3 + "|" + leyendaMedia3 + "&chco=000000,0000ff&chxt=y&"
                        + "chxl=1:|0|10000&chds=10,30000\"" + "  alt=\"" + textoAlternativo3 + "\">";
                graficaActual = graficaActual.replace("chd=t:,", "chd=t:");
                graficaActual = graficaActual.replace("|,", "|");
                plantilla3 = plantilla3 + "<p>" + graficaActual;
            }
            googleCharts.add(plantilla3);
        }
        String titulo = "Estadisticas online";
        String script = "<script type=\"text/JavaScript\">" + "<!-- function timedRefresh(timeoutPeriod) {"
                + "setTimeout(\"location.reload(true);\",timeoutPeriod);" + "} //   -->  </script> ";
        String encabezado = "<html><head><meta content=\"text/html; "
                + "charset=ISO-8859-1\" http-equiv=\"content-type\"><title>" + titulo + "</title>" + script
                + "</head> <body onload=\"JavaScript:timedRefresh(5000);\">" + " <h1>" + titulo
                + "</h1><br><br><br> ";
        String graficas = "";
        for (String i : googleCharts) {
            graficas = graficas + "<br><br><br>" + i;
        }
        String pie = "<br>Powered by: <A HREF=\"http://www.google.com/\">"
                + "<IMG SRC=\"http://www.google.com/logos/Logo_40wht.gif\" "
                + "border=\"0\" ALT=\"Google\" align=\"absmiddle\">" + "</A></body> </html>";
        pw = new PrintWriter(nombreFichero);
        pw.println(encabezado + graficas + pie);
        pw.flush();
        pw.close();
        start();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:hr.fer.zemris.vhdllab.dao.impl.OwnedEntityDaoTest.java

/**
 * UserId is too long./*from  www .  ja  v a  2s .  c  o m*/
 */
@Test(expected = InvalidStateException.class)
public void userIdTooLong() {
    entity.setName("name");
    entity.setUserId(RandomStringUtils.randomAlphabetic(256));
    dao.persist(entity);
}