You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2007/07/31 19:57:35 UTC
svn commit: r561411 - in /incubator/tuscany/sandbox/lresende/sca/itest: ./
locate-service/ locate-service/src/ locate-service/src/main/
locate-service/src/main/java/ locate-service/src/main/java/echoService/
locate-service/src/main/resources/ locate-se...
Author: lresende
Date: Tue Jul 31 10:57:34 2007
New Revision: 561411
URL: http://svn.apache.org/viewvc?view=rev&rev=561411
Log:
Simplified version of test case from TUSCANY-1347
Added:
incubator/tuscany/sandbox/lresende/sca/itest/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/pom.xml
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoService.java
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoServiceImpl.java
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoCallback.java
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoService.java
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoServiceImpl.java
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/RelayServiceImpl.java
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseService.java
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseServiceImpl.java
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/resources/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/resources/SCAEchoServiceDefaultComposite.composite
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/test/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/test/java/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/test/java/echoService/
incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/test/java/echoService/EchoServiceTestCase.java
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/pom.xml?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/pom.xml (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/pom.xml Tue Jul 31 10:57:34 2007
@@ -0,0 +1,64 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-itest-locate-service</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany echoService Integration Tests</name>
+ <properties>
+ <ws.type>axis2</ws.type>
+ </properties>
+
+<!--
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>always</forkMode>
+ <argLine>-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=3720,server=y,suspend=y</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+-->
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoService.java?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoService.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoService.java Tue Jul 31 10:57:34 2007
@@ -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 echoService;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Callback;
+
+/**
+ * SCA Test Service for passing and receiving various datatype arguments and return types.
+ * This service may be implemented to return the argument or pass the request. These implemented components can be connected to create complex composites.
+ *
+ */
+@Remotable
+@Callback(EchoCallback.class)
+public interface AsyncEchoService {
+
+ /**
+ * An echo method to receive a <code>String</code> equaling the value of the input parameter.
+ *
+ *
+ * @param input <code>String</code> value for data test parameter
+ */
+ public void echo(String input);
+
+}
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoServiceImpl.java?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoServiceImpl.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/AsyncEchoServiceImpl.java Tue Jul 31 10:57:34 2007
@@ -0,0 +1,39 @@
+/*
+ * 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 echoService;
+
+import org.osoa.sca.annotations.Service;
+import org.osoa.sca.annotations.Callback;
+
+/**
+ * SCA Test Echo Service implements the EchoService as a 'terminating' component
+ * building block for assembling composites.
+ *
+ */
+@Service(AsyncEchoService.class)
+public class AsyncEchoServiceImpl implements AsyncEchoService {
+
+ @Callback
+ protected EchoCallback _callback;
+
+ public void echo(String input) {
+ _callback.echoResults(input);
+ }
+
+}
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoCallback.java?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoCallback.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoCallback.java Tue Jul 31 10:57:34 2007
@@ -0,0 +1,40 @@
+/*
+ * 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 echoService;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * SCA Test Service for passing and receiving various datatype arguments and return types.
+ * This service may be implemented to return the argument or pass the request. These implemented components can be connected to create complex composites.
+ *
+ */
+
+@Remotable
+public interface EchoCallback {
+
+ /**
+ * An echo method to receive a <code>String</code> equaling the value of the input parameter.
+ *
+ *
+ * @param input <code>String</code> value for data test parameter
+ */
+ public void echoResults(String result);
+
+}
\ No newline at end of file
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoService.java?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoService.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoService.java Tue Jul 31 10:57:34 2007
@@ -0,0 +1,51 @@
+/*
+ * 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 echoService;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * SCA Test Service for passing and receiving various datatype arguments and return types.
+ * This service may be implemented to return the argument or pass the request. These implemented components can be connected to create complex composites.
+ *
+ */
+@Remotable
+public interface EchoService {
+
+ /**
+ * An echo method to receive a <code>String</code> equaling the value of the input parameter.
+ *
+ *
+ * @param input <code>String</code> value for data test parameter
+ * @return <code>String</code> value sent for input
+ */
+ public String echo(String input);
+
+ /**
+ * An echo method to receive a <code>String</code> equaling the value of the input parameter in upper case.
+ *
+ *
+ * @param input <code>String</code> value for data test parameter
+ * @return <code>String</code> value sent for input in upper case
+ */
+ public String loudEcho(String input);
+
+ public String asyncEcho(String input);
+
+}
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoServiceImpl.java?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoServiceImpl.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/EchoServiceImpl.java Tue Jul 31 10:57:34 2007
@@ -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 echoService;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * SCA Test Echo Service implements the EchoService as a 'terminating' component building block for assembling composites.
+ *
+ */
+@Service(EchoService.class)
+public class EchoServiceImpl implements EchoService, EchoCallback {
+ @Reference
+ protected UppercaseService uppercaseService;
+
+ @Reference
+ protected AsyncEchoService asyncEchoService;
+
+ String _result = null;
+
+ public String echo(String input) {
+ return input;
+ }
+
+ public String loudEcho(String input) {
+ return uppercaseService.uppercase(input);
+ }
+
+ public String asyncEcho(String input) {
+ asyncEchoService.echo(input);
+
+ int count = 0;
+ while (_result == null & count < 5) // wait ten seconds max
+ {
+ try {
+ synchronized(this) {
+ this.wait(1024);
+ }
+ count = count + 1;
+ } catch (InterruptedException e) {
+
+ }
+ }
+ return _result;
+
+ }
+
+ public void echoResults(String result) {
+ _result = result;
+ }
+}
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/RelayServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/RelayServiceImpl.java?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/RelayServiceImpl.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/RelayServiceImpl.java Tue Jul 31 10:57:34 2007
@@ -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 echoService;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * SCA Test Relay Service implements the EchoService as a 'connecting' component
+ * building block for assembling composites. This service relies on a reference
+ * to another EchoService declared with the <code>@Reference</code> annotation. This reference must be defined in the SCDL for
+ * any component which uses this service.
+ *
+ */
+@Service(EchoService.class)
+public class RelayServiceImpl implements EchoService {
+
+ /**
+ * Reference to another EchoService which must be defined for the component
+ * in SCDL file.
+ *
+ */
+ @Reference
+ protected EchoService echoService;
+
+ private String message = "Relay ===> ";
+
+ /**
+ * Relays result of echo called on default echo service.
+ */
+ public String echo(String input) {
+ return message + echoService.echo(input);
+ }
+
+ /**
+ * Relays result of loudEcho called on default echo service.
+ */
+ public String loudEcho(String input) {
+ return message + echoService.loudEcho(input);
+ }
+
+ /**
+ * Relays result of asyncEcho called on default echo service.
+ */
+ public String asyncEcho(String input) {
+ return message + echoService.asyncEcho(input);
+ }
+}
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseService.java?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseService.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseService.java Tue Jul 31 10:57:34 2007
@@ -0,0 +1,28 @@
+/*
+ * 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 echoService;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface UppercaseService {
+
+ public String uppercase(String input);
+
+}
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseServiceImpl.java?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseServiceImpl.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/java/echoService/UppercaseServiceImpl.java Tue Jul 31 10:57:34 2007
@@ -0,0 +1,30 @@
+/*
+ * 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 echoService;
+
+import org.osoa.sca.annotations.Service;
+
+@Service(UppercaseService.class)
+public class UppercaseServiceImpl implements UppercaseService {
+
+ public String uppercase(String input) {
+ return input.toUpperCase() + "!";
+ }
+
+}
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/resources/SCAEchoServiceDefaultComposite.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/resources/SCAEchoServiceDefaultComposite.composite?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/resources/SCAEchoServiceDefaultComposite.composite (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/main/resources/SCAEchoServiceDefaultComposite.composite Tue Jul 31 10:57:34 2007
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:v="http://www.osoa.org/xmlns/sca/values/1.0"
+ name="SCAEchoServiceDefaultComposite">
+
+ <component name="SCAEchoServiceDefaultComponent">
+ <implementation.java class="org.apache.tuscany.sca.test.echoService.EchoServiceImpl"/>
+ <reference name="uppercaseService" target="SCAUppercaseService"/>
+ <reference name="asyncEchoService" target="SCAAsyncEchoService"/>
+ </component>
+
+ <component name="SCAUppercaseService">
+ <implementation.java class="org.apache.tuscany.sca.test.echoService.UppercaseServiceImpl"/>
+ </component>
+
+ <component name="SCAAsyncEchoService">
+ <implementation.java class="org.apache.tuscany.sca.test.echoService.AsyncEchoServiceImpl"/>
+ </component>
+
+ <component name="SCARelayServiceDefaultComponent">
+ <implementation.java class="org.apache.tuscany.sca.test.echoService.RelayServiceImpl"/>
+ <reference name="echoService" target="SCAEchoServiceDefaultComponent/EchoService"/>
+ </component>
+
+</composite>
+
Added: incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/test/java/echoService/EchoServiceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/test/java/echoService/EchoServiceTestCase.java?view=auto&rev=561411
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/test/java/echoService/EchoServiceTestCase.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/itest/locate-service/src/test/java/echoService/EchoServiceTestCase.java Tue Jul 31 10:57:34 2007
@@ -0,0 +1,112 @@
+/*
+ * 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 echoService;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import echoService.EchoService;
+
+public class EchoServiceTestCase extends TestCase {
+ private static final String SERVICE = "SCARelayServiceDefaultComponent/EchoService";
+ private static final String ASYNC_SERVICE = "SCAAsyncEchoService";
+ private static final String INVALID_SERVICE = "SCARelayServiceDefaultComponent/EchoServiceXXX";
+
+ private SCADomain domain;
+
+ @Override
+ protected void setUp() throws Exception {
+ try {
+ domain = SCADomain.newInstance("SCAEchoServiceDefaultComposite.composite");
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+ /**
+ * test_simpleEchoService
+ *
+ * <br>
+ * Use Case Description: Locate a service that works.
+ *
+ * <br>
+ * Test description: Demonstrate successful location and use of a service.
+ *
+ */
+ public void test_simpleEchoService() {
+ EchoService echoService = (EchoService) domain.getService(EchoService.class, SERVICE);
+
+ assertNotNull("Could not located echoService using SCAEchoServiceDefaultReference " + SERVICE, echoService);
+
+ echoService.echo("Hello?");
+ }
+
+ /**
+ * test_asyncEchoService
+ *
+ * <br>
+ * Use Case Description: Locate a service that exploits callback which results in exception.
+ *
+ * <br>
+ * Test description: Attempt to locate a service that exploits callback. Test passes if org.osoa.sca.ServiceRuntimeException is caught.
+ *
+ */
+ public void test_asyncEchoService() {
+ try {
+ EchoService echoService = (EchoService) domain.getService(EchoService.class, ASYNC_SERVICE);
+
+ String result = echoService.asyncEcho("Hello?");
+ System.out.println("Result =>" + result);
+ assertEquals(result, "Hello?");
+
+
+ } catch (org.osoa.sca.ServiceRuntimeException e) {
+ fail("Unexpected exception : " + e.getMessage());
+ }
+ }
+
+ /**
+ * test_asyncEchoService
+ *
+ * <br>
+ * Use Case Description: Locate a service that exploits callback which results in exception.
+ *
+ * <br>
+ * Test description: Attempt to locate a service that exploits callback. Test passes if org.osoa.sca.ServiceRuntimeException is caught.
+ *
+ */
+ public void test_invalidEchoService() {
+ try {
+ EchoService echoService = (EchoService) domain.getService(EchoService.class, INVALID_SERVICE);
+ assertNull(echoService);
+ fail("Expected to generate org.osoa.sca.ServiceRuntimeException but did not when invoking service with async");
+ } catch (org.osoa.sca.ServiceRuntimeException e) {
+ // expected.
+ }
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org