org.apache.flink.formats.avro.utils.TestDataGenerator Java Examples

The following examples show how to use org.apache.flink.formats.avro.utils.TestDataGenerator. 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: AvroSerializerSnapshotTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void recordSerializedShouldBeDeserializeWithTheResortedSerializer() throws IOException {
	// user is an avro generated test object.
	final User user = TestDataGenerator.generateRandomUser(new Random());
	final AvroSerializer<User> originalSerializer = new AvroSerializer<>(User.class);
	//
	// first serialize the record
	//
	ByteBuffer serializedUser = serialize(originalSerializer, user);
	//
	// then restore a serializer from the snapshot
	//
	TypeSerializer<User> restoredSerializer = originalSerializer.snapshotConfiguration().restoreSerializer();
	//
	// now deserialize the user with the resorted serializer.
	//
	User restoredUser = deserialize(restoredSerializer, serializedUser);

	assertThat(user, is(restoredUser));
}
 
Example #2
Source File: AvroSerializerSnapshotTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void recordSerializedShouldBeDeserializeWithTheResortedSerializer() throws IOException {
	// user is an avro generated test object.
	final User user = TestDataGenerator.generateRandomUser(new Random());
	final AvroSerializer<User> originalSerializer = new AvroSerializer<>(User.class);
	//
	// first serialize the record
	//
	ByteBuffer serializedUser = serialize(originalSerializer, user);
	//
	// then restore a serializer from the snapshot
	//
	TypeSerializer<User> restoredSerializer = originalSerializer.snapshotConfiguration().restoreSerializer();
	//
	// now deserialize the user with the resorted serializer.
	//
	User restoredUser = deserialize(restoredSerializer, serializedUser);

	assertThat(user, is(restoredUser));
}
 
Example #3
Source File: AvroSerializerSnapshotTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void recordSerializedShouldBeDeserializeWithTheResortedSerializer() throws IOException {
	// user is an avro generated test object.
	final User user = TestDataGenerator.generateRandomUser(new Random());
	final AvroSerializer<User> originalSerializer = new AvroSerializer<>(User.class);
	//
	// first serialize the record
	//
	ByteBuffer serializedUser = serialize(originalSerializer, user);
	//
	// then restore a serializer from the snapshot
	//
	TypeSerializer<User> restoredSerializer = originalSerializer.snapshotConfiguration().restoreSerializer();
	//
	// now deserialize the user with the resorted serializer.
	//
	User restoredUser = deserialize(restoredSerializer, serializedUser);

	assertThat(user, is(restoredUser));
}
 
Example #4
Source File: AvroSerializerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected User[] getTestData() {
	final Random rnd = new Random();
	final User[] users = new User[20];

	for (int i = 0; i < users.length; i++) {
		users[i] = TestDataGenerator.generateRandomUser(rnd);
	}

	return users;
}
 
Example #5
Source File: AvroSerializerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected User[] getTestData() {
	final Random rnd = new Random();
	final User[] users = new User[20];

	for (int i = 0; i < users.length; i++) {
		users[i] = TestDataGenerator.generateRandomUser(rnd);
	}

	return users;
}
 
Example #6
Source File: AvroSerializerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected User[] getTestData() {
	final Random rnd = new Random();
	final User[] users = new User[20];

	for (int i = 0; i < users.length; i++) {
		users[i] = TestDataGenerator.generateRandomUser(rnd);
	}

	return users;
}