Java Code Examples for org.apache.flink.util.InstantiationUtil#createCopyWritable()

The following examples show how to use org.apache.flink.util.InstantiationUtil#createCopyWritable() . 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: TaskEventTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * This test checks the serialization/deserialization of {@link IntegerTaskEvent} objects.
 */
@Test
public void testIntegerTaskEvent() {

	try {
		final IntegerTaskEvent orig = new IntegerTaskEvent(11);
		final IntegerTaskEvent copy = InstantiationUtil.createCopyWritable(orig);

		assertEquals(orig.getInteger(), copy.getInteger());
		assertEquals(orig.hashCode(), copy.hashCode());
		assertTrue(orig.equals(copy));

	} catch (IOException ioe) {
		fail(ioe.getMessage());
	}
}
 
Example 2
Source File: TaskEventTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * This test checks the serialization/deserialization of {@link StringTaskEvent} objects.
 */
@Test
public void testStringTaskEvent() {

	try {

		final StringTaskEvent orig = new StringTaskEvent("Test");
		final StringTaskEvent copy = InstantiationUtil.createCopyWritable(orig);

		assertEquals(orig.getString(), copy.getString());
		assertEquals(orig.hashCode(), copy.hashCode());
		assertTrue(orig.equals(copy));

	} catch (IOException ioe) {
		fail(ioe.getMessage());
	}
}
 
Example 3
Source File: TaskEventTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * This test checks the serialization/deserialization of {@link IntegerTaskEvent} objects.
 */
@Test
public void testIntegerTaskEvent() {

	try {
		final IntegerTaskEvent orig = new IntegerTaskEvent(11);
		final IntegerTaskEvent copy = InstantiationUtil.createCopyWritable(orig);

		assertEquals(orig.getInteger(), copy.getInteger());
		assertEquals(orig.hashCode(), copy.hashCode());
		assertTrue(orig.equals(copy));

	} catch (IOException ioe) {
		fail(ioe.getMessage());
	}
}
 
Example 4
Source File: TaskEventTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * This test checks the serialization/deserialization of {@link StringTaskEvent} objects.
 */
@Test
public void testStringTaskEvent() {

	try {

		final StringTaskEvent orig = new StringTaskEvent("Test");
		final StringTaskEvent copy = InstantiationUtil.createCopyWritable(orig);

		assertEquals(orig.getString(), copy.getString());
		assertEquals(orig.hashCode(), copy.hashCode());
		assertTrue(orig.equals(copy));

	} catch (IOException ioe) {
		fail(ioe.getMessage());
	}
}
 
Example 5
Source File: TaskEventTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * This test checks the serialization/deserialization of {@link IntegerTaskEvent} objects.
 */
@Test
public void testIntegerTaskEvent() {

	try {
		final IntegerTaskEvent orig = new IntegerTaskEvent(11);
		final IntegerTaskEvent copy = InstantiationUtil.createCopyWritable(orig);

		assertEquals(orig.getInteger(), copy.getInteger());
		assertEquals(orig.hashCode(), copy.hashCode());
		assertTrue(orig.equals(copy));

	} catch (IOException ioe) {
		fail(ioe.getMessage());
	}
}
 
Example 6
Source File: TaskEventTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * This test checks the serialization/deserialization of {@link StringTaskEvent} objects.
 */
@Test
public void testStringTaskEvent() {

	try {

		final StringTaskEvent orig = new StringTaskEvent("Test");
		final StringTaskEvent copy = InstantiationUtil.createCopyWritable(orig);

		assertEquals(orig.getString(), copy.getString());
		assertEquals(orig.hashCode(), copy.hashCode());
		assertTrue(orig.equals(copy));

	} catch (IOException ioe) {
		fail(ioe.getMessage());
	}
}
 
Example 7
Source File: ConfigurationTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * This test checks the serialization/deserialization of configuration objects.
 */
