You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2007/07/20 20:28:30 UTC

svn commit: r558081 - in /incubator/tuscany/java/sca/itest/scopes: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/tuscany/ src/main/java/org/apache/tuscany/sca/ src/main/java/org/apache/tuscany/sc...

Author: antelder
Date: Fri Jul 20 11:28:28 2007
New Revision: 558081

URL: http://svn.apache.org/viewvc?view=rev&rev=558081
Log:
TUSCANY-940, commit the scopes test from the itest zip, not quite working yet

Added:
    incubator/tuscany/java/sca/itest/scopes/   (with props)
    incubator/tuscany/java/sca/itest/scopes/pom.xml   (with props)
    incubator/tuscany/java/sca/itest/scopes/src/
    incubator/tuscany/java/sca/itest/scopes/src/main/
    incubator/tuscany/java/sca/itest/scopes/src/main/java/
    incubator/tuscany/java/sca/itest/scopes/src/main/java/org/
    incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/
    incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/
    incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/
    incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/
    incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/
    incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java   (with props)
    incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/RequestScopeStateVerifierImpl.java   (with props)
    incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java   (with props)
    incubator/tuscany/java/sca/itest/scopes/src/main/resources/
    incubator/tuscany/java/sca/itest/scopes/src/main/resources/scopes.composite
    incubator/tuscany/java/sca/itest/scopes/src/test/
    incubator/tuscany/java/sca/itest/scopes/src/test/java/
    incubator/tuscany/java/sca/itest/scopes/src/test/java/org/
    incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/
    incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/
    incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/
    incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/
    incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTest.java   (with props)

Propchange: incubator/tuscany/java/sca/itest/scopes/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jul 20 11:28:28 2007
@@ -0,0 +1,18 @@
+dojo
+work
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+derby.log
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+.felix
+

Added: incubator/tuscany/java/sca/itest/scopes/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/scopes/pom.xml?view=auto&rev=558081
==============================================================================
--- incubator/tuscany/java/sca/itest/scopes/pom.xml (added)
+++ incubator/tuscany/java/sca/itest/scopes/pom.xml Fri Jul 20 11:28:28 2007
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * 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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-itest</artifactId>
+        <version>1.0-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <name>Apache Tuscany Scopes Integration Tests</name>
+    <artifactId>tuscany-itest-scopes</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+    </dependencies>
+
+</project>
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/itest/scopes/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/scopes/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/itest/scopes/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java?view=auto&rev=558081
==============================================================================
--- incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java (added)
+++ incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java Fri Jul 20 11:28:28 2007
@@ -0,0 +1,44 @@
+/*
+ * 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.itest.scopes;
+
+import org.osoa.sca.annotations.Scope;
+
+// Test module scope
+@Scope("COMPOSITE")
+public class CompositeScopeStateVerifierImpl implements StateVerifier {
+
+    // State data for this module (composite).
+    // In order to support thread-based state verification,
+    // the module state needs to be a ThreadLocal.
+    ThreadLocal<Integer> moduleState;
+
+    public CompositeScopeStateVerifierImpl() {
+      moduleState = new ThreadLocal<Integer>();
+    }
+
+    public void setState(int i) {
+      moduleState.set(i);
+    }
+
+    public boolean checkState(int i) {
+      return (moduleState.get() == i);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/RequestScopeStateVerifierImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/RequestScopeStateVerifierImpl.java?view=auto&rev=558081
==============================================================================
--- incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/RequestScopeStateVerifierImpl.java (added)
+++ incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/RequestScopeStateVerifierImpl.java Fri Jul 20 11:28:28 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.itest.scopes;
+import org.osoa.sca.annotations.Scope;
+
+// Test request scope
+@Scope("REQUEST")
+public class RequestScopeStateVerifierImpl implements StateVerifier {
+
+    // State data for this request thread.
+    int requestState;
+
+    public void setState(int i) {
+      requestState = i;
+    }
+
+    public boolean checkState(int i) {
+      return (requestState == i);
+    }
+
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/RequestScopeStateVerifierImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/RequestScopeStateVerifierImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java?view=auto&rev=558081
==============================================================================
--- incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java (added)
+++ incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java Fri Jul 20 11:28:28 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.itest.scopes;
+
+public interface StateVerifier {
+    void setState(int i);
+    boolean checkState(int i);
+}
+

Propchange: incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/scopes/src/main/resources/scopes.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/scopes/src/main/resources/scopes.composite?view=auto&rev=558081
==============================================================================
--- incubator/tuscany/java/sca/itest/scopes/src/main/resources/scopes.composite (added)
+++ incubator/tuscany/java/sca/itest/scopes/src/main/resources/scopes.composite Fri Jul 20 11:28:28 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+       name="Scopes">
+
+    <!-- Components used to test scopes. -->
+
+ 	<component name="RequestScopeComponent">
+		<implementation.java class="org.apache.tuscany.sca.itest.scopes.RequestScopeStateVerifierImpl"/>
+    </component>
+
+ 	<component name="ModuleScopeComponent">
+		<implementation.java class="org.apache.tuscany.sca.itest.scopes.CompositeScopeStateVerifierImpl"/>
+    </component>
+
+</composite>

Added: incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTest.java?view=auto&rev=558081
==============================================================================
--- incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTest.java (added)
+++ incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTest.java Fri Jul 20 11:28:28 2007
@@ -0,0 +1,91 @@
+/*
+ * 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.test;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.itest.scopes.StateVerifier;
+
+public class ScopeTest extends TestCase {
+
+    final static int numThreads = 4; // number of threads to drive each scope container
+    final static int iterations = 200; // number of iterations per thread
+    private SCADomain domain;
+
+    // Test scope containers.
+    // The request scope container isn't hooked up for some reason so the code below
+    // that tests request scope is commented out.
+    // Code could be added to test session scope once it is supported in a standalone environment.
+
+    public void testScopes() throws InterruptedException {
+
+      Thread[] moduleScopeThreadTable = new Thread[numThreads];
+      Thread[] requestScopeThreadTable = new Thread[numThreads];
+
+      for(int i=0; i<numThreads; i++)
+      {
+        moduleScopeThreadTable[i] = new ModuleScopeTestThread();
+        requestScopeThreadTable[i] = new RequestScopeTestThread();
+      }
+      for(int j=0; j<numThreads; j++)
+      {
+        moduleScopeThreadTable[j].start();
+        requestScopeThreadTable[j].start();
+      }
+      for(int k=0; k<numThreads; k++)
+      {
+        moduleScopeThreadTable[k].join();
+        requestScopeThreadTable[k].join();
+      }
+    }
+
+    private  class ModuleScopeTestThread extends Thread {
+      public void run() {
+        StateVerifier moduleScopeService = domain.getService(StateVerifier.class, "ModuleScopeComponent");
+        for(int i=1; i<=iterations; i++) {
+          moduleScopeService.setState(i);
+          if (!moduleScopeService.checkState(i))
+            fail("The module scope service lost its state on iteration " + i);
+        }
+      }
+    }
+
+    private class RequestScopeTestThread extends Thread {
+      public void run() {
+        StateVerifier requestScopeService = domain.getService(StateVerifier.class, "RequestScopeComponent");
+        for(int i=1; i<=iterations; i++) {
+          requestScopeService.setState(i);
+          if (!requestScopeService.checkState(i))
+            fail("The request scope service lost its state on iteration " + i);
+        }
+      }
+    }
+
+    protected void setUp() throws Exception {
+        domain = SCADomain.newInstance("scopes.composite");
+    }
+
+    protected void tearDown() throws Exception {
+        if (domain != null) {
+            domain.close();
+        }
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org