Java Code Examples for org.apache.flink.util.StringUtils#getRandomString()
The following examples show how to use
org.apache.flink.util.StringUtils#getRandomString() .
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: StringValueSerializationTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testLongValues() { try { String[] testStrings = new String[] { StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2) }; testSerialization(testStrings); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Exception in test: " + e.getMessage()); } }
Example 2
Source File: StringValueSerializationTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testLongValues() { try { String[] testStrings = new String[] { StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2) }; testSerialization(testStrings); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Exception in test: " + e.getMessage()); } }
Example 3
Source File: AbstractGenericArraySerializerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testString() { String[] arr1 = new String[] {"abc", "", StringUtils.getRandomString(new Random(289347567856686223L), 10, 100), StringUtils.getRandomString(new Random(289347567856686223L), 15, 50), StringUtils.getRandomString(new Random(289347567856686223L), 30, 170), StringUtils.getRandomString(new Random(289347567856686223L), 14, 15), ""}; String[] arr2 = new String[] {"foo", "", StringUtils.getRandomString(new Random(289347567856686223L), 10, 100), StringUtils.getRandomString(new Random(289347567856686223L), 1000, 5000), StringUtils.getRandomString(new Random(289347567856686223L), 30000, 35000), StringUtils.getRandomString(new Random(289347567856686223L), 100*1024, 105*1024), "bar"}; // run tests with the string serializer as the component serializer runTests(String.class, new StringSerializer(), arr1, arr2); // run the tests with the generic serializer as the component serializer runTests(arr1, arr2); }
Example 4
Source File: StringSerializationTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testMixedValues() { try { String[] testStrings = new String[] { StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), "", StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), null, StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), null, "", StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), "", null }; testSerialization(testStrings); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Exception in test: " + e.getMessage()); } }
Example 5
Source File: StringValueSerializationTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testBinaryCopyOfLongStrings() { try { String[] testStrings = new String[] { StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), "", StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), "", StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), "" }; testCopy(testStrings); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Exception in test: " + e.getMessage()); } }
Example 6
Source File: StringSerializationTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testBinaryCopyOfLongStrings() { try { String[] testStrings = new String[] { StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), "", StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), null, StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), null, "", StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2), "", null }; testCopy(testStrings); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Exception in test: " + e.getMessage()); } }
Example 7
Source File: AbstractGenericArraySerializerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSimpleTypesObjects() { SimpleTypes a = new SimpleTypes(); SimpleTypes b = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes c = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes d = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes e = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes f = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes g = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); runTests(new SimpleTypes[] {a, b, c}, new SimpleTypes[] {d, e, f, g}); }
Example 8
Source File: AbstractGenericArraySerializerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSimpleTypesObjects() { SimpleTypes a = new SimpleTypes(); SimpleTypes b = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes c = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes d = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes e = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes f = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); SimpleTypes g = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(), StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble()); runTests(new SimpleTypes[] {a, b, c}, new SimpleTypes[] {d, e, f, g}); }
Example 9
Source File: TupleSerializerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testTuple2StringDouble() { Random rnd = new Random(807346528946L); @SuppressWarnings("unchecked") Tuple2<String, Double>[] testTuples = new Tuple2[] { new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()), new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()), new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()), new Tuple2<String, Double>("", rnd.nextDouble()), new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()), new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()) }; runTests(-1, testTuples); }
Example 10
Source File: TupleSerializerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testTuple2StringDouble() { Random rnd = new Random(807346528946L); @SuppressWarnings("unchecked") Tuple2<String, Double>[] testTuples = new Tuple2[] { new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()), new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()), new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()), new Tuple2<String, Double>("", rnd.nextDouble()), new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()), new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()) }; runTests(-1, testTuples); }
Example 11
Source File: AbstractGenericArraySerializerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testString() { String[] arr1 = new String[] {"abc", "", StringUtils.getRandomString(new Random(289347567856686223L), 10, 100), StringUtils.getRandomString(new Random(289347567856686223L), 15, 50), StringUtils.getRandomString(new Random(289347567856686223L), 30, 170), StringUtils.getRandomString(new Random(289347567856686223L), 14, 15), ""}; String[] arr2 = new String[] {"foo", "", StringUtils.getRandomString(new Random(289347567856686223L), 10, 100), StringUtils.getRandomString(new Random(289347567856686223L), 1000, 5000), StringUtils.getRandomString(new Random(289347567856686223L), 30000, 35000), StringUtils.getRandomString(new Random(289347567856686223L), 100*1024, 105*1024), "bar"}; // run tests with the string serializer as the component serializer runTests(String.class, new StringSerializer(), arr1, arr2); // run the tests with the generic serializer as the component serializer runTests(arr1, arr2); }
Example 12
Source File: StringSerializationTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testStringBinaryCompatibility() { try { String[] testStrings = new String[] { StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2, (char) 1, (char) 127), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2, (char) 128, (char) 16383), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2, (char) 16384, (char) 65535), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2, (char) 1, (char) 16383), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2, (char) 1, (char) 65535), StringUtils.getRandomString(rnd, 10000, 1024 * 1024 * 2, (char) 128, (char) 65535) }; for (String testString: testStrings) { // new and old impl should produce the same binary result byte[] oldBytes = serializeBytes(testString, StringSerializationTest::oldWriteString); byte[] newBytes = serializeBytes(testString, StringSerializationTest::newWriteString); assertArrayEquals(oldBytes, newBytes); // old impl should read bytes from new one String oldString = deserializeBytes(newBytes, StringSerializationTest::oldReadString); assertEquals(oldString, testString); // new impl should read bytes from old one String newString = deserializeBytes(oldBytes, StringSerializationTest::newReadString); assertEquals(newString, testString); // it should roundtrip over new impl String roundtrip = deserializeBytes(newBytes, StringSerializationTest::newReadString); assertEquals(roundtrip, testString); } } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); fail("Exception in test: " + e.getMessage()); } }
Example 13
Source File: TupleSerializerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testTuple2StringStringArray() { Random rnd = new Random(289347567856686223L); String[] arr1 = new String[] {"abc", "", StringUtils.getRandomString(rnd, 10, 100), StringUtils.getRandomString(rnd, 15, 50), StringUtils.getRandomString(rnd, 30, 170), StringUtils.getRandomString(rnd, 14, 15), ""}; String[] arr2 = new String[] {"foo", "", StringUtils.getRandomString(rnd, 10, 100), StringUtils.getRandomString(rnd, 1000, 5000), StringUtils.getRandomString(rnd, 30000, 35000), StringUtils.getRandomString(rnd, 100*1024, 105*1024), "bar"}; @SuppressWarnings("unchecked") Tuple2<String, String[]>[] testTuples = new Tuple2[] { new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr1), new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr2), new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr1), new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr2), new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr2) }; runTests(-1, testTuples); }
Example 14
Source File: HadoopS3RecoverableWriterITCase.java From flink with Apache License 2.0 | 5 votes |
@Before public void prepare() throws Exception { basePathForTest = new Path( basePath, StringUtils.getRandomString(RND, 16, 16, 'a', 'z')); cleanupLocalDir(); }
Example 15
Source File: AbstractRecoverableWriterTest.java From flink with Apache License 2.0 | 4 votes |
private static String randomName() { return StringUtils.getRandomString(RND, 16, 16, 'a', 'z'); }
Example 16
Source File: AbstractTtlStateVerifier.java From flink with Apache License 2.0 | 4 votes |
@Nonnull static String randomString() { return StringUtils.getRandomString(RANDOM, 2, 20); }
Example 17
Source File: FileSystemBehaviorTestSuite.java From flink with Apache License 2.0 | 4 votes |
private static String randomName() { return StringUtils.getRandomString(RND, 16, 16, 'a', 'z'); }
Example 18
Source File: FileSystemBehaviorTestSuite.java From flink with Apache License 2.0 | 4 votes |
private static String randomName() { return StringUtils.getRandomString(RND, 16, 16, 'a', 'z'); }
Example 19
Source File: FileSystemBehaviorTestSuite.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private static String randomName() { return StringUtils.getRandomString(RND, 16, 16, 'a', 'z'); }
Example 20
Source File: AbstractTtlStateVerifier.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Nonnull static String randomString() { return StringUtils.getRandomString(RANDOM, 2, 20); }