clean up
Project: http://git-wip-us.apache.org/repos/asf/ode-jacob/repo Commit: http://git-wip-us.apache.org/repos/asf/ode-jacob/commit/fdaf1f27 Tree: http://git-wip-us.apache.org/repos/asf/ode-jacob/tree/fdaf1f27 Diff: http://git-wip-us.apache.org/repos/asf/ode-jacob/diff/fdaf1f27 Branch: refs/heads/master Commit: fdaf1f278fee65e4766d83efd52ba3e016d91aab Parents: 561ab31 Author: Tammo van Lessen <[email protected]> Authored: Fri Aug 16 00:33:42 2013 +0200 Committer: Tammo van Lessen <[email protected]> Committed: Fri Aug 16 00:33:42 2013 +0200 ---------------------------------------------------------------------- .../apache/ode/jacob/vpu/ChannelRefTest.java | 71 ++++++++++++++++++++ .../org/apache/ode/jacob/vpu/ChannelTest.java | 71 -------------------- .../jacob/vpu/ProxyConstructorTimingTest.java | 1 - 3 files changed, 71 insertions(+), 72 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/fdaf1f27/src/test/java/org/apache/ode/jacob/vpu/ChannelRefTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/ode/jacob/vpu/ChannelRefTest.java b/src/test/java/org/apache/ode/jacob/vpu/ChannelRefTest.java new file mode 100644 index 0000000..756a34f --- /dev/null +++ b/src/test/java/org/apache/ode/jacob/vpu/ChannelRefTest.java @@ -0,0 +1,71 @@ +/* + * 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.vpu; + +import static org.apache.ode.jacob.Jacob.newCommChannel; +import static org.junit.Assert.*; +import org.apache.ode.jacob.ChannelRef; +import org.apache.ode.jacob.oo.Synch; +import org.apache.ode.jacob.oo.Val; +import org.apache.ode.jacob.soup.CommChannel; + +import org.junit.Test; + +public class ChannelRefTest { + + @Test + public void testConnectWithInterface() { + JacobVPU vpu = new JacobVPU(); + vpu.setContext(new ExecutionQueueImpl()); + + vpu.inject(new Runnable() { + + @Override + public void run() { + ChannelRef cref = newCommChannel("unbound channel"); + CommChannel cchannel = cref.getEndpoint(CommChannel.class); + assertNotNull(cchannel); + assertNull(cchannel.getType()); + + // now connect it to Val.class + Val val = cref.getEndpoint(Val.class); + assertNotNull(val); + assertEquals(Val.class, cchannel.getType()); + + // now try to associate it with a different channel interface + try { + cref.getEndpoint(Synch.class); + fail("we should get an IllegalStateException"); + } catch (IllegalStateException e) { + assertEquals("ChannelRef is already associated with a channel of a different type", e.getMessage()); + } + + // now try to associate with the same channel + Val val2 = cref.getEndpoint(Val.class); + assertNotNull(val2); + assertSame(val, val2); + + } + }); + + assertEquals(true, vpu.getContext().hasReactions()); + vpu.execute(); + assertEquals(false, vpu.getContext().hasReactions()); + } +} http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/fdaf1f27/src/test/java/org/apache/ode/jacob/vpu/ChannelTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/ode/jacob/vpu/ChannelTest.java b/src/test/java/org/apache/ode/jacob/vpu/ChannelTest.java deleted file mode 100644 index 3361dfe..0000000 --- a/src/test/java/org/apache/ode/jacob/vpu/ChannelTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.vpu; - -import static org.apache.ode.jacob.Jacob.newCommChannel; -import static org.junit.Assert.*; -import org.apache.ode.jacob.ChannelRef; -import org.apache.ode.jacob.oo.Synch; -import org.apache.ode.jacob.oo.Val; -import org.apache.ode.jacob.soup.CommChannel; - -import org.junit.Test; - -public class ChannelTest { - - @Test - public void testConnectWithInterface() { - JacobVPU vpu = new JacobVPU(); - vpu.setContext(new ExecutionQueueImpl()); - - vpu.inject(new Runnable() { - - @Override - public void run() { - ChannelRef cref = newCommChannel("unbound channel"); - CommChannel cchannel = cref.getEndpoint(CommChannel.class); - assertNotNull(cchannel); - assertNull(cchannel.getType()); - - // now connect it to Val.class - Val val = cref.getEndpoint(Val.class); - assertNotNull(val); - assertEquals(Val.class, cchannel.getType()); - - // now try to associate it with a different channel interface - try { - cref.getEndpoint(Synch.class); - fail("we should get an IllegalStateException"); - } catch (IllegalStateException e) { - assertEquals("ChannelRef is already associated with a channel of a different type", e.getMessage()); - } - - // now try to associate with the same channel - Val val2 = cref.getEndpoint(Val.class); - assertNotNull(val2); - assertSame(val, val2); - - } - }); - - assertEquals(true, vpu.getContext().hasReactions()); - vpu.execute(); - assertEquals(false, vpu.getContext().hasReactions()); - } -} http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/fdaf1f27/src/test/java/org/apache/ode/jacob/vpu/ProxyConstructorTimingTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/ode/jacob/vpu/ProxyConstructorTimingTest.java b/src/test/java/org/apache/ode/jacob/vpu/ProxyConstructorTimingTest.java index 92bc9bb..4468699 100644 --- a/src/test/java/org/apache/ode/jacob/vpu/ProxyConstructorTimingTest.java +++ b/src/test/java/org/apache/ode/jacob/vpu/ProxyConstructorTimingTest.java @@ -26,7 +26,6 @@ import junit.framework.TestCase; import org.apache.ode.jacob.oo.Channel; import org.apache.ode.jacob.oo.ChannelProxy; -import org.apache.ode.jacob.oo.MessageHandler; public class ProxyConstructorTimingTest extends TestCase {
