summaryrefslogtreecommitdiffstats
path: root/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope')
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java61
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java143
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java95
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java220
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java167
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java89
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java93
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java72
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java76
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java78
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java189
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java64
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java166
13 files changed, 0 insertions, 1513 deletions
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.java
deleted file mode 100644
index a6e4de3c48..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/AbstractScopeContainerTestCase.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.core.component.scope;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.spi.component.ScopeContainer;
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-
-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 AtomicComponent<T> component;
- protected InstanceWrapper<T> wrapper;
-
- @SuppressWarnings("unchecked")
- protected void setUp() throws Exception {
- super.setUp();
- control = EasyMock.createStrictControl();
- component = control.createMock(AtomicComponent.class);
- wrapper = control.createMock(InstanceWrapper.class);
- }
-
- protected void preRegisterComponent() throws Exception {
- scopeContainer.start();
- scopeContainer.register(component, groupId);
- EasyMock.expect(component.isEagerInit()).andStubReturn(false);
- }
-
- protected void expectCreateWrapper() throws Exception {
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java
deleted file mode 100644
index cb66af27b0..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicCompositeScopeTestCase.java
+++ /dev/null
@@ -1,143 +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.core.component.scope;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-import org.apache.tuscany.spi.component.ScopeContainer;
-import org.apache.tuscany.spi.component.TargetResolutionException;
-import org.apache.tuscany.spi.model.Scope;
-
-/**
- * @version $$Rev$$ $$Date$$
- */
-public class BasicCompositeScopeTestCase<T> extends TestCase {
- protected IMocksControl control;
- protected ScopeContainer<URI> scopeContainer;
- protected URI groupId;
- protected URI contextId;
- protected AtomicComponent<T> component;
- protected InstanceWrapper<T> wrapper;
-
- public void testCorrectScope() {
- assertEquals(Scope.COMPOSITE, scopeContainer.getScope());
- }
-
- public void testWrapperCreation() throws Exception {
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- control.replay();
- scopeContainer.register(component, groupId);
- assertSame(wrapper, scopeContainer.getWrapper(component, contextId));
- assertSame(wrapper, scopeContainer.getWrapper(component, contextId));
- assertSame(wrapper, scopeContainer.getAssociatedWrapper(component, contextId));
- control.verify();
- }
-
- public void testGetAssociatedInstanceNonExistent() throws Exception {
- URI uri = URI.create("oops");
- EasyMock.expect(component.getUri()).andReturn(uri);
- control.replay();
- scopeContainer.register(component, groupId);
- try {
- scopeContainer.getAssociatedWrapper(component, contextId);
- fail();
- } catch (TargetResolutionException e) {
- assertEquals(uri.toString(), e.getMessage());
- }
- control.verify();
- }
-
- /*
- public void testLifecycleWithNoEagerInit() throws Exception {
- EasyMock.expect(component.getInitLevel()).andReturn(0);
- control.replay();
- scopeContainer.startContext(contextId, groupId);
- scopeContainer.stopContext(contextId);
- control.verify();
- }
-
- public void testLifecycleWithEagerInit() throws Exception {
- EasyMock.expect(component.getInitLevel()).andReturn(1);
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- wrapper.stop();
- EasyMock.replay(component, wrapper);
- scopeContainer.onEvent(new ComponentStart(this, null));
- scopeContainer.onEvent(new ComponentStop(this, null));
- EasyMock.verify(component, wrapper);
- }
-
- public void testDestroyOrder() throws Exception {
- scopeContainer = new CompositeScopeContainer(null);
- scopeContainer.start();
- IMocksControl control = EasyMock.createStrictControl();
- InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class);
- InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class);
- InstanceWrapper wrapper3 = control.createMock(InstanceWrapper.class);
- AtomicComponent component1 = control.createMock(AtomicComponent.class);
- AtomicComponent component2 = control.createMock(AtomicComponent.class);
- AtomicComponent component3 = control.createMock(AtomicComponent.class);
-
- EasyMock.expect(component1.getInitLevel()).andStubReturn(-1);
- EasyMock.expect(component2.getInitLevel()).andStubReturn(1);
- EasyMock.expect(component3.getInitLevel()).andStubReturn(-1);
-
- EasyMock.expect(component2.createInstanceWrapper()).andReturn(wrapper2);
- wrapper2.start();
- EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1);
- wrapper1.start();
- EasyMock.expect(component3.createInstanceWrapper()).andReturn(wrapper3);
- wrapper3.start();
- wrapper3.stop();
- wrapper1.stop();
- wrapper2.stop();
- control.replay();
-
- scopeContainer.register(component1, contextId);
- scopeContainer.register(component2, contextId);
- scopeContainer.register(component3, contextId);
- scopeContainer.onEvent(new ComponentStart(this, null));
- assertSame(wrapper1, scopeContainer.getWrapper(component1));
- assertSame(wrapper2, scopeContainer.getWrapper(component2));
- assertSame(wrapper3, scopeContainer.getWrapper(component3));
- scopeContainer.onEvent(new ComponentStop(this, null));
- control.verify();
- }
- */
- @SuppressWarnings("unchecked")
- protected void setUp() throws Exception {
- super.setUp();
- groupId = contextId = URI.create("compositeId");
- control = EasyMock.createStrictControl();
- component = control.createMock(AtomicComponent.class);
- EasyMock.expect(component.isEagerInit()).andStubReturn(false);
- wrapper = control.createMock(InstanceWrapper.class);
-
- scopeContainer = new CompositeScopeContainer<URI>(null);
- scopeContainer.start();
- scopeContainer.startContext(contextId, groupId);
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java
deleted file mode 100644
index 02f5540dea..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java
+++ /dev/null
@@ -1,95 +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.core.component.scope;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.component.SimpleWorkContext;
-import org.apache.tuscany.core.services.store.memory.MemoryStore;
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-import org.apache.tuscany.spi.component.ScopeContainer;
-import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.services.store.StoreMonitor;
-import org.easymock.EasyMock;
-
-/**
- * @version $$Rev: 471111 $$ $$Date: 2006-11-03 23:06:48 -0500 (Fri, 03 Nov 2006) $$
- */
-public class BasicConversationalScopeTestCase extends TestCase {
- private AtomicComponent component;
- private InstanceWrapper wrapper;
- private ScopeContainer scopeContainer;
- private WorkContext workContext;
-
-/*
- public void testLifecycleManagement() throws Exception {
- // start the request
- String conversation = "conv";
- workContext.setIdentifier(Scope.CONVERSATION, conversation);
-
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- // FIXME shouldn't stop be called when the component is removed?
-// wrapper.stop();
- EasyMock.replay(component, wrapper);
- assertSame(wrapper, scopeContainer.getWrapper(component));
- assertSame(wrapper, scopeContainer.getWrapper(component));
- scopeContainer.remove(component);
- EasyMock.verify(component, wrapper);
- }
-*/
-
-/*
- public void testCoversationIsolation() throws Exception {
- String conversation1 = "conv";
- String conversation2 = "conv2";
-
- InstanceWrapper wrapper2 = EasyMock.createStrictMock(InstanceWrapper.class);
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper2);
- wrapper2.start();
- EasyMock.replay(component, wrapper, wrapper2);
- workContext.setIdentifier(Scope.CONVERSATION, conversation1);
- assertSame(wrapper, scopeContainer.getWrapper(component));
- workContext.setIdentifier(Scope.CONVERSATION, conversation2);
- assertSame(wrapper2, scopeContainer.getWrapper(component));
- EasyMock.verify(component, wrapper);
- }
-*/
- public void testX() {
-}
-
- protected void setUp() throws Exception {
- super.setUp();
- component = EasyMock.createStrictMock(AtomicComponent.class);
- EasyMock.expect(component.getMaxAge()).andStubReturn(-1);
- EasyMock.expect(component.getMaxIdleTime()).andStubReturn(-1);
- wrapper = EasyMock.createStrictMock(InstanceWrapper.class);
-
- StoreMonitor monitor = EasyMock.createMock(StoreMonitor.class);
- monitor.start(EasyMock.isA(String.class));
- monitor.stop(EasyMock.isA(String.class));
- MemoryStore store = new MemoryStore(monitor);
- workContext = new SimpleWorkContext();
- scopeContainer = new ConversationalScopeContainer(store, workContext, null);
- scopeContainer.start();
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java
deleted file mode 100644
index 1f29c92c92..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java
+++ /dev/null
@@ -1,220 +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.core.component.scope;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.component.SimpleWorkContext;
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-import org.apache.tuscany.spi.component.ScopeContainer;
-import org.apache.tuscany.spi.component.ScopeContainerMonitor;
-import org.apache.tuscany.spi.component.WorkContext;
-import org.easymock.EasyMock;
-
-/**
- * @version $$Rev$$ $$Date$$
- */
-public abstract class BasicHttpSessionScopeTestCase extends TestCase {
- private ScopeContainerMonitor monitor;
- private ScopeContainer scopeContainer;
- private AtomicComponent component;
- private InstanceWrapper wrapper;
- private WorkContext workContext;
-
- public void testLifecycleManagement() throws Exception {
-/*
- // start the request
- Object session = new Object();
- workContext.setIdentifier(Scope.SESSION, session);
-
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- wrapper.stop();
- EasyMock.replay(component, wrapper);
- assertSame(wrapper, scopeContainer.getWrapper(component));
- assertSame(wrapper, scopeContainer.getWrapper(component));
- scopeContainer.onEvent(new HttpSessionEnd(this, session));
- EasyMock.verify(component, wrapper);
-*/
- }
-
- public void testGetAssociatedInstance() throws Exception {
-/*
- // start the request
- Object session = new Object();
- workContext.setIdentifier(Scope.SESSION, session);
-
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- EasyMock.replay(component, wrapper);
- assertSame(wrapper, scopeContainer.getWrapper(component));
- assertSame(wrapper, scopeContainer.getAssociatedWrapper(component));
- EasyMock.verify(component, wrapper);
-*/
- }
-
- public void testGetAssociatedInstanceNonExistent() throws Exception {
-/*
- URI id = URI.create("oops");
- EasyMock.expect(component.getUri()).andReturn(id);
- EasyMock.replay(component);
-
- // start the request
- Object session = new Object();
- workContext.setIdentifier(Scope.SESSION, session);
- try {
- scopeContainer.getAssociatedWrapper(component);
- fail();
- } catch (TargetNotFoundException e) {
- assertEquals(id.toString(), e.getMessage());
- EasyMock.verify(component);
- }
-*/
- }
-
- public void testSessionIsolation() throws Exception {
-/*
- // start the request
- Object session1 = new Object();
- Object session2 = new Object();
-
- InstanceWrapper wrapper2 = EasyMock.createNiceMock(InstanceWrapper.class);
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper2);
- wrapper2.start();
- EasyMock.replay(component, wrapper);
- workContext.setIdentifier(Scope.SESSION, session1);
- assertSame(wrapper, scopeContainer.getWrapper(component));
- assertSame(wrapper, scopeContainer.getAssociatedWrapper(component));
- workContext.setIdentifier(Scope.SESSION, session2);
- assertSame(wrapper2, scopeContainer.getWrapper(component));
- assertSame(wrapper2, scopeContainer.getAssociatedWrapper(component));
- workContext.setIdentifier(Scope.SESSION, session1);
- assertSame(wrapper, scopeContainer.getWrapper(component));
- EasyMock.verify(component, wrapper);
-*/
- }
-
- public void testDestroyErrorMonitor() throws Exception {
-/*
- TargetDestructionException ex = new TargetDestructionException("oops", "again");
- monitor.destructionError(ex);
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- wrapper.stop();
- EasyMock.expectLastCall().andThrow(ex);
- EasyMock.replay(component, wrapper, monitor);
-
- Object id = new Object();
- scopeContainer.onEvent(new HttpSessionStart(this, id));
- workContext.setIdentifier(Scope.SESSION, id);
- assertSame(wrapper, scopeContainer.getWrapper(component));
- scopeContainer.onEvent(new HttpSessionEnd(this, id));
- EasyMock.verify(component, wrapper, monitor);
-*/
- }
-
- public void testDestroyOrder() throws Exception {
-/*
- Object session = new Object();
- workContext.setIdentifier(Scope.SESSION, session);
-
- IMocksControl control = EasyMock.createStrictControl();
- InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class);
- InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class);
- InstanceWrapper wrapper3 = control.createMock(InstanceWrapper.class);
- AtomicComponent component1 = control.createMock(AtomicComponent.class);
- AtomicComponent component2 = control.createMock(AtomicComponent.class);
- AtomicComponent component3 = control.createMock(AtomicComponent.class);
-
- component1.addListener(scopeContainer);
- component2.addListener(scopeContainer);
- component3.addListener(scopeContainer);
- EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1);
- wrapper1.start();
- EasyMock.expect(component2.createInstanceWrapper()).andReturn(wrapper2);
- wrapper2.start();
- EasyMock.expect(component3.createInstanceWrapper()).andReturn(wrapper3);
- wrapper3.start();
- wrapper3.stop();
- wrapper2.stop();
- wrapper1.stop();
- control.replay();
-
- scopeContainer.register(component1, null);
- scopeContainer.register(component2, null);
- scopeContainer.register(component3, null);
- scopeContainer.onEvent(new HttpSessionStart(this, session));
- assertSame(wrapper1, scopeContainer.getWrapper(component1));
- assertSame(wrapper2, scopeContainer.getWrapper(component2));
- assertSame(wrapper3, scopeContainer.getWrapper(component3));
- scopeContainer.onEvent(new HttpSessionEnd(this, session));
- control.verify();
-*/
- }
-
- public void testReuseSession() throws Exception {
-/*
- Object session = new Object();
- workContext.setIdentifier(Scope.SESSION, session);
-
- IMocksControl control = EasyMock.createStrictControl();
- InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class);
- InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class);
- AtomicComponent component1 = control.createMock(AtomicComponent.class);
-
- component1.addListener(scopeContainer);
- EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1);
- wrapper1.start();
- wrapper1.stop();
- EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper2);
- wrapper2.start();
- wrapper2.stop();
- control.replay();
-
- scopeContainer.register(component1, null);
- scopeContainer.onEvent(new HttpSessionStart(this, session));
- assertSame(wrapper1, scopeContainer.getWrapper(component1));
- scopeContainer.onEvent(new HttpSessionEnd(this, session));
-
- scopeContainer.onEvent(new HttpSessionStart(this, session));
- assertSame(wrapper2, scopeContainer.getWrapper(component1));
- scopeContainer.onEvent(new HttpSessionEnd(this, session));
- control.verify();
-*/
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- component = EasyMock.createStrictMock(AtomicComponent.class);
- wrapper = EasyMock.createStrictMock(InstanceWrapper.class);
-
- workContext = new SimpleWorkContext();
- monitor = EasyMock.createStrictMock(ScopeContainerMonitor.class);
- scopeContainer = new HttpSessionScopeContainer(workContext, monitor);
- scopeContainer.start();
-
- component.addListener(scopeContainer);
- EasyMock.replay(component);
- scopeContainer.register(component, null);
- EasyMock.reset(component);
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java
deleted file mode 100644
index 4aad2dc0c6..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicRequestScopeTestCase.java
+++ /dev/null
@@ -1,167 +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.core.component.scope;
-
-import junit.framework.TestCase;
-import org.easymock.EasyMock;
-
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-import org.apache.tuscany.spi.component.ScopeContainer;
-import org.apache.tuscany.spi.component.ScopeContainerMonitor;
-
-/**
- * @version $$Rev$$ $$Date$$
- */
-public abstract class BasicRequestScopeTestCase extends TestCase {
- private ScopeContainerMonitor monitor;
- private ScopeContainer scopeContainer;
- private AtomicComponent component;
- private InstanceWrapper wrapper;
-
- public void testLifecycleManagement() throws Exception {
-/*
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- EasyMock.replay(component, wrapper);
- assertSame(wrapper, scopeContainer.getWrapper(component));
- assertSame(wrapper, scopeContainer.getWrapper(component));
- EasyMock.verify(component, wrapper);
-*/
- }
-
- public void testGetAssociatedInstance() throws Exception {
-/*
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- EasyMock.replay(component, wrapper);
- assertSame(wrapper, scopeContainer.getWrapper(component));
- assertSame(wrapper, scopeContainer.getAssociatedWrapper(component));
- EasyMock.verify(component, wrapper);
-*/
- }
-
- public void testGetAssociatedInstanceNonExistent() throws Exception {
-/*
- URI id = URI.create("oops");
- EasyMock.expect(component.getUri()).andReturn(id);
- EasyMock.replay(component);
-
- try {
- scopeContainer.getAssociatedWrapper(component);
- fail();
- } catch (TargetNotFoundException e) {
- assertEquals(id.toString(), e.getMessage());
- EasyMock.verify(component);
- }
-*/
- }
-
- public void testRequestIsolation() throws Exception {
-/*
- IMocksControl control = EasyMock.createStrictControl();
- InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class);
- InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class);
- AtomicComponent component1 = control.createMock(AtomicComponent.class);
- AtomicComponent component2 = control.createMock(AtomicComponent.class);
-
- EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1);
- wrapper1.start();
- wrapper1.stop();
- EasyMock.expect(component2.createInstanceWrapper()).andReturn(wrapper2);
- wrapper2.start();
- wrapper2.stop();
- control.replay();
-
- scopeContainer.register(component1, null);
- scopeContainer.register(component2, null);
- scopeContainer.onEvent(new RequestStart(this));
- assertSame(wrapper1, scopeContainer.getWrapper(component1));
- scopeContainer.onEvent(new RequestEnd(this));
- scopeContainer.onEvent(new RequestStart(this));
- assertSame(wrapper2, scopeContainer.getWrapper(component2));
- scopeContainer.onEvent(new RequestEnd(this));
- control.verify();
-*/
- }
-
- public void testDestroyErrorMonitor() throws Exception {
-/*
- TargetDestructionException ex = new TargetDestructionException("oops", "again");
- monitor.destructionError(ex);
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- wrapper.stop();
- EasyMock.expectLastCall().andThrow(ex);
- EasyMock.replay(component, wrapper, monitor);
-
- scopeContainer.onEvent(new RequestStart(this));
- assertSame(wrapper, scopeContainer.getWrapper(component));
- scopeContainer.onEvent(new RequestEnd(this));
- EasyMock.verify(component, wrapper, monitor);
-*/
- }
-
- public void testDestroyOrder() throws Exception {
-/*
- IMocksControl control = EasyMock.createStrictControl();
- InstanceWrapper wrapper1 = control.createMock(InstanceWrapper.class);
- InstanceWrapper wrapper2 = control.createMock(InstanceWrapper.class);
- InstanceWrapper wrapper3 = control.createMock(InstanceWrapper.class);
- AtomicComponent component1 = control.createMock(AtomicComponent.class);
- AtomicComponent component2 = control.createMock(AtomicComponent.class);
- AtomicComponent component3 = control.createMock(AtomicComponent.class);
-
- EasyMock.expect(component1.createInstanceWrapper()).andReturn(wrapper1);
- wrapper1.start();
- EasyMock.expect(component2.createInstanceWrapper()).andReturn(wrapper2);
- wrapper2.start();
- EasyMock.expect(component3.createInstanceWrapper()).andReturn(wrapper3);
- wrapper3.start();
- wrapper3.stop();
- wrapper2.stop();
- wrapper1.stop();
- control.replay();
-
- scopeContainer.register(component1, null);
- scopeContainer.register(component2, null);
- scopeContainer.register(component3, null);
- scopeContainer.onEvent(new RequestStart(this));
- assertSame(wrapper1, scopeContainer.getWrapper(component1));
- assertSame(wrapper2, scopeContainer.getWrapper(component2));
- assertSame(wrapper3, scopeContainer.getWrapper(component3));
- scopeContainer.onEvent(new RequestEnd(this));
- control.verify();
-*/
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- component = EasyMock.createStrictMock(AtomicComponent.class);
- wrapper = EasyMock.createStrictMock(InstanceWrapper.class);
- monitor = EasyMock.createStrictMock(ScopeContainerMonitor.class);
- scopeContainer = new RequestScopeContainer(monitor);
- scopeContainer.start();
-
- component.addListener(scopeContainer);
- EasyMock.replay(component);
- scopeContainer.register(component, null);
- EasyMock.reset(component);
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java
deleted file mode 100644
index a7cab71ade..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicStatelessScopeTestCase.java
+++ /dev/null
@@ -1,89 +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.core.component.scope;
-
-import junit.framework.TestCase;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-import org.apache.tuscany.spi.model.Scope;
-
-/**
- * Unit tests for the composite scope container
- *
- * @version $Rev$ $Date$
- */
-public class BasicStatelessScopeTestCase<T> extends TestCase {
- private StatelessScopeContainer<String> scopeContainer;
- private String contextId;
- private IMocksControl control;
- private AtomicComponent<T> component;
- private InstanceWrapper<T> wrapper;
-
- public void testCorrectScope() {
- assertEquals(Scope.STATELESS, scopeContainer.getScope());
- }
-
- public void testInstanceCreation() throws Exception {
- @SuppressWarnings("unchecked")
- InstanceWrapper<T> wrapper2 = control.createMock(InstanceWrapper.class);
-
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- wrapper.start();
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper2);
- wrapper2.start();
- control.replay();
-
- assertSame(wrapper, scopeContainer.getWrapper(component, contextId));
- assertSame(wrapper2, scopeContainer.getWrapper(component, contextId));
- control.verify();
- }
-
- public void testGetAssociatedInstance() throws Exception {
- control.replay();
- try {
- // always throws an exception, which is the semantic for stateless implementations
- scopeContainer.getAssociatedWrapper(component, contextId);
- fail();
- } catch (UnsupportedOperationException e) {
- // ok
- }
- control.verify();
- }
-
- public void testReturnWrapper() throws Exception {
- wrapper.stop();
- control.replay();
- scopeContainer.returnWrapper(component, wrapper, contextId);
- control.verify();
- }
-
- @SuppressWarnings("unchecked")
- protected void setUp() throws Exception {
- super.setUp();
- scopeContainer = new StatelessScopeContainer<String>(null);
- contextId = "context";
-
- control = EasyMock.createStrictControl();
- component = control.createMock(AtomicComponent.class);
- wrapper = control.createMock(InstanceWrapper.class);
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.java
deleted file mode 100644
index 01c426e917..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/CompositeScopeInitDestroyErrorTestCase.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.core.component.scope;
-
-import java.net.URI;
-
-import org.apache.tuscany.spi.ObjectCreationException;
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.ScopeContainerMonitor;
-import org.apache.tuscany.spi.component.TargetDestructionException;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-import org.apache.tuscany.spi.component.TargetResolutionException;
-import org.apache.tuscany.spi.component.GroupInitializationException;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.component.event.ComponentStart;
-import org.apache.tuscany.core.component.event.ComponentStop;
-import org.easymock.EasyMock;
-
-/**
- * @version $Rev$ $Date$
- */
-public class CompositeScopeInitDestroyErrorTestCase extends TestCase {
- private URI groupId;
-
- public void testInitializeError() throws Exception {
- CompositeScopeContainer scope = new CompositeScopeContainer(null);
- scope.start();
-
- ObjectCreationException ex = new ObjectCreationException("");
- AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
- EasyMock.expect(component.createInstanceWrapper()).andThrow(ex);
- EasyMock.expect(component.isEagerInit()).andStubReturn(true);
- EasyMock.expect(component.getInitLevel()).andStubReturn(1);
- EasyMock.replay(component);
- scope.register(component, groupId);
- try {
- scope.startContext(groupId, groupId);
- } catch (GroupInitializationException e) {
- assertSame(ex, e.getCauses().get(0));
- }
- EasyMock.verify(component);
- }
-
- public void testDestroyErrorMonitor() throws Exception {
- InstanceWrapper wrapper = EasyMock.createMock(InstanceWrapper.class);
- wrapper.start();
- wrapper.stop();
- EasyMock.expectLastCall().andThrow(new TargetDestructionException("", ""));
- EasyMock.replay(wrapper);
-
- ScopeContainerMonitor monitor;
- monitor = EasyMock.createMock(ScopeContainerMonitor.class);
- monitor.destructionError(EasyMock.isA(TargetDestructionException.class));
- EasyMock.replay(monitor);
- CompositeScopeContainer scope = new CompositeScopeContainer(monitor);
- scope.start();
-
- AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- EasyMock.expect(component.isEagerInit()).andStubReturn(true);
- EasyMock.expect(component.getInitLevel()).andStubReturn(1);
- EasyMock.replay(component);
- scope.register(component, groupId);
- scope.startContext(groupId, groupId);
- scope.stopContext(groupId);
- EasyMock.verify(monitor);
- EasyMock.verify(component);
- EasyMock.verify(wrapper);
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
- groupId = URI.create("composite");
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java
deleted file mode 100644
index caf0c0cc5e..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java
+++ /dev/null
@@ -1,72 +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.core.component.scope;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.component.SimpleWorkContext;
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.event.RuntimeEventListener;
-import org.apache.tuscany.spi.services.store.Store;
-import org.apache.tuscany.spi.services.store.StoreExpirationEvent;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ConversationalScopeContainerDestroyOnExpirationTestCase extends TestCase {
- private Store store;
- private RuntimeEventListener listener;
- private WorkContext context;
- private InstanceWrapper wrapper;
- private AtomicComponent component;
-
- /**
- * Verifies the scope container registers a callback listener for component instance destroy events when a
- * conversational instance expires
- */
- public void testDestroyNotification() throws Exception {
- store.addListener(EasyMock.isA(RuntimeEventListener.class));
- EasyMock.expectLastCall().andStubAnswer(new IAnswer<Object>(){
- public Object answer() throws Throwable {
- listener = (RuntimeEventListener) EasyMock.getCurrentArguments()[0];
- return null;
- }
- });
- wrapper.stop();
- EasyMock.replay(store);
- EasyMock.replay(wrapper);
-
- new ConversationalScopeContainer(store, context, null);
- listener.onEvent(new StoreExpirationEvent(this, component, wrapper));
- EasyMock.verify(store);
- EasyMock.verify(wrapper);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- store = EasyMock.createMock(Store.class);
- wrapper = EasyMock.createMock(InstanceWrapper.class);
- component = EasyMock.createMock(AtomicComponent.class);
- context = new SimpleWorkContext();
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java
deleted file mode 100644
index e896b410d0..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java
+++ /dev/null
@@ -1,76 +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.core.component.scope;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.component.SimpleWorkContext;
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-import org.apache.tuscany.spi.component.SCAObject;
-import org.apache.tuscany.spi.component.ScopeContainer;
-import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.event.RuntimeEventListener;
-import org.apache.tuscany.spi.model.Scope;
-import org.apache.tuscany.spi.services.store.Store;
-import org.easymock.EasyMock;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ConversationalScopeContainerMaxAgeTestCase extends TestCase {
-
- private ScopeContainer container;
- private WorkContext context;
- private Store store;
- private AtomicComponent component;
- private InstanceWrapper wrapper;
-
- public void testMaxAgeUpdate() throws Exception {
-/*
- context.setIdentifier(Scope.CONVERSATION, "12345");
- assertSame(wrapper, container.getWrapper(component));
- EasyMock.verify(store);
-*/
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- context = new SimpleWorkContext();
- component = EasyMock.createMock(AtomicComponent.class);
- EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce();
- EasyMock.expect(component.getMaxAge()).andReturn(600000L).atLeastOnce();
- EasyMock.replay(component);
-
- wrapper = EasyMock.createMock(InstanceWrapper.class);
-
- store = EasyMock.createMock(Store.class);
- EasyMock.expect(store.readRecord(EasyMock.isA(SCAObject.class), EasyMock.isA(String.class))).andReturn(wrapper);
- store.addListener(EasyMock.isA(RuntimeEventListener.class));
- EasyMock.replay(store);
- container = new ConversationalScopeContainer(store, context, null);
- container.start();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- context.clearIdentifier(Scope.CONVERSATION);
- container.stop();
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java
deleted file mode 100644
index 9ac97bff32..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java
+++ /dev/null
@@ -1,78 +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.core.component.scope;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.component.SimpleWorkContext;
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.InstanceWrapper;
-import org.apache.tuscany.spi.component.SCAObject;
-import org.apache.tuscany.spi.component.ScopeContainer;
-import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.event.RuntimeEventListener;
-import org.apache.tuscany.spi.model.Scope;
-import org.apache.tuscany.spi.services.store.Store;
-import org.easymock.EasyMock;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ConversationalScopeContainerMaxIdleTimeTestCase extends TestCase {
-
- private ScopeContainer container;
- private WorkContext context;
- private Store store;
- private AtomicComponent component;
- private InstanceWrapper wrapper;
-
- public void testMaxIdleTimeUpdate() throws Exception {
-/*
- context.setIdentifier(Scope.CONVERSATION, "12345");
- assertSame(wrapper, container.getWrapper(component));
- EasyMock.verify(store);
-*/
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- wrapper = EasyMock.createMock(InstanceWrapper.class);
- context = new SimpleWorkContext();
- component = EasyMock.createMock(AtomicComponent.class);
- EasyMock.expect(component.getMaxIdleTime()).andStubReturn(600000L);
- EasyMock.replay(component);
- store = EasyMock.createMock(Store.class);
- EasyMock.expect(store.readRecord(EasyMock.isA(SCAObject.class), EasyMock.isA(String.class))).andReturn(wrapper);
- store.addListener(EasyMock.isA(RuntimeEventListener.class));
- store.updateRecord(EasyMock.isA(SCAObject.class),
- EasyMock.isA(String.class),
- EasyMock.eq(wrapper),
- EasyMock.anyLong());
- EasyMock.replay(store);
- container = new ConversationalScopeContainer(store, context, null);
- container.start();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- context.clearIdentifier(Scope.CONVERSATION);
- container.stop();
- }
-
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java
deleted file mode 100644
index a8960c4575..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java
+++ /dev/null
@@ -1,189 +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.core.component.scope;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.component.SimpleWorkContext;
-import org.apache.tuscany.core.services.store.memory.MemoryStore;
-import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.model.Scope;
-import org.apache.tuscany.spi.services.store.Store;
-import org.apache.tuscany.spi.services.store.StoreMonitor;
-import org.easymock.EasyMock;
-
-/**
- * @version $Rev$ $Date$
- */
-public abstract class ConversationalScopeContainerPersistenceTestCase extends TestCase {
- private ConversationalScopeContainer container;
- private WorkContext context;
-
- public void testNotYetPersistedInMemory() throws Exception {
-/*
- InstanceWrapper wrapper = EasyMock.createMock(InstanceWrapper.class);
- wrapper.start();
- EasyMock.replay(wrapper);
-
- String id = UUID.randomUUID().toString();
- context.setIdentifier(Scope.CONVERSATION, id);
- AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
- component.addListener(EasyMock.eq(container));
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- EasyMock.expect(component.getMaxAge()).andReturn(600000L).atLeastOnce();
- EasyMock.replay(component);
-
- container.register(component, null);
- assertSame(wrapper, container.getWrapper(component));
- EasyMock.verify(component);
- EasyMock.verify(wrapper);
-*/
- }
-
- public void testPersistNewInMemory() throws Exception {
-/*
- String id = UUID.randomUUID().toString();
- String id2 = UUID.randomUUID().toString();
- context.setIdentifier(Scope.CONVERSATION, id);
- AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
- component.addListener(EasyMock.eq(container));
- EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce();
- EasyMock.replay(component);
- container.register(component, null);
- InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class);
- InstanceWrapper fooWrapper2 = EasyMock.createMock(InstanceWrapper.class);
- container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000);
- assertEquals(fooWrapper, container.getWrapper(component));
- container.persistNew(component, id2, fooWrapper2, System.currentTimeMillis() + 100000);
- context.setIdentifier(Scope.CONVERSATION, id2);
- assertEquals(fooWrapper2, container.getWrapper(component));
- EasyMock.verify(component);
-*/
- }
-
- public void testPersistInMemory() throws Exception {
-/*
- String id = UUID.randomUUID().toString();
- context.setIdentifier(Scope.CONVERSATION, id);
- AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
- component.addListener(EasyMock.eq(container));
- EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce();
- EasyMock.replay(component);
- container.register(component, null);
- InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class);
- container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000);
- assertEquals(fooWrapper, container.getWrapper(component));
- container.persist(component, id, fooWrapper, System.currentTimeMillis() + 100000);
- assertEquals(fooWrapper, container.getWrapper(component));
- EasyMock.verify(component);
-*/
- }
-
- public void testRemoveInMemory() throws Exception {
-/*
- String id = UUID.randomUUID().toString();
- context.setIdentifier(Scope.CONVERSATION, id);
- AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
- component.addListener(EasyMock.eq(container));
- EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce();
- EasyMock.expect(component.getUri()).andReturn(URI.create("foo")).atLeastOnce();
- EasyMock.replay(component);
- container.register(component, null);
- InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class);
- container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000);
- assertEquals(fooWrapper, container.getWrapper(component));
- container.remove(component);
- try {
- container.getAssociatedWrapper(component);
- fail();
- } catch (TargetNotFoundException e) {
- //expected
- }
- EasyMock.verify(component);
-*/
- }
-
- public void testRecreateAfterRemoveInMemory() throws Exception {
-/*
- InstanceWrapper wrapper = EasyMock.createMock(InstanceWrapper.class);
- wrapper.start();
- EasyMock.replay(wrapper);
-
- String id = UUID.randomUUID().toString();
- context.setIdentifier(Scope.CONVERSATION, id);
- AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
- component.addListener(EasyMock.eq(container));
- EasyMock.expect(component.getMaxAge()).andReturn(600000L).atLeastOnce();
- EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce();
- EasyMock.expect(component.createInstanceWrapper()).andReturn(wrapper);
- EasyMock.replay(component);
-
- container.register(component, null);
- InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class);
- container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000);
- assertEquals(fooWrapper, container.getWrapper(component));
- container.remove(component);
- assertSame(wrapper, container.getWrapper(component));
- EasyMock.verify(component);
-*/
- }
-
- public void testGetPersistedInstance() throws Exception {
-/*
- String id = UUID.randomUUID().toString();
- String id2 = UUID.randomUUID().toString();
- context.setIdentifier(Scope.CONVERSATION, id);
- AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
- EasyMock.expect(component.getUri()).andReturn(URI.create("foo")).atLeastOnce();
- EasyMock.expect(component.getMaxIdleTime()).andReturn(-1L).atLeastOnce();
- component.addListener(EasyMock.eq(container));
- EasyMock.replay(component);
- container.register(component, null);
-
- InstanceWrapper fooWrapper = EasyMock.createMock(InstanceWrapper.class);
- container.persistNew(component, id, fooWrapper, System.currentTimeMillis() + 100000);
- assertEquals(fooWrapper, container.getAssociatedWrapper(component));
- assertEquals(fooWrapper, container.getAssociatedWrapper(component));
- context.setIdentifier(Scope.CONVERSATION, id2);
- try {
- container.getAssociatedWrapper(component);
- fail();
- } catch (TargetNotFoundException e) {
- //expected
- }
- EasyMock.verify(component);
-*/
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- context = new SimpleWorkContext();
- StoreMonitor mock = EasyMock.createNiceMock(StoreMonitor.class);
- EasyMock.replay(mock);
- Store store = new MemoryStore(mock);
- container = new ConversationalScopeContainer(store, context, null);
- container.start();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- context.clearIdentifier(Scope.CONVERSATION);
- container.stop();
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java
deleted file mode 100644
index c583ff19c6..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/InstanceWrapperBaseTestCase.java
+++ /dev/null
@@ -1,64 +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.core.component.scope;
-
-import junit.framework.TestCase;
-
-/**
- * @version $Rev$ $Date$
- */
-public class InstanceWrapperBaseTestCase extends TestCase {
- private static final Object INSTANCE = new Object();
- private InstanceWrapperBase<Object> wrapper;
-
- public void testLifecycle() throws Exception {
- assertFalse(wrapper.isStarted());
- try {
- wrapper.getInstance();
- fail();
- } catch (AssertionError e) {
- // expected
- }
- wrapper.start();
- assertTrue(wrapper.isStarted());
- assertSame(INSTANCE, wrapper.getInstance());
- wrapper.stop();
- assertFalse(wrapper.isStarted());
- try {
- wrapper.getInstance();
- fail();
- } catch (AssertionError e) {
- // expected
- }
- }
-
- public void testNullCheck() {
- try {
- new InstanceWrapperBase<Object>(null);
- fail();
- } catch (AssertionError e) {
- // expected
- }
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- wrapper = new InstanceWrapperBase<Object>(INSTANCE);
- }
-}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
deleted file mode 100644
index 94feca05be..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
+++ /dev/null
@@ -1,166 +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.core.component.scope;
-
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.Component;
-import org.apache.tuscany.spi.component.WorkContext;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.component.SimpleWorkContext;
-import org.easymock.EasyMock;
-
-/**
- * @version $Rev$ $Date$
- */
-public class WorkContextTestCase extends TestCase {
-
- public void testSetCurrentAtomicComponent() throws Exception {
- WorkContext ctx = new SimpleWorkContext();
- AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class);
- AtomicComponent component2 = EasyMock.createNiceMock(AtomicComponent.class);
- ctx.setCurrentAtomicComponent(component);
- assertEquals(component, ctx.getCurrentAtomicComponent());
- ctx.setCurrentAtomicComponent(component2);
- assertEquals(component2, ctx.getCurrentAtomicComponent());
- }
-
- public void testNonSetCurrentAtomicComponent() throws Exception {
- WorkContext ctx = new SimpleWorkContext();
- assertNull(ctx.getCurrentAtomicComponent());
- }
-
- public void testIndentifier() throws Exception {
- WorkContext ctx = new SimpleWorkContext();
- Object id = new Object();
- ctx.setIdentifier(this, id);
- assertEquals(id, ctx.getIdentifier(this));
- }
-
- public void testClearIndentifier() throws Exception {
- WorkContext ctx = new SimpleWorkContext();
- Object id = new Object();
- ctx.setIdentifier(this, id);
- ctx.clearIdentifier(this);
- assertNull(ctx.getIdentifier(this));
- }
-
- public void testClearIndentifiers() throws Exception {
- WorkContext ctx = new SimpleWorkContext();
- Object id = new Object();
- Object id2 = new Object();
- ctx.setIdentifier(id, id);
- ctx.setIdentifier(id2, id2);
- ctx.clearIdentifiers();
- assertNull(ctx.getIdentifier(id));
- assertNull(ctx.getIdentifier(id2));
- }
-
- public void testClearNonExistentIndentifier() throws Exception {
- WorkContext ctx = new SimpleWorkContext();
- ctx.clearIdentifier(this);
- }
-
- public void testNullIndentifier() throws Exception {
- WorkContext ctx = new SimpleWorkContext();
- Object id = new Object();
- ctx.setIdentifier(this, id);
- ctx.clearIdentifier(null);
- assertEquals(id, ctx.getIdentifier(this));
- }
-
- public void testNoIndentifier() throws Exception {
- WorkContext ctx = new SimpleWorkContext();
- assertNull(ctx.getIdentifier(this));
- }
-
- public void testSetGetCorrelationId() {
- WorkContext context = new SimpleWorkContext();
- context.setCorrelationId("msg-005");
- assertEquals(context.getCorrelationId(), "msg-005");
- context.setCorrelationId(null);
- assertNull(context.getCorrelationId());
- }
-
- public void testSetGetCorrelationIdInNewThread() throws InterruptedException {
- WorkContext context = new SimpleWorkContext();
- context.setCorrelationId("msg-005");
- assertEquals(context.getCorrelationId(), "msg-005");
- context.setIdentifier("TX", "002");
- ChildThread t = new ChildThread(context);
- t.start();
- t.join();
- assertTrue(t.passed);
- context.setCorrelationId(null);
- assertNull(context.getCorrelationId());
- }
-
- public void testCurrentAtomicComponentDoesNotPropagateToChildThread() throws InterruptedException {
- // NOTE should behaviour be to propagate?
- WorkContext context = new SimpleWorkContext();
- context.setCurrentAtomicComponent(EasyMock.createNiceMock(AtomicComponent.class));
- TestCurrentAtomicComponentChildThread t = new TestCurrentAtomicComponentChildThread(context);
- t.start();
- t.join();
- assertTrue(t.passed);
- context.setCurrentAtomicComponent(null);
- assertNull(context.getCurrentAtomicComponent());
- }
-
- private static final class ChildThread extends Thread {
- private WorkContext context;
- private boolean passed = true;
-
- private ChildThread(WorkContext context) {
- this.context = context;
- }
-
- @Override
- public void run() {
- try {
- assertNull(context.getCorrelationId());
- assertEquals("002", context.getIdentifier("TX"));
- } catch (AssertionError e) {
- passed = false;
- }
- }
-
- }
-
- private static final class TestCurrentAtomicComponentChildThread extends Thread {
- private WorkContext context;
- private boolean passed = true;
-
- private TestCurrentAtomicComponentChildThread(WorkContext context) {
- this.context = context;
- }
-
- @Override
- public void run() {
- try {
- assertNull(context.getCurrentAtomicComponent());
- } catch (AssertionError e) {
- passed = false;
- }
- }
-
- }
-
-
-}