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

The following examples show how to use org.apache.flink.formats.avro.utils.TestDataGenerator. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: AvroSerializerSnapshotTest.java    License: 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 Project: flink   Source File: AvroSerializerSnapshotTest.java    License: 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 Project: flink   Source File: AvroSerializerSnapshotTest.java    License: 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 Project: Flink-CEPplus   Source File: AvroSerializerTest.java    License: 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 Project: flink   Source File: AvroSerializerTest.java    License: 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 Project: flink   Source File: AvroSerializerTest.java    License: 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;
}