private String generateContainerName(String zaleniumContainerName) { final String suffix = RandomStringUtils.randomAlphanumeric(6); return String.format("%s_%s", zaleniumContainerName, suffix); }
/** * <p>Creates a random string whose length is the number of characters * specified.</p> * * <p>Characters will be chosen from the set of all characters.</p> * * @param count the length of random string to create * @return the random string */ public static String random(final int count) { return random(count, false, false); }
/** * <p>Creates a random string whose length is between the inclusive minimum and * the exclusive maximum.</p> * * <p>Characters will be chosen from the set of Latin alphabetic characters (a-z, A-Z).</p> * * @param minLengthInclusive the inclusive minimum length of the string to generate * @param maxLengthExclusive the exclusive maximum length of the string to generate * @return the random string * @since 3.5 */ public static String randomAlphabetic(final int minLengthInclusive, final int maxLengthExclusive) { return randomAlphabetic(RandomUtils.nextInt(minLengthInclusive, maxLengthExclusive)); }
private String randomString( int size ) { return ThreadLocalRandom.current().nextBoolean() ? RandomStringUtils.random( size ) : RandomStringUtils.randomAlphabetic( size ); }
String r1 = RandomStringUtils.random(50); assertEquals("random(50) length", 50, r1.length()); String r2 = RandomStringUtils.random(50); assertEquals("random(50) length", 50, r2.length()); assertTrue("!r1.equals(r2)", !r1.equals(r2)); r1 = RandomStringUtils.randomAscii(50); assertEquals("randomAscii(50) length", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { assertTrue("char between 32 and 127", r1.charAt(i) >= 32 && r1.charAt(i) <= 127); r2 = RandomStringUtils.randomAscii(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); r1 = RandomStringUtils.randomAlphabetic(50); assertEquals("randomAlphabetic(50)", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { assertTrue("r1 contains alphabetic", Character.isLetter(r1.charAt(i)) && !Character.isDigit(r1.charAt(i))); r2 = RandomStringUtils.randomAlphabetic(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); r1 = RandomStringUtils.randomAlphanumeric(50); assertEquals("randomAlphanumeric(50)", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { assertTrue("r1 contains alphanumeric", Character.isLetterOrDigit(r1.charAt(i))); r2 = RandomStringUtils.randomAlphabetic(50); assertTrue("!r1.equals(r2)", !r1.equals(r2));
@Override public String get() { return String.format("%s%s%s", randomAlphabetic(1).toUpperCase(), randomNumeric(7), randomAlphanumeric(1).toUpperCase()); }
@Override protected boolean doAction() throws Exception { Put p = new Put(Bytes.toBytes(RandomStringUtils.randomAlphanumeric(5))); p.addColumn(FAMILY, Bytes.toBytes("\0"), Bytes.toBytes(RandomStringUtils.randomAscii(5))); table.put(p); return true; }
/** * <p>Creates a random string whose length is between the inclusive minimum and * the exclusive maximum.</p> * * <p>Characters will be chosen from the set of \p{Digit} characters.</p> * * @param minLengthInclusive the inclusive minimum length of the string to generate * @param maxLengthExclusive the exclusive maximum length of the string to generate * @return the random string * @since 3.5 */ public static String randomNumeric(final int minLengthInclusive, final int maxLengthExclusive) { return randomNumeric(RandomUtils.nextInt(minLengthInclusive, maxLengthExclusive)); }
@Override public String get() { return String.format("%s-%s", RandomStringUtils.randomNumeric(8), RandomStringUtils.randomAlphabetic(1).toUpperCase()); }
/** * <p>Creates a random string whose length is between the inclusive minimum and * the exclusive maximum.</p> * * <p>Characters will be chosen from the set of characters whose * ASCII value is between {@code 32} and {@code 126} (inclusive).</p> * * @param minLengthInclusive the inclusive minimum length of the string to generate * @param maxLengthExclusive the exclusive maximum length of the string to generate * @return the random string * @since 3.5 */ public static String randomAscii(final int minLengthInclusive, final int maxLengthExclusive) { return randomAscii(RandomUtils.nextInt(minLengthInclusive, maxLengthExclusive)); }
@Override public String get() { return String.format("%s%s%s", randomAlphabetic(1).toUpperCase(), randomNumeric(7), randomAlphanumeric(1).toUpperCase()); }
@Override protected boolean doAction() throws Exception { Put p = new Put(Bytes.toBytes(RandomStringUtils.randomAlphanumeric(5))); p.addColumn(FAMILY, Bytes.toBytes("\0"), Bytes.toBytes(RandomStringUtils.randomAscii(5))); table.put(p); return true; }
private File createRandomFolder( File rootFolder ) throws IOException { File folder = new File( rootFolder, RandomStringUtils.randomNumeric( 5 ) ); fs.mkdirs( folder ); return folder; }
public static InMemoryItem randomItem() { return new InMemoryItem() .with("identifier", randomAlphabetic(10)) .with("datestamp", new Date()) .with("sets", new ListBuilder<String>().add(randomAlphabetic(3)).build()) .with("deleted", Integer.parseInt(randomNumeric(1)) > 5); }
public Label[] getLabels() { int randomLabelValue = ThreadLocalRandom.current().nextInt( 2 ) + 1; Label[] labels = new Label[randomLabelValue]; for ( int i = 0; i < labels.length; i++ ) { labels[i] = Label.label( RandomStringUtils.randomAscii( randomLabelValue ) ); } return labels; }
/** * <p>Creates a random string whose length is between the inclusive minimum and * the exclusive maximum.</p> * * <p>Characters will be chosen from the set of Latin alphabetic * characters (a-z, A-Z) and the digits 0-9.</p> * * @param minLengthInclusive the inclusive minimum length of the string to generate * @param maxLengthExclusive the exclusive maximum length of the string to generate * @return the random string * @since 3.5 */ public static String randomAlphanumeric(final int minLengthInclusive, final int maxLengthExclusive) { return randomAlphanumeric(RandomUtils.nextInt(minLengthInclusive, maxLengthExclusive)); }
/** * <p>Creates a random string whose length is the number of characters * specified.</p> * * <p>Characters will be chosen from the set of Latin alphabetic * characters (a-z, A-Z).</p> * * @param count the length of random string to create * @return the random string */ public static String randomAlphabetic(final int count) { return random(count, true, false); }
/** * Adds a branch to the alternation (...|pattern). Order is important. * * @param cssClass css class that the matching regions should bear * @param regex Regex pattern * * @return The same builder */ public RegexHighlightGrammarBuilder or(Collection<String> cssClass, String regex) { String groupName = RandomStringUtils.randomAlphabetic(8); groupNameToRegex.put(groupName, regex); groupNameToCssClasses.put(groupName, new HashSet<>(cssClass)); return this; }
private static Document randomDocument() { Document doc = new Document(); doc.add( new StringField( "field", RandomStringUtils.randomNumeric( 5 ), Field.Store.YES ) ); return doc; } }
public synchronized void recalculateChecksum() { List<IpAddress> ips = allIPs(); StringBuilder ipsString = new StringBuilder(); ipsString.append(getDomString()); Loggers.SRV_LOG.debug("dom to json: " + getDomString()); if (!CollectionUtils.isEmpty(ips)) { Collections.sort(ips); } for (IpAddress ip : ips) { String string = ip.getIp() + ":" + ip.getPort() + "_" + ip.getWeight() + "_" + ip.isValid() + "_" + ip.getClusterName(); ipsString.append(string); ipsString.append(","); } try { String result; try { MessageDigest md5 = MessageDigest.getInstance("MD5"); result = new BigInteger(1, md5.digest((ipsString.toString()).getBytes(Charset.forName("UTF-8")))).toString(16); } catch (Exception e) { Loggers.SRV_LOG.error("[NACOS-DOM] error while calculating checksum(md5)", e); result = RandomStringUtils.randomAscii(32); } checksum = result; } catch (Exception e) { Loggers.SRV_LOG.error("[NACOS-DOM] error while calculating checksum(md5)", e); checksum = RandomStringUtils.randomAscii(32); } }