You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by kw...@apache.org on 2008/02/26 19:16:34 UTC

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

Author: kwilliams
Date: Tue Feb 26 10:16:27 2008
New Revision: 631319

URL: http://svn.apache.org/viewvc?rev=631319&view=rev
Log:
Adding start of conversation liftime tests

Added:
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java   (with props)
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java   (with props)
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java   (with props)
    incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java   (with props)
    incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversationLifetime.composite   (with props)
    incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java   (with props)

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java?rev=631319&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/CService.java Tue Feb 26 10:16:27 2008
@@ -0,0 +1,64 @@
+/*
+ * 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.osoa.sca.annotations.Conversational;
+
+/**
+ * Simple conversational Service that uses another Conversational Service
+ */
+@Conversational
+public interface CService {
+
+    /**
+     * Returns the state for this service.
+     * 
+     * @return The state for this service
+     */
+    String getState();
+
+    /**
+     * Returns the state for the other service that this service is using
+     * 
+     * @return The state for the other service that this service is using
+     */
+    String getStateOnD();
+
+    /**
+     * Sets the state for this service.
+     * 
+     * @param aState The state for this service
+     */
+    void setState(String aState);
+
+    /**
+     * Sets the state for the other service that this service is using
+     * 
+     * @param aState The state for the other service that this service is using
+     */
+    void setStateOnD(String aState);
+    
+    Object getConversationIDWithD();
+    
+    Object getUserConversationIDWithD();
+    
+    void setUserConversationIDWithD(String theID);
+    
+    void endConversationWithD();
+}

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

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

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java?rev=631319&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/DService.java Tue Feb 26 10:16:27 2008
@@ -0,0 +1,42 @@
+/*
+ * 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.osoa.sca.annotations.Conversational;
+
+/**
+ * Simple conversational Service
+ */
+@Conversational
+public interface DService {
+    
+    /**
+     * Returns the state for this service.
+     * 
+     * @return The state for this service
+     */
+    String getState();
+
+    /**
+     * Sets the state for this service.
+     * 
+     * @param aState The state for this service
+     */
+    void setState(String aState);
+}

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

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

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java?rev=631319&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/CServiceImpl.java Tue Feb 26 10:16:27 2008
@@ -0,0 +1,125 @@
+/*
+ * 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.CService;
+import org.apache.tuscany.sca.itest.conversational.Constants;
+import org.apache.tuscany.sca.itest.conversational.DService;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Simple conversational Service that uses another Conversational Service
+ */
+@Service(CService.class)
+@Scope("CONVERSATION")
+public class CServiceImpl implements CService {
+
+    /**
+     * The state 
+     */
+    private String state = Constants.A_INITIAL_VALUE;
+    
+    /**
+     * The reference to the other service
+     */
+    private ServiceReference<DService> dServiceRef;
+    /**
+     * Constructor
+     *
+     */
+    public CServiceImpl() {
+        System.out.println("---> CServiceImpl constructor for " + this);
+    }
+
+    /**
+     * Inject the reference to the other service
+     * @param servRef Ref to the other service.
+     */
+    @Reference(name="d")
+    public void setD(ServiceReference<DService> servRef) {
+        System.out.println("---> Setting reference to D on " + this + " to " + servRef);
+        this.dServiceRef = servRef;
+    }
+    
+    /**
+     * Returns the state for this service.
+     * 
+     * @return The state for this service
+     */
+    public String getState() {
+        return state;
+    }
+
+    /**
+     * Returns the state for the other service that this service is using
+     * 
+     * @return The state for the other service that this service is using
+     */
+    public String getStateOnD() {
+        return dServiceRef.getService().getState();
+    }
+
+    /**
+     * Sets the state for this service.
+     * 
+     * @param aState The state for this service
+     */
+    public void setState(String aState) {
+        this.state = aState;
+    }
+
+    /**
+     * Sets the state for the other service that this service is using
+     * 
+     * @param aState The state for the other service that this service is using
+     */
+    public void setStateOnD(String aState) {
+        dServiceRef.getService().setState(aState);
+    }
+    
+    /**
+     * Sets the conversation ID for this service
+     * @param id The Conversation ID
+     */
+    @ConversationID
+    public void setConversationID(String id) {
+        System.out.println("Conversation ID for " + this + " is set to " + id);
+    }
+    
+    public Object getConversationIDWithD() {
+        return dServiceRef.getConversation().getConversationID();
+    }
+
+    public void endConversationWithD() {
+      
+        dServiceRef.getConversation().end();
+    }
+
+    public Object getUserConversationIDWithD() {
+        return dServiceRef.getConversationID();
+    }
+    
+    public void setUserConversationIDWithD(String theID) {
+        dServiceRef.setConversationID(theID);
+    }
+}

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

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

