summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/2.0-M2/vtest/java-api/conversation/lifetime/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/LifetimeTestCase.java
blob: 52c11b881c77fffa9cad4a759f327f4cd9b7bb76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
 * 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.lifetime;

import org.apache.tuscany.sca.vtest.utilities.ServiceFinder;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.oasisopen.sca.ConversationEndedException;

/**
 * 
 */
public class LifetimeTestCase {

    protected static String compositeName = "lifetime.composite";
    protected static AService aService = null;

    @BeforeClass
    public static void init() throws Exception {
        try {
            System.out.println("Setting up");
            ServiceFinder.init(compositeName);
            aService = ServiceFinder.getService(AService.class, "AComponent");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    @AfterClass
    public static void destroy() throws Exception {

        System.out.println("Cleaning up");
        ServiceFinder.cleanup();

    }

    /**
     * Lines 475, 476
     * <p>
     * Conversations start on the client side when one of the following occur: A
     * "@Reference" to a conversational service is injected, ... and then a
     * method of the service is called
     */
    @Test
    public void lifetime1() throws Exception {
        aService.testConversationStarted();
    }

    /**
     * Lines 477, 478, 479
     * <p>
     * Conversations start on the client side when one of the following occur
     * ... A call is made to CompositeContext.getServiceReference and then a
     * method of the service is called.
     */
    @Test
    //@Ignore("TUSCANY-2243")
    public void lifetime2() throws Exception {
        aService.testConversationStarted2();
    }

    /**
     * Line 481, 482
     * <p>
     * The client can continue an existing conversation, by: Holding the service
     * reference that was created when the conversation started
     */
    @Test
    public void lifetime3() throws Exception {
        aService.testConversationContinue();
    }

    /**
     * Line 481, 483
     * <p>
     * The client can continue an existing conversation, by: ... � Getting the
     * service reference object passed as a parameter from another service, even
     * remotely
     */
    @Test
    public void lifetime4() throws Exception {
        // aService.testConversationContinue2();
    }

    /**
     * Line 481, 484
     * <p>
     * The client can continue an existing conversation, by:<br> � Loading a
     * service reference that had been written to some form of persistent
     * storage
     */
    @Test
    public void lifetime6() throws Exception {
        aService.testConversationContinue3();
    }

    /**
     * Line 487, 488
     * <p>
     * A conversation ends, and any state associated with the conversation is
     * freed up, when: <br>
     * ...A server operation that has been annotated "@EndConveration" has been
     * called
     */
    @Test
    public void lifetime7() throws Exception {
        aService.testConversationEnd();
    }

    /**
     * Line 487, 489
     * <p>
     * A conversation ends, and any state associated with the conversation is
     * freed up, when: <br>
     * ...The server calls an "@EndsConversation" method on the "@Callback"
     * reference <br>
     */
    @Test
    public void lifetime8() throws Exception {
        aService.testConversationEnd2();
    }

    /**
     * Line 487, 490
     * <p>
     * 487 A conversation ends, and any state associated with the conversation
     * is freed up, when: <br>
     * ... The server's conversation lifetime timeout occurs
     */
    @Test
    public void lifetime9() throws Exception {
        aService.testConversationEnd3();
    }

    /**
     * Line 487, 491
     * <p>
     * A conversation ends, and any state associated with the conversation is
     * freed up, when: <br>
     * ...The client calls Conversation.end()
     */
    @Test
    public void lifetime10() throws Exception {
        aService.testConversationEnd4();
    }

    /**
     * Line 487, 492
     * <p>
     * A conversation ends, and any state associated with the conversation is
     * freed up, when: <br>
     * ...Any non-business exception is thrown by a conversational operation
     */
    @Test
    //@Ignore("TUSCANY-2283")
    public void lifetime11() throws Exception {
        aService.testConversationEnd5();
        aService.testConversationEnd9();
    }

    /**
     * Line 494, 495
     * <p>
     * If a method is invoked on a service reference after an
     * "@EndsConversation" method has been called then a new conversation will
     * automatically be started.
     */
    @Test
    public void lifetime12() throws Exception {
        aService.testConversationEnd6();
    }

    /**
     * Line 495, 496, 497
     * <p>
     * If ServiceReference.getConversationID() is called after the
     * "@EndsConversation" method: is called, but before the next conversation
     * has been started, it will return null.
     */
    @Test
    public void lifetime13() throws Exception {
        aService.testConversationEnd7();
    }

    /**
     * Line 498, 499
     * <p>
     * If a service reference is used after the service provider's conversation
     * timeout has caused the conversation to be ended, then
     * ConversationEndedException will be thrown.
     */
    @Test(expected = ConversationEndedException.class)
    public void lifetime14() throws Exception {
        aService.testConversationEnd8();
    }

}