List of usage examples for org.apache.commons.lang RandomStringUtils randomAlphanumeric
public static String randomAlphanumeric(int count)
Creates a random string whose length is the number of characters specified.
Characters will be chosen from the set of alpha-numeric characters.
From source file:org.apache.atlas.TestUtilsV2.java
public static AtlasEntityWithExtInfo createTableEntityV2(AtlasEntity dbEntity) { AtlasEntity tblEntity = new AtlasEntity(TABLE_TYPE); tblEntity.setAttribute(NAME, RandomStringUtils.randomAlphanumeric(10)); tblEntity.setAttribute("description", "random table"); tblEntity.setAttribute("type", "type"); tblEntity.setAttribute("tableType", "MANAGED"); tblEntity.setAttribute("database", AtlasTypeUtil.getAtlasObjectId(dbEntity)); tblEntity.setAttribute("created", new Date()); final AtlasStruct partitionStruct = new AtlasStruct("partition_struct_type", "name", "part0"); tblEntity.setAttribute("partitions", new ArrayList<AtlasStruct>() { {/*ww w.j a v a 2 s.c o m*/ add(partitionStruct); } }); tblEntity.setAttribute("parametersMap", new java.util.HashMap<String, String>() { { put("key1", "value1"); } }); AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(tblEntity); ret.addReferredEntity(dbEntity); return ret; }
From source file:org.apache.atlas.TestUtilsV2.java
public static AtlasEntity createProcessEntity(List<AtlasObjectId> inputs, List<AtlasObjectId> outputs) { AtlasEntity entity = new AtlasEntity(PROCESS_TYPE); entity.setAttribute(NAME, RandomStringUtils.randomAlphanumeric(10)); entity.setAttribute("inputs", inputs); entity.setAttribute("outputs", outputs); return entity; }
From source file:org.apache.atlas.typesystem.types.BaseTest.java
protected String newName() { return RandomStringUtils.randomAlphanumeric(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.atlas.web.TestUtils.java
public static String random() { return RandomStringUtils.randomAlphanumeric(10); }
From source file:org.apache.bookkeeper.metadata.etcd.EtcdCookieTest.java
@Test public void readWriteRemoveCookie() throws Exception { String bookieId = runtime.getMethodName() + ":3181"; // read the cookie doesn't exist try {//from ww w .j a v a 2 s . c o m regMgr.readCookie(bookieId); fail("Should fail reading cookie if cookie doesn't exist"); } catch (CookieNotFoundException cnfe) { // expected } // create the cookie String cookieData = RandomStringUtils.randomAlphanumeric(1024); Versioned<byte[]> cookie = new Versioned<>(cookieData.getBytes(UTF_8), Version.NEW); regMgr.writeCookie(bookieId, cookie); // read the cookie Versioned<byte[]> readCookie = regMgr.readCookie(bookieId); assertEquals(cookieData, new String(readCookie.getValue(), UTF_8)); // attempt to create the cookie again String newCookieData = RandomStringUtils.randomAlphabetic(512); Versioned<byte[]> newCookie = new Versioned<>(newCookieData.getBytes(UTF_8), Version.NEW); try { regMgr.writeCookie(bookieId, newCookie); fail("Should fail creating cookie if the cookie already exists"); } catch (MetadataStoreException mse) { assertTrue(mse.getMessage().contains("Conflict on writing cookie")); } Versioned<byte[]> readCookie2 = regMgr.readCookie(bookieId); assertCookieEquals(readCookie, readCookie2); // attempt to update the cookie with a wrong version newCookie = new Versioned<>(newCookieData.getBytes(UTF_8), new LongVersion(Long.MAX_VALUE)); try { regMgr.writeCookie(bookieId, newCookie); } catch (MetadataStoreException mse) { assertTrue(mse.getMessage().contains("Conflict on writing cookie")); } readCookie2 = regMgr.readCookie(bookieId); assertCookieEquals(readCookie, readCookie2); // delete the cookie with a wrong version LongVersion badVersion = new LongVersion(Long.MAX_VALUE); try { regMgr.removeCookie(bookieId, badVersion); fail("Should fail to remove cookie with bad version"); } catch (MetadataStoreException mse) { assertTrue(mse.getMessage().contains("bad version '" + badVersion + "'")); } readCookie2 = regMgr.readCookie(bookieId); assertCookieEquals(readCookie, readCookie2); // update the cookie with right version newCookie = new Versioned<>(newCookieData.getBytes(UTF_8), readCookie2.getVersion()); regMgr.writeCookie(bookieId, newCookie); readCookie2 = regMgr.readCookie(bookieId); assertEquals(newCookieData, new String(readCookie2.getValue(), UTF_8)); assertEquals(Occurred.AFTER, readCookie2.getVersion().compare(readCookie.getVersion())); // delete the cookie with right version regMgr.removeCookie(bookieId, readCookie2.getVersion()); try { regMgr.readCookie(bookieId); fail("Should fail reading cookie if cookie doesn't exist"); } catch (CookieNotFoundException cnfe) { // expected } // remove a cookie that doesn't exist try { regMgr.removeCookie(bookieId, readCookie2.getVersion()); fail("Should fail removing cookie if cookie doesn't exist"); } catch (CookieNotFoundException cnfe) { // expected } }
From source file:org.apache.falcon.catalog.CatalogPartitionHandlerTest.java
private Feed createFeed(boolean clearPartitions) throws Exception { Feed feed = (Feed) storeEntity(EntityType.FEED, "feed" + RandomStringUtils.randomAlphanumeric(10)); if (clearPartitions) { feed.setPartitions(null);//from www .j a v a 2 s . com HiveTestUtils.createExternalTable(metastoreUrl, CATALOG_DB, CATALOG_TABLE, Arrays.asList("ds"), "/projects/falcon/clicks"); } else { HiveTestUtils.createExternalTable(metastoreUrl, CATALOG_DB, CATALOG_TABLE, Arrays.asList("ds", "country", "region"), "/projects/falcon/clicks"); } feed.setProperties(getProperties(CatalogPartitionHandler.CATALOG_TABLE, "catalog:default:clicks#ds={YEAR}-{MONTH}-{DAY}-{HOUR}")); return feed; }
From source file:org.apache.geode.test.junit.rules.JarFileRule.java
@Override protected void before() throws IOException { temporaryFolder.create();/*from w w w. j av a 2s . c om*/ this.jarFile = temporaryFolder.newFile(jarName); if (makeJarLarge) { classBuilder.writeJarFromContent(className, "public class " + className + "{" + "String test = \"" + RandomStringUtils.randomAlphanumeric(10000) + "\";" + "String test2 = \"" + RandomStringUtils.randomAlphanumeric(10000) + "\";" + "String test3 = \"" + RandomStringUtils.randomAlphanumeric(10000) + "\";" + "String test4 = \"" + RandomStringUtils.randomAlphanumeric(10000) + "\";" + "}", jarFile); } else { classBuilder.writeJarFromName(className, jarFile); } }
From source file:org.apache.hadoop.dynamodb.test.DynamoDBTestUtils.java
public static String getRandomString() { int length = rnd.nextInt(STRING_LENGTH) + 1; return RandomStringUtils.randomAlphanumeric(length); }
From source file:org.apache.hadoop.fs.FileSystemTestHelper.java
/** * Create helper with test root located at <wd>/build/test/data *///from w ww.ja v a 2s.com public FileSystemTestHelper() { this(System.getProperty("test.build.data", "target/test/data") + "/" + RandomStringUtils.randomAlphanumeric(10)); }