You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by mc...@apache.org on 2008/04/08 11:28:16 UTC

svn commit: r645808 - in /incubator/tuscany/java/sca/itest/callablereferences/src: main/java/org/apache/tuscany/sca/itest/callablerefconversational/ main/resources/ test/java/org/apache/tuscany/sca/itest/callableref/

Author: mcombellack
Date: Tue Apr  8 02:28:14 2008
New Revision: 645808

URL: http://svn.apache.org/viewvc?rev=645808&view=rev
Log:
TUSCANY-2208 - Added an iTest to show the problem with ComponentContext.createSelfReference() for Conversational Components. Note: The tests are disabled as they do not pass. To enable the tests, just remove the // from @Test in the class CallableReferenceConversationalTestCase

Added:
    incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/
    incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java   (with props)
    incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java   (with props)
    incubator/tuscany/java/sca/itest/callablereferences/src/main/resources/CallableReferenceConversationalTest.composite   (with props)
    incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java   (with props)

Added: incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java?rev=645808&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java (added)
+++ incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java Tue Apr  8 02:28:14 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.callablerefconversational;
+
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Conversational;
+
+/**
+ * Simple conversational Service that is used to testing the method
+ * ComponentContext.createSelfReference()
+ * 
+ * @version $Date$ $Revision$
+ */
+@Conversational
+public interface ConversationalService {
+    /**
+     * Default value for the user data
+     */
+    String DEFAULT_USER_DATA = "NOT SET";
+
+    /**
+     * Retrieves the conversation ID for this Service
+     * 
+     * @return The conversation ID for this Service
+     */
+    Object getConversationID();
+
+    /**
+     * Creates a self reference to this Service
+     * 
+     * @return A self reference to this Service
+     */
+    ServiceReference<ConversationalService> createSelfRef();
+
+    /**
+     * Sets some user data on the instance
+     * 
+     * @param a_Data Some data
+     * 
+     * @See {@link #getUserData()}
+     */
+    void setUserData(String a_Data);
+
+    /**
+     * Gets some user data on the instance
+     * 
+     * @return Some data
+     * 
+     * @See {@link #setUserData(String)}
+     */
+    String getUserData();
+}

Propchange: incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java?rev=645808&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java (added)
+++ incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java Tue Apr  8 02:28:14 2008
@@ -0,0 +1,111 @@
+/*
+ * 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.callablerefconversational;
+
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Simple conversational Service that is used to testing the method
+ * ComponentContext.createSelfReference()
+ * 
+ * @version $Date$ $Revision$
+ */
+@Service(ConversationalService.class)
+@Scope("CONVERSATION")
+public class ConversationalServiceImpl implements ConversationalService {
+
+    /**
+     * The Conversation ID
+     */
+    private Object m_ConversationID;
+
+    /**
+     * Reference to the ComponentContext.
+     */
+    @Context
+    protected ComponentContext m_Ctx;
+
+    /**
+     * Some user data
+     */
+    private String m_UserData = DEFAULT_USER_DATA;
+
+    /**
+     * Constructor
+     */
+    public ConversationalServiceImpl() {
+        System.out.println("New instance of " + this + " created");
+    }
+
+    /**
+     * Used to inject the Conversation ID
+     * 
+     * @param a_ConversationID the Conversation ID
+     */
+    @ConversationID
+    public void setConversationID(Object a_ConversationID) {
+        m_ConversationID = a_ConversationID;
+        System.out.println("Converstation ID set on " + this + " to " + a_ConversationID);
+    }
+
+    /**
+     * Retrieves the conversation ID for this Service
+     * 
+     * @return The conversation ID for this Service
+     */
+    public Object getConversationID() {
+        return m_ConversationID;
+    }
+
+    /**
+     * Creates a self reference to this Service
+     * 
+     * @return A self reference to this Service
+     */
+    public ServiceReference<ConversationalService> createSelfRef() {
+        return m_Ctx.createSelfReference(ConversationalService.class);
+    }
+
+    /**
+     * Sets some user data on the instance
+     * 
+     * @param a_Data Some data
+     * 
+     * @See {@link #getUserData()}
+     */
+    public void setUserData(String a_Data) {
+        m_UserData = a_Data;
+    }
+
+    /**
+     * Gets some user data on the instance
+     * 
+     * @return Some data
+     * 
+     * @See {@link #setUserData(String)}
+     */
+    public String getUserData() {
+        return m_UserData;
+    }
+}