Added: incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java?rev=631319&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/DServiceImpl.java Tue Feb 26 10:16:27 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.Constants;
+import org.apache.tuscany.sca.itest.conversational.DService;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Simple conversational Service
+ */
+@Service(DService.class)
+@Scope("CONVERSATION")
+public class DServiceImpl implements DService {
+
+    /**
+     * The state for this service
+     */
+    private String state = Constants.B_INITIAL_VALUE;
+
+    /**
+     * Constructor
+     */
+    public DServiceImpl() {
+        System.out.println("---> DServiceImpl constructor for " + this);
+    }
+    
+    /**
+     * Returns the state for this service.
+     * 
+     * @return The state for this service
+     */
+    public String getState() {
+        return state;
+    }
+
+    /**
+     * Sets the state for this service.
+     * 
+     * @param aState The state for this service
+     */
+    public void setState(String aState) {
+        this.state = aState;
+    }
+
+    /**
+     * Sets the conversation ID for this service
+     * @param id The Conversation ID
+     */
+    @ConversationID
+    public void setConversationID(String id) {
+        System.out.println("Conversation ID for " + this + " is set to " + id);
+    }
+}

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

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

Added: incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversationLifetime.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversationLifetime.composite?rev=631319&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversationLifetime.composite (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversationLifetime.composite Tue Feb 26 10:16:27 2008
@@ -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"
+	targetNamespace="http://conversations"
+	name="conversationLifetimeTest">
+
+    <component name="ConversationalCComponent">
+        <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.CServiceImpl"/>
+        <reference name="d" target="ConversationalDComponent" />
+    </component>
+
+    <component name="ConversationalDComponent">
+        <implementation.java class="org.apache.tuscany.sca.itest.conversational.impl.DServiceImpl"/>
+    </component>
+
+</composite>

Propchange: incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversationLifetime.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversationLifetime.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/itest/conversations/src/main/resources/conversationLifetime.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java?rev=631319&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java (added)
+++ incubator/tuscany/java/sca/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationLifetimeTestCase.java Tue Feb 26 10:16:27 2008
@@ -0,0 +1,73 @@
+/*
+ * 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;
+
+public class ConversationLifetimeTestCase {
+
+    private SCADomain domain;
+
+    @Before
+    public void setUp() throws Exception {
+        domain = SCADomain.newInstance("conversationLifetime.composite");
+
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        if (domain != null) {
+            domain.close();
+        }
+    }
+
+    
+    /**
+     * Verify that user provided conversation ID is returned from Conversation.getConversationID()
+     */
+    @Test
+    public void testSetUserSuppliedConversationID() {
+        CService service = domain.getService(CService.class, "ConversationalCComponent");
+        service.setUserConversationIDWithD("A user set conversation ID");
+        service.getStateOnD();
+        Assert.assertEquals(service.getUserConversationIDWithD(), service.getConversationIDWithD());
+        Assert.assertEquals(service.getConversationIDWithD(),"A user set conversation ID");
+   }
+    
+
+    /**
+     * Verify that a new conversation is started if conversational service method is called subsequent
+     * to a call to Conversation.end()
+     */
+    @Test
+    public void explicitEnd() {
+        CService service = domain.getService(CService.class, "ConversationalCComponent");
+        service.getStateOnD();
+        Object firstID = service.getConversationIDWithD();
+        service.endConversationWithD();
+        service.getStateOnD();
+        Assert.assertNotSame(firstID, service.getConversationIDWithD());
+    }
+    
+}

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

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