@Test
public void testConfigurationSerializationAndGetters() {
	try {
		final Configuration orig = new Configuration();
		orig.setString("mykey", "myvalue");
		orig.setInteger("mynumber", 100);
		orig.setLong("longvalue", 478236947162389746L);
		orig.setFloat("PI", 3.1415926f);
		orig.setDouble("E", Math.E);
		orig.setBoolean("shouldbetrue", true);
		orig.setBytes("bytes sequence", new byte[] { 1, 2, 3, 4, 5 });
		orig.setClass("myclass", this.getClass());

		final Configuration copy = InstantiationUtil.createCopyWritable(orig);
		assertEquals("myvalue", copy.getString("mykey", "null"));
		assertEquals(100, copy.getInteger("mynumber", 0));
		assertEquals(478236947162389746L, copy.getLong("longvalue", 0L));
		assertEquals(3.1415926f, copy.getFloat("PI", 3.1415926f), 0.0);
		assertEquals(Math.E, copy.getDouble("E", 0.0), 0.0);
		assertEquals(true, copy.getBoolean("shouldbetrue", false));
		assertArrayEquals(new byte[] { 1, 2, 3, 4, 5 }, copy.getBytes("bytes sequence", null));
		assertEquals(getClass(), copy.getClass("myclass", null, getClass().getClassLoader()));

		assertEquals(orig, copy);
		assertEquals(orig.keySet(), copy.keySet());
		assertEquals(orig.hashCode(), copy.hashCode());

	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 8
Source File: ConfigurationTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test checks the serialization/deserialization of configuration objects.
 */
@Test
public void testConfigurationSerializationAndGetters() {
	try {
		final Configuration orig = new Configuration();
		orig.setString("mykey", "myvalue");
		orig.setInteger("mynumber", 100);
		orig.setLong("longvalue", 478236947162389746L);
		orig.setFloat("PI", 3.1415926f);
		orig.setDouble("E", Math.E);
		orig.setBoolean("shouldbetrue", true);
		orig.setBytes("bytes sequence", new byte[] { 1, 2, 3, 4, 5 });
		orig.setClass("myclass", this.getClass());

		final Configuration copy = InstantiationUtil.createCopyWritable(orig);
		assertEquals("myvalue", copy.getString("mykey", "null"));
		assertEquals(100, copy.getInteger("mynumber", 0));
		assertEquals(478236947162389746L, copy.getLong("longvalue", 0L));
		assertEquals(3.1415926f, copy.getFloat("PI", 3.1415926f), 0.0);
		assertEquals(Math.E, copy.getDouble("E", 0.0), 0.0);
		assertEquals(true, copy.getBoolean("shouldbetrue", false));
		assertArrayEquals(new byte[] { 1, 2, 3, 4, 5 }, copy.getBytes("bytes sequence", null));
		assertEquals(getClass(), copy.getClass("myclass", null, getClass().getClassLoader()));

		assertEquals(orig, copy);
		assertEquals(orig.keySet(), copy.keySet());
		assertEquals(orig.hashCode(), copy.hashCode());

	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example 9
Source File: ConfigurationTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * This test checks the serialization/deserialization of configuration objects.
 */
@Test
public void testConfigurationSerializationAndGetters() {
	try {
		final Configuration orig = new Configuration();
		orig.setString("mykey", "myvalue");
		orig.setInteger("mynumber", 100);
		orig.setLong("longvalue", 478236947162389746L);
		orig.setFloat("PI", 3.1415926f);
		orig.setDouble("E", Math.E);
		orig.setBoolean("shouldbetrue", true);
		orig.setBytes("bytes sequence", new byte[] { 1, 2, 3, 4, 5 });
		orig.setClass("myclass", this.getClass());

		final Configuration copy = InstantiationUtil.createCopyWritable(orig);
		assertEquals("myvalue", copy.getString("mykey", "null"));
		assertEquals(100, copy.getInteger("mynumber", 0));
		assertEquals(478236947162389746L, copy.getLong("longvalue", 0L));
		assertEquals(3.1415926f, copy.getFloat("PI", 3.1415926f), 0.0);
		assertEquals(Math.E, copy.getDouble("E", 0.0), 0.0);
		assertEquals(true, copy.getBoolean("shouldbetrue", false));
		assertArrayEquals(new byte[] { 1, 2, 3, 4, 5 }, copy.getBytes("bytes sequence", null));
		assertEquals(getClass(), copy.getClass("myclass", null, getClass().getClassLoader()));

		assertEquals(orig, copy);
		assertEquals(orig.keySet(), copy.keySet());
		assertEquals(orig.hashCode(), copy.hashCode());

	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}