diff options
Diffstat (limited to 'sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway')
8 files changed, 690 insertions, 0 deletions
diff --git a/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/build.xml b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/build.xml new file mode 100644 index 0000000000..fe3b38aa80 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/build.xml @@ -0,0 +1,127 @@ +<!-- + * 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 name="oneway" default="runServer"> + + <property name="m2.repo" value="${user.home}\.m2\repository" /> + + <path id="repo.classpath"> + <pathelement location="target/classes"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-core-spi\2.0-Beta4\tuscany-core-spi-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-host-http\2.0-Beta4\tuscany-host-http-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-ws-axis2\2.0-Beta4\tuscany-binding-ws-axis2-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-policy\2.0-Beta4\tuscany-policy-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\xerces\xercesImpl\2.8.1\xercesImpl-2.8.1.jar"/> + <pathelement location="${m2.repo}\org\mortbay\jetty\jetty-util\6.1.3\jetty-util-6.1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\geronimo\specs\geronimo-jms_1.1_spec\1.1\geronimo-jms_1.1_spec-1.1.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-implementation-java-runtime\2.0-Beta4\tuscany-implementation-java-runtime-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\wsdl4j\wsdl4j\1.6.2\wsdl4j-1.6.2.jar"/> + <pathelement location="${m2.repo}\commons-codec\commons-codec\1.3\commons-codec-1.3.jar"/> + <pathelement location="${m2.repo}\xml-apis\xml-apis\1.3.03\xml-apis-1.3.03.jar"/> + <pathelement location="${m2.repo}\org\apache\ws\security\wss4j\1.5.3\wss4j-1.5.3.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-contribution-namespace\2.0-Beta4\tuscany-contribution-namespace-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\jdom\jdom\1.0\jdom-1.0.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-assembly-xsd\2.0-Beta4\tuscany-assembly-xsd-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-assembly\2.0-Beta4\tuscany-assembly-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\rampart\rampart-trust\1.3\rampart-trust-1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-core-databinding\2.0-Beta4\tuscany-core-databinding-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar"/> + <pathelement location="${m2.repo}\org\apache\ws\commons\axiom\axiom-api\1.2.5\axiom-api-1.2.5.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-policy-xml\2.0-Beta4\tuscany-policy-xml-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\axis2\axis2-kernel\1.3\axis2-kernel-1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-sca-api\2.0-Beta4\tuscany-sca-api-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\cglib\cglib-nodep\2.1_3\cglib-nodep-2.1_3.jar"/> + <pathelement location="${m2.repo}\org\apache\httpcomponents\httpcore\4.0-alpha5\httpcore-4.0-alpha5.jar"/> + <pathelement location="${m2.repo}\backport-util-concurrent\backport-util-concurrent\2.2\backport-util-concurrent-2.2.jar"/> + <pathelement location="${m2.repo}\commons-logging\commons-logging\1.1\commons-logging-1.1.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-contribution-java\2.0-Beta4\tuscany-contribution-java-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\geronimo\specs\geronimo-activation_1.1_spec\1.0-M1\geronimo-activation_1.1_spec-1.0-M1.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-databinding\2.0-Beta4\tuscany-databinding-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\logkit\logkit\1.0.1\logkit-1.0.1.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-ws-xml\2.0-Beta4\tuscany-binding-ws-xml-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\commons-fileupload\commons-fileupload\1.1.1\commons-fileupload-1.1.1.jar"/> + <pathelement location="${m2.repo}\annogen\annogen\0.1.0\annogen-0.1.0.jar"/> + <pathelement location="${m2.repo}\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar"/> + <pathelement location="${m2.repo}\org\apache\axis2\axis2-adb\1.3\axis2-adb-1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-policy-security\2.0-Beta4\tuscany-policy-security-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-assembly-xml\2.0-Beta4\tuscany-assembly-xml-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\axis2\axis2-mtompolicy\1.3\axis2-mtompolicy-1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-domain\2.0-Beta4\tuscany-domain-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\commons-httpclient\commons-httpclient\3.0.1\commons-httpclient-3.0.1.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface-java\2.0-Beta4\tuscany-interface-java-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\axis2\axis2-java2wsdl\1.3\axis2-java2wsdl-1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\httpcomponents\httpcore-nio\4.0-alpha5\httpcore-nio-4.0-alpha5.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-contribution\2.0-Beta4\tuscany-contribution-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-implementation-java\2.0-Beta4\tuscany-implementation-java-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\xalan\xalan\2.7.0\xalan-2.7.0.jar"/> + <pathelement location="${m2.repo}\com\ibm\icu\icu4j\2.6.1\icu4j-2.6.1.jar"/> + <pathelement location="${m2.repo}\org\apache\rampart\rampart-core\1.3\rampart-core-1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\geronimo\specs\geronimo-commonj_1.1_spec\1.0\geronimo-commonj_1.1_spec-1.0.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-domain-api\2.0-Beta4\tuscany-domain-api-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-sca\2.0-Beta4\tuscany-binding-sca-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\xom\xom\1.0\xom-1.0.jar"/> + <pathelement location="${m2.repo}\org\apache\ant\ant-launcher\1.7.0\ant-launcher-1.7.0.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-host-jetty\2.0-Beta4\tuscany-host-jetty-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\rampart\rampart-policy\1.3\rampart-policy-1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\httpcomponents\httpcore-niossl\4.0-alpha5\httpcore-niossl-4.0-alpha5.jar"/> + <pathelement location="${m2.repo}\junit\junit\4.2\junit-4.2.jar"/> + <pathelement location="${m2.repo}\org\apache\ws\commons\axiom\axiom-impl\1.2.5\axiom-impl-1.2.5.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-implementation-java-xml\2.0-Beta4\tuscany-implementation-java-xml-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-sca-xml\2.0-Beta4\tuscany-binding-sca-xml-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\neethi\neethi\2.0.2\neethi-2.0.2.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface-wsdl\2.0-Beta4\tuscany-interface-wsdl-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-ws\2.0-Beta4\tuscany-binding-ws-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\javax\activation\activation\1.1\activation-1.1.jar"/> + <pathelement location="${m2.repo}\org\apache\ant\ant\1.7.0\ant-1.7.0.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-databinding-axiom\2.0-Beta4\tuscany-databinding-axiom-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\mortbay\jetty\jetty\6.1.3\jetty-6.1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\geronimo\specs\geronimo-javamail_1.4_spec\1.0-M1\geronimo-javamail_1.4_spec-1.0-M1.jar"/> + <pathelement location="${m2.repo}\avalon-framework\avalon-framework\4.1.3\avalon-framework-4.1.3.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-core\2.0-Beta4\tuscany-core-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface-wsdl-xml\2.0-Beta4\tuscany-interface-wsdl-xml-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-contribution-impl\2.0-Beta4\tuscany-contribution-impl-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-node\2.0-Beta4\tuscany-node-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-definitions\2.0-Beta4\tuscany-definitions-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\santuario\xmlsec\1.4.0\xmlsec-1.4.0.jar"/> + <pathelement location="${m2.repo}\jaxen\jaxen\1.1.1\jaxen-1.1.1.jar"/> + <pathelement location="${m2.repo}\commons-io\commons-io\1.2\commons-io-1.2.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-host-embedded\2.0-Beta4\tuscany-host-embedded-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\ws\commons\axiom\axiom-dom\1.2.5\axiom-dom-1.2.5.jar"/> + <pathelement location="${m2.repo}\log4j\log4j\1.2.12\log4j-1.2.12.jar"/> + <pathelement location="${m2.repo}\javax\mail\mail\1.4\mail-1.4.jar"/> + <pathelement location="${m2.repo}\org\apache\axis2\axis2-codegen\1.3\axis2-codegen-1.3.jar"/> + <pathelement location="${m2.repo}\org\codehaus\woodstox\wstx-asl\3.2.1\wstx-asl-3.2.1.jar"/> + <pathelement location="${m2.repo}\stax\stax-api\1.0.1\stax-api-1.0.1.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface-java-xml\2.0-Beta4\tuscany-interface-java-xml-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\apache\ws\commons\schema\XmlSchema\1.3.2\XmlSchema-1.3.2.jar"/> + <pathelement location="${m2.repo}\xerces\xmlParserAPIs\2.6.2\xmlParserAPIs-2.6.2.jar"/> + <pathelement location="${m2.repo}\org\apache\woden\woden\1.0-incubating-M7b\woden-1.0-incubating-M7b.jar"/> + <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface\2.0-Beta4\tuscany-interface-2.0-Beta4.jar"/> + <pathelement location="${m2.repo}\org\easymock\easymock\2.2\easymock-2.2.jar"/> + </path> + + <target name="runServer"> + <java classname="org.apache.tuscany.sca.itest.oneway.impl.OneWayServer" + fork="true"> + <classpath> + <path refid="repo.classpath"/> + </classpath> + </java> + </target> + +</project> diff --git a/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/pom.xml b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/pom.xml new file mode 100644 index 0000000000..f326bc8630 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/pom.xml @@ -0,0 +1,52 @@ +<?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>2.0-Beta4</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>itest-oneway</artifactId> + <name>Apache Tuscany SCA iTest OneWay</name> + <version>2.0-Beta4</version> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-base-runtime-pom</artifactId> + <type>pom</type> + <version>2.0-Beta4</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-runtime-axis2</artifactId> + <version>2.0-Beta4</version> + </dependency> + + <dependency> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty</artifactId> + <version>6.1.19</version> + </dependency> + </dependencies> +</project> diff --git a/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java new file mode 100644 index 0000000000..ecd239d5fb --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayClient.java @@ -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 org.apache.tuscany.sca.itest.oneway; + +/** + * The client for the oneway itest. + * + * @version $Rev$ $Date$ + */ +public interface OneWayClient { + + /** + * This method will invoke the doSomething() @OneWay method on the OneWayService + * the specified number of times. + * + * @param count The number of times to invoke doSomething() on the OneWayService + */ + void doSomething(int count); + + /** + * This method will invoke a @OneWay method that throws an exception. + */ + void doSomethingWhichThrowsException(); +} diff --git a/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java new file mode 100644 index 0000000000..ba74b67d31 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/OneWayService.java @@ -0,0 +1,47 @@ +/* + * 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.oneway; + + +import org.oasisopen.sca.annotation.OneWay; +import org.oasisopen.sca.annotation.Remotable; + + +/** + * The service interface used when testing @OneWay interactions. + * + * @version $Rev$ $Date$ + */ +@Remotable +public interface OneWayService { + + /** + * This OneWay method will increment the callCount by 1. + * + * @param count Not used + */ + @OneWay + void doSomething(int count); + + /** + * This one way method will throw a NullPointerException. + */ + @OneWay + void doSomethingWhichThrowsException(); +} diff --git a/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java new file mode 100644 index 0000000000..8ed3c3d638 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayClientImpl.java @@ -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.oneway.impl; + +import org.apache.tuscany.sca.itest.oneway.OneWayClient; +import org.apache.tuscany.sca.itest.oneway.OneWayService; +import org.junit.Assert; +import org.oasisopen.sca.annotation.Reference; + + +/** + * The client for the oneway itest. + * + * @version $Rev$ $Date$ + */ +public class OneWayClientImpl implements OneWayClient { + /** + * Injected reference to the OneWayService. + */ + @Reference + protected OneWayService oneWayService; + + /** + * Tracks the number of calls of the doSomething() method on the OneWayService. + */ + public static int callCount = 0; + + /** + * {@inheritDoc} + */ + public void doSomething(int count) { + callCount = callCount + count; + + for (int loopCount = 0; loopCount < count; loopCount++) { + //System.out.println("Client: doSomething " + loopCount); + //System.out.flush(); + oneWayService.doSomething(loopCount); + } + } + + /** + * {@inheritDoc} + */ + public void doSomethingWhichThrowsException() { + Assert.assertNotNull(oneWayService); + oneWayService.doSomethingWhichThrowsException(); + } +} diff --git a/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java new file mode 100644 index 0000000000..1c36073cf1 --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/java/org/apache/tuscany/sca/itest/oneway/impl/OneWayServiceImpl.java @@ -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.oneway.impl; + +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.tuscany.sca.itest.oneway.OneWayService; + +/** + * The service for the oneway itest. + * + * @version $Rev$ $Date$ + */ + + +public class OneWayServiceImpl implements OneWayService { + + /** + * This is the error message that will be in the Exception thrown by + * the doSomethingWhichThrowsException() method. + */ + public static final String EXCEPTION_MESSAGE = "Sample RuntimeException from a @OneWay method"; + + /** + * Counts the number of invocations to doSomething(). + */ + public static final AtomicInteger CALL_COUNT = new AtomicInteger(); + + /** + * Counts the number of invocations of the doSomethingWhichThrowsException() method. + */ + public static final AtomicInteger CALL_COUNT_FOR_THROWS_EXCEPTION_METHOD = new AtomicInteger(); + + /** + * {@inheritDoc} + */ + public void doSomething(int count) { + CALL_COUNT.incrementAndGet(); + + // System.out.println("Service: doSomething " + count + " callCount = " + callCount); + // System.out.flush(); + } + + /** + * {@inheritDoc} + */ + public void doSomethingWhichThrowsException() { + System.out.println("OneWay invoked. About to throw an Exception"); + CALL_COUNT_FOR_THROWS_EXCEPTION_METHOD.incrementAndGet(); + throw new NullPointerException(EXCEPTION_MESSAGE); + } +} diff --git a/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite new file mode 100644 index 0000000000..b375944bbd --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite @@ -0,0 +1,57 @@ +<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://oneway"
+ name="OneWayITest">
+
+ <component name="OneWayClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.oneway.impl.OneWayClientImpl"/>
+ <reference name="oneWayService" target="OneWayServiceComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.oneway.OneWayService" />
+ </reference>
+ </component>
+
+ <component name="OneWayServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.oneway.impl.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <interface.java interface="org.apache.tuscany.sca.itest.oneway.OneWayService" />
+ <binding.ws uri="http://localhost:8085/OneWayServiceComponent"/>
+ </service>
+ </component>
+
+
+ <!-- OneWay Client and Server Components that use the standard SCA Binding so we can validate -->
+ <!-- that the NonBlockingInterceptor logs an message when an Exception is thrown by the code -->
+ <!-- that is called. See TUSCANY-2225 -->
+ <component name="OneWayClientComponentSCABinding">
+ <implementation.java class="org.apache.tuscany.sca.itest.oneway.impl.OneWayClientImpl"/>
+ <reference name="oneWayService" target="OneWayServiceComponentSCABinding">
+ <interface.java interface="org.apache.tuscany.sca.itest.oneway.OneWayService" />
+ </reference>
+ </component>
+
+ <component name="OneWayServiceComponentSCABinding">
+ <implementation.java class="org.apache.tuscany.sca.itest.oneway.impl.OneWayServiceImpl"/>
+ <service name="OneWayService">
+ <interface.java interface="org.apache.tuscany.sca.itest.oneway.OneWayService" />
+ </service>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java new file mode 100644 index 0000000000..1f771ea4ce --- /dev/null +++ b/sca-java-2.x/tags/2.0-Beta4-RC1/testing/itest/oneway/src/test/java/org/apache/tuscany/sca/itest/oneway/OneWayTestCase.java @@ -0,0 +1,235 @@ +/* + * 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.oneway; + +import java.io.File; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor; +import org.apache.tuscany.sca.itest.oneway.impl.OneWayClientImpl; +import org.apache.tuscany.sca.itest.oneway.impl.OneWayServiceImpl; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This test case will test invoking @OneWay operations. + * + * @version $Date$ $Revision$ + */ +public class OneWayTestCase { + /** + * Maximum period of time that we are prepared to wait for all the @OneWay + * method calls to complete in milliseconds. + */ + private static final int MAX_SLEEP_TIME = 10000; + + private Node node; + + /** + * Initialise the SCADomain. + * + * @throws Exception Failed to initialise the SCADomain + */ + @Before + public void setUp() throws Exception { + + NodeFactory factory = NodeFactory.newInstance(); + node = factory.createNode(new File("src/main/resources/OneWayContribution/META-INF/sca-deployables/oneWay.composite").toURI().toURL().toString(), + new Contribution("TestContribution", new File("src/main/resources/OneWayContribution/META-INF/sca-deployables/").toURI().toURL().toString())); + node.start(); + + } + + /** + * This method will ensure that the SCADomain is shutdown. + * + * @throws Exception Failed to shutdown the SCADomain + */ + @After + public void tearDown() throws Exception { + node.stop(); + } + + /** + * This test will test repeatedly calling a @OneWay operation and ensure that the correct + * number of @OneWay operations are run. + * + * @throws Exception Test failed + */ + @Test + public void testOneWay() throws Exception { + OneWayClient client = + node.getService(OneWayClient.class, "OneWayClientComponent"); + + int count = 100; + + for (int i = 0; i < 10; i++) { + // System.out.println("Test: doSomething " + count); + // System.out.flush(); + client.doSomething(count); + + // TUSCANY-2192 - We need to sleep to allow the @OneWay method calls to complete. + // Note: This can take different periods depending on the speed and load + // on the computer where the test is being run. + // This loop will wait for the required number of @OneWay method calls to + // have taken place or MAX_SLEEP_TIME to have passed. + long startSleep = System.currentTimeMillis(); + while (OneWayClientImpl.callCount != OneWayServiceImpl.CALL_COUNT.get() + && System.currentTimeMillis() - startSleep < MAX_SLEEP_TIME) { + Thread.sleep(100); + // System.out.println("" + OneWayClientImpl.callCount + "," + OneWayServiceImpl.callCount); + } + + System.out.println("Finished callCount = " + OneWayServiceImpl.CALL_COUNT); + + Assert.assertEquals(OneWayClientImpl.callCount, OneWayServiceImpl.CALL_COUNT.get()); + } + } + + /** + * This method will invoke a @OneWay method that throws an exception + * when invoked over a SCA Binding which uses the NonBlockingInterceptor and + * ensure that the Exception is logged. + * See TUSCANY-2225 + */ + @Test + public void testOneWayUsingNonBlockingInterceptorThrowsAnException() { + OneWayClient client = + node.getService(OneWayClient.class, "OneWayClientComponentSCABinding"); + + // We need to modify the JDK Logger for the NonBlockingInterceptor so we + // can check that it logs a message for the @OneWay invocation that throws + // an Exception + Logger nbiLogger = Logger.getLogger(NonBlockingInterceptor.class.getName()); + DummyJDKHandler handler = new DummyJDKHandler(); + nbiLogger.addHandler(handler); + + // Add a message on the console to explain the stack dump that is going to be + // displayed and state that this is not a problem but expected behaviour + System.out.println(); + System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); + System.out.println("IMPORTANT: The error message that appears on the console"); + System.out.println("below is an expected error if it is a NullPointerException"); + System.out.println(" with the message of:"); + System.out.println(" \"" + OneWayServiceImpl.EXCEPTION_MESSAGE + "\""); + System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); + System.out.println(); + System.out.flush(); + + // Invoke the @OneWay method that throws an exception + client.doSomethingWhichThrowsException(); + + // The logging is done asynchronously so we will need to wait a bit before + // the log message appears. + long start = System.currentTimeMillis(); + boolean logged = false; + while (System.currentTimeMillis() - start < MAX_SLEEP_TIME && !logged) { + // Has the log message been logged? + if (handler.exceptionLogged.get()) { + logged = true; + } else { + try { + Thread.sleep(25); + } catch (InterruptedException ex) { + Assert.fail("Unexpected exception " + ex); + } + } + } + + // Add a message explaining that errors beyond this point should be reported + System.out.println(); + System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); + System.out.println("End of expected exceptions. Any errors beyond this point are errors!"); + System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); + System.out.println(); + System.out.flush(); + + // Remove the handler + nbiLogger.removeHandler(handler); + + // Make sure that the exception was logged + Assert.assertTrue(handler.exceptionLogged.get()); + } + + /** + * A handler that is added to the JDK Logging system to examine the log messages + * generated to ensure that a @OneWay method that throws an Exception will + * generate a log message. + */ + private class DummyJDKHandler extends Handler { + + /** + * Used to track whether the exception has been logged. + */ + private AtomicBoolean exceptionLogged = new AtomicBoolean(false); + + /** + * Constructor. + */ + private DummyJDKHandler() { + super.setLevel(Level.ALL); + } + + /** + * {@inheritDoc} + */ + @Override + public void close() throws SecurityException { + // Nothing to do + } + + /** + * {@inheritDoc} + */ + @Override + public void flush() { + // Nothing to do + } + + /** + * Examines the LogRecord and checks whether it matches the one we are looking for. + * If it matches, it will set exceptionLogged to True. + * + * @param record The Log Record that is being published + */ + @Override + public void publish(LogRecord record) { + // The log message we are looking for is Severe + if (record.getLevel() == Level.SEVERE) { + if (record.getThrown() != null + && record.getThrown().toString().indexOf( + OneWayServiceImpl.EXCEPTION_MESSAGE) != -1) { + // We have found our Exception. + exceptionLogged.set(true); + } + } + } + } +} |