From 28d9bc59aa4522f08b23baf37745fd8cd6b74d9d Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Sat, 13 Sep 2008 22:17:41 +0000 Subject: Renamed modules to match the structure in r643746 and make it possible to create a patch on top of that revision. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@695044 13f79535-47bb-0310-9956-ffa450edef68 --- .../DefaultExtensionPointRegistryTestCase.java | 52 ------- .../sca/core/event/BaseEventPublisherTestCase.java | 98 ------------ .../tuscany/sca/core/event/EventTestCase.java | 69 --------- .../sca/core/invocation/PhaseManagerTestCase.java | 51 ------- .../sca/core/invocation/PhaseSorterTestCase.java | 63 -------- .../core/scope/AbstractScopeContainerTestCase.java | 69 --------- .../sca/core/store/MemoryStoreTestCase.java | 165 --------------------- .../wire/CallbackInterfaceInterceptorTestCase.java | 62 -------- .../sca/core/wire/InvocationChainImplTestCase.java | 93 ------------ .../core/wire/NonBlockingInterceptorTestCase.java | 73 --------- 10 files changed, 795 deletions(-) delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistryTestCase.java delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/invocation/PhaseManagerTestCase.java delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/invocation/PhaseSorterTestCase.java delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainerTestCase.java delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/CallbackInterfaceInterceptorTestCase.java delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java delete mode 100644 branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/NonBlockingInterceptorTestCase.java (limited to 'branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core') diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistryTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistryTestCase.java deleted file mode 100644 index b3d1d42ed3..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistryTestCase.java +++ /dev/null @@ -1,52 +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.tuscany.sca.core; - -import junit.framework.TestCase; - -public class DefaultExtensionPointRegistryTestCase extends TestCase { - private ExtensionPointRegistry registry; - - @Override - protected void setUp() throws Exception { - super.setUp(); - registry = new DefaultExtensionPointRegistry(); - } - - public void testRegistry() { - MyRegistry service = new MyREgistryImpl(); - registry.addExtensionPoint(service); - assertSame(service, registry.getExtensionPoint(MyRegistry.class)); - registry.removeExtensionPoint(service); - assertNull(registry.getExtensionPoint(MyRegistry.class)); - } - - public static interface MyRegistry { - void doSomething(); - } - - private static class MyREgistryImpl implements MyRegistry { - - public void doSomething() { - } - - } - -} diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java deleted file mode 100644 index d4cc0e64d8..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java +++ /dev/null @@ -1,98 +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.tuscany.sca.core.event; - - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.event.Event; -import org.apache.tuscany.sca.event.EventFilter; -import org.apache.tuscany.sca.event.EventPublisher; -import org.apache.tuscany.sca.event.RuntimeEventListener; -import org.apache.tuscany.sca.event.TrueFilter; -import org.easymock.EasyMock; - -/** - * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $ - */ -public class BaseEventPublisherTestCase extends TestCase { - EventPublisher publisher; - - public void testFireListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.same(event)); - EasyMock.expectLastCall(); - EasyMock.replay(listener); - publisher.addListener(listener); - publisher.publish(event); - EasyMock.verify(listener); - } - - public void testRemoveListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - EasyMock.replay(listener); - publisher.addListener(listener); - publisher.removeListener(listener); - publisher.publish(event); - EasyMock.verify(listener); - } - - public void testFalseFilterListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - EasyMock.replay(listener); - publisher.addListener(new FalseFilter(), listener); - publisher.publish(event); - EasyMock.verify(listener); - } - - public void testTrueFilterListener() { - Event event = new TestEvent(); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.same(event)); - EasyMock.expectLastCall(); - EasyMock.replay(listener); - publisher.addListener(new TrueFilter(), listener); - publisher.publish(event); - EasyMock.verify(listener); - } - - @Override - protected void setUp() throws Exception { - publisher = new BaseEventPublisher() { - }; - } - - private class TestEvent implements Event { - public Object getSource() { - return null; - } - } - - private class FalseFilter implements EventFilter { - - public boolean match(Event event) { - return false; - } - } - - -} diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java deleted file mode 100644 index 13f5c14c77..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java +++ /dev/null @@ -1,69 +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.tuscany.sca.core.event; - -import java.net.URI; - -import junit.framework.TestCase; - -/** - * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $ - */ -public class EventTestCase extends TestCase { - private URI uri = URI.create("foo"); - - public void testCompositeStart() { - ComponentStart event = new ComponentStart(this, uri); - assertEquals(uri, event.getComponentURI()); - } - - public void testCompositeStop() { - ComponentStop event = new ComponentStop(this, uri); - assertEquals(uri, event.getComponentURI()); - } - - public void testHttpSessionStart() { - Object id = new Object(); - HttpSessionStart event = new HttpSessionStart(this, id); - assertEquals(this, event.getSource()); - assertEquals(id, event.getSessionID()); - } - - public void testHttpSessionEnd() { - Object id = new Object(); - HttpSessionEnd event = new HttpSessionEnd(this, id); - assertEquals(this, event.getSource()); - assertEquals(id, event.getSessionID()); - } - - public void testRequestStart() { - RequestStart event = new RequestStart(this); - assertEquals(this, event.getSource()); - } - - public void testReequestEnd() { - RequestEnd event = new RequestEnd(this); - assertEquals(this, event.getSource()); - } - - - @Override - protected void setUp() throws Exception { - } -} diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/invocation/PhaseManagerTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/invocation/PhaseManagerTestCase.java deleted file mode 100644 index b8a9d5a591..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/invocation/PhaseManagerTestCase.java +++ /dev/null @@ -1,51 +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.tuscany.sca.core.invocation; - -import java.util.List; - -import junit.framework.Assert; - -import org.junit.Test; - -/** - * @version $Rev: 632098 $ $Date: 2008-02-28 11:37:57 -0800 (Thu, 28 Feb 2008) $ - */ -public class PhaseManagerTestCase { - - @Test - public void testDiscovery() { - PhaseManager pm = new PhaseManager("org.apache.tuscany.sca.invocation.PhaseTest"); - List phases = pm.getAllPhases(); - System.out.println(phases.size()); - System.out.println(phases); - // Assert.assertEquals(15, phases.size()); - Assert.assertEquals("reference.first", phases.get(0)); - - int rt = phases.indexOf("reference.transaction"); - Assert.assertTrue(rt > phases.indexOf("reference.interface")); - - int st = phases.indexOf("service.transaction"); - Assert.assertTrue(st > phases.indexOf("service.binding")); - - int it = phases.indexOf("implementation.transaction"); - Assert.assertTrue(it < phases.indexOf("implementation.policy")); - } -} diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/invocation/PhaseSorterTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/invocation/PhaseSorterTestCase.java deleted file mode 100644 index a309ac4b15..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/invocation/PhaseSorterTestCase.java +++ /dev/null @@ -1,63 +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.tuscany.sca.core.invocation; - -import java.util.Arrays; -import java.util.List; - -import junit.framework.TestCase; - -public class PhaseSorterTestCase extends TestCase { - private PhaseSorter graph; - - @Override - protected void setUp() throws Exception { - super.setUp(); - graph = new PhaseSorter(); - } - - public void testSort() { - graph.addEdge("a", "b"); - graph.addEdge("a", "c"); - graph.addEdge("c", "d"); - graph.addEdge("b", "c"); - List order = graph.topologicalSort(true); - assertEquals(Arrays.asList("a", "b", "c", "d"), order); - assertTrue(!graph.getVertices().isEmpty()); - - graph.addEdge("d", "a"); - try { - order = graph.topologicalSort(true); - assertTrue("Should have failed", false); - } catch (IllegalArgumentException e) { - assertTrue(true); - } - - graph.removeEdge("d", "a"); - order = graph.topologicalSort(false); - assertEquals(Arrays.asList("a", "b", "c", "d"), order); - assertTrue(graph.getVertices().isEmpty()); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainerTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainerTestCase.java deleted file mode 100644 index 5601d18746..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainerTestCase.java +++ /dev/null @@ -1,69 +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.tuscany.sca.core.scope; - -import java.net.URI; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.core.context.InstanceWrapper; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.easymock.EasyMock; -import org.easymock.IMocksControl; - -/** - * @version $Rev: 568826 $ $Date: 2007-08-22 22:27:34 -0700 (Wed, 22 Aug 2007) $ - */ -public abstract class AbstractScopeContainerTestCase extends TestCase { - protected IMocksControl control; - protected ScopeContainer scopeContainer; - protected URI groupId; - protected KEY contextId; - protected RuntimeComponent component; - protected ScopedImplementation implementation; - protected InstanceWrapper wrapper; - - @SuppressWarnings("unchecked") - @Override - protected void setUp() throws Exception { - super.setUp(); - control = EasyMock.createStrictControl(); - component = control.createMock(RuntimeComponent.class); - wrapper = control.createMock(InstanceWrapper.class); - implementation = control.createMock(ScopedImplementation.class); - EasyMock.expect(component.getImplementation()).andReturn(implementation).anyTimes(); - } - - protected void preRegisterComponent() throws Exception { - scopeContainer.start(); - EasyMock.expect(implementation.isEagerInit()).andStubReturn(false); - } - - protected void expectCreateWrapper() throws Exception { - EasyMock.expect(implementation.createInstanceWrapper()).andReturn(wrapper); - wrapper.start(); - } - - protected static interface ScopedImplementation extends ScopedImplementationProvider, Implementation { - - } - - -} diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java deleted file mode 100644 index 3725ce74b0..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java +++ /dev/null @@ -1,165 +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.tuscany.sca.core.store; - -import java.util.UUID; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.event.RuntimeEventListener; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.store.DuplicateRecordException; -import org.apache.tuscany.sca.store.Store; -import org.apache.tuscany.sca.store.StoreExpirationEvent; -import org.apache.tuscany.sca.store.StoreMonitor; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $ - */ -public class MemoryStoreTestCase extends TestCase { - private StoreMonitor monitor; - - public void testEviction() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, 1); - Thread.sleep(200); - assertNull(store.readRecord(component, id)); - store.destroy(); - } - - public void testNotifyOnEviction() throws Exception { - final CountDownLatch latch = new CountDownLatch(1); - RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class); - listener.onEvent(EasyMock.isA(StoreExpirationEvent.class)); - EasyMock.expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - latch.countDown(); - return null; - } - }); - EasyMock.replay(listener); - MemoryStore store = new MemoryStore(monitor); - store.addListener(listener); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, 1); - if (!latch.await(1000, TimeUnit.MILLISECONDS)) { - // failed to notify listener - fail(); - } - EasyMock.verify(listener); - } - - public void testNoEviction() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, Store.NEVER); - Thread.sleep(100); - assertNotNull(store.readRecord(component, id)); - store.destroy(); - } - - public void testInsertRecord() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, Store.NEVER); - store.destroy(); - } - - public void testInsertAlreadyExists() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createMock(RuntimeComponent.class); - EasyMock.expect(component.getURI()).andReturn("component"); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - store.insertRecord(component, id, value, Store.NEVER); - try { - store.insertRecord(component, id, value, Store.NEVER); - fail(); - } catch (DuplicateRecordException e) { - //expected - } - store.destroy(); - } - - public void testUpdateRecord() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - Object newValue = new Object(); - - store.insertRecord(component, id, value, Store.NEVER); - store.updateRecord(component, id, newValue, 1L); - assertEquals(newValue, store.readRecord(component, id)); - store.destroy(); - } - - public void testDeleteRecord() throws Exception { - MemoryStore store = new MemoryStore(monitor); - store.setReaperInterval(10); - store.init(); - RuntimeComponent component = EasyMock.createNiceMock(RuntimeComponent.class); - EasyMock.replay(component); - String id = UUID.randomUUID().toString(); - Object value = new Object(); - - store.insertRecord(component, id, value, Store.NEVER); - store.removeRecord(component, id); - assertNull(store.readRecord(component, id)); - store.destroy(); - } - - @Override - protected void setUp() throws Exception { - monitor = EasyMock.createNiceMock(StoreMonitor.class); - EasyMock.replay(monitor); - } - -} diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/CallbackInterfaceInterceptorTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/CallbackInterfaceInterceptorTestCase.java deleted file mode 100644 index 424f12800f..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/CallbackInterfaceInterceptorTestCase.java +++ /dev/null @@ -1,62 +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.tuscany.sca.core.wire; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.core.assembly.EndpointReferenceImpl; -import org.apache.tuscany.sca.core.invocation.CallbackInterfaceInterceptor; -import org.apache.tuscany.sca.core.invocation.MessageFactoryImpl; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Message; -import org.easymock.EasyMock; -import org.osoa.sca.NoRegisteredCallbackException; - -/** - * @version $Rev: 608822 $ $Date: 2008-01-04 04:59:56 -0800 (Fri, 04 Jan 2008) $ - */ -public class CallbackInterfaceInterceptorTestCase extends TestCase { - - public void testHasCallbackObject() { - CallbackInterfaceInterceptor interceptor = new CallbackInterfaceInterceptor(); - Interceptor next = EasyMock.createMock(Interceptor.class); - EasyMock.expect(next.invoke(EasyMock.isA(Message.class))).andReturn(null); - EasyMock.replay(next); - interceptor.setNext(next); - Message msg = new MessageFactoryImpl().createMessage(); - msg.setFrom(new EndpointReferenceImpl("uri")); - msg.getFrom().getReferenceParameters().setCallbackObjectID("ABC"); - interceptor.invoke(msg); - EasyMock.verify(next); - } - - public void testNoCallbackObject() { - CallbackInterfaceInterceptor interceptor = new CallbackInterfaceInterceptor(); - Message msg = new MessageFactoryImpl().createMessage(); - msg.setFrom(new EndpointReferenceImpl("uri")); - msg.getFrom().getReferenceParameters().setCallbackObjectID(null); - try { - interceptor.invoke(msg); - fail(); - } catch (NoRegisteredCallbackException e) { - // expected - } - } - -} diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java deleted file mode 100644 index 120fe861c8..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java +++ /dev/null @@ -1,93 +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.tuscany.sca.core.wire; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.core.invocation.InvocationChainImpl; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.impl.OperationImpl; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.Phase; - -/** - * @version $Rev: 632064 $ $Date: 2008-02-28 09:18:51 -0800 (Thu, 28 Feb 2008) $ - */ -public class InvocationChainImplTestCase extends TestCase { - - public void testInsertAtEnd() throws Exception { - Operation op = newOperation("foo"); - InvocationChain chain = new InvocationChainImpl(op, op, true); - Interceptor inter2 = new MockInterceptor(); - Interceptor inter1 = new MockInterceptor(); - chain.addInterceptor(inter1); - chain.addInterceptor(inter2); - Interceptor head = (Interceptor)chain.getHeadInvoker(); - assertEquals(inter1, head); - assertEquals(inter2, head.getNext()); - assertEquals(inter2, chain.getTailInvoker()); - - } - - public void testAddByPhase() throws Exception { - Operation op = newOperation("foo"); - InvocationChain chain = new InvocationChainImpl(op, op, false); - Interceptor inter1 = new MockInterceptor(); - Interceptor inter2 = new MockInterceptor(); - Interceptor inter3 = new MockInterceptor(); - Interceptor inter4 = new MockInterceptor(); - chain.addInterceptor(inter3); // SERVICE - chain.addInterceptor(Phase.IMPLEMENTATION_POLICY, inter4); - chain.addInterceptor(Phase.SERVICE_POLICY, inter2); - chain.addInterceptor(Phase.SERVICE_BINDING, inter1); - Interceptor head = (Interceptor)chain.getHeadInvoker(); - assertEquals(inter1, head); - assertEquals(inter2, inter1.getNext()); - assertEquals(inter3, inter2.getNext()); - assertEquals(inter4, inter3.getNext()); - assertEquals(inter4, chain.getTailInvoker()); - } - - private class MockInterceptor implements Interceptor { - - private Invoker next; - - public Message invoke(Message msg) { - return null; - } - - public void setNext(Invoker next) { - this.next = next; - } - - public Invoker getNext() { - return next; - } - - } - - private static Operation newOperation(String name) { - Operation operation = new OperationImpl(); - operation.setName(name); - return operation; - } -} diff --git a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/NonBlockingInterceptorTestCase.java b/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/NonBlockingInterceptorTestCase.java deleted file mode 100644 index 971d9493c8..0000000000 --- a/branches/sca-android/modules/core-android/src/test/java/org/apache/tuscany/sca/core/wire/NonBlockingInterceptorTestCase.java +++ /dev/null @@ -1,73 +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.tuscany.sca.core.wire; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.getCurrentArguments; -import static org.easymock.EasyMock.isA; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import junit.framework.TestCase; - -import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor; -import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.work.WorkScheduler; -import org.easymock.EasyMock; -import org.easymock.IAnswer; - -/** - * @version $Rev: 576235 $ $Date: 2007-09-16 19:07:54 -0700 (Sun, 16 Sep 2007) $ - */ -public class NonBlockingInterceptorTestCase extends TestCase { - - public void testInvoke() throws Exception { - WorkScheduler scheduler = createMock(WorkScheduler.class); - scheduler.scheduleWork(isA(Runnable.class)); - expectLastCall().andStubAnswer(new IAnswer() { - public Object answer() throws Throwable { - Runnable runnable = (Runnable) getCurrentArguments()[0]; - runnable.run(); - return null; - } - }); - replay(scheduler); - Message context = createMock(Message.class); - //String convID = "convID"; - //TODO port to the new way of dealing with conversation IDs later - //EasyMock.expect(context.getConversationID()).andReturn(convID); - EasyMock.replay(context); - ThreadMessageContext.setMessageContext(context); - Message msg = createMock(Message.class); - //TODO port to the new way of dealing with conversation IDs later - //msg.setConversationID(convID); - Interceptor next = EasyMock.createMock(Interceptor.class); - EasyMock.expect(next.invoke(EasyMock.eq(msg))).andReturn(msg); - EasyMock.replay(next); - EasyMock.replay(msg); - Interceptor interceptor = new NonBlockingInterceptor(scheduler, next); - interceptor.invoke(msg); - verify(context); - verify(next); - verify(msg); - } - -} -- cgit v1.2.3