tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r462890 - /incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
Date Wed, 11 Oct 2006 18:05:39 GMT
Author: rfeng
Date: Wed Oct 11 11:05:37 2006
New Revision: 462890

URL: http://svn.apache.org/viewvc?view=rev&rev=462890
Log:
Add more tests to the WorkContextImpl

Modified:
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java?view=diff&rev=462890&r1=462889&r2=462890
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
Wed Oct 11 11:05:37 2006
@@ -88,6 +88,55 @@
         WorkContext ctx = new WorkContextImpl();
         assertNull(ctx.getIdentifier(this));
     }
+    
+    public void testSetGetMessageIds() {
+        WorkContext context = new WorkContextImpl();
+        context.setCurrentMessageId("msg-009");
+        context.setCurrentCorrelationId("msg-005");
+        assertEquals(context.getCurrentMessageId(), "msg-009");
+        assertEquals(context.getCurrentCorrelationId(), "msg-005");
+        context.setCurrentMessageId(null);
+        context.setCurrentCorrelationId(null);
+        assertNull(context.getCurrentMessageId());
+        assertNull(context.getCurrentCorrelationId());
+    }
 
+    public void testSetGetMessageIdsInNewThread() throws InterruptedException {
+        WorkContext context = new WorkContextImpl();
+        context.setCurrentMessageId("msg-009");
+        context.setCurrentCorrelationId("msg-005");
+        assertEquals(context.getCurrentMessageId(), "msg-009");
+        assertEquals(context.getCurrentCorrelationId(), "msg-005");
+        context.setIdentifier("TX", "002");
+        ChildThread t = new ChildThread(context);
+        t.start();
+        t.join();
+        assertTrue(t.passed);
+        context.setCurrentMessageId(null);
+        context.setCurrentCorrelationId(null);
+        assertNull(context.getCurrentMessageId());
+        assertNull(context.getCurrentCorrelationId());
+    }
+
+    private static 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.getCurrentMessageId());
+                assertNull(context.getCurrentCorrelationId());
+                assertEquals("002", context.getIdentifier("TX"));
+            } catch (AssertionError e) {
+                passed = false;
+            }
+        }
+
+    }
 
 }



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


Mime
View raw message