summaryrefslogtreecommitdiffstats
path: root/java/sca/itest/scopes/src/test
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-12-05 00:48:31 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-12-05 00:48:31 +0000
commitf44c07576a61f6f4915ea8fd2aa5af9fee71745f (patch)
treeda023390d4bb97f353cdff9e6ca11a3f2eb9236b /java/sca/itest/scopes/src/test
parent10a9f2e5c0be26d6a44f1f90b677b9c5b7f985a9 (diff)
Convert, clean and bring up a set of itests
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@723537 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/itest/scopes/src/test')
-rw-r--r--java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java97
1 files changed, 51 insertions, 46 deletions
diff --git a/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java b/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java
index ce2519cbc0..028cea6304 100644
--- a/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java
+++ b/java/sca/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java
@@ -18,76 +18,81 @@
*/
package org.apache.tuscany.sca.test;
-import junit.framework.TestCase;
+import static org.junit.Assert.fail;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
import org.apache.tuscany.sca.itest.scopes.StateVerifier;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-public class ScopeTestCase extends TestCase {
+public class ScopeTestCase {
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;
+ private Node node;
// 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.
-
+ @Test
public void testScopes() throws InterruptedException {
- Thread[] moduleScopeThreadTable = new Thread[numThreads];
- Thread[] requestScopeThreadTable = new Thread[numThreads];
+ 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();
- }
+ 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 {
- @Override
- 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 ModuleScopeTestThread extends Thread {
+
+ public void run() {
+ StateVerifier moduleScopeService = node.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 {
- @Override
- 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);
+
+ public void run() {
+ StateVerifier requestScopeService = node.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);
+ }
}
- }
}
- @Override
- protected void setUp() throws Exception {
- domain = SCADomain.newInstance("scopes.composite");
+ @Before
+ public void setUp() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("scopes.composite");
+ node = NodeFactory.newInstance().createNode("scopes.composite", new Contribution("c1", location));
+ node.start();
}
- @Override
- protected void tearDown() throws Exception {
- domain.close();
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
}
-
+
}