blob: 0f9d171295be24322b68dd5727dad1964fad2a78 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.ode.jacob.examples.cell;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.ode.jacob.JacobRunnable;
import org.apache.ode.jacob.ReceiveProcess;
import org.apache.ode.jacob.Val;
import org.apache.ode.jacob.vpu.ExecutionQueueImpl;
import org.apache.ode.jacob.vpu.JacobVPU;
import static org.apache.ode.jacob.ProcessUtil.receive;
public class JacobCellTest extends TestCase {
private static Object _val;
public JacobCellTest(String testName) {
super(testName);
}
public void testJacobCell1() throws IOException {
ExecutionQueueImpl fsoup = new ExecutionQueueImpl(null);
JacobVPU vpu = new JacobVPU();
vpu.setContext(fsoup);
vpu.inject(new CellTest1());
while (vpu.execute()) {
vpu.flush();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
fsoup.write(bos);
bos.close();
System.err.println("CONTINUATION SIZE: " + bos.size());
}
vpu.dumpState();
fsoup.dumpState(System.err);
assertNotNull(_val);
assertEquals("foo", _val);
}
@SuppressWarnings("serial")
static class CellTest1 extends JacobRunnable {
public void run() {
Cell cell = newChannel(Cell.class, "cell");
Val ret = newChannel(Val.class, "val");
instance(new CELL_<String>(cell, "foo"));
object(receive(ret, new Val() {
public void val(Object retVal) {
_val = retVal;
}
}));
cell.read(ret);
}
}
}