List of usage examples for org.apache.commons.javaflow Continuation startWith
public static Continuation startWith(final Runnable pTarget, final Object pContext)
From source file:com.topekalabs.bigmachine.lib.app.SimpleContinuationTest.java
@Test public void simpleTest() { MutableInt context = new MutableInt(); Continuation c = Continuation.startWith(new SimpleContinuationRunnable(), context); Assert.assertEquals("The value of the context was not set properly", SimpleContinuationRunnable.FIRST_VALUE, context.getValue());/*from w ww .j a va 2s. com*/ Continuation.continueWith(c, context); Assert.assertEquals("The value of the context was not set properly", SimpleContinuationRunnable.SECOND_VALUE, context.getValue()); }
From source file:com.topekalabs.bigmachine.lib.app.ContinuationSerializationTest.java
@Test public void simpleSerializationTest() throws Exception { MutableInt context = new MutableInt(); Continuation c = Continuation.startWith(new SimpleContinuationRunnable(), context); logger.debug("Is serializable: {}", c.isSerializable()); Assert.assertEquals("The value of the context was not set properly", SimpleContinuationRunnable.FIRST_VALUE, context.getValue());// w ww . j a va2 s .co m ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(c); oos.close(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())); c = (Continuation) ois.readObject(); ois.close(); Continuation.continueWith(c, context); Assert.assertEquals("The value of the context was not set properly", SimpleContinuationRunnable.SECOND_VALUE, context.getValue()); }