diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:07:19 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:07:19 +0000 |
commit | 6fadbc9cd1fcf03d0b3630f772d91df149b70428 (patch) | |
tree | 32752e491abb97fc8ef4f246455e3b5fd2814862 /branches/sca-java-1.0.1/modules/core/src/test | |
parent | 5559ef5edbf8d3616f7a4b497b2a459b0ee4082b (diff) |
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835123 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.0.1/modules/core/src/test')
9 files changed, 0 insertions, 715 deletions
diff --git a/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistryTestCase.java b/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistryTestCase.java deleted file mode 100644 index 7b44736d4b..0000000000 --- a/branches/sca-java-1.0.1/modules/core/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-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java b/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/event/BaseEventPublisherTestCase.java deleted file mode 100644 index 2bc78c3d35..0000000000 --- a/branches/sca-java-1.0.1/modules/core/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$ $Date$ - */ -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-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java b/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/event/EventTestCase.java deleted file mode 100644 index 48dcf8df07..0000000000 --- a/branches/sca-java-1.0.1/modules/core/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$ $Date$ - */ -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-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainerTestCase.java b/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainerTestCase.java deleted file mode 100644 index 64114f7fb2..0000000000 --- a/branches/sca-java-1.0.1/modules/core/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$ $Date$ - */ -public abstract class AbstractScopeContainerTestCase<T, KEY> extends TestCase { - protected IMocksControl control; - protected ScopeContainer<KEY> scopeContainer; - protected URI groupId; - protected KEY contextId; - protected RuntimeComponent component; - protected ScopedImplementation implementation; - protected InstanceWrapper<T> 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-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java b/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/store/MemoryStoreTestCase.java deleted file mode 100644 index d46d77b4b8..0000000000 --- a/branches/sca-java-1.0.1/modules/core/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$ $Date$ - */ -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<Object>() { - 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-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/CallbackInterfaceInterceptorTestCase.java b/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/CallbackInterfaceInterceptorTestCase.java deleted file mode 100644 index bc5d426a9f..0000000000 --- a/branches/sca-java-1.0.1/modules/core/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$ $Date$ - */ -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.getTo().getReferenceParameters().setCallbackObjectID("java:" + System.identityHashCode("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.getTo().getReferenceParameters().setCallbackObjectID(null); - try { - interceptor.invoke(msg); - fail(); - } catch (NoRegisteredCallbackException e) { - // expected - } - } - -} diff --git a/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java b/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java deleted file mode 100644 index 83f7bdd887..0000000000 --- a/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/InvocationChainImplTestCase.java +++ /dev/null @@ -1,66 +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.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; - -/** - * @version $Rev$ $Date$ - */ -public class InvocationChainImplTestCase extends TestCase { - - public void testInsertAtEnd() throws Exception { - InvocationChain chain = new InvocationChainImpl(new OperationImpl("foo")); - 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()); - - } - - 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; - } - - } - -} diff --git a/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/NonBlockingInterceptorTestCase.java b/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/core/wire/NonBlockingInterceptorTestCase.java deleted file mode 100644 index e3fdf483ad..0000000000 --- a/branches/sca-java-1.0.1/modules/core/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$ $Date$ - */ -public class NonBlockingInterceptorTestCase extends TestCase { - - public void testInvoke() throws Exception { - WorkScheduler scheduler = createMock(WorkScheduler.class); - scheduler.scheduleWork(isA(Runnable.class)); - expectLastCall().andStubAnswer(new IAnswer<Object>() { - 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); - } - -} diff --git a/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java b/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java deleted file mode 100644 index 341d889b7d..0000000000 --- a/branches/sca-java-1.0.1/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java +++ /dev/null @@ -1,61 +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.scope; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.core.scope.Scope; - -/** - * @version $Rev$ $Date$ - */ -public class ScopeTestCase extends TestCase { - - public void testEquals() throws Exception { - Scope scope = new Scope("COMPOSITE"); - assertTrue(scope.equals(Scope.COMPOSITE)); - } - - public void testEqualsNew() throws Exception { - Scope foo = new Scope("foo"); - Scope foo2 = new Scope("FOO"); - assertTrue(foo.equals(foo2)); - } - - public void testNotEquals() throws Exception { - Scope foo = new Scope("BAR"); - Scope foo2 = new Scope("FOO"); - assertFalse(foo.equals(foo2)); - } - - public void testNotEqualsDifferent() throws Exception { - Scope foo = new Scope("FOO"); - assertFalse(foo.equals(new Bar("FOO"))); - } - - public class Bar { - String scope; - - public Bar(String scope) { - this.scope = scope; - } - } - - -} |