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/21 11:30:38 UTC

svn commit: r558278 - in /incubator/tuscany/java/sca/itest/conversations/src: main/java/org/apache/tuscany/sca/itest/conversational/impl/ main/resources/ test/java/org/apache/tuscany/sca/itest/conversational/

Author: antelder
Date: Sat Jul 21 02:30:37 2007
New Revision: 558278

URL: http://svn.apache.org/viewvc?view=rev&rev=558278
Log:
Conversations, add max age/idle test

Added:
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java   (with props)
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java   (with props)
    incubator/tuscany/java/sca/itest/conversations/src/main/resources/ConversationAge.composite
    incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTest.java   (with props)

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java?view=auto&rev=558278
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java Sat Jul 21 02:30:37 2007
@@ -0,0 +1,67 @@
+/*
+ * 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.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.osoa.sca.annotations.ConversationAttributes;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(ConversationalService.class)
+@Scope("CONVERSATION")
+@ConversationAttributes(maxAge="1 seconds")
+public class ConversationAgeComponentImpl implements ConversationalService {
+
+    private int count;
+
+    public void destroy() {
+    }
+
+    public void endConversation() {
+    }
+
+    public void endConversationCallback() {
+    }
+
+    public void incrementCount() {
+    }
+
+    public void incrementCountCallback() {
+    }
+
+    public void init() {
+    }
+
+    public void initializeCount(int count) {
+        this.count = count;
+    }
+
+    public void initializeCountCallback(int count) {
+    }
+
+    public int retrieveCount() {
+        return count;
+    }
+
+    public int retrieveCountCallback() {
+        return 0;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java?view=auto&rev=558278
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java Sat Jul 21 02:30:37 2007
@@ -0,0 +1,67 @@
+/*
+ * 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.conversational.impl;
+
+import org.apache.tuscany.sca.itest.conversational.ConversationalService;
+import org.osoa.sca.annotations.ConversationAttributes;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(ConversationalService.class)
+@Scope("CONVERSATION")
+@ConversationAttributes(maxIdleTime="1 seconds")
+public class ConversationMaxIdleComponentImpl implements ConversationalService {
+
+    private int count;
+
+    public void destroy() {
+    }
+
+    public void endConversation() {
+    }
+
+    public void endConversationCallback() {
+    }
+
+    public void incrementCount() {
+    }
+
+    public void incrementCountCallback() {
+    }
+
+    public void init() {
+    }
+
+    public void initializeCount(int count) {
+        this.count = count;
+    }
+
+    public void initializeCountCallback(int count) {
+    }
+
+    public int retrieveCount() {
+        return count;
+    }
+
+    public int retrieveCountCallback() {
+        return 0;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/conversations/src/main/resources/ConversationAge.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/resources/ConversationAge.composite?view=auto&rev=558278
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/resources/ConversationAge.composite (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/resources/ConversationAge.composite Sat Jul 21 02:30:37 2007
@@ -0,0 +1,31 @@
+<?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="ConversationalIdTest">
+ 	      
+    <component name="ConversationAgeComponent">
+		<implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationAgeComponentImpl"/>
+	</component>          
+     
+    <component name="ConversationIdleComponent">
+		<implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.ConversationMaxIdleComponentImpl"/>
+	</component>          
+
+</composite>

Added: incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTest.java?view=auto&rev=558278
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTest.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTest.java Sat Jul 21 02:30:37 2007
@@ -0,0 +1,95 @@
+/*
+ * 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.conversational;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osoa.sca.ConversationEndedException;
+
+public class ConversationalAgeTest {
+
+    private SCADomain domain;
+
+    @Before
+    public void setUp() throws Exception {
+        System.setProperty("org.apache.tuscany.sca.core.scope.ConversationalScopeContainer.ReaperInterval", "2");        
+        domain = SCADomain.newInstance("ConversationAge.composite");
+
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        System.clearProperty("org.apache.tuscany.sca.core.scope.ConversationalScopeContainer.ReaperInterval");        
+        if (domain != null) {
+            domain.close();
+        }
+    }
+
+    @Test
+    public void testMaxAge() throws InterruptedException {
+
+        ConversationalService conversationalService =
+            domain.getService(ConversationalService.class, "ConversationAgeComponent");
+
+        Assert.assertEquals(0, conversationalService.retrieveCount());
+        conversationalService.initializeCount(42);
+        Assert.assertEquals(42, conversationalService.retrieveCount());
+        Assert.assertEquals(42, conversationalService.retrieveCount());
+        Thread.sleep(3100);
+        Assert.assertEquals(0, conversationalService.retrieveCount());
+    }
+
+    @Test
+    public void testAgeExpired() throws InterruptedException {
+
+        ConversationalService conversationalService =
+            domain.getService(ConversationalService.class, "ConversationAgeComponent");
+
+        Assert.assertEquals(0, conversationalService.retrieveCount());
+        conversationalService.initializeCount(42);
+        Assert.assertEquals(42, conversationalService.retrieveCount());
+        Assert.assertEquals(42, conversationalService.retrieveCount());
+        Thread.sleep(1100);
+        try {
+            Assert.assertEquals(0, conversationalService.retrieveCount());
+            Assert.fail();
+        } catch (ConversationEndedException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testMaxIdle() throws InterruptedException {
+
+        ConversationalService conversationalService =
+            domain.getService(ConversationalService.class, "ConversationIdleComponent");
+
+        Assert.assertEquals(0, conversationalService.retrieveCount());
+        conversationalService.initializeCount(42);
+        Assert.assertEquals(42, conversationalService.retrieveCount());
+        Assert.assertEquals(42, conversationalService.retrieveCount());
+        Thread.sleep(3100);
+        Assert.assertEquals(0, conversationalService.retrieveCount());
+    }
+
+}

Propchange: incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTest.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