Java Code Examples for org.apache.commons.lang.RandomStringUtils#randomAlphabetic()
The following examples show how to use
org.apache.commons.lang.RandomStringUtils#randomAlphabetic() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateMultiCacheAdviceTest.java From simple-spring-memcached with MIT License | 6 votes |
@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)); } 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); } }
Example 2
Source File: ConfigurationBuilderTest.java From chassis with Apache License 2.0 | 6 votes |
@Test public void buildConfigurationInAws(){ String az = "testaz"; String instanceId = RandomStringUtils.randomAlphabetic(10); String region = Regions.DEFAULT_REGION.getName(); ServerInstanceContext serverInstanceContext = EasyMock.createMock(ServerInstanceContext.class); EasyMock.expect(serverInstanceContext.getAvailabilityZone()).andReturn(az); EasyMock.expect(serverInstanceContext.getInstanceId()).andReturn(instanceId); EasyMock.expect(serverInstanceContext.getRegion()).andReturn(region); EasyMock.expect(serverInstanceContext.getPrivateIp()).andReturn("127.0.0.1"); EasyMock.expect(serverInstanceContext.getPublicIp()).andReturn(null); EasyMock.replay(serverInstanceContext); Configuration configuration = configurationBuilder.withServerInstanceContext(serverInstanceContext).build(); Assert.assertEquals(az, configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_AVAILABILITY_ZONE.getPropertyName())); Assert.assertEquals(instanceId, configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_ID.getPropertyName())); Assert.assertEquals(region, configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_REGION.getPropertyName())); Assert.assertEquals("127.0.0.1", configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_PRIVATE_IP.getPropertyName())); Assert.assertEquals(null, configuration.getString(BootstrapConfigKeys.AWS_INSTANCE_PUBLIC_IP.getPropertyName())); EasyMock.verify(serverInstanceContext); }
Example 3
Source File: UniqueNameVerifierTest.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void verifyResourceTableColumnNameAreUniqueWhenComputingShortName2() { // Category short name will be shorten to 49 chars, and create 3 identical // short-names String indicatorGroupSetName = RandomStringUtils.randomAlphabetic( 50 ); final List<IndicatorGroupSet> indicatorGroupSets = IntStream.of( 1, 2, 3 ) .mapToObj( i -> new IndicatorGroupSet( indicatorGroupSetName + 1 ) ) .peek( c -> c.setUid( CodeGenerator.generateUid() ) ).collect( Collectors.toList() ); IndicatorGroupSetResourceTable indicatorGroupSetResourceTable = new IndicatorGroupSetResourceTable( indicatorGroupSets ); final String sql = indicatorGroupSetResourceTable.getCreateTempTableStatement(); assertEquals( countMatches( sql, "\"" + indicatorGroupSets.get( 0 ).getName() + "\"" ), 1 ); assertEquals( countMatches( sql, "\"" + indicatorGroupSets.get( 0 ).getName() + "1\"" ), 1 ); assertEquals( countMatches( sql, "\"" + indicatorGroupSets.get( 0 ).getName() + "2\"" ), 1 ); }
Example 4
Source File: SampleExtensionService.java From smarthome with Eclipse Public License 2.0 | 6 votes |
@Activate protected void activate() { types.add(new ExtensionType("binding", "Bindings")); types.add(new ExtensionType("ui", "User Interfaces")); types.add(new ExtensionType("persistence", "Persistence Services")); for (ExtensionType type : types) { for (int i = 0; i < 10; i++) { String id = type.getId() + Integer.toString(i); boolean installed = Math.random() > 0.5; String name = RandomStringUtils.randomAlphabetic(5); String label = name + " " + StringUtils.capitalize(type.getId()); String typeId = type.getId(); String version = "1.0"; String link = (Math.random() < 0.5) ? null : "http://lmgtfy.com/?q=" + name; String description = createDescription(); String imageLink = null; String backgroundColor = createRandomColor(); Extension extension = new Extension(id, typeId, label, version, link, installed, description, backgroundColor, imageLink); extensions.put(extension.getId(), extension); } } }
Example 5
Source File: FixedByteSingleValueMultiColumnReaderWriterTest.java From incubator-pinot with Apache License 2.0 | 6 votes |
private void testMutability() { for (int i = 0; i < NUM_ROWS; i++) { int row = _random.nextInt(NUM_ROWS); int intValue = _random.nextInt(); _readerWriter.setInt(row, 0, intValue); Assert.assertEquals(_readerWriter.getInt(row, 0), intValue); long longValue = _random.nextLong(); _readerWriter.setLong(row, 1, longValue); Assert.assertEquals(_readerWriter.getLong(row, 1), longValue); float floatValue = _random.nextFloat(); _readerWriter.setFloat(row, 2, floatValue); Assert.assertEquals(_readerWriter.getFloat(row, 2), floatValue); double doubleValue = _random.nextDouble(); _readerWriter.setDouble(row, 3, doubleValue); Assert.assertEquals(_readerWriter.getDouble(row, 3), doubleValue); String stringValue = RandomStringUtils.randomAlphabetic(STRING_LENGTH); _readerWriter.setString(row, 4, stringValue); Assert.assertEquals(_readerWriter.getString(row, 4), stringValue); } }
Example 6
Source File: ConfigComponentLookUpAndCopyAftBase.java From rice with Educational Community License v2.0 | 6 votes |
public void testConfigComponentLookUpAndCopy() throws Exception { selectFrameIframePortlet(); waitAndClickSearchSecond(); waitAndClickByLinkText("copy"); String fourLetters = RandomStringUtils.randomAlphabetic(4); waitAndTypeByName("document.documentHeader.documentDescription","Test description of Component copy " + AutomatedFunctionalTestUtils .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"); }
Example 7
Source File: TestExecutionContextImplTest.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Test public void testWithSubjectNoProgressThread(){ String subject = RandomStringUtils.randomAlphabetic(10); TestExecutionContext<String> context = new TestExecutionContextImpl<>(subject); Assert.assertEquals(subject, context.getSubject()); // Check that nothing explodes context.getProgressListener().setTotal(100); context.getProgressListener().setCompleted(5); context.getProgressListener().setMessage("Nearly there"); context.getProgressListener().complete(); context.checkCancelled(); }
Example 8
Source File: NioUdpDataSenderTest.java From pinpoint with Apache License 2.0 | 5 votes |
@Test(expected = IOException.class) public void exceedMessageSendTest() throws IOException { String random = RandomStringUtils.randomAlphabetic(ThriftUdpMessageSerializer.UDP_MAX_PACKET_LENGTH + 100); TAgentInfo agentInfo = new TAgentInfo(); agentInfo.setAgentId(random); NioUDPDataSender sender = newNioUdpDataSender(); sender.send(agentInfo); waitMessageReceived(1); }
Example 9
Source File: ValueProviderParameterImplTest.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@BeforeClass public static void setup() { name = RandomStringUtils.randomAlphabetic(5); value = RandomStringUtils.randomAlphanumeric(10); parameters = new ValueProviderParameter[8]; for (int i = 0; i < 8; i++) { parameters[i] = new ValueProviderParameterImpl(name, i % 2 == (i < 4 ? 0 : 1) ? value : null, i % 4 > 1, (i % 4) % 3 != 0); } EncryptionProvider.initialize(); }
Example 10
Source File: ConfigurationParameterImplTest.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@BeforeClass public static void setup() { name = RandomStringUtils.randomAlphabetic(5); value = RandomStringUtils.randomAlphanumeric(10); injectorName = RandomStringUtils.randomAlphabetic(5); parameters = new ConfigurationParameter[8]; for (int i = 0; i < parameters.length; i++) { parameters[i] = new ConfigurationParameterImpl(name, value, (i & 1) == 1, (i & 2) == 2 ? injectorName : null, i > 4); } EncryptionProvider.initialize(); }
Example 11
Source File: CampusAftBase.java From rice with Educational Community License v2.0 | 5 votes |
private void reattemptPrimaryKey() throws InterruptedException { int attempts = 0; while (isTextPresent("a record with the same primary key already exists.") && ++attempts <= 10) { jGrowl("record with the same primary key already exists trying another, attempt: " + attempts); clearTextByName("document.newMaintainableObject.code"); // primary key String randomNumbeForCode = RandomStringUtils.randomNumeric(1); String randomAlphabeticForCode = RandomStringUtils.randomAlphabetic(1); jiraAwareTypeByName("document.newMaintainableObject.code", randomNumbeForCode + randomAlphabeticForCode); waitAndClickByName("methodToCall.route"); waitForProgress("Submitting..."); } }
Example 12
Source File: DashboardServiceTest.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
private EventChart createEventChart( Program program ) { EventChart eventChart = new EventChart( RandomStringUtils.randomAlphabetic( 5 ) ); eventChart.setProgram( program ); eventChart.setType( ChartType.COLUMN ); return eventChart; }
Example 13
Source File: SelectMappingsQueryTest.java From usergrid with Apache License 2.0 | 5 votes |
/** * Field named testProp can be over-written by field named TESTPROP. */ @Test public void testFieldOverride2() throws Exception { String collectionName = "tennisballs"; // create entity with TESTPROP=value String value = RandomStringUtils.randomAlphabetic( 20 ); Entity entity = new Entity().withProp( "TESTPROP", value ); app().collection( collectionName ).post( entity ); waitForQueueDrainAndRefreshIndex(); // override with testProp=newValue String newValue = RandomStringUtils.randomAlphabetic( 20 ); entity = new Entity().withProp( "testProp", newValue ); app().collection( collectionName ).post( entity ); waitForQueueDrainAndRefreshIndex(); // testProp and TESTPROP should new be queryable by new value QueryParameters params = new QueryParameters() .setQuery( "select * where testProp='" + newValue + "'" ); Collection coll = this.app().collection(collectionName).get( params ); assertEquals( 1, coll.getNumOfEntities() ); params = new QueryParameters() .setQuery( "select * where TESTPROP='" + newValue + "'" ); coll = app().collection(collectionName).get( params ); assertEquals( 1, coll.getNumOfEntities() ); }
Example 14
Source File: ObjectUpdateSynchronizerTest.java From atlas with Apache License 2.0 | 5 votes |
public void run() { objectUpdateSynchronizer.lockObject(CollectionUtils.arrayToList(ids)); for (int i = 0; i < MAX_COUNT; i++) { outputList.add(i); RandomStringUtils.randomAlphabetic(20); } objectUpdateSynchronizer.releaseLockedObjects(); }
Example 15
Source File: StompWebSocketMaxFrameTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testStompSendReceiveWithMaxFramePayloadLength() throws Exception { // Assert that sending message > default 64kb fails int size = 65536; String largeString1 = RandomStringUtils.randomAlphabetic(size); String largeString2 = RandomStringUtils.randomAlphabetic(size); StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri, false); conn.getTransport().setMaxFrameSize(stompWSMaxFrameSize); conn.getTransport().connect(); StompClientConnection conn2 = StompClientConnectionFactory.createClientConnection(wsURI, false); conn2.getTransport().setMaxFrameSize(stompWSMaxFrameSize); conn2.getTransport().connect(); Wait.waitFor(() -> conn2.getTransport().isConnected() && conn.getTransport().isConnected(), 10000); conn.connect(); conn2.connect(); subscribeQueue(conn2, "sub1", getQueuePrefix() + getQueueName()); try { // Client is kicked when sending frame > largest frame size. send(conn, getQueuePrefix() + getQueueName(), "text/plain", largeString1, false); Wait.waitFor(() -> !conn.getTransport().isConnected(), 2000); assertFalse(conn.getTransport().isConnected()); send(conn2, getQueuePrefix() + getQueueName(), "text/plain", largeString2, false); Wait.waitFor(() -> !conn2.getTransport().isConnected(), 2000); assertTrue(conn2.getTransport().isConnected()); ClientStompFrame frame = conn2.receiveFrame(); assertNotNull(frame); assertEquals(largeString2, frame.getBody()); } finally { conn2.closeTransport(); conn.closeTransport(); } }
Example 16
Source File: MutliAviaterFilterTest.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
private void doRegexTest() { AviaterRegexFilter filter3 = new AviaterRegexFilter("otter2.otter_stability1|otter1.otter_stability1|" + RandomStringUtils.randomAlphabetic(200)); boolean result = filter3.filter("otter1.otter_stability1"); Assert.assertEquals(true, result); result = filter3.filter("otter2.otter_stability1"); Assert.assertEquals(true, result); }
Example 17
Source File: TopNCounterTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
protected String prepareTestDate() throws IOException { String[] allKeys = new String[KEY_SPACE]; for (int i = 0; i < KEY_SPACE; i++) { allKeys[i] = RandomStringUtils.randomAlphabetic(10); } outputMsg("Start to create test random data..."); long startTime = System.currentTimeMillis(); ZipfDistribution zipf = new ZipfDistribution(KEY_SPACE, 0.5); int keyIndex; File tempFile = File.createTempFile("ZipfDistribution", ".txt"); if (tempFile.exists()) FileUtils.forceDelete(tempFile); Writer fw = new OutputStreamWriter(new FileOutputStream(tempFile), StandardCharsets.UTF_8); try { for (int i = 0; i < TOTAL_RECORDS; i++) { keyIndex = zipf.sample() - 1; fw.write(allKeys[keyIndex]); fw.write('\n'); } } finally { if (fw != null) fw.close(); } outputMsg("Create test data takes : " + (System.currentTimeMillis() - startTime) / 1000 + " seconds."); outputMsg("Test data in : " + tempFile.getAbsolutePath()); return tempFile.getAbsolutePath(); }
Example 18
Source File: TestFetcher.java From indexr with Apache License 2.0 | 4 votes |
@Override public List<UTF8Row> next() throws Exception { if (sleep > 0) { Thread.sleep(sleep); } int colId = 0; StringBuilder sb = new StringBuilder(); sb.append('{'); if (!Strings.isEmpty(tagField) && randomTags != null && !randomTags.isEmpty()) { sb.append("\"").append(tagField).append("\":\"").append(randomTags.get(random.nextInt(randomTags.size()))).append("\","); } for (ColumnSchema cs : schema.getColumns()) { sb.append('\"').append(cs.getName()).append("\": "); switch (cs.getSqlType()) { case DATE: LocalDate date = LocalDate.now(); sb.append('\"').append(date.format(DateTimeUtil.DATE_FORMATTER)).append('\"'); break; case TIME: LocalTime time = LocalTime.now(); sb.append('\"').append(time.format(DateTimeUtil.TIME_FORMATTER)).append('\"'); break; case DATETIME: LocalDateTime dateTime = LocalDateTime.now(); sb.append('\"').append(dateTime.format(DateTimeUtil.DATETIME_FORMATTER)).append('\"'); break; case VARCHAR: if (randomValue) { String colValue = RandomStringUtils.randomAlphabetic(random.nextInt(20)); sb.append('\"').append(colValue).append('\"'); } else { sb.append("\"1\""); } break; default: if (randomValue) { sb.append(random.nextInt()); } else { sb.append(1); } } colId++; if (colId < schema.getColumns().size()) { sb.append(','); } } sb.append('}'); byte[] data = sb.toString().getBytes("utf-8"); return utf8JsonRowCreator.create(data); }
Example 19
Source File: RandomTestMocks.java From BUbiNG with Apache License 2.0 | 4 votes |
public HttpRequest(final int maxNumberOfHeaders, final int maxLenghtOfHeader, final int pos) { this.requestLine = new BasicRequestLine("GET", RandomStringUtils.randomAlphabetic(RNG.nextInt(maxLenghtOfHeader) + 1), PROTOCOL_VERSION); Header[] headers = randomHeaders(maxNumberOfHeaders, maxLenghtOfHeader); headers[RNG.nextInt(headers.length)] = new BasicHeader("Position", Integer.toString(pos)); this.setHeaders(headers); }
Example 20
Source File: BasepackageBinder.java From j-road with Apache License 2.0 | 3 votes |
@Override public String lookupPackageForNamespace(String uri) { String random = RandomStringUtils.randomAlphabetic(5); uri = uri.replace("-", random); String pck = NameUtil.getPackageFromNamespace(uri).replace(random, "_"); return basePackage == null ? pck : basePackage + "." + pck; }