List of usage examples for org.apache.commons.lang RandomStringUtils randomAlphabetic
public static String randomAlphabetic(int count)
Creates a random string whose length is the number of characters specified.
Characters will be chosen from the set of alphabetic characters.
From source file:org.apache.bookkeeper.metadata.etcd.Etcd64bitIdGeneratorTest.java
@Before @Override// w ww. j av a 2 s . c o m public void setUp() throws Exception { super.setUp(); this.scope = "/" + RandomStringUtils.randomAlphabetic(8); this.generator = new Etcd64bitIdGenerator(etcdClient.getKVClient(), scope); log.info("Setup id generator under scope {}", scope); }
From source file:org.apache.bookkeeper.metadata.etcd.EtcdClusterTest.java
@Before @Override/*from w ww.j a v a 2s. c o m*/ public void setUp() throws Exception { super.setUp(); this.scope = RandomStringUtils.randomAlphabetic(32); this.regMgr = new EtcdRegistrationManager(newEtcdClient(), scope); }
From source file:org.apache.bookkeeper.metadata.etcd.EtcdCookieTest.java
@Before @Override// w w w .ja va 2s.c o m public void setUp() throws Exception { super.setUp(); String scope = RandomStringUtils.randomAlphabetic(16); this.regMgr = new EtcdRegistrationManager(newEtcdClient(), scope); }
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 {//w ww.j av a2s .co 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.bookkeeper.metadata.etcd.EtcdLayoutManagerTest.java
@Before @Override/*www. ja va2s . c om*/ public void setUp() throws Exception { super.setUp(); this.scope = "/" + RandomStringUtils.randomAlphabetic(8); this.layoutManager = new EtcdLayoutManager(etcdClient, scope); log.info("setup layout manager under scope {}", scope); }
From source file:org.apache.bookkeeper.metadata.etcd.EtcdLedgerManagerTest.java
@Override @Before//from w ww. ja v a 2 s .c o m public void setUp() throws Exception { super.setUp(); this.scope = RandomStringUtils.randomAlphabetic(8); this.lm = new EtcdLedgerManager(etcdClient, scope); }
From source file:org.apache.bookkeeper.metadata.etcd.EtcdRegistrationTest.java
@Before @Override/*ww w .j a v a 2 s.co m*/ public void setUp() throws Exception { super.setUp(); this.scope = RandomStringUtils.randomAlphabetic(16); this.regClient = new EtcdRegistrationClient(scope, etcdClient); }
From source file:org.apache.bookkeeper.metadata.etcd.helpers.HelpersTest.java
@Before @Override public void setUp() throws Exception { super.setUp(); scope = RandomStringUtils.randomAlphabetic(8); }
From source file:org.apache.bookkeeper.metadata.etcd.testing.EtcdTestBase.java
@BeforeClass public static void setupCluster() throws Exception { etcdContainer = new EtcdContainer(RandomStringUtils.randomAlphabetic(8)); etcdContainer.start();//from www. j av a 2 s . c om log.info("Successfully started etcd at {}", etcdContainer.getClientEndpoint()); }
From source file:org.apache.falcon.resource.AbstractTestBase.java
@BeforeClass public void configure() throws Exception { StartupProperties.get().setProperty("application.services", StartupProperties.get().getProperty("application.services") .replace("org.apache.falcon.service.ProcessSubscriberService", "")); String store = StartupProperties.get().getProperty("config.store.uri"); StartupProperties.get().setProperty("config.store.uri", store + System.currentTimeMillis()); if (new File("webapp/src/main/webapp").exists()) { this.server = new EmbeddedServer(15000, "webapp/src/main/webapp"); } else if (new File("src/main/webapp").exists()) { this.server = new EmbeddedServer(15000, "src/main/webapp"); } else {/*from ww w. j a v a 2 s .c o m*/ throw new RuntimeException("Cannot run jersey tests"); } ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); this.service = client.resource(UriBuilder.fromUri(BASE_URL).build()); this.server.start(); if (System.getProperty("falcon.test.hadoop.embedded", "true").equals("true")) { CLUSTER_FILE_TEMPLATE = "target/cluster-template.xml"; this.cluster = EmbeddedCluster.newCluster("##cluster##", true); Cluster clusterEntity = this.cluster.getCluster(); FileOutputStream out = new FileOutputStream(CLUSTER_FILE_TEMPLATE); marshaller.marshal(clusterEntity, out); out.close(); } else { Map<String, String> overlay = new HashMap<String, String>(); overlay.put("cluster", RandomStringUtils.randomAlphabetic(5)); String file = overlayParametersOverTemplate(CLUSTER_FILE_TEMPLATE, overlay); this.cluster = StandAloneCluster.newCluster(file); clusterName = cluster.getCluster().getName(); } cleanupStore(); // setup dependent workflow and lipath in hdfs FileSystem fs = FileSystem.get(this.cluster.getConf()); fs.mkdirs(new Path("/falcon"), new FsPermission((short) 511)); Path wfParent = new Path("/falcon/test"); fs.delete(wfParent, true); Path wfPath = new Path(wfParent, "workflow"); fs.mkdirs(wfPath); fs.copyFromLocalFile(false, true, new Path(this.getClass().getResource("/fs-workflow.xml").getPath()), new Path(wfPath, "workflow.xml")); fs.mkdirs(new Path(wfParent, "input/2012/04/20/00")); Path outPath = new Path(wfParent, "output"); fs.mkdirs(outPath); fs.setPermission(outPath, new FsPermission((short) 511)); }