Propchange: incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/itest/callablereferences/src/main/resources/CallableReferenceConversationalTest.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callablereferences/src/main/resources/CallableReferenceConversationalTest.composite?rev=645808&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/callablereferences/src/main/resources/CallableReferenceConversationalTest.composite (added)
+++ incubator/tuscany/java/sca/itest/callablereferences/src/main/resources/CallableReferenceConversationalTest.composite Tue Apr  8 02:28:14 2008
@@ -0,0 +1,29 @@
+<?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
+    * 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" xmlns:foo="http://foo" targetNamespace="http://foo"
+    name="CallableReferenceConversation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+    <service name="ConversationalService" promote="ConversationalComponent">
+        <interface.java interface="org.apache.tuscany.sca.itest.callablerefconversational.ConversationalService" />
+    </service>
+
+    <component name="ConversationalComponent">
+        <implementation.java class="org.apache.tuscany.sca.itest.callablerefconversational.ConversationalServiceImpl" />
+    </component>
+</composite>
\ No newline at end of file

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

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

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

Added: incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java?rev=645808&view=auto
==============================================================================
--- incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java (added)
+++ incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java Tue Apr  8 02:28:14 2008
@@ -0,0 +1,109 @@
+/*
+ * 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.callableref;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.itest.callablerefconversational.ConversationalService;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osoa.sca.ServiceReference;
+
+/**
+ * Simple test case that creates a ServiceReference to a Conversational Component
+ * using ComponentContext.createSelfReference()
+ * <p>
+ * This test case is for TUSCANY-2208
+ * 
+ * @version $Date$ $Revision$
+ */
+public class CallableReferenceConversationalTestCase {
+    private static SCADomain domain;
+    private static ConversationalService acomponent;
+
+    @BeforeClass
+    public static void init() throws Exception {
+        domain = SCADomain.newInstance("CallableReferenceConversationalTest.composite");
+        Assert.assertNotNull(domain);
+        acomponent = domain.getService(ConversationalService.class, "ConversationalComponent");
+    }
+
+    @AfterClass
+    public static void destroy() throws Exception {
+        if (domain != null) {
+            domain.close();
+        }
+    }
+
+    /**
+     * This is a dummy test so that this Unit Test has a test so it will build.
+     * Once TUSCANY-2208 is fixed, this dummy test method can be removed 
+     */
+    @Test
+    public void dummyTestRemoveWhenTuscany2208IsFixed() {
+    }
+
+    /**
+     * Tests creating Self References and validate them with Conversation IDs
+     */
+    // Disabled until TUSCANY-2208 is fixed
+    // @Test
+    public void testCreateSelfRefUsingConvID() {
+        Assert.assertNotNull(acomponent);
+
+        final Object origConvID = acomponent.getConversationID();
+        Assert.assertNotNull(origConvID);
+        final ServiceReference<ConversationalService> ref = acomponent.createSelfRef();
+        Assert.assertNotNull(ref);
+
+        final ConversationalService resolvedRef = ref.getService();
+        Assert.assertNotNull(resolvedRef);
+        final Object newConvID = resolvedRef.getConversationID();
+        Assert.assertNotNull(newConvID);
+
+        Assert.assertEquals(origConvID, newConvID);
+    }
+
+    /**
+     * Tests creating Self References and validate them with user specified data 
+     */
+    // Disabled until TUSCANY-2208 is fixed
+    // @Test
+    public void testCreateSelfRefUsingUserData() {
+        Assert.assertNotNull(acomponent);
+
+        final String origUserData = acomponent.getUserData();
+        Assert.assertEquals(ConversationalService.DEFAULT_USER_DATA, origUserData);
+
+        final String userData = "Some new user data set at " + System.currentTimeMillis();
+        acomponent.setUserData(userData);
+
+        final ServiceReference<ConversationalService> ref = acomponent.createSelfRef();
+        Assert.assertNotNull(ref);
+
+        final ConversationalService resolvedRef = ref.getService();
+        Assert.assertNotNull(resolvedRef);
+        final String newUserData = resolvedRef.getUserData();
+        Assert.assertNotNull(newUserData);
+
+        Assert.assertEquals(userData, newUserData);
+    }
+}

Propchange: incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.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