Author: kwilliams
Date: Fri May  9 16:01:07 2008
New Revision: 654975

URL: http://svn.apache.org/viewvc?rev=654975&view=rev
Log:
More tests for conversation callback-id, TUSCANY-2247

Added:
    
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/
    
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/AServiceCallback.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/BService.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/
    
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/AServiceImpl.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/BServiceImpl.java
   (with props)
    
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-id.composite
   (with props)
Modified:
    
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java

Added: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/AServiceCallback.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/AServiceCallback.java?rev=654975&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/AServiceCallback.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/AServiceCallback.java
 Fri May  9 16:01:07 2008
@@ -0,0 +1,33 @@
+/*
+ * 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.vtest.javaapi.conversation.callback.id;
+
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Remotable Service
+ */
[EMAIL PROTECTED]
[EMAIL PROTECTED]
+public interface AServiceCallback {
+
+    public void callBack(String someState);
+    
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/AServiceCallback.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/AServiceCallback.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/BService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/BService.java?rev=654975&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/BService.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/BService.java
 Fri May  9 16:01:07 2008
@@ -0,0 +1,41 @@
+/*
+ * 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.vtest.javaapi.conversation.callback.id;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service
+ */
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED](AServiceCallback.class)
+public interface BService {
+
+    public void setState(String someState);
+    
+    public String getState();
+
+    public void testCallBack(String string);
+
+    public void testCallBack2(String string);
+
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/BService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/BService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/AServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/AServiceImpl.java?rev=654975&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/AServiceImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/AServiceImpl.java
 Fri May  9 16:01:07 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.vtest.javaapi.conversation.callback.id.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.AService;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.Utilities;
+import 
org.apache.tuscany.sca.vtest.javaapi.conversation.callback.id.AServiceCallback;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.id.BService;
+import org.junit.Assert;
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
[EMAIL PROTECTED](AService.class)
[EMAIL PROTECTED]("CONVERSATION")
+public class AServiceImpl implements AService, AServiceCallback {
+
+    @Reference
+    protected ServiceReference<BService> b;
+    
+    @Context
+    protected RequestContext requestContext;
+    
+    private String someState;
+
+    public void callBack(String someState) {
+        System.out.println("A-callback called with this state => " + 
someState);
+        
Assert.assertNotNull(requestContext.getServiceReference().getCallbackID());
+        this.someState = someState;
+    }
+
+    public void testCallback() {
+        b.getService().testCallBack("Some string");
+        int count = 4;
+        while (someState == null && count > 0) {
+            Utilities.delayQuarterSecond();
+            count--;
+        }
+        if (someState == null)
+            Assert.fail("Callback not received by this instance");
+    }
+
+    public void testCallback2() {
+        b.getService().testCallBack2("Some string");
+        int count = 4;
+        while (someState == null && count > 0) {
+            Utilities.delayQuarterSecond();
+            count--;
+        }
+        if (someState == null)
+            Assert.fail("Callback not received by this instance");
+    }
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/AServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/AServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/BServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/BServiceImpl.java?rev=654975&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/BServiceImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/BServiceImpl.java
 Fri May  9 16:01:07 2008
@@ -0,0 +1,60 @@
+/*
+ * 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.vtest.javaapi.conversation.callback.id.impl;
+
+import 
org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.AServiceCallback;
+import 
org.apache.tuscany.sca.vtest.javaapi.conversation.callback.accessing.BService;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
[EMAIL PROTECTED](BService.class)
[EMAIL PROTECTED]("CONVERSATION")
+public class BServiceImpl implements BService {
+
+    String someState;
+
+    @Callback
+    protected CallableReference<AServiceCallback> callback;
+    
+    @Context
+    protected ComponentContext componentContext;
+
+    public void setState(String someState) {
+        this.someState = someState;
+    }
+
+    public String getState() {
+        return someState;
+    }
+
+    public void testCallBack(String someState) {
+        callback.getService().callBack(someState);
+    }
+
+    public void testCallBack2(String someState) {
+        AServiceCallback callback = 
componentContext.getRequestContext().getCallback();
+        callback.callBack(someState);
+    }
+
+}

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/BServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/id/impl/BServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-id.composite
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-id.composite?rev=654975&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-id.composite
 (added)
+++ 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-id.composite
 Fri May  9 16:01:07 2008
@@ -0,0 +1,34 @@
+<?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://java-api-tests"; 
name="Conversation-callback-multi">
+
+       <component name="AComponent">
+               <implementation.java
+                       
class="org.apache.tuscany.sca.vtest.javaapi.conversation.callback.id.impl.AServiceImpl"
 />
+               <reference name="b" target="BComponent" />
+       </component>
+
+       <component name="BComponent">
+               <implementation.java
+                       
class="org.apache.tuscany.sca.vtest.javaapi.conversation.callback.id.impl.BServiceImpl"
 />
+       </component>
+
+</composite>

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-id.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-id.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/main/resources/callback-id.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java?rev=654975&r1=654974&r2=654975&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java
 Fri May  9 16:01:07 2008
@@ -229,6 +229,23 @@
      * client in this case needs to set the callback ID before invoking the
      * service and then needs to get the callback ID when the response is
      * received.
+     * <p>
+     * Lines 747-755
+     * <p>
+     * The identity that is used to identify a callback request is, by
+     * default, generated by the system. However, it is possible to provide an
+     * application specified identity that should be used to identify the
+     * callback by calling the ServiceReference.setCallbackID() method. This 
can
+     * be used even either stateful or stateless callbacks. The identity will 
be
+     * sent to the service provider, and the binding must guarantee that the
+     * service provider will send the ID back when any callback method is
+     * invoked. The callback identity has the same restrictions as the
+     * conversation ID. It should either be a string or an object that can be
+     * serialized into XML. Bindings determine the particular mechanisms to use
+     * for transmission of the identity and these may lead to further
+     * restrictions when using a given binding.
+     * <p>
+     * TODO - Need to add explicit test back to stateful for 747-755
      */
     @Test
     public void statelessCallback2() throws Exception {
@@ -314,7 +331,30 @@
         domain = SCADomain.newInstance("callback-accessing.composite");
         aService = domain.getService(AService.class, "AComponent");
         aService.testCallback();
-        aService.testCallback2(); //Lines 695-696
+        aService.testCallback2(); // Lines 695-696
+
+    }
+
+    /**
+     * Lines 708-724
+     * <p>
+     * On the client side, the service that implements the callback can access
+     * the callback ID (i.e. reference parameters) that was returned with the
+     * callback operation also by accessing the request context, as follows:
+     * <p>
+     * On the client side, the object returned by the getServiceReference()
+     * method represents the service reference that was used to send the
+     * original request. The object returned by getCallbackID() represents the
+     * identity associated with the callback, which may be a single String or
+     * may be an object (as described below in “Customizing the Callback
+     * Identity”).
+     */
+    @Test
+    public void callBackId() throws Exception {
+        System.out.println("Setting up for callback id tests");
+        domain = SCADomain.newInstance("callback-id.composite");
+        aService = domain.getService(AService.class, "AComponent");
+        aService.testCallback();
 
     }
 }


Reply via email to