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:gobblin.data.management.copy.CopyableFileUtils.java
private static String getRandomPath() { return new Path(RandomStringUtils.randomAlphabetic(6), RandomStringUtils.randomAlphabetic(6)).toString(); }
From source file:com.redhat.rhn.manager.system.test.VirtualizationEntitlementsManagerTest.java
public void testListFlexGuests() throws Exception { Org org = UserTestUtils.createNewOrgFull(RandomStringUtils.randomAlphabetic(10)); User user = UserTestUtils.createUser(RandomStringUtils.randomAlphabetic(10), org.getId()); user.addRole(RoleFactory.ORG_ADMIN); UserFactory.save(user);//from w w w. jav a 2s . c o m setupFlexGuestTest(user, false); }
From source file:com.googlesource.gerrit.plugins.supermanifest.RepoSuperManifestIT.java
void setupTestRepos(String prefix) throws Exception { testRepoKeys = new Project.NameKey[2]; testRepoCommits = new String[2]; for (int i = 0; i < 2; i++) { testRepoKeys[i] = projectOperations.newProject() .name(RandomStringUtils.randomAlphabetic(8) + prefix + i).create(); TestRepository<InMemoryRepository> repo = cloneProject(testRepoKeys[i], admin); PushOneCommit push = pushFactory.create(admin.getIdent(), repo, "Subject", "file" + i, "file"); Result r = push.to("refs/heads/master"); r.assertOkStatus();// ww w . j av a2 s .c om testRepoCommits[i] = r.getCommit().getName(); } }
From source file:edu.sampleu.kim.api.identity.IdentityPersonLookUpEditAftBase.java
public void testIdentityPersonLookUpEdit() throws Exception { String randomSalary = RandomStringUtils.randomNumeric(6); String randomMiddleName = RandomStringUtils.randomAlphabetic(6); ;// w ww . ja v a2 s. co m String randomAddress = RandomStringUtils.randomNumeric(6); ; String randomExtension = RandomStringUtils.randomNumeric(6); ; String randomEmail = RandomStringUtils.randomAlphabetic(6); ; selectFrameIframePortlet(); waitAndTypeByName("principalName", "fran"); waitAndClickSearchSecond(); selectFrameIframePortlet(); waitAndClickByXpath("//a[@title='edit Person withPrincipal ID=fran ']"); waitAndTypeByName("document.documentHeader.documentDescription", "Test description of person"); // Add new information if it is not present. Otherwise, edit the existing information. if (isElementPresentByName("document.affiliations[0].campusCode")) { clearTextByName("document.affiliations[0].empInfos[0].baseSalaryAmount"); waitAndTypeByName("document.affiliations[0].empInfos[0].baseSalaryAmount", "1" + randomSalary); } else { selectByName("newAffln.affiliationTypeCode", "Staff"); selectByName("newAffln.campusCode", "BL - BLOOMINGTON"); waitAndClickByName("newAffln.dflt"); waitAndClickByName("methodToCall.addAffln.anchor"); waitAndTypeByName("document.affiliations[0].newEmpInfo.employeeId", "9999999999"); waitAndClickByName("document.affiliations[0].newEmpInfo.primary"); selectByName("document.affiliations[0].newEmpInfo.employmentStatusCode", "Active"); selectByName("document.affiliations[0].newEmpInfo.employmentTypeCode", "Professional"); waitAndTypeByName("document.affiliations[0].newEmpInfo.baseSalaryAmount", "1" + randomSalary); waitAndTypeByXpath("//*[@id='document.affiliations[0].newEmpInfo.primaryDepartmentCode']", "BL-BUS"); waitAndClickByName("methodToCall.addEmpInfo.line0.anchor"); } waitAndClickByName("methodToCall.showAllTabs"); // Add nick name or edit the existing one if (isTextPresent("CrazyNickName")) { clearTextByName("document.names[1].middleName"); waitAndTypeByName("document.names[1].middleName", randomMiddleName); } else { waitAndTypeByName("newName.firstName", "CrazyNickName"); waitAndTypeByName("newName.middleName", randomMiddleName); waitAndTypeByName("newName.lastName", "fran"); waitAndClickByName("methodToCall.addName.anchor"); } // Add address or edit the existing one if (isTextPresent("CrazyHomeAddress")) { clearTextByName("document.addrs[0].line1"); waitAndTypeByName("document.addrs[0].line1", randomAddress + " Main St"); } else { waitAndTypeByName("newAddress.line1", randomAddress + " Main St"); waitAndTypeByName("newAddress.line2", "CrazyHomeAddress"); waitAndTypeByName("newAddress.city", "Bloomington"); selectByName("newAddress.stateProvinceCode", "ALASKA"); waitAndTypeByName("newAddress.postalCode", "61821"); selectByName("newAddress.countryCode", "United States"); waitAndClickByName("newAddress.dflt"); waitAndClickByName("methodToCall.addAddress.anchor"); } // Add phone number or edit the existing one if (isTextPresent("555-555-5555")) { clearTextByName("document.phones[0].extensionNumber"); waitAndTypeByName("document.phones[0].extensionNumber", randomExtension); } else { waitAndTypeByName("newPhone.phoneNumber", "555-555-5555"); waitAndTypeByName("newPhone.extensionNumber", randomExtension); selectByName("newPhone.countryCode", "United States"); waitAndClickByName("newPhone.dflt"); waitAndClickByName("methodToCall.addPhone.anchor"); } // Add home email or edit the existing one if (isTextPresent("@gmailCrazy.com")) { clearTextByName("document.emails[1].emailAddress"); waitAndTypeByName("document.emails[1].emailAddress", randomEmail + "@gmailCrazy.com"); } else { waitAndTypeByName("newEmail.emailAddress", randomEmail + "@gmailCrazy.com"); waitAndClickByName("methodToCall.addEmail.anchor"); } waitAndClickByName("methodToCall.route"); waitForTextPresent("Document was successfully submitted."); selectTopFrame(); waitAndClickAdministration(); waitAndClickByLinkText("Person"); selectFrameIframePortlet(); waitAndTypeByName("principalName", "fran"); waitAndClickSearchSecond(); selectFrameIframePortlet(); waitAndClickByXpath("//a[@title='edit Person withPrincipal ID=fran ']"); waitAndClickByName("methodToCall.showAllTabs"); waitForTextPresent("1," + StringUtils.substring(randomSalary, 0, 3) + "," + StringUtils.substring(randomSalary, 3, 6) + ".00"); assertTextPresent(randomMiddleName); assertTextPresent(randomAddress); assertTextPresent(randomExtension); assertTextPresent(randomEmail); testCancelConfirmation(); }
From source file:hr.fer.zemris.vhdllab.dao.impl.FileInfoDaoTest.java
/** * Data is too long./*ww w . ja v a 2s . c o m*/ */ @Test(expected = InvalidStateException.class) public void dataTooLong() { // assume there is enough memory for this test assumeTrue(Runtime.getRuntime().freeMemory() > 17 * 1000 * 1000); entity.setName("name"); entity.setType(FileType.SOURCE); entity.setData(RandomStringUtils.randomAlphabetic(16000001)); dao.persist(entity); }
From source file:com.googlesource.gerrit.plugins.supermanifest.JiriSuperManifestIT.java
void setupTestRepos(String prefix) throws Exception { testRepoKeys = new NameKey[2]; for (int i = 0; i < 2; i++) { testRepoKeys[i] = projectOperations.newProject() .name(RandomStringUtils.randomAlphabetic(8) + prefix + i).create(); TestRepository<InMemoryRepository> repo = cloneProject(testRepoKeys[i], admin); PushOneCommit push = pushFactory.create(admin.getIdent(), repo, "Subject", "file" + i, "file"); push.to("refs/heads/master").assertOkStatus(); }/*from w ww . j a v a 2 s. c o m*/ }
From source file:com.kixeye.chassis.bootstrap.webapp.WebAppIntegrationTest.java
@Before public void before() throws Exception { System.setProperty(APP_VERSION_KEY.getPropertyName(), VERSION); System.setProperty("http.enabled", "true"); TestUtils.resetArchaius();//from w w w .j a va 2 s. c o m environment = RandomStringUtils.randomAlphabetic(10); }
From source file:com.google.code.ssm.aop.UpdateMultiCacheAdviceTest.java
@Test public void testGetCacheKeys() throws Exception { final int size = 10; final List<Object> sources = new ArrayList<Object>(); for (int ix = 0; ix < size; ix++) { sources.add(RandomStringUtils.randomAlphanumeric(3 + ix)); }//from ww w .ja v a 2s . c o m final String namespace = RandomStringUtils.randomAlphabetic(20); final AnnotationData annotationData = new AnnotationData(); annotationData.setNamespace(namespace); final List<String> results = cut.getCacheBase().getCacheKeyBuilder().getCacheKeys(sources, annotationData.getNamespace()); assertEquals(size, results.size()); for (int ix = 0; ix < size; ix++) { final String result = results.get(ix); assertTrue(result.indexOf(namespace) != -1); final String source = (String) sources.get(ix); assertTrue(result.indexOf(source) != -1); } }
From source file:com.lingxiang2014.controller.shop.PasswordController.java
@RequestMapping(value = "/find", method = RequestMethod.POST) public @ResponseBody Message find(String captchaId, String captcha, String username, String email) { if (!captchaService.isValid(CaptchaType.findPassword, captchaId, captcha)) { return Message.error("shop.captcha.invalid"); }//from w w w . ja v a2 s. c om if (StringUtils.isEmpty(username) || StringUtils.isEmpty(email)) { return Message.error("shop.common.invalid"); } Member member = memberService.findByUsername(username); if (member == null) { return Message.error("shop.password.memberNotExist"); } if (!member.getEmail().equalsIgnoreCase(email)) { return Message.error("shop.password.invalidEmail"); } Setting setting = SettingUtils.get(); SafeKey safeKey = new SafeKey(); safeKey.setValue(UUID.randomUUID().toString() + DigestUtils.md5Hex(RandomStringUtils.randomAlphabetic(30))); safeKey.setExpire(setting.getSafeKeyExpiryTime() != 0 ? DateUtils.addMinutes(new Date(), setting.getSafeKeyExpiryTime()) : null); member.setSafeKey(safeKey); memberService.update(member); mailService.sendFindPasswordMail(member.getEmail(), member.getUsername(), safeKey); return Message.success("shop.password.mailSuccess"); }
From source file:eu.scape_project.up2ti.container.ZipContainer.java
/** * Extracts a zip file specified by the zipFilePath to a directory specified by * destDirectory (will be created if does not exists) * @param containerFileName//from w w w .j av a2 s.c om * @param destDirectory * @throws IOException */ public void unzip(String containerFileName, InputStream containerFileStream) throws IOException { extractDirectoryName = "/tmp/up2ti_" + RandomStringUtils.randomAlphabetic(10) + "/"; File destDir = new File(extractDirectoryName); destDir.mkdir(); String subDestDirStr = extractDirectoryName + containerFileName + "/"; File subDestDir = new File(subDestDirStr); subDestDir.mkdir(); ZipInputStream zipIn = new ZipInputStream(containerFileStream); ZipEntry entry = zipIn.getNextEntry(); while (entry != null) { String filePath = subDestDirStr + entry.getName(); if (!entry.isDirectory()) { extractFile(zipIn, filePath); } else { File dir = new File(filePath); dir.mkdir(); } zipIn.closeEntry(); entry = zipIn.getNextEntry(); } zipIn.close(); }