From bdb9944ab586ffe4d1d5a996521d35ed77855e7f Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 14 Sep 2009 11:59:56 +0000 Subject: Copy all the JMS itests from 1.x to 2.x, none change for 2.x yet git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@814596 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/itest/jms/args/pom.xml | 99 +++ .../apache/tuscany/sca/binding/jms/ClientImpl.java | 41 + .../apache/tuscany/sca/binding/jms/MyService.java | 29 + .../tuscany/sca/binding/jms/ServiceImpl.java | 38 + .../jms/args/src/main/resources/jndi.properties | 38 + .../main/resources/selectors/selectors.composite | 39 + .../tuscany/sca/binding/jms/ArgsTestCase.java | 61 ++ java/sca/itest/jms/callbacks/pom.xml | 100 +++ .../apache/tuscany/sca/binding/jms/JMSClient.java | 28 + .../tuscany/sca/binding/jms/JMSClientImpl.java | 50 ++ .../apache/tuscany/sca/binding/jms/JMSService.java | 34 + .../sca/binding/jms/JMSServiceCallback.java | 32 + .../tuscany/sca/binding/jms/JMSServiceImpl.java | 47 ++ .../callbacks/src/main/resources/jndi.properties | 39 + .../src/main/resources/simple/client.composite | 44 + .../src/main/resources/simple/tempq.composite | 50 ++ .../tuscany/sca/binding/jms/CallbackTestCase.java | 60 ++ .../sca/binding/jms/TempCallbackQTestCase.java | 63 ++ java/sca/itest/jms/definitions/pom.xml | 99 +++ .../tuscany/sca/binding/jms/OneWayClientImpl.java | 41 + .../tuscany/sca/binding/jms/OneWayService.java | 29 + .../tuscany/sca/binding/jms/OneWayServiceImpl.java | 34 + .../definitions/src/main/resources/definitions.xml | 28 + .../resources/definitions/definitions.composite | 39 + .../definitions/src/main/resources/jndi.properties | 38 + .../sca/binding/jms/DefinitionsTestCase.java | 61 ++ java/sca/itest/jms/exceptions/pom.xml | 115 +++ .../tuscany/sca/binding/jms/CheckedExcpetion.java | 28 + .../sca/binding/jms/CheckedExcpetion2Args.java | 28 + .../sca/binding/jms/CheckedExcpetionChained.java | 28 + .../sca/binding/jms/CheckedExcpetionNoArgs.java | 28 + .../tuscany/sca/binding/jms/ExceptionService.java | 33 + .../sca/binding/jms/ExceptionServiceImpl.java | 44 + .../main/resources/exceptions/service.composite | 43 + .../exceptions/src/main/resources/jndi.properties | 40 + .../sca/binding/jms/ExceptionsTestCase.java | 211 +++++ java/sca/itest/jms/format/pom.xml | 102 +++ .../jmsbytes/helloworld/CheckedException.java | 28 + .../jmsbytes/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 50 ++ .../jmsbytes/helloworld/HelloWorldService.java | 35 + .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 40 + .../helloworld/HelloWorldServiceReference.java | 35 + .../jmsbytesxml/helloworld/CheckedException.java | 28 + .../helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 46 ++ .../jmsbytesxml/helloworld/HelloWorldService.java | 34 + .../helloworld/HelloWorldServiceImpl.java | 39 + .../jmsdefault/helloworld/CheckedException.java | 28 + .../jmsdefault/helloworld/HelloWorldReference.java | 36 + .../helloworld/HelloWorldReferenceImpl.java | 85 ++ .../jmsdefault/helloworld/HelloWorldService.java | 39 + .../helloworld/HelloWorldServiceImpl.java | 52 ++ .../jms/format/jmsdefault/helloworld/Person.java | 42 + .../jmsmessage/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 41 + .../jmsmessage/helloworld/HelloWorldService.java | 34 + .../helloworld/HelloWorldServiceImpl.java | 51 ++ .../helloworld/HelloWorldServiceReferenceSide.java | 37 + .../jms/format/jmsmessage/helloworld/README | 3 + .../jmsobject/helloworld/CheckedException.java | 28 + .../jmsobject/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 112 +++ .../jmsobject/helloworld/HelloWorldService.java | 41 + .../helloworld/HelloWorldServiceImpl.java | 63 ++ .../jms/format/jmsobject/helloworld/Person.java | 47 ++ .../jmstext/helloworld/CheckedException.java | 28 + .../jmstext/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 46 ++ .../jmstext/helloworld/HelloWorldService.java | 35 + .../jmstext/helloworld/HelloWorldServiceImpl.java | 38 + .../helloworld/HelloWorldServiceReference.java | 35 + .../jmstextxml/helloworld/CheckedException.java | 28 + .../jmstextxml/helloworld/HelloWorldReference.java | 33 + .../helloworld/HelloWorldReferenceImpl.java | 62 ++ .../jmstextxml/helloworld/HelloWorldService.java | 36 + .../helloworld/HelloWorldServiceImpl.java | 45 + .../jms/format/jmstextxml/helloworld/Person.java | 42 + .../helloworld/HelloWorldReferenceImpl.java | 38 + .../helloworld/HelloWorldService.java | 33 + .../helloworld/HelloWorldServiceImpl.java | 35 + .../helloworld/Person.java | 42 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../main/resources/jmsbytes/helloworld.composite | 45 + .../resources/jmsbytesxml/helloworld.composite | 45 + .../main/resources/jmsdefault/helloworld.composite | 94 +++ .../src/main/resources/jmsdefault/helloworld.wsdl | 139 ++++ .../main/resources/jmsmessage/helloworld.composite | 46 ++ .../src/main/resources/jmsmessage/helloworld.wsdl | 129 +++ .../main/resources/jmsobject/helloworld.composite | 62 ++ .../src/main/resources/jmsobject/helloworld.wsdl | 355 ++++++++ .../main/resources/jmstext/helloworld.composite | 45 + .../main/resources/jmstextxml/helloworld.composite | 80 ++ .../src/main/resources/jmstextxml/helloworld.wsdl | 139 ++++ .../jmstextxmlinjmsobjectout/helloworld.composite | 52 ++ .../jmstextxmlinjmsobjectout/helloworld.wsdl | 139 ++++ .../jms/format/src/main/resources/jndi.properties | 39 + .../binding/jms/format/FormatJMSBytesTestCase.java | 75 ++ .../jms/format/FormatJMSBytesXMLTestCase.java | 64 ++ .../jms/format/FormatJMSDefaultTestCase.java | 74 ++ .../jms/format/FormatJMSMessageTestCase.java | 64 ++ .../jms/format/FormatJMSObjectTestCase.java | 80 ++ .../binding/jms/format/FormatJMSTextTestCase.java | 66 ++ .../FormatJMSTextXMLInJMSObjectOutTestCase.java | 69 ++ .../jms/format/FormatJMSTextXMLTestCase.java | 68 ++ java/sca/itest/jms/general/pom.xml | 109 +++ .../tuscany/sca/binding/jms/CheckedExcpetion.java | 28 + .../sca/binding/jms/CheckedExcpetion2Args.java | 28 + .../sca/binding/jms/CheckedExcpetionChained.java | 28 + .../sca/binding/jms/CheckedExcpetionNoArgs.java | 28 + .../tuscany/sca/binding/jms/ExceptionService.java | 33 + .../sca/binding/jms/ExceptionServiceClient.java | 57 ++ .../sca/binding/jms/ExceptionServiceImpl.java | 44 + .../sca/binding/jms/HelloWorldClientImpl.java | 41 + .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../apache/tuscany/sca/binding/jms/JMSClient.java | 28 + .../apache/tuscany/sca/binding/jms/MsgClient.java | 29 + .../tuscany/sca/binding/jms/MsgClientImpl.java | 38 + .../tuscany/sca/binding/jms/MsgClientService.java | 33 + .../apache/tuscany/sca/binding/jms/MsgService.java | 32 + .../tuscany/sca/binding/jms/MsgServiceImpl.java | 39 + .../tuscany/sca/binding/jms/OneWayClientImpl.java | 41 + .../sca/binding/jms/OneWayObjectService.java | 29 + .../sca/binding/jms/OneWayObjectServiceImpl.java | 34 + .../tuscany/sca/binding/jms/OneWayService.java | 29 + .../tuscany/sca/binding/jms/OneWayServiceImpl.java | 34 + .../sca/binding/jms/TestMessageProcessor.java | 57 ++ .../src/main/resources/defaults/client.composite | 33 + .../src/main/resources/defaults/service.composite | 30 + .../src/main/resources/dynamic/client.composite | 36 + .../src/main/resources/exceptions/client.composite | 33 + .../main/resources/exceptions/service.composite | 30 + .../src/main/resources/external/client.composite | 38 + .../src/main/resources/external/service.composite | 35 + .../jms/general/src/main/resources/jndi.properties | 39 + .../main/resources/nonSCAclient/service.composite | 50 ++ .../main/resources/oneway/OneWayClient.composite | 35 + .../main/resources/oneway/OneWayService.composite | 32 + .../main/resources/policyHeaders/definitions.xml | 54 ++ .../policyHeaders/policyHeaders.composite | 46 ++ .../main/resources/properties/properties.composite | 55 ++ .../src/main/resources/simple/client.composite | 39 + .../src/main/resources/simple/mpclient.composite | 38 + .../src/main/resources/simple/mpservice.composite | 36 + .../src/main/resources/simple/service.composite | 36 + .../src/main/resources/simple/uriclient.composite | 33 + .../tuscany/sca/binding/jms/DefaultsTestCase.java | 54 ++ .../sca/binding/jms/DynamicReplyQTestCase.java | 53 ++ .../sca/binding/jms/ExceptionsTestCase.java | 109 +++ .../sca/binding/jms/ExternalBrokerTestCase.java | 70 ++ .../sca/binding/jms/MessageProcessorTestCase.java | 57 ++ .../sca/binding/jms/NonSCAClientTestCase.java | 142 ++++ .../tuscany/sca/binding/jms/OneWayTestCase.java | 58 ++ .../sca/binding/jms/PolicyHeadersTestCase.java | 95 +++ .../sca/binding/jms/PropertiesTestCase.java | 93 +++ .../tuscany/sca/binding/jms/RPCTestCase.java | 54 ++ .../tuscany/sca/binding/jms/URIRPCTestCase.java | 54 ++ java/sca/itest/jms/noreplyto/pom.xml | 102 +++ .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../noreplyto/src/main/resources/jndi.properties | 39 + .../noreplyto/src/main/resources/service.composite | 37 + .../tuscany/sca/binding/jms/NoReplyToTestCase.java | 100 +++ java/sca/itest/jms/nulls/pom.xml | 99 +++ .../apache/tuscany/sca/binding/jms/ClientImpl.java | 41 + .../apache/tuscany/sca/binding/jms/MyService.java | 28 + .../tuscany/sca/binding/jms/ServiceImpl.java | 28 + .../jms/nulls/src/main/resources/jndi.properties | 38 + .../jms/nulls/src/main/resources/nulls.composite | 58 ++ .../tuscany/sca/binding/jms/NullsTestCase.java | 59 ++ java/sca/itest/jms/oneway-nocf/pom.xml | 109 +++ .../tuscany/sca/binding/jms/OneWayClientImpl.java | 41 + .../tuscany/sca/binding/jms/OneWayService.java | 29 + .../tuscany/sca/binding/jms/OneWayServiceImpl.java | 34 + .../oneway-nocf/src/main/resources/jndi.properties | 38 + .../main/resources/oneway/OneWayClient.composite | 36 + .../main/resources/oneway/OneWayService.composite | 33 + .../tuscany/sca/binding/jms/OneWayTestCase.java | 58 ++ java/sca/itest/jms/responsecf/pom.xml | 109 +++ .../sca/binding/jms/HelloWorldClientImpl.java | 41 + .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../src/main/resources/cf/client.composite | 38 + .../src/main/resources/cf/service.composite | 35 + .../responsecf/src/main/resources/jndi.properties | 39 + .../sca/binding/jms/ResponseCFTestCase.java | 53 ++ java/sca/itest/jms/selectors/pom.xml | 99 +++ .../apache/tuscany/sca/binding/jms/ClientImpl.java | 41 + .../tuscany/sca/binding/jms/SelectorService.java | 29 + .../sca/binding/jms/SelectorServiceImpl1.java | 40 + .../sca/binding/jms/SelectorServiceImpl2.java | 38 + .../sca/binding/jms/SelectorServiceImpl3.java | 38 + .../jmsdefault/HelloWorldReference.java | 32 + .../jmsdefault/HelloWorldReferenceImpl.java | 39 + .../jmsdefault/HelloWorldService.java | 38 + .../jmsdefault/HelloWorldServiceImpl.java | 47 ++ .../jmsuserprop/HelloWorldReference.java | 32 + .../jmsuserprop/HelloWorldReferenceImpl.java | 36 + .../jmsuserprop/HelloWorldService.java | 38 + .../jmsuserprop/HelloWorldServiceImpl.java | 47 ++ .../main/resources/jmsdefault/helloworld.composite | 66 ++ .../resources/jmsuserprop/helloworld.composite | 62 ++ .../selectors/src/main/resources/jndi.properties | 38 + .../main/resources/selectors/selectors.composite | 68 ++ .../jms/OperationselectorJMSDefaultTestCase.java | 63 ++ .../jms/OperationselectorJMSUserPropTestCase.java | 63 ++ .../tuscany/sca/binding/jms/SelectorsTestCase.java | 75 ++ java/sca/itest/jms/topics/pom.xml | 99 +++ .../tuscany/sca/binding/jms/OneWayClientImpl.java | 41 + .../tuscany/sca/binding/jms/OneWayService.java | 29 + .../tuscany/sca/binding/jms/OneWayServiceImpl.java | 34 + .../jms/topics/src/main/resources/jndi.properties | 38 + .../main/resources/topics/TopicsClient.composite | 35 + .../main/resources/topics/TopicsService.composite | 32 + .../tuscany/sca/binding/jms/TopicsTestCase.java | 58 ++ java/sca/itest/jms/ttl/pom.xml | 99 +++ .../main/java/itest/MockInitialContextFactory.java | 904 +++++++++++++++++++++ .../tuscany/sca/binding/jms/ClientIface.java | 30 + .../apache/tuscany/sca/binding/jms/ClientImpl.java | 39 + .../jms/ttl/src/main/resources/jndi.properties | 38 + .../itest/jms/ttl/src/main/resources/ttl.composite | 36 + .../tuscany/sca/binding/jms/TTLTestCase.java | 63 ++ 223 files changed, 12243 insertions(+) create mode 100644 java/sca/itest/jms/args/pom.xml create mode 100644 java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java create mode 100644 java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java create mode 100644 java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java create mode 100644 java/sca/itest/jms/args/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/args/src/main/resources/selectors/selectors.composite create mode 100644 java/sca/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java create mode 100644 java/sca/itest/jms/callbacks/pom.xml create mode 100644 java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java create mode 100644 java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java create mode 100644 java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java create mode 100644 java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java create mode 100644 java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java create mode 100644 java/sca/itest/jms/callbacks/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/callbacks/src/main/resources/simple/client.composite create mode 100644 java/sca/itest/jms/callbacks/src/main/resources/simple/tempq.composite create mode 100644 java/sca/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java create mode 100644 java/sca/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java create mode 100644 java/sca/itest/jms/definitions/pom.xml create mode 100644 java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java create mode 100644 java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java create mode 100644 java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java create mode 100644 java/sca/itest/jms/definitions/src/main/resources/definitions.xml create mode 100644 java/sca/itest/jms/definitions/src/main/resources/definitions/definitions.composite create mode 100644 java/sca/itest/jms/definitions/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java create mode 100644 java/sca/itest/jms/exceptions/pom.xml create mode 100644 java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java create mode 100644 java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java create mode 100644 java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java create mode 100644 java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java create mode 100644 java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java create mode 100644 java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java create mode 100644 java/sca/itest/jms/exceptions/src/main/resources/exceptions/service.composite create mode 100644 java/sca/itest/jms/exceptions/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java create mode 100644 java/sca/itest/jms/format/pom.xml create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java create mode 100644 java/sca/itest/jms/format/src/main/resources/META-INF/sca-contribution.xml create mode 100644 java/sca/itest/jms/format/src/main/resources/jmsbytes/helloworld.composite create mode 100644 java/sca/itest/jms/format/src/main/resources/jmsbytesxml/helloworld.composite create mode 100644 java/sca/itest/jms/format/src/main/resources/jmsdefault/helloworld.composite create mode 100644 java/sca/itest/jms/format/src/main/resources/jmsdefault/helloworld.wsdl create mode 100644 java/sca/itest/jms/format/src/main/resources/jmsmessage/helloworld.composite create mode 100644 java/sca/itest/jms/format/src/main/resources/jmsmessage/helloworld.wsdl create mode 100644 java/sca/itest/jms/format/src/main/resources/jmsobject/helloworld.composite create mode 100644 java/sca/itest/jms/format/src/main/resources/jmsobject/helloworld.wsdl create mode 100644 java/sca/itest/jms/format/src/main/resources/jmstext/helloworld.composite create mode 100644 java/sca/itest/jms/format/src/main/resources/jmstextxml/helloworld.composite create mode 100644 java/sca/itest/jms/format/src/main/resources/jmstextxml/helloworld.wsdl create mode 100644 java/sca/itest/jms/format/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite create mode 100644 java/sca/itest/jms/format/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl create mode 100644 java/sca/itest/jms/format/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java create mode 100644 java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java create mode 100644 java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java create mode 100644 java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java create mode 100644 java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java create mode 100644 java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java create mode 100644 java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java create mode 100644 java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java create mode 100644 java/sca/itest/jms/general/pom.xml create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java create mode 100644 java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java create mode 100644 java/sca/itest/jms/general/src/main/resources/defaults/client.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/defaults/service.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/dynamic/client.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/exceptions/client.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/exceptions/service.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/external/client.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/external/service.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/general/src/main/resources/nonSCAclient/service.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/oneway/OneWayClient.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/oneway/OneWayService.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/policyHeaders/definitions.xml create mode 100644 java/sca/itest/jms/general/src/main/resources/policyHeaders/policyHeaders.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/properties/properties.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/simple/client.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/simple/mpclient.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/simple/mpservice.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/simple/service.composite create mode 100644 java/sca/itest/jms/general/src/main/resources/simple/uriclient.composite create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/MessageProcessorTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java create mode 100644 java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java create mode 100644 java/sca/itest/jms/noreplyto/pom.xml create mode 100644 java/sca/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 java/sca/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/noreplyto/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/noreplyto/src/main/resources/service.composite create mode 100644 java/sca/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java create mode 100644 java/sca/itest/jms/nulls/pom.xml create mode 100644 java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java create mode 100644 java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java create mode 100644 java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java create mode 100644 java/sca/itest/jms/nulls/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/nulls/src/main/resources/nulls.composite create mode 100644 java/sca/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java create mode 100644 java/sca/itest/jms/oneway-nocf/pom.xml create mode 100644 java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java create mode 100644 java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java create mode 100644 java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java create mode 100644 java/sca/itest/jms/oneway-nocf/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite create mode 100644 java/sca/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite create mode 100644 java/sca/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java create mode 100644 java/sca/itest/jms/responsecf/pom.xml create mode 100644 java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java create mode 100644 java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/responsecf/src/main/resources/cf/client.composite create mode 100644 java/sca/itest/jms/responsecf/src/main/resources/cf/service.composite create mode 100644 java/sca/itest/jms/responsecf/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java create mode 100644 java/sca/itest/jms/selectors/pom.xml create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java create mode 100644 java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java create mode 100644 java/sca/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite create mode 100644 java/sca/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite create mode 100644 java/sca/itest/jms/selectors/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/selectors/src/main/resources/selectors/selectors.composite create mode 100644 java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java create mode 100644 java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java create mode 100644 java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java create mode 100644 java/sca/itest/jms/topics/pom.xml create mode 100644 java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java create mode 100644 java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java create mode 100644 java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java create mode 100644 java/sca/itest/jms/topics/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/topics/src/main/resources/topics/TopicsClient.composite create mode 100644 java/sca/itest/jms/topics/src/main/resources/topics/TopicsService.composite create mode 100644 java/sca/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java create mode 100644 java/sca/itest/jms/ttl/pom.xml create mode 100644 java/sca/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java create mode 100644 java/sca/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java create mode 100644 java/sca/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java create mode 100644 java/sca/itest/jms/ttl/src/main/resources/jndi.properties create mode 100644 java/sca/itest/jms/ttl/src/main/resources/ttl.composite create mode 100644 java/sca/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java diff --git a/java/sca/itest/jms/args/pom.xml b/java/sca/itest/jms/args/pom.xml new file mode 100644 index 0000000000..ed3bafe32f --- /dev/null +++ b/java/sca/itest/jms/args/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-args + Apache Tuscany SCA iTest JMS Args + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6-SNAPSHOT + test + + + + + org.apache.activemq + activemq-core + 5.1.0 + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java new file mode 100644 index 0000000000..51ce5f4f24 --- /dev/null +++ b/java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the OneWay service. + */ +@Service(MyService.class) +public class ClientImpl implements MyService { + + private MyService serviceA; + + @Reference + public void setServiceA(MyService service) { + this.serviceA = service; + } + + public void sayHello(String name, String n2) { + serviceA.sayHello(name, n2); + } + +} diff --git a/java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java b/java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java new file mode 100644 index 0000000000..487e5f2cbb --- /dev/null +++ b/java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java @@ -0,0 +1,29 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyService { + + @OneWay + void sayHello(String name, String n2); +} diff --git a/java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java b/java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java new file mode 100644 index 0000000000..18324d5d1d --- /dev/null +++ b/java/sca/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java @@ -0,0 +1,38 @@ +/* + * 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.binding.jms; + + +public class ServiceImpl implements MyService { + + public static Object lock = new Object(); + public static String name; + public static String n2; + + public void sayHello(String name, String n2) { + System.out.println("SelectorServiceImpl1 " + name + n2); + ServiceImpl.name = name; + ServiceImpl.n2 = n2; + synchronized (ServiceImpl.lock) { + ServiceImpl.lock.notify(); + } + } + +} diff --git a/java/sca/itest/jms/args/src/main/resources/jndi.properties b/java/sca/itest/jms/args/src/main/resources/jndi.properties new file mode 100644 index 0000000000..bb431a592b --- /dev/null +++ b/java/sca/itest/jms/args/src/main/resources/jndi.properties @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory, ConnectionFactory2 + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic +topic.ServiceTopic = ServiceTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/args/src/main/resources/selectors/selectors.composite b/java/sca/itest/jms/args/src/main/resources/selectors/selectors.composite new file mode 100644 index 0000000000..74c352934f --- /dev/null +++ b/java/sca/itest/jms/args/src/main/resources/selectors/selectors.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java b/java/sca/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java new file mode 100644 index 0000000000..228366d596 --- /dev/null +++ b/java/sca/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java @@ -0,0 +1,61 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + */ +public class ArgsTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "selectors/selectors.composite"); + } + + @Test + public void testSayHello() throws Exception { + MyService client1 = scaDomain.getService(MyService.class, "Client1"); + + client1.sayHello("petra", "beate"); + + synchronized(ServiceImpl.lock) { + if (ServiceImpl.name == null) { + ServiceImpl.lock.wait(5000); + } + } + + assertEquals("petra", ServiceImpl.name); + assertEquals("beate", ServiceImpl.n2); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/callbacks/pom.xml b/java/sca/itest/jms/callbacks/pom.xml new file mode 100644 index 0000000000..bf5e35e747 --- /dev/null +++ b/java/sca/itest/jms/callbacks/pom.xml @@ -0,0 +1,100 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-callbacks + Apache Tuscany SCA iTest JMS Tests For Callbacks + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6-SNAPSHOT + test + + + + + org.apache.activemq + activemq-core + 5.1.0 + test + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java new file mode 100644 index 0000000000..d4cd5df431 --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java @@ -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 org.apache.tuscany.sca.binding.jms; + + +/** + * The client interface + */ +public interface JMSClient { + + void aClientMethod(); +} diff --git a/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java new file mode 100644 index 0000000000..9d75685a8a --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java @@ -0,0 +1,50 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * Remote Web service client with callback interface + */ +@Service(JMSClient.class) +public class JMSClientImpl implements JMSClient, JMSServiceCallback { + + @Reference protected JMSService myService; + + public static String result; + public static Object lock = new Object(); + + public void aClientMethod() { + System.out.println("aClientMethod " + this + " on thread " + Thread.currentThread()); + myService.someMethod(" -> someMethod "); // calls the server + System.out.println("aClientMethod return from someMethod on thread " + Thread.currentThread()); + } + + public void receiveResult(String result) { + System.out.println("receiveResult " + this + " '" + result + "' on thread " + Thread.currentThread()); + JMSClientImpl.result = result; + + // wakeup the waiting testcase + synchronized (lock) { + lock.notifyAll(); + } + } +} diff --git a/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java new file mode 100644 index 0000000000..9c2c657b55 --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java @@ -0,0 +1,34 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * The remote service that will be invoked by the client + */ +@Remotable +@Callback(JMSServiceCallback.class) +public interface JMSService { + + @OneWay + void someMethod(String arg); +} diff --git a/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java new file mode 100644 index 0000000000..5697d819c7 --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java @@ -0,0 +1,32 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * The callback interface for {@link JMSService}. + */ +@Remotable +public interface JMSServiceCallback { + + @OneWay + void receiveResult(String result); +} diff --git a/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java new file mode 100644 index 0000000000..b15b40c8a6 --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.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.binding.jms; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Service; + +/** + * This class implements MyService and uses a callback. + */ +@Service(JMSService.class) +public class JMSServiceImpl implements JMSService { + + private JMSServiceCallback myServiceCallback; + + @Callback + public void setMyServiceCallback(JMSServiceCallback myServiceCallback) { + System.out.println("setMyServiceCallback on thread " + Thread.currentThread() + " cb: " + myServiceCallback); + this.myServiceCallback = myServiceCallback; + } + + public void someMethod(String arg) { + System.out.println("someMethod '" + arg + "' on thread " + Thread.currentThread()); + try { + myServiceCallback.receiveResult(arg + " -> receiveResult "); + } catch(Exception e) { + System.out.println("RuntimeException invoking receiveResult: " + e.toString()); + e.printStackTrace(); + } + } +} diff --git a/java/sca/itest/jms/callbacks/src/main/resources/jndi.properties b/java/sca/itest/jms/callbacks/src/main/resources/jndi.properties new file mode 100644 index 0000000000..608fe747f5 --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/main/resources/jndi.properties @@ -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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.ServiceQueue = ServiceQueue +queue.CallbackQueue = CallbackQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/callbacks/src/main/resources/simple/client.composite b/java/sca/itest/jms/callbacks/src/main/resources/simple/client.composite new file mode 100644 index 0000000000..93d8acb65b --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/main/resources/simple/client.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/callbacks/src/main/resources/simple/tempq.composite b/java/sca/itest/jms/callbacks/src/main/resources/simple/tempq.composite new file mode 100644 index 0000000000..636e951d03 --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/main/resources/simple/tempq.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java b/java/sca/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java new file mode 100644 index 0000000000..cb9acb1bc1 --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java @@ -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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class CallbackTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "simple/client.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + JMSClient client = scaDomain.getService(JMSClient.class, "ClientComponent"); + + client.aClientMethod(); + + // wait for up to 5 seconds but should wake up as soon as done + synchronized(JMSClientImpl.lock) { + JMSClientImpl.lock.wait(5000); + } + + assertEquals(" -> someMethod -> receiveResult ", JMSClientImpl.result); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java b/java/sca/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java new file mode 100644 index 0000000000..9f450574df --- /dev/null +++ b/java/sca/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java @@ -0,0 +1,63 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import java.net.MalformedURLException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class TempCallbackQTestCase { + + private SCADomain scaDomain; + + @Before + public void init() throws MalformedURLException { + scaDomain = SCADomain.newInstance("http://localhost", "/", "simple/tempq.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + JMSClient client = scaDomain.getService(JMSClient.class, "ClientComponent"); + + client.aClientMethod(); + + // wait for up to 5 seconds but should wake up as soon as done + synchronized (JMSClientImpl.lock) { + JMSClientImpl.lock.wait(5000); + } + + assertEquals(" -> someMethod -> receiveResult ", JMSClientImpl.result); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } + +} diff --git a/java/sca/itest/jms/definitions/pom.xml b/java/sca/itest/jms/definitions/pom.xml new file mode 100644 index 0000000000..6077aa000f --- /dev/null +++ b/java/sca/itest/jms/definitions/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-definitions + Apache Tuscany SCA iTest JMS Tests For Properties + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6-SNAPSHOT + test + + + + + org.apache.activemq + activemq-core + 5.1.0 + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java new file mode 100644 index 0000000000..4d00d2df0d --- /dev/null +++ b/java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the OneWay service. + */ +@Service(OneWayService.class) +public class OneWayClientImpl implements OneWayService { + + private OneWayService serviceA; + + @Reference + public void setServiceA(OneWayService service) { + this.serviceA = service; + } + + public void sayHello(String name) { + serviceA.sayHello(name); + } + +} diff --git a/java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java new file mode 100644 index 0000000000..377f227ceb --- /dev/null +++ b/java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java @@ -0,0 +1,29 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface OneWayService { + + @OneWay + void sayHello(String name); +} diff --git a/java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java new file mode 100644 index 0000000000..6b763874df --- /dev/null +++ b/java/sca/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java @@ -0,0 +1,34 @@ +/* + * 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.binding.jms; + +public class OneWayServiceImpl implements OneWayService { + + public static Object lock = new Object(); + public static String name; + + public void sayHello(String name) { + OneWayServiceImpl.name = name; + synchronized (OneWayServiceImpl.lock) { + OneWayServiceImpl.lock.notify(); + } + } + +} diff --git a/java/sca/itest/jms/definitions/src/main/resources/definitions.xml b/java/sca/itest/jms/definitions/src/main/resources/definitions.xml new file mode 100644 index 0000000000..07b9f4aaa8 --- /dev/null +++ b/java/sca/itest/jms/definitions/src/main/resources/definitions.xml @@ -0,0 +1,28 @@ + + + + + + + + + + diff --git a/java/sca/itest/jms/definitions/src/main/resources/definitions/definitions.composite b/java/sca/itest/jms/definitions/src/main/resources/definitions/definitions.composite new file mode 100644 index 0000000000..99e4e5016e --- /dev/null +++ b/java/sca/itest/jms/definitions/src/main/resources/definitions/definitions.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/definitions/src/main/resources/jndi.properties b/java/sca/itest/jms/definitions/src/main/resources/jndi.properties new file mode 100644 index 0000000000..f7555e0beb --- /dev/null +++ b/java/sca/itest/jms/definitions/src/main/resources/jndi.properties @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = MyConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.MyServiceQueue= MyServiceQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java b/java/sca/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java new file mode 100644 index 0000000000..9de3bff7c3 --- /dev/null +++ b/java/sca/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java @@ -0,0 +1,61 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + */ +public class DefinitionsTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "definitions/definitions.composite"); + } + + @Test + public void testSayHello() throws Exception { + OneWayService client = scaDomain.getService(OneWayService.class, "OneWayClient"); + + client.sayHello("petra"); + + // wait for up to 5 seconds but should wake up as soon as done + synchronized(OneWayServiceImpl.lock) { + if (OneWayServiceImpl.name == null) { + OneWayServiceImpl.lock.wait(5000); + } + } + + assertEquals("petra", OneWayServiceImpl.name); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/exceptions/pom.xml b/java/sca/itest/jms/exceptions/pom.xml new file mode 100644 index 0000000000..0caaf0d6e9 --- /dev/null +++ b/java/sca/itest/jms/exceptions/pom.xml @@ -0,0 +1,115 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-nonscaclient-exceptions + Apache Tuscany SCA iTest JMS NonSCA Client Exceptions + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-policy + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + xmlunit + xmlunit + 1.2 + test + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java new file mode 100644 index 0000000000..469882f3b3 --- /dev/null +++ b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class CheckedExcpetion extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedExcpetion(String s) { + super(s); + } +} diff --git a/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java new file mode 100644 index 0000000000..19b584950a --- /dev/null +++ b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class CheckedExcpetion2Args extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedExcpetion2Args(String s, Throwable e) { + super(s, e); + } +} diff --git a/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java new file mode 100644 index 0000000000..b12e3a562e --- /dev/null +++ b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class CheckedExcpetionChained extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedExcpetionChained(Throwable e) { + super(e); + } +} diff --git a/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java new file mode 100644 index 0000000000..b23db73c01 --- /dev/null +++ b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class CheckedExcpetionNoArgs extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedExcpetionNoArgs() { + super(); + } +} diff --git a/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java new file mode 100644 index 0000000000..cc21afaa60 --- /dev/null +++ b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface ExceptionService { + + public void throwChecked() throws CheckedExcpetion; + public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs; + public void throwChecked2Args() throws CheckedExcpetion2Args; + public void throwCheckedChained() throws CheckedExcpetionChained; + + public void throwUnChecked(); +} diff --git a/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java new file mode 100644 index 0000000000..866acf1ce1 --- /dev/null +++ b/java/sca/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java @@ -0,0 +1,44 @@ +/* + * 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.binding.jms; + +public class ExceptionServiceImpl implements ExceptionService { + + public void throwChecked() throws CheckedExcpetion { + throw new CheckedExcpetion("foo"); + } + + public void throwChecked2Args() throws CheckedExcpetion2Args { + throw new CheckedExcpetion2Args("foo", new Exception("bla")); + } + + public void throwCheckedChained() throws CheckedExcpetionChained { + throw new CheckedExcpetionChained(new Exception("bla")); + } + + public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs { + throw new CheckedExcpetionNoArgs(); + } + + public void throwUnChecked() { + throw new RuntimeException("bla"); + } + +} diff --git a/java/sca/itest/jms/exceptions/src/main/resources/exceptions/service.composite b/java/sca/itest/jms/exceptions/src/main/resources/exceptions/service.composite new file mode 100644 index 0000000000..0dcbb0687a --- /dev/null +++ b/java/sca/itest/jms/exceptions/src/main/resources/exceptions/service.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/exceptions/src/main/resources/jndi.properties b/java/sca/itest/jms/exceptions/src/main/resources/jndi.properties new file mode 100644 index 0000000000..72d5457faf --- /dev/null +++ b/java/sca/itest/jms/exceptions/src/main/resources/jndi.properties @@ -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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.TextExceptionService = TextRequestQueue +queue.ObjectExceptionService = ObjectRequestQueue +queue.ResponseQueue = ResponseQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/java/sca/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java new file mode 100644 index 0000000000..1dec4a6f92 --- /dev/null +++ b/java/sca/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java @@ -0,0 +1,211 @@ +/* + * 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.binding.jms; + +import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.Properties; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.xml.sax.SAXException; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class ExceptionsTestCase { + + private static SCADomain scaDomain; + private Session session; + private InitialContext context; + private Connection connection; + + private static final String CHECKED_XML = + "foo"; + private static final String CHECKED_NOARGS_XML = ""; + private static final String CHECKED_2ARGS_XML = + "foo"; + private static final String CHECKED_CHAINED_XML = + "java.lang.Exception: bla"; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "exceptions/service.composite"); + } + + @Test + public void testTextChecked() throws NamingException, JMSException, SAXException, IOException { + sendJMSTextRequest("throwChecked"); + Message m = receiveJMSResponse(); + assertXMLEqual(CHECKED_XML, ((TextMessage)m).getText()); + } + + @Test + public void testTextCheckedNoArgs() throws NamingException, JMSException, SAXException, IOException { + sendJMSTextRequest("throwCheckedNoArgs"); + Message m = receiveJMSResponse(); + assertXMLEqual(CHECKED_NOARGS_XML, ((TextMessage)m).getText()); + } + + @Test + public void testTextChecked2Args() throws NamingException, JMSException, SAXException, IOException { + sendJMSTextRequest("throwChecked2Args"); + Message m = receiveJMSResponse(); + assertXMLEqual(CHECKED_2ARGS_XML, ((TextMessage)m).getText()); + } + + @Test + public void testTextCheckedChained() throws NamingException, JMSException, SAXException, IOException { + sendJMSTextRequest("throwCheckedChained"); + Message m = receiveJMSResponse(); + assertXMLEqual(CHECKED_CHAINED_XML, ((TextMessage)m).getText()); + } + + @Test + public void testTextUnChecked() throws NamingException, JMSException, SAXException, IOException { + sendJMSTextRequest("throwUnChecked"); + Message m = receiveJMSResponse(); + + // FIXME: what should the response message be for unchecked exceptions with wireFormat.textXML??? + Object o = ((ObjectMessage)m).getObject(); + assertTrue(o instanceof RuntimeException); + assertTrue("java.lang.RuntimeException".equals(o.getClass().getName())); + assertEquals("java.lang.RuntimeException: bla", ((RuntimeException)o).getMessage()); + } + + @Test + public void testObjectChecked() throws NamingException, JMSException { + sendJMSObjectRequest("throwChecked"); + Message m = receiveJMSResponse(); + Object o = ((ObjectMessage)m).getObject(); + assertTrue(o instanceof CheckedExcpetion); + assertEquals("foo", ((CheckedExcpetion)o).getMessage()); + } + + @Test + public void testObjectCheckedNoArgs() throws NamingException, JMSException { + sendJMSObjectRequest("throwCheckedNoArgs"); + Message m = receiveJMSResponse(); + Object o = ((ObjectMessage)m).getObject(); + assertTrue(o instanceof CheckedExcpetionNoArgs); + } + + @Test + public void testObjectChecked2Args() throws NamingException, JMSException { + sendJMSObjectRequest("throwChecked2Args"); + Message m = receiveJMSResponse(); + Object o = ((ObjectMessage)m).getObject(); + assertTrue(o instanceof CheckedExcpetion2Args); + assertEquals("foo", ((CheckedExcpetion2Args)o).getMessage()); + assertEquals("bla", ((CheckedExcpetion2Args)o).getCause().getMessage()); + } + + @Test + public void testObjectCheckedChained() throws NamingException, JMSException { + sendJMSObjectRequest("throwCheckedChained"); + Message m = receiveJMSResponse(); + Object o = ((ObjectMessage)m).getObject(); + assertTrue(o instanceof CheckedExcpetionChained); + assertEquals("bla", ((CheckedExcpetionChained)o).getCause().getMessage()); + } + + @Test + public void testObjectUnChecked() throws NamingException, JMSException { + sendJMSObjectRequest("throwUnChecked"); + Message m = receiveJMSResponse(); + Object o = ((ObjectMessage)m).getObject(); + assertTrue(o instanceof RuntimeException); + assertTrue("java.lang.RuntimeException".equals(o.getClass().getName())); + assertEquals("java.lang.RuntimeException: bla", ((RuntimeException)o).getMessage()); + } + + @After + public void end() throws JMSException { + if (scaDomain != null) { + scaDomain.close(); + } + if (connection != null) { + connection.close(); + } + } + + private void sendJMSTextRequest(String operationName) throws NamingException, JMSException { + context = new InitialContext(new Properties()); + ConnectionFactory cf = (ConnectionFactory)context.lookup("ConnectionFactory"); + connection = cf.createConnection(); + connection.start(); + + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Destination toDest = (Destination)context.lookup("TextExceptionService"); + + TextMessage m = session.createTextMessage(); + m.setStringProperty("scaOperationName", operationName); + m.setJMSReplyTo((Destination)context.lookup("ResponseQueue")); + m.setText("<_ns_:" + operationName + " xmlns:_ns_=\"http://jms.binding.sca.tuscany.apache.org/\" />"); + + MessageProducer producer = session.createProducer(toDest); + producer.send(m); + } + + private void sendJMSObjectRequest(String operationName) throws NamingException, JMSException { + context = new InitialContext(new Properties()); + ConnectionFactory cf = (ConnectionFactory)context.lookup("ConnectionFactory"); + connection = cf.createConnection(); + connection.start(); + + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Destination toDest = (Destination)context.lookup("ObjectExceptionService"); + + ObjectMessage m = session.createObjectMessage(); + m.setStringProperty("scaOperationName", operationName); + m.setJMSReplyTo((Destination)context.lookup("ResponseQueue")); + m.setObject(new Object[0]); + + MessageProducer producer = session.createProducer(toDest); + producer.send(m); + } + + private Message receiveJMSResponse() throws NamingException, JMSException { + Destination replyDest = (Destination)context.lookup("ResponseQueue"); + MessageConsumer consumer = session.createConsumer(replyDest); + Message m = consumer.receive(5000); + if (m == null) { + throw new RuntimeException("No reply message received"); + } + return m; + } +} diff --git a/java/sca/itest/jms/format/pom.xml b/java/sca/itest/jms/format/pom.xml new file mode 100644 index 0000000000..f625960eb8 --- /dev/null +++ b/java/sca/itest/jms/format/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-format + Apache Tuscany SCA iTest JMS Message Format + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java new file mode 100644 index 0000000000..e8a7102afd --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld; + +public class CheckedException extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedException(String s) { + super(s); + } +} diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java new file mode 100644 index 0000000000..b1f62c1422 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java @@ -0,0 +1,32 @@ +/* + * 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.binding.jms.format.jmsbytes.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetings(String message); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..efed4842ea --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java @@ -0,0 +1,50 @@ +/* + * 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.binding.jms.format.jmsbytes.helloworld; + +import org.osoa.sca.annotations.Reference; + + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldServiceReference helloWorldService1; + + public String getGreetings(String name){ + byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes()); + String stringValue = new String(bytesValue); + + try { + helloWorldService1.throwChecked(name.getBytes()); + } catch (Exception e) { + // Test to see what happens if we talk to a service + // that declares a checked exception through an + // interface that doesn't + stringValue += " " + e.getCause().getMessage(); + } + + try { + helloWorldService1.throwUnChecked(name.getBytes()); + } catch (Exception e) { + stringValue += " " + e.getMessage(); + } + return stringValue; + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..5ae7032993 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java @@ -0,0 +1,35 @@ +/* + * 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.binding.jms.format.jmsbytes.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public byte[] getByteArrayGreetings(byte[] msg); + + public void throwChecked(byte[] msg) throws CheckedException; + public void throwUnChecked(byte[] msg); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..803be4cbe6 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.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.binding.jms.format.jmsbytes.helloworld; + + +public class HelloWorldServiceImpl implements HelloWorldService { + + public byte[] getByteArrayGreetings(byte[] msg){ + + String name = new String(msg); + name = "Hello " + name; + + return name.getBytes(); + } + + public void throwChecked(byte[] msg) throws CheckedException { + throw new CheckedException("foo"); + } + + public void throwUnChecked(byte[] msg) { + throw new RuntimeException("bla"); + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java new file mode 100644 index 0000000000..5fad413ebe --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java @@ -0,0 +1,35 @@ +/* + * 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.binding.jms.format.jmsbytes.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldServiceReference { + + public byte[] getByteArrayGreetings(byte[] msg); + + public void throwChecked(byte[] msg) ; + public void throwUnChecked(byte[] msg); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java new file mode 100644 index 0000000000..251fa58cfe --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmsbytesxml.helloworld; + +public class CheckedException extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedException(String s) { + super(s); + } +} diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java new file mode 100644 index 0000000000..dd58c9554e --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java @@ -0,0 +1,32 @@ +/* + * 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.binding.jms.format.jmsbytesxml.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetings(String message); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..02a3d944f7 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java @@ -0,0 +1,46 @@ +/* + * 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.binding.jms.format.jmsbytesxml.helloworld; + +import org.osoa.sca.annotations.Reference; + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldService helloWorldService1; + + public String getGreetings(String name){ + byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes()); + String stringValue = new String(bytesValue); + + try { + helloWorldService1.throwChecked(name.getBytes()); + } catch (CheckedException e) { + stringValue += " " + e.getMessage(); + } + + try { + helloWorldService1.throwUnChecked(name.getBytes()); + } catch (Exception e) { + stringValue += " " + e.getMessage(); + } + return stringValue; + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..9c2198e6ca --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java @@ -0,0 +1,34 @@ +/* + * 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.binding.jms.format.jmsbytesxml.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public byte[] getByteArrayGreetings(byte[] msg); + + public void throwChecked(byte[] msg) throws CheckedException; + public void throwUnChecked(byte[] msg); +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..75e07564ce --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmsbytesxml.helloworld; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public byte[] getByteArrayGreetings(byte[] msg){ + + String name = new String(msg); + name = "Hello " + name; + + return name.getBytes(); + } + + public void throwChecked(byte[] msg) throws CheckedException { + throw new CheckedException("foo"); + } + + public void throwUnChecked(byte[] msg) { + throw new RuntimeException("bla"); + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java new file mode 100644 index 0000000000..ee02ac5f39 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld; + +public class CheckedException extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedException(String s) { + super(s); + } +} diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java new file mode 100644 index 0000000000..8744a57daf --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java @@ -0,0 +1,36 @@ +/* + * 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.binding.jms.format.jmsdefault.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetings(String name); + + public String getPersonGreetings(Person person); + + public void nullInVoidOut(); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..f465767056 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java @@ -0,0 +1,85 @@ +/* + * 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.binding.jms.format.jmsdefault.helloworld; + +import org.osoa.sca.annotations.Reference; + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldService helloWorldService1; + + @Reference + protected HelloWorldService helloWorldService2; + + @Reference + protected HelloWorldService helloWorldService3; + + @Reference + protected HelloWorldService helloWorldService4; + + public String getGreetings(String name){ + String stringValue = helloWorldService1.getGreetings(name) + " " + + helloWorldService2.getGreetings(name) + " " + + helloWorldService3.getGreetings(name) + " " + + helloWorldService4.getGreetings(name); + + try { + helloWorldService3.throwChecked(name); + } catch (CheckedException e) { + stringValue += " " + e.getMessage(); + } + + try { + helloWorldService3.throwUnChecked(name); + } catch (Exception e) { + stringValue += " " + e.getMessage(); + } + + try { + helloWorldService4.throwChecked(name); + } catch (CheckedException e) { + stringValue += " " + e.getMessage(); + } + + try { + helloWorldService4.throwUnChecked(name); + } catch (Exception e) { + stringValue += " " + e.getMessage(); + } + + return stringValue; + } + + public String getPersonGreetings(Person person){ + return helloWorldService1.getPersonGreetings(person) + " " + + helloWorldService2.getPersonGreetings(person) + " " + + helloWorldService3.getPersonGreetings(person) + " " + + helloWorldService4.getPersonGreetings(person); + } + + public void nullInVoidOut() { + helloWorldService1.nullInVoidOut(); + helloWorldService2.nullInVoidOut(); + helloWorldService3.nullInVoidOut(); + helloWorldService4.nullInVoidOut(); + + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..545fcc894d --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld; + +import org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.CheckedException; +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); + + public String getPersonGreetings(Person person); + + public void nullInVoidOut(); + + public void throwChecked(String msg) throws CheckedException; + public void throwUnChecked(String msg); +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..aca727a9db --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java @@ -0,0 +1,52 @@ +/* + * 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.binding.jms.format.jmsdefault.helloworld; + +import org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.CheckedException; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public static int nullInVoidOutCalled = 0; + + public String getGreetings(String name){ + String response = "Hello " + name; + System.out.println("getGreetings: " + response); + return response; + } + + public String getPersonGreetings(Person person){ + String response = "Hello " + person.getFirstName() + " " + person.getLastName(); + System.out.println("getPersonGreetings: " + response); + return response; + } + + public void nullInVoidOut() { + System.out.println("nullInVoidOut"); + nullInVoidOutCalled++; + } + + public void throwChecked(String msg) throws CheckedException { + throw new CheckedException("foo"); + } + + public void throwUnChecked(String msg) { + throw new RuntimeException("bla"); + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java new file mode 100644 index 0000000000..c28347bf8e --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java @@ -0,0 +1,42 @@ +/* + * 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.binding.jms.format.jmsdefault.helloworld; + +public class Person { + String firstName; + String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java new file mode 100644 index 0000000000..948732adb4 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java @@ -0,0 +1,32 @@ +/* + * 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.binding.jms.format.jmsmessage.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetings(String message); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..ed697f8a38 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java @@ -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.binding.jms.format.jmsmessage.helloworld; + +import org.osoa.sca.annotations.Reference; + + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldServiceReferenceSide helloWorldService1; + + public String getGreetings(String name){ + helloWorldService1.getGreetings(name); + + try { + Thread.sleep(2000); + } catch (Exception ex) { + // do nothing + } + + return HelloWorldServiceImpl.getGreetings(); + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..574188d466 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java @@ -0,0 +1,34 @@ +/* + * 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.binding.jms.format.jmsmessage.helloworld; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + @OneWay + public void onMessage(javax.jms.Message message); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2956df755b --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld; + +import javax.jms.TextMessage; + +public class HelloWorldServiceImpl implements HelloWorldService { + + private static String greetings = "not set"; + + public void onMessage(javax.jms.Message message){ + + String name = null; + + try { + name = ((TextMessage)message).getText(); + } catch (Exception ex) { + name = "EXCEPTION"; + } + greetings = "Hello " + name; + } + + public static String getGreetings(){ + return greetings; + } + + // javax.jms.BytesMessage + // javax.jms.MapMessage + // javax.jms.ObjectMessage + // javax.jms.StreamMessage + // javax.jms.TextMessage + + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java new file mode 100644 index 0000000000..39af400f6a --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java @@ -0,0 +1,37 @@ +/* + * 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.binding.jms.format.jmsmessage.helloworld; + +import javax.jws.soap.SOAPBinding; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldServiceReferenceSide { + + @OneWay + @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE) + public void getGreetings(String message); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README new file mode 100644 index 0000000000..81ea3edffb --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README @@ -0,0 +1,3 @@ +This test uses an SCA composite to fake a scenario where the reference is an SCA reference but the +service is a non-SCA JMS endpoint. This gives us the opportunity to play about with the interface +configuration at the reference to see how the contents of the JMS message can be controlled. \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java new file mode 100644 index 0000000000..da82b2fd5c --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld; + +public class CheckedException extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedException(String s) { + super(s); + } +} diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java new file mode 100644 index 0000000000..e89598cb96 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java @@ -0,0 +1,32 @@ +/* + * 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.binding.jms.format.jmsobject.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetingsWrapSingle(String firstName, String lastName); + public String getGreetingsDontWrapSingle(String firstName, String lastName); +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..bb853673e8 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld; + +import org.osoa.sca.annotations.Reference; + + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldService helloWorldServiceWrapSingle; + + @Reference + protected HelloWorldService helloWorldServiceDontWrapSingle; + + public String getGreetingsWrapSingle(String firstName, String lastName){ + Person person = new Person(); + person.setFirstName(firstName); + person.setLastName(lastName); + + String returnString = ""; + + Person returnPerson = helloWorldServiceWrapSingle.getPersonGreetings(person); + returnString = returnPerson.getFirstName() + " " + returnPerson.getLastName(); + + Person returnNullPerson = helloWorldServiceWrapSingle.getNullReturnGreetings(person); + + if (returnNullPerson == null){ + returnString += " Hello2 null"; + } + + String returnGreeting = helloWorldServiceWrapSingle.getArrayGreeting(new String[]{firstName, lastName}); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceWrapSingle.getMultiArrayGreetings(new String[]{firstName, firstName},new String[]{lastName, lastName}); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceWrapSingle.getMultiGreetings(firstName, lastName); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceWrapSingle.getObjectGreeting(person); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceWrapSingle.getObjectArrayGreeting(new Object[]{person}); + returnString += " " + returnGreeting; + + return returnString; + } + + public String getGreetingsDontWrapSingle(String firstName, String lastName){ + Person person = new Person(); + person.setFirstName(firstName); + person.setLastName(lastName); + + String returnString = ""; + + Person returnPerson = helloWorldServiceDontWrapSingle.getPersonGreetings(person); + returnString = returnPerson.getFirstName() + " " + returnPerson.getLastName(); + + Person returnNullPerson = helloWorldServiceDontWrapSingle.getNullReturnGreetings(person); + + if (returnNullPerson == null){ + returnString += " Hello2 null"; + } + + String returnGreeting = helloWorldServiceDontWrapSingle.getArrayGreeting(new String[]{firstName, lastName}); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceDontWrapSingle.getMultiArrayGreetings(new String[]{firstName, firstName},new String[]{lastName, lastName}); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceDontWrapSingle.getMultiGreetings(firstName, lastName); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceDontWrapSingle.getObjectGreeting(person); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceDontWrapSingle.getObjectArrayGreeting(new Object[]{person}); + returnString += " " + returnGreeting; + + try { + helloWorldServiceDontWrapSingle.throwChecked(person); + } catch (CheckedException e) { + returnString += " " + e.getMessage(); + } + + try { + helloWorldServiceDontWrapSingle.throwUnChecked(person); + } catch (Exception e) { + returnString += " " + e.getCause().getMessage(); + } + + return returnString; + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..8976887daa --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java @@ -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.binding.jms.format.jmsobject.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public Person getPersonGreetings(Person person); + public Person getNullReturnGreetings(Person person); + public String getArrayGreeting(String[] names); + public String getMultiArrayGreetings(String[] firstName, String[] lastName); + public String getMultiGreetings(String firstName, String lastName); + public String getObjectGreeting(Object person); + public String getObjectArrayGreeting(Object[] pearson); + + public void throwChecked(Person person) throws CheckedException; + public void throwUnChecked(Person person); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..0c76c01362 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java @@ -0,0 +1,63 @@ +/* + * 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.binding.jms.format.jmsobject.helloworld; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public Person getPersonGreetings(Person person){ + + person.setFirstName("Hello1 " + person.getFirstName()); + person.setLastName("Hello1 " + person.getLastName()); + + return person; + } + + public Person getNullReturnGreetings(Person person){ + return null; + } + + public String getArrayGreeting(String[] names) { + return "Hello3 " + names[0]; + } + + public String getMultiArrayGreetings(String[] firstName, String[] lastName) { + return "Hello4 " + firstName[0] + " " + lastName[0]; + } + + public String getMultiGreetings(String firstName, String lastName) { + return "Hello5 " + firstName + " " + lastName; + } + + public String getObjectGreeting(Object person) { + return "Hello6 " + ((Person)person).getFirstName() + " " + ((Person)person).getLastName(); + } + + public String getObjectArrayGreeting(Object[] person) { + return "Hello7 " + ((Person)person[0]).getFirstName() + " " + ((Person)person[0]).getLastName(); + } + + public void throwChecked(Person person) throws CheckedException { + throw new CheckedException("foo"); + } + + public void throwUnChecked(Person person) { + throw new RuntimeException("bla"); + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java new file mode 100644 index 0000000000..35c383ace9 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.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.binding.jms.format.jmsobject.helloworld; + +import java.io.Serializable; + +public class Person implements Serializable { + + private static final long serialVersionUID = -6842761353978551779L; + + String firstName; + String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java new file mode 100644 index 0000000000..e2732a295c --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmstext.helloworld; + +public class CheckedException extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedException(String s) { + super(s); + } +} diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java new file mode 100644 index 0000000000..304e145161 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java @@ -0,0 +1,32 @@ +/* + * 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.binding.jms.format.jmstext.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetings(String message); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..2587a51704 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java @@ -0,0 +1,46 @@ +/* + * 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.binding.jms.format.jmstext.helloworld; + +import org.osoa.sca.annotations.Reference; + + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldService helloWorldService1; + + public String getGreetings(String name){ + String stringValue = helloWorldService1.getStringGreetings(name); + + try { + helloWorldService1.throwChecked(name); + } catch (Exception e) { + stringValue += " " + e.getMessage(); + } + + try { + helloWorldService1.throwUnChecked(name); + } catch (Exception e) { + stringValue += " " + e.getMessage(); + } + return stringValue; + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..f46f3e2d04 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java @@ -0,0 +1,35 @@ +/* + * 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.binding.jms.format.jmstext.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getStringGreetings(String msg); + + public void throwChecked(String msg) throws CheckedException; + public void throwUnChecked(String msg); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..988222c296 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java @@ -0,0 +1,38 @@ +/* + * 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.binding.jms.format.jmstext.helloworld; + + +public class HelloWorldServiceImpl implements HelloWorldService { + + public String getStringGreetings(String msg){ + + msg = "Hello " + msg; + return msg; + } + + public void throwChecked(String msg) throws CheckedException { + throw new CheckedException("foo"); + } + + public void throwUnChecked(String msg) { + throw new RuntimeException("bla"); + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java new file mode 100644 index 0000000000..6015ab8930 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java @@ -0,0 +1,35 @@ +/* + * 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.binding.jms.format.jmstext.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldServiceReference { + + public String getStringGreetings(String msg); + + public void throwChecked(String msg) ; + public void throwUnChecked(String msg); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java new file mode 100644 index 0000000000..c45e3899e0 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java @@ -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 org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld; + +public class CheckedException extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedException(String s) { + super(s); + } +} diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java new file mode 100644 index 0000000000..e5cd9db281 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java @@ -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.binding.jms.format.jmstextxml.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetings(String name); + public String getPersonGreetings(Person person); + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..c54e195178 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java @@ -0,0 +1,62 @@ +/* + * 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.binding.jms.format.jmstextxml.helloworld; + +import org.osoa.sca.annotations.Reference; + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldService helloWorldService1; + + @Reference + protected HelloWorldService helloWorldService2; + + @Reference + protected HelloWorldService helloWorldService3; + + public String getGreetings(String name){ + String stringValue = helloWorldService1.getGreetings(name) + " " + + helloWorldService2.getGreetings(name) + " " + + helloWorldService3.getGreetings(name); + + return stringValue; + } + + public String getPersonGreetings(Person person){ + String stringValue = helloWorldService1.getPersonGreetings(person) + " " + + helloWorldService2.getPersonGreetings(person) + " " + + helloWorldService3.getPersonGreetings(person); + + try { + helloWorldService1.throwChecked(person.getLastName()); + } catch (CheckedException e) { + stringValue += " " + e.getMessage(); + } + + try { + helloWorldService1.throwUnChecked(person.getLastName()); + } catch (Exception e) { + stringValue += " " + e.getMessage(); + } + + return stringValue; + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..a98f589b9a --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java @@ -0,0 +1,36 @@ +/* + * 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.binding.jms.format.jmstextxml.helloworld; + +import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.CheckedException; +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); + public String getPersonGreetings(Person person); + + public void throwChecked(String msg) throws CheckedException; + public void throwUnChecked(String msg); +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..7965388013 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java @@ -0,0 +1,45 @@ +/* + * 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.binding.jms.format.jmstextxml.helloworld; + +import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.CheckedException; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public String getGreetings(String name){ + String response = "Hello " + name; + System.out.println("getGreetings: " + response); + return response; + } + + public String getPersonGreetings(Person person){ + String response = "Hello " + person.getFirstName() + " " + person.getLastName(); + System.out.println("getPersonGreetings: " + response); + return response; + } + + public void throwChecked(String msg) throws CheckedException { + throw new CheckedException("foo"); + } + + public void throwUnChecked(String msg) { + throw new RuntimeException("bla"); + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java new file mode 100644 index 0000000000..8f9c3564f8 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java @@ -0,0 +1,42 @@ +/* + * 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.binding.jms.format.jmstextxml.helloworld; + +public class Person { + String firstName; + String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..732b49ea6c --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java @@ -0,0 +1,38 @@ +/* + * 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.binding.jms.format.jmstextxmlinjmsobjectout.helloworld; + +import org.osoa.sca.annotations.Reference; + + +public class HelloWorldReferenceImpl implements HelloWorldService { + + @Reference + protected HelloWorldService helloWorldService1; + + public String getGreetings(String name){ + return helloWorldService1.getGreetings(name).toString(); + } + + public String getPersonGreetings(Person person){ + return helloWorldService1.getPersonGreetings(person).toString(); + } + +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..65323a3d63 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java @@ -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.binding.jms.format.jmstextxmlinjmsobjectout.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); + + public String getPersonGreetings(Person person); +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2f2c53b41d --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java @@ -0,0 +1,35 @@ +/* + * 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.binding.jms.format.jmstextxmlinjmsobjectout.helloworld; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public String getGreetings(String name){ + String response = "Hello " + name; + System.out.println("getGreetings: " + response); + return response; + } + + public String getPersonGreetings(Person person){ + String response = "Hello " + person.getFirstName() + " " + person.getLastName(); + System.out.println("getPersonGreetings: " + response); + return response; + } +} + diff --git a/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java new file mode 100644 index 0000000000..ad6fe0b043 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java @@ -0,0 +1,42 @@ +/* + * 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.binding.jms.format.jmstextxmlinjmsobjectout.helloworld; + +public class Person { + String firstName; + String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + +} + diff --git a/java/sca/itest/jms/format/src/main/resources/META-INF/sca-contribution.xml b/java/sca/itest/jms/format/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..f2564234fd --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/java/sca/itest/jms/format/src/main/resources/jmsbytes/helloworld.composite b/java/sca/itest/jms/format/src/main/resources/jmsbytes/helloworld.composite new file mode 100644 index 0000000000..ea6ed6c464 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmsbytes/helloworld.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/resources/jmsbytesxml/helloworld.composite b/java/sca/itest/jms/format/src/main/resources/jmsbytesxml/helloworld.composite new file mode 100644 index 0000000000..fff5656c98 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmsbytesxml/helloworld.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/resources/jmsdefault/helloworld.composite b/java/sca/itest/jms/format/src/main/resources/jmsdefault/helloworld.composite new file mode 100644 index 0000000000..2c54bf8bc5 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmsdefault/helloworld.composite @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/resources/jmsdefault/helloworld.wsdl b/java/sca/itest/jms/format/src/main/resources/jmsdefault/helloworld.wsdl new file mode 100644 index 0000000000..30372cc02f --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmsdefault/helloworld.wsdl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/format/src/main/resources/jmsmessage/helloworld.composite b/java/sca/itest/jms/format/src/main/resources/jmsmessage/helloworld.composite new file mode 100644 index 0000000000..6202e947f5 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmsmessage/helloworld.composite @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/resources/jmsmessage/helloworld.wsdl b/java/sca/itest/jms/format/src/main/resources/jmsmessage/helloworld.wsdl new file mode 100644 index 0000000000..092c56b31d --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmsmessage/helloworld.wsdl @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/format/src/main/resources/jmsobject/helloworld.composite b/java/sca/itest/jms/format/src/main/resources/jmsobject/helloworld.composite new file mode 100644 index 0000000000..3ca541c9fb --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmsobject/helloworld.composite @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/resources/jmsobject/helloworld.wsdl b/java/sca/itest/jms/format/src/main/resources/jmsobject/helloworld.wsdl new file mode 100644 index 0000000000..a2af528e9e --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmsobject/helloworld.wsdl @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/resources/jmstext/helloworld.composite b/java/sca/itest/jms/format/src/main/resources/jmstext/helloworld.composite new file mode 100644 index 0000000000..5b3e710a51 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmstext/helloworld.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/resources/jmstextxml/helloworld.composite b/java/sca/itest/jms/format/src/main/resources/jmstextxml/helloworld.composite new file mode 100644 index 0000000000..2d25f2c3f4 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmstextxml/helloworld.composite @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/resources/jmstextxml/helloworld.wsdl b/java/sca/itest/jms/format/src/main/resources/jmstextxml/helloworld.wsdl new file mode 100644 index 0000000000..30372cc02f --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmstextxml/helloworld.wsdl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/format/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite b/java/sca/itest/jms/format/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite new file mode 100644 index 0000000000..3f05ac2683 --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/format/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl b/java/sca/itest/jms/format/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl new file mode 100644 index 0000000000..30372cc02f --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/format/src/main/resources/jndi.properties b/java/sca/itest/jms/format/src/main/resources/jndi.properties new file mode 100644 index 0000000000..9abdff215d --- /dev/null +++ b/java/sca/itest/jms/format/src/main/resources/jndi.properties @@ -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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.RequestQueue = RequestQueue +queue.ResponseQueue = ResponseQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java new file mode 100644 index 0000000000..a0429aa59f --- /dev/null +++ b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java @@ -0,0 +1,75 @@ +/* + * 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.binding.jms.format; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.HelloWorldReference; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class FormatJMSBytesTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmsbytes/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldService = ((SCAClient)node).getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); + + System.out.println(helloWorldService.getGreetings("Fred Bloggs")); +/* TUSCANY-2967 - disable this change while we decide what to do and + * return faults as JMSObject messages to be consistent + * again with other wire formats + assertEquals("Hello Fred Bloggs " + + "org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.CheckedException: foo " + + "org.osoa.sca.ServiceRuntimeException: java.lang.RuntimeException: bla", + helloWorldService.getGreetings("Fred Bloggs")); +*/ + assertEquals("Hello Fred Bloggs " + + "foo " + + "remote service exception, see nested exception" , + helloWorldService.getGreetings("Fred Bloggs")); + + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java new file mode 100644 index 0000000000..ec9a1adeb4 --- /dev/null +++ b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.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.binding.jms.format; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.HelloWorldReference; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class FormatJMSBytesXMLTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmsbytesxml/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldService = ((SCAClient)node).getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); + + System.out.println(helloWorldService.getGreetings("Fred Bloggs")); + assertEquals("Hello Fred Bloggs foo remote service exception, see nested exception", helloWorldService.getGreetings("Fred Bloggs")); + + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java new file mode 100644 index 0000000000..dc2cc13679 --- /dev/null +++ b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java @@ -0,0 +1,74 @@ +/* + * 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.binding.jms.format; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldReference; +import org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.HelloWorldServiceImpl; +import org.apache.tuscany.sca.binding.jms.format.jmsdefault.helloworld.Person; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class FormatJMSDefaultTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmsdefault/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldService = ((SCAClient)node).getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); + + assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs foo remote service exception, see nested exception foo remote service exception, see nested exception", helloWorldService.getGreetings("Fred Bloggs")); + + Person person = new Person(); + person.setFirstName("Fred"); + person.setLastName("Bloggs"); + assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs", helloWorldService.getPersonGreetings(person)); + + // this just makes sure that there are no exceptions thrown for this case + helloWorldService.nullInVoidOut(); + Assert.assertEquals(4, HelloWorldServiceImpl.nullInVoidOutCalled); + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java new file mode 100644 index 0000000000..c617a984ef --- /dev/null +++ b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.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.binding.jms.format; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.format.jmsmessage.helloworld.HelloWorldReference; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class FormatJMSMessageTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmsmessage/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldService = ((SCAClient)node).getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); + + System.out.println(helloWorldService.getGreetings("Fred Bloggs")); + assertEquals("Hello Fred Bloggs", helloWorldService.getGreetings("Fred Bloggs")); + + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java new file mode 100644 index 0000000000..462ebb557e --- /dev/null +++ b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java @@ -0,0 +1,80 @@ +/* + * 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.binding.jms.format; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld.HelloWorldReference; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class FormatJMSObjectTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmsobject/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldService = ((SCAClient) node).getService( + HelloWorldReference.class, "HelloWorldReferenceComponent"); + + assertEquals("Hello1 Fred Hello1 Bloggs Hello2 null Hello3 Fred Hello4 Fred Bloggs Hello5 Fred Bloggs Hello6 Fred Bloggs Hello7 Fred Bloggs", + helloWorldService.getGreetingsWrapSingle("Fred", "Bloggs")); + + assertEquals("Hello1 Fred Hello1 Bloggs Hello2 null Hello3 Fred Hello4 Fred Bloggs Hello5 Fred Bloggs Hello6 Fred Bloggs Hello7 Fred Bloggs foo java.lang.RuntimeException: bla", + helloWorldService.getGreetingsDontWrapSingle("Fred", "Bloggs")); + + } + + @Ignore + @Test + public void testWaitForInput() { + System.out.println("Press a key to end"); + try { + System.in.read(); + } catch (Exception ex) { + } + System.out.println("Shutting down"); + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java new file mode 100644 index 0000000000..d45e6492ce --- /dev/null +++ b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java @@ -0,0 +1,66 @@ +/* + * 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.binding.jms.format; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld.HelloWorldReference; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class FormatJMSTextTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmstext/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldService = ((SCAClient)node).getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); + + System.out.println(helloWorldService.getGreetings("Fred Bloggs")); + assertEquals("Hello Fred Bloggs " + + "foo remote service exception, see nested exception", + helloWorldService.getGreetings("Fred Bloggs")); + + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java new file mode 100644 index 0000000000..5d3b0ac9e3 --- /dev/null +++ b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java @@ -0,0 +1,69 @@ +/* + * 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.binding.jms.format; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld.HelloWorldService; +import org.apache.tuscany.sca.binding.jms.format.jmstextxmlinjmsobjectout.helloworld.Person; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class FormatJMSTextXMLInJMSObjectOutTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmstextxmlinjmsobjectout/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldService helloWorldService = ((SCAClient)node).getService(HelloWorldService.class, "HelloWorldReferenceComponent"); + + assertEquals("Hello Fred Bloggs", helloWorldService.getGreetings("Fred Bloggs")); + + Person person = new Person(); + person.setFirstName("Fred"); + person.setLastName("Bloggs"); + assertEquals("Hello Fred Bloggs", helloWorldService.getPersonGreetings(person)); + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java new file mode 100644 index 0000000000..5650d06a36 --- /dev/null +++ b/java/sca/itest/jms/format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.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.binding.jms.format; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.HelloWorldReference; +import org.apache.tuscany.sca.binding.jms.format.jmstextxml.helloworld.Person; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class FormatJMSTextXMLTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmstextxml/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldService = ((SCAClient)node).getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); + + assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs", helloWorldService.getGreetings("Fred Bloggs")); + + Person person = new Person(); + person.setFirstName("Fred"); + person.setLastName("Bloggs"); + assertEquals("Hello Fred Bloggs Hello Fred Bloggs Hello Fred Bloggs foo remote service exception, see nested exception", helloWorldService.getPersonGreetings(person)); + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/general/pom.xml b/java/sca/itest/jms/general/pom.xml new file mode 100644 index 0000000000..7f30339383 --- /dev/null +++ b/java/sca/itest/jms/general/pom.xml @@ -0,0 +1,109 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms + Apache Tuscany SCA iTest JMS + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-policy + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java new file mode 100644 index 0000000000..7b1c63d437 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class CheckedExcpetion extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedExcpetion(String s) { + super(s); + } +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java new file mode 100644 index 0000000000..19b584950a --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class CheckedExcpetion2Args extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedExcpetion2Args(String s, Throwable e) { + super(s, e); + } +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java new file mode 100644 index 0000000000..b12e3a562e --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class CheckedExcpetionChained extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedExcpetionChained(Throwable e) { + super(e); + } +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java new file mode 100644 index 0000000000..b23db73c01 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class CheckedExcpetionNoArgs extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedExcpetionNoArgs() { + super(); + } +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java new file mode 100644 index 0000000000..4351b17cd6 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface ExceptionService { + + public void throwChecked() throws CheckedExcpetion; + public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs; + public void throwChecked2Args() throws CheckedExcpetion2Args; + public void throwCheckedChained() throws CheckedExcpetionChained; + + public void throwUnChecked(); +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java new file mode 100644 index 0000000000..cb244a5160 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java @@ -0,0 +1,57 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service. + */ +@Service(ExceptionService.class) +public class ExceptionServiceClient implements ExceptionService { + + private ExceptionService service; + + @Reference + public void setService(ExceptionService service) { + this.service = service; + } + + public void throwChecked() throws CheckedExcpetion { + service.throwChecked(); + } + + public void throwChecked2Args() throws CheckedExcpetion2Args { + service.throwChecked2Args(); + } + + public void throwCheckedChained() throws CheckedExcpetionChained { + service.throwCheckedChained(); + } + + public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs { + service.throwCheckedNoArgs(); + } + + public void throwUnChecked() { + service.throwUnChecked(); + } + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java new file mode 100644 index 0000000000..40780709f4 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java @@ -0,0 +1,44 @@ +/* + * 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.binding.jms; + +public class ExceptionServiceImpl implements ExceptionService { + + public void throwChecked() throws CheckedExcpetion { + throw new CheckedExcpetion("foo"); + } + + public void throwChecked2Args() throws CheckedExcpetion2Args { + throw new CheckedExcpetion2Args("foo", new Exception("bla")); + } + + public void throwCheckedChained() throws CheckedExcpetionChained { + throw new CheckedExcpetionChained(new Exception("bla")); + } + + public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs { + throw new CheckedExcpetionNoArgs(); + } + + public void throwUnChecked() { + throw new RuntimeException("bla"); + } + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java new file mode 100644 index 0000000000..86d4719646 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service. + */ +@Service(HelloWorldService.class) +public class HelloWorldClientImpl implements HelloWorldService { + + private HelloWorldService serviceA; + + @Reference + public void setServiceA(HelloWorldService service) { + this.serviceA = service; + } + + public String sayHello(String name) { + return serviceA.sayHello(name); + } + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java new file mode 100644 index 0000000000..abb29aec4c --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java @@ -0,0 +1,26 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorldService { + String sayHello(String name); +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..21d2de2cf0 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public String sayHello(String name) { + if ("bang".equals(name)) { + throw new RuntimeException("blem wit"); + } + return "jmsHello " + name; + } + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java new file mode 100644 index 0000000000..d4cd5df431 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java @@ -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 org.apache.tuscany.sca.binding.jms; + + +/** + * The client interface + */ +public interface JMSClient { + + void aClientMethod(); +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java new file mode 100644 index 0000000000..464072b42d --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java @@ -0,0 +1,29 @@ +/* + * 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.binding.jms; + + +/** + * The client interface + */ +public interface MsgClient { + + void aClientMethod(); + void op2(); +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java new file mode 100644 index 0000000000..b4d1cbccda --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java @@ -0,0 +1,38 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(MsgClient.class) +public class MsgClientImpl implements MsgClient { + + @Reference protected MsgClientService myService; + + public void aClientMethod() { + myService.aClientMethod(); + } + + public void op2() { + myService.op2(); + } + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java new file mode 100644 index 0000000000..e8242467cc --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Remotable; + + +/** + * The client interface + */ +@Remotable +public interface MsgClientService { + + void aClientMethod(); + + void op2(); +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java new file mode 100644 index 0000000000..d376d74295 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java @@ -0,0 +1,32 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.AllowsPassByReference; +import org.osoa.sca.annotations.Remotable; + + +@Remotable +@AllowsPassByReference +public interface MsgService { + + void onMessage(javax.jms.Message msg); + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java new file mode 100644 index 0000000000..142343e349 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java @@ -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 org.apache.tuscany.sca.binding.jms; + +import javax.jms.Message; + +import org.osoa.sca.annotations.Service; + +@Service(MsgService.class) +public class MsgServiceImpl implements MsgService { + + public static Object lock = new Object(); + public static Message msg; + + public void onMessage(Message msg) { + MsgServiceImpl.msg = msg; + synchronized(lock) { + lock.notifyAll(); + } + } + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java new file mode 100644 index 0000000000..218cccf64c --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the OneWay service. + */ +@Service(OneWayService.class) +public class OneWayClientImpl implements OneWayService { + + private OneWayService serviceA; + + @Reference + public void setServiceA(OneWayService service) { + this.serviceA = service; + } + + public void sayHello(String name) { + serviceA.sayHello(name); + } + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java new file mode 100644 index 0000000000..9795089952 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java @@ -0,0 +1,29 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface OneWayObjectService { + + @OneWay + void sayHello(Object name); +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java new file mode 100644 index 0000000000..25a89fc5b4 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java @@ -0,0 +1,34 @@ +/* + * 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.binding.jms; + +public class OneWayObjectServiceImpl implements OneWayObjectService { + + public static Object mutex = new Object(); + public static Object name; + + public void sayHello(Object name) { + OneWayObjectServiceImpl.name = name; + synchronized (OneWayObjectServiceImpl.mutex) { + OneWayObjectServiceImpl.mutex.notify(); + } + } + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java new file mode 100644 index 0000000000..f16f853ba7 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java @@ -0,0 +1,29 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface OneWayService { + + @OneWay + void sayHello(String name); +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java new file mode 100644 index 0000000000..bff4536fa0 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java @@ -0,0 +1,34 @@ +/* + * 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.binding.jms; + +public class OneWayServiceImpl implements OneWayService { + + public static Object mutex = new Object(); + public static String name; + + public void sayHello(String name) { + OneWayServiceImpl.name = name; + synchronized (OneWayServiceImpl.mutex) { + OneWayServiceImpl.mutex.notify(); + } + } + +} diff --git a/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java new file mode 100644 index 0000000000..cdf9bef93f --- /dev/null +++ b/java/sca/itest/jms/general/src/main/java/org/apache/tuscany/sca/binding/jms/TestMessageProcessor.java @@ -0,0 +1,57 @@ +/* + * 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.binding.jms; + +import javax.jms.Message; +import javax.jms.Session; + +import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; +import org.apache.tuscany.sca.binding.jms.provider.TextMessageProcessor; + +public class TestMessageProcessor extends TextMessageProcessor { + + public static boolean insertPayloadIntoJMSMessageCalled; + public static boolean extractPayloadFromJMSMessageCalled; + public static boolean setOperationNameCalled; + + public TestMessageProcessor(JMSBinding jmsBinding) { + super(jmsBinding); + } + public Object extractPayloadFromJMSMessage(Message message) { + extractPayloadFromJMSMessageCalled = true; + return super.extractPayloadFromJMSMessage(message); + } + + public String getOperationName(Message message) { + // is this used? + return super.getOperationName(message); + } + + public Message insertPayloadIntoJMSMessage(Session session, Object payload) { + insertPayloadIntoJMSMessageCalled = true; + return super.insertPayloadIntoJMSMessage(session, payload); + } + + public void setOperationName(String operationName, Message message) { + setOperationNameCalled = true; + super.setOperationName(operationName, message); + } + +} diff --git a/java/sca/itest/jms/general/src/main/resources/defaults/client.composite b/java/sca/itest/jms/general/src/main/resources/defaults/client.composite new file mode 100644 index 0000000000..991b0cf11b --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/defaults/client.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/defaults/service.composite b/java/sca/itest/jms/general/src/main/resources/defaults/service.composite new file mode 100644 index 0000000000..3f299bc787 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/defaults/service.composite @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/dynamic/client.composite b/java/sca/itest/jms/general/src/main/resources/dynamic/client.composite new file mode 100644 index 0000000000..afa4135f1d --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/dynamic/client.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/exceptions/client.composite b/java/sca/itest/jms/general/src/main/resources/exceptions/client.composite new file mode 100644 index 0000000000..8bb7f86252 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/exceptions/client.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/exceptions/service.composite b/java/sca/itest/jms/general/src/main/resources/exceptions/service.composite new file mode 100644 index 0000000000..052ff9d985 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/exceptions/service.composite @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/external/client.composite b/java/sca/itest/jms/general/src/main/resources/external/client.composite new file mode 100644 index 0000000000..7a0013be4d --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/external/client.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/external/service.composite b/java/sca/itest/jms/general/src/main/resources/external/service.composite new file mode 100644 index 0000000000..b9f33e5afc --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/external/service.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/jndi.properties b/java/sca/itest/jms/general/src/main/resources/jndi.properties new file mode 100644 index 0000000000..9abdff215d --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/jndi.properties @@ -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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.RequestQueue = RequestQueue +queue.ResponseQueue = ResponseQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/general/src/main/resources/nonSCAclient/service.composite b/java/sca/itest/jms/general/src/main/resources/nonSCAclient/service.composite new file mode 100644 index 0000000000..ea821c347b --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/nonSCAclient/service.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/oneway/OneWayClient.composite b/java/sca/itest/jms/general/src/main/resources/oneway/OneWayClient.composite new file mode 100644 index 0000000000..bed0663f58 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/oneway/OneWayClient.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/oneway/OneWayService.composite b/java/sca/itest/jms/general/src/main/resources/oneway/OneWayService.composite new file mode 100644 index 0000000000..3d08de7d51 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/oneway/OneWayService.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/policyHeaders/definitions.xml b/java/sca/itest/jms/general/src/main/resources/policyHeaders/definitions.xml new file mode 100644 index 0000000000..dd4350c6fe --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/policyHeaders/definitions.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/general/src/main/resources/policyHeaders/policyHeaders.composite b/java/sca/itest/jms/general/src/main/resources/policyHeaders/policyHeaders.composite new file mode 100644 index 0000000000..8902f1d32a --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/policyHeaders/policyHeaders.composite @@ -0,0 +1,46 @@ + + + + + + + + + + myHeadP1 + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/properties/properties.composite b/java/sca/itest/jms/general/src/main/resources/properties/properties.composite new file mode 100644 index 0000000000..43bd611b24 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/properties/properties.composite @@ -0,0 +1,55 @@ + + + + + + + + + + myHeadP1 + + + + foo + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/simple/client.composite b/java/sca/itest/jms/general/src/main/resources/simple/client.composite new file mode 100644 index 0000000000..6454370419 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/simple/client.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/simple/mpclient.composite b/java/sca/itest/jms/general/src/main/resources/simple/mpclient.composite new file mode 100644 index 0000000000..5389c427dc --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/simple/mpclient.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/simple/mpservice.composite b/java/sca/itest/jms/general/src/main/resources/simple/mpservice.composite new file mode 100644 index 0000000000..6d0d11f4b6 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/simple/mpservice.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/simple/service.composite b/java/sca/itest/jms/general/src/main/resources/simple/service.composite new file mode 100644 index 0000000000..4dfdb5f27d --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/simple/service.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/main/resources/simple/uriclient.composite b/java/sca/itest/jms/general/src/main/resources/simple/uriclient.composite new file mode 100644 index 0000000000..83ef9c3c95 --- /dev/null +++ b/java/sca/itest/jms/general/src/main/resources/simple/uriclient.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java new file mode 100644 index 0000000000..dca9386637 --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java @@ -0,0 +1,54 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class DefaultsTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = + SCADomain.newInstance("http://localhost", "/", "defaults/client.composite", "defaults/service.composite"); + // scaDomain = SCADomain.newInstance("http://localhost", "/", "simple/client.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldClient"); + assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra")); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java new file mode 100644 index 0000000000..f4750e5453 --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java @@ -0,0 +1,53 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class DynamicReplyQTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = + SCADomain.newInstance("http://localhost", "/", "dynamic/client.composite", "simple/service.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldClient"); + assertEquals("jmsHello Beate", helloWorldService.sayHello("Beate")); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java new file mode 100644 index 0000000000..bd326b36d2 --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java @@ -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.binding.jms; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class ExceptionsTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = + SCADomain.newInstance("http://localhost", "/", "exceptions/client.composite", "exceptions/service.composite"); + } + + @Test + public void testChecked() { + ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); + try { + service.throwChecked(); + fail(); + } catch (CheckedExcpetion e) { + assertEquals("foo", e.getMessage()); + } + } + + @Test + public void testCheckedNoArgs() { + ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); + try { + service.throwCheckedNoArgs(); + fail(); + } catch (CheckedExcpetionNoArgs e) { + // ok + } + } + + @Test + public void testChecked2Args() { + ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); + try { + service.throwChecked2Args(); + fail(); + } catch (CheckedExcpetion2Args e) { + assertEquals("foo", e.getMessage()); +// FIXME: TUSCANY-2848: lost the cause! +// assertNotNull(e.getCause()); +// assertEquals("bla", e.getCause().getMessage()); + } + } + + @Test + public void testCheckedChained() { + ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); + try { + service.throwCheckedChained(); + fail(); + } catch (CheckedExcpetionChained e) { + // FIXME: TUSCANY-2848: lost the cause! +// assertNotNull(e.getCause()); +// assertEquals("bla", e.getCause().getMessage()); + } + } + + @Test + public void testUnChecked() { + ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); + try { + service.throwUnChecked(); + fail(); + } catch (Exception e) { + assertEquals("java.lang.RuntimeException: bla", e.getCause().getMessage()); + } + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java new file mode 100644 index 0000000000..c34ad07901 --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java @@ -0,0 +1,70 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.activemq.broker.BrokerService; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests using the JMS binding with an external JMS broker + */ +public class ExternalBrokerTestCase { + + private static SCADomain scaDomain; + private BrokerService broker; + + @Before + public void init() throws Exception { + startBroker(); + scaDomain = SCADomain.newInstance("http://localhost", "/", "external/client.composite", "external/service.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldClient"); + assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra")); + } + + @After + public void end() throws Exception { + if (scaDomain != null) { + scaDomain.close(); + } + stopBroker(); + } + + protected void startBroker() throws Exception { + broker = new BrokerService(); + broker.setPersistent(false); + broker.setUseJmx(false); + broker.addConnector("tcp://localhost:61616"); + broker.start(); + } + protected void stopBroker() throws Exception { + if (broker != null) { + broker.stop(); + } + } + +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/MessageProcessorTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/MessageProcessorTestCase.java new file mode 100644 index 0000000000..44f9754e29 --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/MessageProcessorTestCase.java @@ -0,0 +1,57 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class MessageProcessorTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = + SCADomain.newInstance("http://localhost", "/", "simple/mpclient.composite", "simple/mpservice.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldClientMP"); + assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra")); + assertTrue(TestMessageProcessor.extractPayloadFromJMSMessageCalled); + assertTrue(TestMessageProcessor.insertPayloadIntoJMSMessageCalled); + assertTrue(TestMessageProcessor.setOperationNameCalled); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java new file mode 100644 index 0000000000..d982e651cd --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java @@ -0,0 +1,142 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +import javax.jms.JMSException; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.naming.NamingException; + +import org.apache.activemq.broker.BrokerService; +import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; +import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryImpl; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class NonSCAClientTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() throws Exception { + startBroker(); + scaDomain = SCADomain.newInstance("http://localhost", "/", "nonSCAclient/service.composite"); + OneWayServiceImpl.name = null; + } + + @Test + public void testXMLText() throws Exception { + + synchronized (OneWayServiceImpl.mutex) { + + sendTextMessage("dynamicQueues/OneWayService", "Petra"); + + // wait up to 10 seconds but it will likely be a lot less + // as the service invocation will wake this up earlier + if (OneWayServiceImpl.name == null) { + OneWayServiceImpl.mutex.wait(10000); + } + } + assertEquals("Petra", OneWayServiceImpl.name); + } + + @Test + public void testText() throws Exception { + + synchronized (OneWayServiceImpl.mutex) { + + sendTextMessage("dynamicQueues/TextDest", "Petra"); + + // wait up to 10 seconds but it will likely be a lot less + // as the service invocation will wake this up earlier + OneWayServiceImpl.mutex.wait(10000); + } + assertEquals("Petra", OneWayServiceImpl.name); + } + + @Test + public void testObject() throws Exception { + + Set arg = new HashSet(); + arg.add(new Integer(3)); + + synchronized (OneWayObjectServiceImpl.mutex) { + + sendObjectMessage("dynamicQueues/ObjectDest", arg); + + // wait up to 10 seconds but it will likely be a lot less + // as the service invocation will wake this up earlier + OneWayObjectServiceImpl.mutex.wait(10000); + } + assertEquals(arg, OneWayObjectServiceImpl.name); + } + + @After + public void end() throws Exception { + if (scaDomain != null) { + scaDomain.close(); + } + stopBroker(); + } + + private BrokerService broker; + protected void startBroker() throws Exception { + broker = new BrokerService(); + broker.setPersistent(false); + broker.setUseJmx(false); + broker.addConnector("tcp://localhost:61623"); + broker.start(); + } + protected void stopBroker() throws Exception { + if (broker != null) { + broker.stop(); + } + } + + protected static void sendTextMessage(String destName, String payload) throws JMSException, NamingException { + JMSResourceFactory rf = new JMSResourceFactoryImpl(null, null, null, "tcp://localhost:61623"); + Session session = rf.getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer p = session.createProducer(rf.lookupDestination(destName)); + rf.getConnection().start(); + session.run(); + p.send(session.createTextMessage(payload)); + rf.closeConnection(); + } + + protected static void sendObjectMessage(String destName, Object payload) throws JMSException, NamingException { + JMSResourceFactory rf = new JMSResourceFactoryImpl(null, null, null, "tcp://localhost:61623"); + Session session = rf.getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer p = session.createProducer(rf.lookupDestination(destName)); + rf.getConnection().start(); + session.run(); + p.send(session.createObjectMessage((Serializable)payload)); + rf.closeConnection(); + } +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java new file mode 100644 index 0000000000..26dda13cf9 --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java @@ -0,0 +1,58 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class OneWayTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "oneway/OneWayClient.composite", "oneway/OneWayService.composite"); + } + + @Test + public void testOneWayInvoked() throws Exception { + OneWayService oneWayService = scaDomain.getService(OneWayService.class, "OneWayClient"); + oneWayService.sayHello("Petra"); + synchronized (OneWayServiceImpl.mutex) { + // wait up to 10 seconds but it will likely be a lot less + // as the service invocation will wake this up earlier + OneWayServiceImpl.mutex.wait(10000); + } + assertEquals("Petra", OneWayServiceImpl.name); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java new file mode 100644 index 0000000000..5e208a3081 --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java @@ -0,0 +1,95 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import javax.jms.DeliveryMode; +import javax.jms.Message; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +/** + */ +public class PolicyHeadersTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "policyHeaders/policyHeaders.composite"); + } + + @Test + public void testProps1() throws Exception { + JMSClient client = scaDomain.getService(JMSClient.class, "ClientComponent"); + + client.aClientMethod(); + + // wait for up to 5 seconds but should wake up as soon as done + synchronized(MsgServiceImpl.lock) { + if (MsgServiceImpl.msg == null) { + MsgServiceImpl.lock.wait(5000); // For debugging set higher. + } + } + assertNotNull(MsgServiceImpl.msg); + + assertEquals("myType", MsgServiceImpl.msg.getJMSType()); + assertEquals("xyz", MsgServiceImpl.msg.getJMSCorrelationID()); + assertEquals(DeliveryMode.PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode()); + assertEquals(7, MsgServiceImpl.msg.getJMSPriority()); + assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1")); + } + + @Test + @Ignore + public void testOp2() throws Exception { + MsgClient client = scaDomain.getService(MsgClient.class, "ClientComponent"); + + client.op2(); + + // wait for up to 5 seconds but should wake up as soon as done + synchronized(MsgServiceImpl.lock) { + if (MsgServiceImpl.msg == null) { + MsgServiceImpl.lock.wait(5000); + } + } + assertNotNull(MsgServiceImpl.msg); + + assertEquals("op2Type", MsgServiceImpl.msg.getJMSType()); + assertEquals("op2CID", MsgServiceImpl.msg.getJMSCorrelationID()); + assertEquals(DeliveryMode.NON_PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode()); + assertEquals(3, MsgServiceImpl.msg.getJMSPriority()); + assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1")); + assertEquals("foo", MsgServiceImpl.msg.getStringProperty("op2P2")); + assertEquals("nativeOp2", MsgServiceImpl.msg.getStringProperty("scaOperationName")); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java new file mode 100644 index 0000000000..f4ba59e61b --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java @@ -0,0 +1,93 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import javax.jms.DeliveryMode; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + */ +public class PropertiesTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "properties/properties.composite"); + } + + @Test + public void testProps1() throws Exception { + JMSClient client = scaDomain.getService(JMSClient.class, "ClientComponent"); + + client.aClientMethod(); + + // wait for up to 5 seconds but should wake up as soon as done + synchronized(MsgServiceImpl.lock) { + if (MsgServiceImpl.msg == null) { + MsgServiceImpl.lock.wait(5000); + } + } + assertNotNull(MsgServiceImpl.msg); + + assertEquals("myType", MsgServiceImpl.msg.getJMSType()); + assertEquals("xyz", MsgServiceImpl.msg.getJMSCorrelationID()); + assertEquals(DeliveryMode.PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode()); + // assertEquals(3, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work with ActiveMQ + assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1")); + } + + @Test + public void testOp2() throws Exception { + MsgClient client = scaDomain.getService(MsgClient.class, "ClientComponent"); + + client.op2(); + + // wait for up to 5 seconds but should wake up as soon as done + synchronized(MsgServiceImpl.lock) { + if (MsgServiceImpl.msg == null) { + MsgServiceImpl.lock.wait(6000); + } + } + assertNotNull(MsgServiceImpl.msg); + + assertEquals("op2Type", MsgServiceImpl.msg.getJMSType()); + assertEquals("op2CID", MsgServiceImpl.msg.getJMSCorrelationID()); + // assertEquals(DeliveryMode.NON_PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode()); // Doesn't seem to work with ActiveMQ + // assertEquals(3, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work with ActiveMQ + assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1")); + assertEquals("foo", MsgServiceImpl.msg.getStringProperty("op2P2")); + //operation properties are a service side thing + //assertEquals("nativeOp2", MsgServiceImpl.msg.getStringProperty("scaOperationName")); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java new file mode 100644 index 0000000000..c1882a1e26 --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java @@ -0,0 +1,54 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class RPCTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = + SCADomain.newInstance("http://localhost", "/", "simple/client.composite", "simple/service.composite"); + // scaDomain = SCADomain.newInstance("http://localhost", "/", "simple/client.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldClient"); + assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra")); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java new file mode 100644 index 0000000000..bed5515d7f --- /dev/null +++ b/java/sca/itest/jms/general/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java @@ -0,0 +1,54 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class URIRPCTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = + SCADomain.newInstance("http://localhost", "/", "simple/uriclient.composite", "simple/service.composite"); + // scaDomain = SCADomain.newInstance("http://localhost", "/", "simple/client.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldClient"); + assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra")); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/noreplyto/pom.xml b/java/sca/itest/jms/noreplyto/pom.xml new file mode 100644 index 0000000000..fb980d4f0b --- /dev/null +++ b/java/sca/itest/jms/noreplyto/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-noreplyto + Apache Tuscany SCA iTest JMS No replyTo + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-policy + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/java/sca/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java new file mode 100644 index 0000000000..28b281a0c4 --- /dev/null +++ b/java/sca/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java @@ -0,0 +1,26 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorldService { + String sayHello(String name); +} diff --git a/java/sca/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/java/sca/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2c6d9d0d17 --- /dev/null +++ b/java/sca/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public String sayHello(String name) { + if ("bang".equals(name)) { + throw new RuntimeException("blem wit"); + } + return "jmsHello " + name; + } + +} diff --git a/java/sca/itest/jms/noreplyto/src/main/resources/jndi.properties b/java/sca/itest/jms/noreplyto/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/java/sca/itest/jms/noreplyto/src/main/resources/jndi.properties @@ -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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.RequestQueue = RequestQueue +queue.ResponseQueue = ResponseQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/noreplyto/src/main/resources/service.composite b/java/sca/itest/jms/noreplyto/src/main/resources/service.composite new file mode 100644 index 0000000000..f6cc48fa0f --- /dev/null +++ b/java/sca/itest/jms/noreplyto/src/main/resources/service.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java b/java/sca/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java new file mode 100644 index 0000000000..3db0e634be --- /dev/null +++ b/java/sca/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java @@ -0,0 +1,100 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import java.io.Serializable; +import java.util.Properties; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.Session; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Uses a non-Tuscany JMS client to send/receive a JMS request to a Tuscany/SCA JMS service + */ +public class NoReplyToTestCase { + + private static SCADomain scaDomain; + private Session session; + private InitialContext context; + private Connection connection; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "service.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + sendJMSRequest(); + String response = receiveJMSResponse(); + assertEquals("jmsHello Petra", response); + } + + private void sendJMSRequest() throws NamingException, JMSException { + context = new InitialContext(new Properties()); + ConnectionFactory cf = (ConnectionFactory)context.lookup("ConnectionFactory"); + connection = cf.createConnection(); + connection.start(); + + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Destination toDest = (Destination)context.lookup("RequestQueue"); + + ObjectMessage m = session.createObjectMessage(); + m.setObject("Petra"); + + MessageProducer producer = session.createProducer(toDest); + producer.send(m); + } + + private String receiveJMSResponse() throws NamingException, JMSException { + Destination replyDest = (Destination)context.lookup("ResponseQueue"); + MessageConsumer consumer = session.createConsumer(replyDest); + Message m = consumer.receive(5000); + if (m == null) { + throw new RuntimeException("No reply message received"); + } + return ((ObjectMessage)m).getObject().toString(); + } + + @After + public void end() throws JMSException { + if (scaDomain != null) { + scaDomain.close(); + } + if (connection != null) { + connection.close(); + } + } +} diff --git a/java/sca/itest/jms/nulls/pom.xml b/java/sca/itest/jms/nulls/pom.xml new file mode 100644 index 0000000000..96c60fd63f --- /dev/null +++ b/java/sca/itest/jms/nulls/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-nulls + Apache Tuscany SCA iTest JMS Nulls + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6-SNAPSHOT + test + + + + + org.apache.activemq + activemq-core + 5.1.0 + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java new file mode 100644 index 0000000000..f7f930f443 --- /dev/null +++ b/java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the OneWay service. + */ +@Service(MyService.class) +public class ClientImpl implements MyService { + + private MyService serviceA; + + @Reference + public void setServiceA(MyService service) { + this.serviceA = service; + } + + public void sayHello() { + serviceA.sayHello(); + } + +} diff --git a/java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java b/java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java new file mode 100644 index 0000000000..5c43f02ca4 --- /dev/null +++ b/java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java @@ -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 org.apache.tuscany.sca.binding.jms; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyService { + + void sayHello(); + +} diff --git a/java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java b/java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java new file mode 100644 index 0000000000..89758becff --- /dev/null +++ b/java/sca/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java @@ -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 org.apache.tuscany.sca.binding.jms; + + +public class ServiceImpl implements MyService { + + public void sayHello() { + } + +} diff --git a/java/sca/itest/jms/nulls/src/main/resources/jndi.properties b/java/sca/itest/jms/nulls/src/main/resources/jndi.properties new file mode 100644 index 0000000000..bb431a592b --- /dev/null +++ b/java/sca/itest/jms/nulls/src/main/resources/jndi.properties @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory, ConnectionFactory2 + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic +topic.ServiceTopic = ServiceTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/nulls/src/main/resources/nulls.composite b/java/sca/itest/jms/nulls/src/main/resources/nulls.composite new file mode 100644 index 0000000000..99717d4c0f --- /dev/null +++ b/java/sca/itest/jms/nulls/src/main/resources/nulls.composite @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java b/java/sca/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java new file mode 100644 index 0000000000..e8aa803369 --- /dev/null +++ b/java/sca/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java @@ -0,0 +1,59 @@ +/* + * 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.binding.jms; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + */ +public class NullsTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "nulls.composite"); + } + + @Test + public void testSayHello() throws Exception { + MyService client1 = scaDomain.getService(MyService.class, "Client1"); + + client1.sayHello(); + + } + + @Test + public void testSayHelloObjectFormat() throws Exception { + MyService client1 = scaDomain.getService(MyService.class, "Client2"); + + client1.sayHello(); + + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/oneway-nocf/pom.xml b/java/sca/itest/jms/oneway-nocf/pom.xml new file mode 100644 index 0000000000..add122c3ca --- /dev/null +++ b/java/sca/itest/jms/oneway-nocf/pom.xml @@ -0,0 +1,109 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-oneway-nocf + Apache Tuscany SCA iTest JMS for a oneway service + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-policy + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java new file mode 100644 index 0000000000..4d00d2df0d --- /dev/null +++ b/java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the OneWay service. + */ +@Service(OneWayService.class) +public class OneWayClientImpl implements OneWayService { + + private OneWayService serviceA; + + @Reference + public void setServiceA(OneWayService service) { + this.serviceA = service; + } + + public void sayHello(String name) { + serviceA.sayHello(name); + } + +} diff --git a/java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java new file mode 100644 index 0000000000..377f227ceb --- /dev/null +++ b/java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java @@ -0,0 +1,29 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface OneWayService { + + @OneWay + void sayHello(String name); +} diff --git a/java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java new file mode 100644 index 0000000000..0036391696 --- /dev/null +++ b/java/sca/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java @@ -0,0 +1,34 @@ +/* + * 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.binding.jms; + +public class OneWayServiceImpl implements OneWayService { + + public static Object mutex = new Object(); + public static String name; + + public void sayHello(String name) { + OneWayServiceImpl.name = name; + synchronized (OneWayServiceImpl.mutex) { + OneWayServiceImpl.mutex.notify(); + } + } + +} diff --git a/java/sca/itest/jms/oneway-nocf/src/main/resources/jndi.properties b/java/sca/itest/jms/oneway-nocf/src/main/resources/jndi.properties new file mode 100644 index 0000000000..8934614a8a --- /dev/null +++ b/java/sca/itest/jms/oneway-nocf/src/main/resources/jndi.properties @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = SomeConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.SomeQueue = RequestQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite b/java/sca/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite new file mode 100644 index 0000000000..ec7b19ff98 --- /dev/null +++ b/java/sca/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite b/java/sca/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite new file mode 100644 index 0000000000..dff7d0c77f --- /dev/null +++ b/java/sca/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java b/java/sca/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java new file mode 100644 index 0000000000..adc7813bee --- /dev/null +++ b/java/sca/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java @@ -0,0 +1,58 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class OneWayTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "oneway/OneWayClient.composite", "oneway/OneWayService.composite"); + } + + @Test + public void testOneWayInvoked() throws Exception { + OneWayService oneWayService = scaDomain.getService(OneWayService.class, "OneWayClient"); + oneWayService.sayHello("Petra"); + synchronized (OneWayServiceImpl.mutex) { + // wait up to 10 seconds but it will likely be a lot less + // as the service invocation will wake this up earlier + OneWayServiceImpl.mutex.wait(10000); + } + assertEquals("Petra", OneWayServiceImpl.name); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/responsecf/pom.xml b/java/sca/itest/jms/responsecf/pom.xml new file mode 100644 index 0000000000..a25c83066e --- /dev/null +++ b/java/sca/itest/jms/responsecf/pom.xml @@ -0,0 +1,109 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-responsecf + Apache Tuscany SCA iTest JMS Response ConnectionFactory + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-policy + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java new file mode 100644 index 0000000000..1f310e0685 --- /dev/null +++ b/java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service. + */ +@Service(HelloWorldService.class) +public class HelloWorldClientImpl implements HelloWorldService { + + private HelloWorldService serviceA; + + @Reference + public void setServiceA(HelloWorldService service) { + this.serviceA = service; + } + + public String sayHello(String name) { + return serviceA.sayHello(name); + } + +} diff --git a/java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java new file mode 100644 index 0000000000..28b281a0c4 --- /dev/null +++ b/java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java @@ -0,0 +1,26 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloWorldService { + String sayHello(String name); +} diff --git a/java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2c6d9d0d17 --- /dev/null +++ b/java/sca/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java @@ -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 org.apache.tuscany.sca.binding.jms; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public String sayHello(String name) { + if ("bang".equals(name)) { + throw new RuntimeException("blem wit"); + } + return "jmsHello " + name; + } + +} diff --git a/java/sca/itest/jms/responsecf/src/main/resources/cf/client.composite b/java/sca/itest/jms/responsecf/src/main/resources/cf/client.composite new file mode 100644 index 0000000000..3e16e794cb --- /dev/null +++ b/java/sca/itest/jms/responsecf/src/main/resources/cf/client.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/responsecf/src/main/resources/cf/service.composite b/java/sca/itest/jms/responsecf/src/main/resources/cf/service.composite new file mode 100644 index 0000000000..9a13b0cb0e --- /dev/null +++ b/java/sca/itest/jms/responsecf/src/main/resources/cf/service.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/responsecf/src/main/resources/jndi.properties b/java/sca/itest/jms/responsecf/src/main/resources/jndi.properties new file mode 100644 index 0000000000..a41e42950e --- /dev/null +++ b/java/sca/itest/jms/responsecf/src/main/resources/jndi.properties @@ -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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory, ResponseCF + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.DestQueueA = RequestQueue +queue.RespQueueA = ResponseQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java b/java/sca/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java new file mode 100644 index 0000000000..fd7b167963 --- /dev/null +++ b/java/sca/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java @@ -0,0 +1,53 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a response ConnectionFactory + */ +public class ResponseCFTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = + SCADomain.newInstance("http://localhost", "/", "cf/client.composite", "cf/service.composite"); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldClient"); + assertEquals("jmsHello Petra", helloWorldService.sayHello("Petra")); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/selectors/pom.xml b/java/sca/itest/jms/selectors/pom.xml new file mode 100644 index 0000000000..95d9681da7 --- /dev/null +++ b/java/sca/itest/jms/selectors/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-selectors + Apache Tuscany SCA iTest JMS Tests For Selectors + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6-SNAPSHOT + test + + + + + org.apache.activemq + activemq-core + 5.1.0 + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java new file mode 100644 index 0000000000..0ad6440593 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the OneWay service. + */ +@Service(SelectorService.class) +public class ClientImpl implements SelectorService { + + private SelectorService serviceA; + + @Reference + public void setServiceA(SelectorService service) { + this.serviceA = service; + } + + public void sayHello(String name) { + serviceA.sayHello(name); + } + +} diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java new file mode 100644 index 0000000000..f26a3ce68b --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java @@ -0,0 +1,29 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface SelectorService { + + @OneWay + void sayHello(String name); +} diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java new file mode 100644 index 0000000000..fb53c877e6 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.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.binding.jms; + +import java.util.ArrayList; +import java.util.List; + +public class SelectorServiceImpl1 implements SelectorService { + + public static Object lock = new Object(); + public static List names = new ArrayList(); + + public void sayHello(String name) { + System.out.println("SelectorServiceImpl1 " + name); + SelectorServiceImpl1.names.add(name); + if (names.size() == 2) { + synchronized (SelectorServiceImpl1.lock) { + SelectorServiceImpl1.lock.notify(); + } + } + } + +} diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java new file mode 100644 index 0000000000..1bbaf5d6f4 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java @@ -0,0 +1,38 @@ +/* + * 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.binding.jms; + +public class SelectorServiceImpl2 implements SelectorService { + + public static Object lock = new Object(); + public static String name; + + public void sayHello(String name) { + if (SelectorServiceImpl2.name != null) { + throw new IllegalStateException("name already set"); + } + System.out.println("SelectorServiceImpl2 " + name); + SelectorServiceImpl2.name = name; + synchronized (SelectorServiceImpl2.lock) { + SelectorServiceImpl2.lock.notify(); + } + } + +} diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java new file mode 100644 index 0000000000..4bdc4edcb5 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java @@ -0,0 +1,38 @@ +/* + * 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.binding.jms; + +public class SelectorServiceImpl3 implements SelectorService { + + public static Object lock = new Object(); + public static String name; + + public void sayHello(String name) { + if (SelectorServiceImpl3.name != null) { + throw new IllegalStateException("name already set"); + } + System.out.println("SelectorServiceImpl3 " + name); + SelectorServiceImpl3.name = name; + synchronized (SelectorServiceImpl3.lock) { + SelectorServiceImpl3.lock.notify(); + } + } + +} diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java new file mode 100644 index 0000000000..2b2c5d571a --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java @@ -0,0 +1,32 @@ +/* + * 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.binding.jms.operationselector.jmsdefault; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetings(String name); + +} + diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..9ab8221417 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java @@ -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 org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault; + +import org.osoa.sca.annotations.Reference; + + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldService helloWorldService1; + + @Reference + protected HelloWorldService helloWorldService2; + + public String getGreetings(String name){ + return helloWorldService1.getGreetingsOne(name) + " " + + helloWorldService1.getGreetingsTwo(name) + " " + + helloWorldService2.getGreetingsOne(name) + " " + + helloWorldService1.getGreetingsThree(name); + } +} + diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java new file mode 100644 index 0000000000..c7bdba492f --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java @@ -0,0 +1,38 @@ +/* + * 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.binding.jms.operationselector.jmsdefault; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetingsOne(String name); + + public String getGreetingsTwo(String name); + + public String getGreetingsThree(String name); + + public String getGreetingsFour(String name); + +} + diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..b2df9137c8 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.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.binding.jms.operationselector.jmsdefault; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public String getGreetingsOne(String name){ + String response = "Hello One " + name; + System.out.println("getGreetingsOne: " + response); + return response; + } + + public String getGreetingsTwo(String name){ + String response = "Hello Two " + name; + System.out.println("getGreetingsTwo: " + response); + return response; + } + + public String getGreetingsThree(String name){ + String response = "Hello Three " + name; + System.out.println("getGreetingsThree: " + response); + return response; + } + + public String getGreetingsFour(String name){ + String response = "Hello Four " + name; + System.out.println("getGreetingsFour: " + response); + return response; + } +} + diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java new file mode 100644 index 0000000000..573ae8d068 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java @@ -0,0 +1,32 @@ +/* + * 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.binding.jms.operationselector.jmsuserprop; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldReference { + + public String getGreetings(String name); + +} + diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java new file mode 100644 index 0000000000..744612bc14 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java @@ -0,0 +1,36 @@ +/* + * 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.binding.jms.operationselector.jmsuserprop; + +import org.osoa.sca.annotations.Reference; + + +public class HelloWorldReferenceImpl implements HelloWorldReference { + + @Reference + protected HelloWorldService helloWorldService1; + + + public String getGreetings(String name){ + return helloWorldService1.getGreetingsOne(name) + " " + + helloWorldService1.getGreetingsTwo(name) + " " + + helloWorldService1.getGreetingsThree(name); + } +} + diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java new file mode 100644 index 0000000000..7dca243bdf --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java @@ -0,0 +1,38 @@ +/* + * 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.binding.jms.operationselector.jmsuserprop; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetingsOne(String name); + + public String getGreetingsTwo(String name); + + public String getGreetingsThree(String name); + + public String getGreetingsFour(String name); + +} + diff --git a/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..724de6ff7c --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.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.binding.jms.operationselector.jmsuserprop; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public String getGreetingsOne(String name){ + String response = "Hello One " + name; + System.out.println("getGreetingsOne: " + response); + return response; + } + + public String getGreetingsTwo(String name){ + String response = "Hello Two " + name; + System.out.println("getGreetingsTwo: " + response); + return response; + } + + public String getGreetingsThree(String name){ + String response = "Hello Three " + name; + System.out.println("getGreetingsThree: " + response); + return response; + } + + public String getGreetingsFour(String name){ + String response = "Hello Four " + name; + System.out.println("getGreetingsFour: " + response); + return response; + } +} + diff --git a/java/sca/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite b/java/sca/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite new file mode 100644 index 0000000000..8f6994b843 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + getGreetingsThree + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite b/java/sca/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite new file mode 100644 index 0000000000..1aa5444e17 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite @@ -0,0 +1,62 @@ + + + + + + + + + + + + getGreetingsOne + + + + + getGreetingsThree + + + + + getGreetingsTwo + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/sca/itest/jms/selectors/src/main/resources/jndi.properties b/java/sca/itest/jms/selectors/src/main/resources/jndi.properties new file mode 100644 index 0000000000..bb431a592b --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/resources/jndi.properties @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory, ConnectionFactory2 + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic +topic.ServiceTopic = ServiceTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/selectors/src/main/resources/selectors/selectors.composite b/java/sca/itest/jms/selectors/src/main/resources/selectors/selectors.composite new file mode 100644 index 0000000000..83fb50531b --- /dev/null +++ b/java/sca/itest/jms/selectors/src/main/resources/selectors/selectors.composite @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java b/java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java new file mode 100644 index 0000000000..46ca6b9844 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java @@ -0,0 +1,63 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.HelloWorldReference; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class OperationselectorJMSDefaultTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmsdefault/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldReference = ((SCAClient)node).getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); + + assertEquals("Hello One Fred Bloggs Hello Two Fred Bloggs Hello Three Fred Bloggs Hello Four Fred Bloggs", helloWorldReference.getGreetings("Fred Bloggs")); + + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java b/java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java new file mode 100644 index 0000000000..c9cf1a80c8 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java @@ -0,0 +1,63 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.HelloWorldReference; +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class OperationselectorJMSUserPropTestCase { + + private static SCANode node; + + @Before + public void init() { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("jmsuserprop/helloworld.composite", + new SCAContribution("test", "./target/classes")); + + node.start(); + } + + @Test + public void testHelloWorldCreate() throws Exception { + HelloWorldReference helloWorldReference = ((SCAClient)node).getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); + + assertEquals("Hello One Fred Bloggs Hello Four Fred Bloggs Hello Two Fred Bloggs", helloWorldReference.getGreetings("Fred Bloggs")); + + } + + @After + public void end() { + if (node != null) { + node.stop(); + } + } +} diff --git a/java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java b/java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java new file mode 100644 index 0000000000..ea548c22e6 --- /dev/null +++ b/java/sca/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java @@ -0,0 +1,75 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + */ +public class SelectorsTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "selectors/selectors.composite"); + } + + @Test + public void testSayHello() throws Exception { + SelectorService client1 = scaDomain.getService(SelectorService.class, "Client1"); + SelectorService client2 = scaDomain.getService(SelectorService.class, "Client2"); + + client1.sayHello("petra"); + client2.sayHello("beate"); + + // wait for up to 5 seconds but should wake up as soon as done + synchronized(SelectorServiceImpl2.lock) { + if (SelectorServiceImpl2.name == null) { + SelectorServiceImpl2.lock.wait(5000); + } + } + synchronized(SelectorServiceImpl3.lock) { + if (SelectorServiceImpl3.name == null) { + SelectorServiceImpl3.lock.wait(5000); + } + } + synchronized(SelectorServiceImpl1.lock) { + if (SelectorServiceImpl1.names.size() != 2) { + SelectorServiceImpl1.lock.wait(5000); + } + } + + assertEquals("petra", SelectorServiceImpl2.name); + assertEquals("beate", SelectorServiceImpl3.name); + assertEquals(2, SelectorServiceImpl1.names.size()); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/topics/pom.xml b/java/sca/itest/jms/topics/pom.xml new file mode 100644 index 0000000000..febdc1eec7 --- /dev/null +++ b/java/sca/itest/jms/topics/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-topics + Apache Tuscany SCA JMS Tests for topics + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6-SNAPSHOT + test + + + + + org.apache.activemq + activemq-core + 5.1.0 + test + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java new file mode 100644 index 0000000000..4d00d2df0d --- /dev/null +++ b/java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java @@ -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.binding.jms; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the OneWay service. + */ +@Service(OneWayService.class) +public class OneWayClientImpl implements OneWayService { + + private OneWayService serviceA; + + @Reference + public void setServiceA(OneWayService service) { + this.serviceA = service; + } + + public void sayHello(String name) { + serviceA.sayHello(name); + } + +} diff --git a/java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java new file mode 100644 index 0000000000..377f227ceb --- /dev/null +++ b/java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java @@ -0,0 +1,29 @@ +/* + * 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.binding.jms; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface OneWayService { + + @OneWay + void sayHello(String name); +} diff --git a/java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java new file mode 100644 index 0000000000..0036391696 --- /dev/null +++ b/java/sca/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java @@ -0,0 +1,34 @@ +/* + * 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.binding.jms; + +public class OneWayServiceImpl implements OneWayService { + + public static Object mutex = new Object(); + public static String name; + + public void sayHello(String name) { + OneWayServiceImpl.name = name; + synchronized (OneWayServiceImpl.mutex) { + OneWayServiceImpl.mutex.notify(); + } + } + +} diff --git a/java/sca/itest/jms/topics/src/main/resources/jndi.properties b/java/sca/itest/jms/topics/src/main/resources/jndi.properties new file mode 100644 index 0000000000..9888d5843b --- /dev/null +++ b/java/sca/itest/jms/topics/src/main/resources/jndi.properties @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic +topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/topics/src/main/resources/topics/TopicsClient.composite b/java/sca/itest/jms/topics/src/main/resources/topics/TopicsClient.composite new file mode 100644 index 0000000000..cf876932d9 --- /dev/null +++ b/java/sca/itest/jms/topics/src/main/resources/topics/TopicsClient.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/topics/src/main/resources/topics/TopicsService.composite b/java/sca/itest/jms/topics/src/main/resources/topics/TopicsService.composite new file mode 100644 index 0000000000..2f2678ab0b --- /dev/null +++ b/java/sca/itest/jms/topics/src/main/resources/topics/TopicsService.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java b/java/sca/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java new file mode 100644 index 0000000000..f0b7537bcc --- /dev/null +++ b/java/sca/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java @@ -0,0 +1,58 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * This shows how to test the JMS binding using a simple HelloWorld application. + */ +public class TopicsTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "topics/TopicsClient.composite", "topics/TopicsService.composite"); + } + + @Test + public void testOneWayInvoked() throws Exception { + OneWayService oneWayService = scaDomain.getService(OneWayService.class, "OneWayClient"); + oneWayService.sayHello("Petra"); + synchronized (OneWayServiceImpl.mutex) { + // wait up to 10 seconds but it will likely be a lot less + // as the service invocation will wake this up earlier + OneWayServiceImpl.mutex.wait(10000); + } + assertEquals("Petra", OneWayServiceImpl.name); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} diff --git a/java/sca/itest/jms/ttl/pom.xml b/java/sca/itest/jms/ttl/pom.xml new file mode 100644 index 0000000000..b87e6b55ec --- /dev/null +++ b/java/sca/itest/jms/ttl/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../../pom.xml + + itest-jms-ttl + Apache Tuscany SCA iTest JMS Time To Live + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6-SNAPSHOT + test + + + + + org.apache.activemq + activemq-core + 5.1.0 + + + + + + ${artifactId} + + diff --git a/java/sca/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java b/java/sca/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java new file mode 100644 index 0000000000..336fecf67b --- /dev/null +++ b/java/sca/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java @@ -0,0 +1,904 @@ +/* + * 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 itest; + +import java.io.Serializable; +import java.util.Enumeration; +import java.util.Hashtable; + +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.ConnectionConsumer; +import javax.jms.ConnectionFactory; +import javax.jms.ConnectionMetaData; +import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.ServerSessionPool; +import javax.jms.Session; +import javax.jms.StreamMessage; +import javax.jms.TemporaryQueue; +import javax.jms.TemporaryTopic; +import javax.jms.TextMessage; +import javax.jms.Topic; +import javax.jms.TopicSubscriber; +import javax.naming.Binding; +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NameClassPair; +import javax.naming.NameParser; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; + +/** + * Some classes that mock up various JMS interfaces with the end result + * of having the Time-To-Live value set on the static timeToLive + * + * This class is referenced from the AMQ jndi.properties file + */ +public class MockInitialContextFactory extends org.apache.activemq.jndi.ActiveMQInitialContextFactory{ + + public static Object lock = new Object(); + public static Long timeToLive; + + public Context getInitialContext(Hashtable environment) throws NamingException { + return new Context() { + + public Object addToEnvironment(String propName, Object propVal) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public void bind(Name name, Object obj) throws NamingException { + // TODO Auto-generated method stub + + } + + public void bind(String name, Object obj) throws NamingException { + // TODO Auto-generated method stub + + } + + public void close() throws NamingException { + // TODO Auto-generated method stub + + } + + public Name composeName(Name name, Name prefix) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public String composeName(String name, String prefix) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public Context createSubcontext(Name name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public Context createSubcontext(String name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public void destroySubcontext(Name name) throws NamingException { + // TODO Auto-generated method stub + + } + + public void destroySubcontext(String name) throws NamingException { + // TODO Auto-generated method stub + + } + + public Hashtable getEnvironment() throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public String getNameInNamespace() throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public NameParser getNameParser(Name name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public NameParser getNameParser(String name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public NamingEnumeration list(Name name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public NamingEnumeration list(String name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public NamingEnumeration listBindings(Name name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public NamingEnumeration listBindings(String name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public Object lookup(Name name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public Object lookup(String name) throws NamingException { + if (name.endsWith("ConnectionFactory")) { + return new ConnectionFactory() { + public Connection createConnection() throws JMSException { + return new Connection(){ + + public void close() throws JMSException { + // TODO Auto-generated method stub + + } + + public ConnectionConsumer createConnectionConsumer(Destination arg0, + String arg1, + ServerSessionPool arg2, + int arg3) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public ConnectionConsumer createDurableConnectionConsumer(Topic arg0, + String arg1, + String arg2, + ServerSessionPool arg3, + int arg4) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public Session createSession(boolean arg0, int arg1) throws JMSException { + // TODO Auto-generated method stub + return new Session() { + + public void close() throws JMSException { + // TODO Auto-generated method stub + + } + + public void commit() throws JMSException { + // TODO Auto-generated method stub + + } + + public QueueBrowser createBrowser(Queue arg0) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public QueueBrowser createBrowser(Queue arg0, String arg1) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public BytesMessage createBytesMessage() throws JMSException { + // TODO Auto-generated method stub + return new BytesMessage() { + + public long getBodyLength() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public boolean readBoolean() throws JMSException { + // TODO Auto-generated method stub + return false; + } + + public byte readByte() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public int readBytes(byte[] arg0) throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public int readBytes(byte[] arg0, int arg1) throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public char readChar() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public double readDouble() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public float readFloat() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public int readInt() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public long readLong() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public short readShort() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public String readUTF() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public int readUnsignedByte() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public int readUnsignedShort() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public void reset() throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeBoolean(boolean arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeByte(byte arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeBytes(byte[] arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeBytes(byte[] arg0, int arg1, int arg2) + throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeChar(char arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeDouble(double arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeFloat(float arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeInt(int arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeLong(long arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeObject(Object arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeShort(short arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void writeUTF(String arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void acknowledge() throws JMSException { + // TODO Auto-generated method stub + + } + + public void clearBody() throws JMSException { + // TODO Auto-generated method stub + + } + + public void clearProperties() throws JMSException { + // TODO Auto-generated method stub + + } + + public boolean getBooleanProperty(String arg0) throws JMSException { + // TODO Auto-generated method stub + return false; + } + + public byte getByteProperty(String arg0) throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public double getDoubleProperty(String arg0) throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public float getFloatProperty(String arg0) throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public int getIntProperty(String arg0) throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public String getJMSCorrelationID() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public byte[] getJMSCorrelationIDAsBytes() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public int getJMSDeliveryMode() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public Destination getJMSDestination() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public long getJMSExpiration() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public String getJMSMessageID() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public int getJMSPriority() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public boolean getJMSRedelivered() throws JMSException { + // TODO Auto-generated method stub + return false; + } + + public Destination getJMSReplyTo() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public long getJMSTimestamp() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public String getJMSType() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public long getLongProperty(String arg0) throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public Object getObjectProperty(String arg0) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public Enumeration getPropertyNames() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public short getShortProperty(String arg0) throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public String getStringProperty(String arg0) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public boolean propertyExists(String arg0) throws JMSException { + // TODO Auto-generated method stub + return false; + } + + public void setBooleanProperty(String arg0, boolean arg1) + throws JMSException { + // TODO Auto-generated method stub + + } + + public void setByteProperty(String arg0, byte arg1) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setDoubleProperty(String arg0, double arg1) + throws JMSException { + // TODO Auto-generated method stub + + } + + public void setFloatProperty(String arg0, float arg1) + throws JMSException { + // TODO Auto-generated method stub + + } + + public void setIntProperty(String arg0, int arg1) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSCorrelationID(String arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSCorrelationIDAsBytes(byte[] arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSDeliveryMode(int arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSDestination(Destination arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSExpiration(long arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSMessageID(String arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSPriority(int arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSRedelivered(boolean arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSReplyTo(Destination arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSTimestamp(long arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setJMSType(String arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setLongProperty(String arg0, long arg1) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setObjectProperty(String arg0, Object arg1) + throws JMSException { + // TODO Auto-generated method stub + + } + + public void setShortProperty(String arg0, short arg1) + throws JMSException { + // TODO Auto-generated method stub + + } + + public void setStringProperty(String arg0, String arg1) + throws JMSException { + // TODO Auto-generated method stub + + }}; + } + + public MessageConsumer createConsumer(Destination arg0) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public MessageConsumer createConsumer(Destination arg0, String arg1) + throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public MessageConsumer createConsumer(Destination arg0, + String arg1, + boolean arg2) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1) + throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public TopicSubscriber createDurableSubscriber(Topic arg0, + String arg1, + String arg2, + boolean arg3) + throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public MapMessage createMapMessage() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public Message createMessage() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public ObjectMessage createObjectMessage() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public ObjectMessage createObjectMessage(Serializable arg0) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public MessageProducer createProducer(Destination arg0) throws JMSException { + return new MessageProducer() { + + public void close() throws JMSException { + // TODO Auto-generated method stub + + } + + public int getDeliveryMode() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public Destination getDestination() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public boolean getDisableMessageID() throws JMSException { + // TODO Auto-generated method stub + return false; + } + + public boolean getDisableMessageTimestamp() throws JMSException { + // TODO Auto-generated method stub + return false; + } + + public int getPriority() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public long getTimeToLive() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public void send(Message arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void send(Destination arg0, Message arg1) throws JMSException { + // TODO Auto-generated method stub + + } + + public void send(Message arg0, int arg1, int arg2, long arg3) + throws JMSException { + // TODO Auto-generated method stub + + } + + public void send(Destination arg0, + Message arg1, + int arg2, + int arg3, + long arg4) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setDeliveryMode(int arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setDisableMessageID(boolean arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setDisableMessageTimestamp(boolean arg0) + throws JMSException { + // TODO Auto-generated method stub + + } + + public void setPriority(int arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setTimeToLive(long arg0) throws JMSException { + MockInitialContextFactory.timeToLive = Long.valueOf(arg0); + synchronized(MockInitialContextFactory.lock) { + MockInitialContextFactory.lock.notifyAll(); + } + }}; + } + + public Queue createQueue(String arg0) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public StreamMessage createStreamMessage() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public TemporaryQueue createTemporaryQueue() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public TemporaryTopic createTemporaryTopic() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public TextMessage createTextMessage() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public TextMessage createTextMessage(String arg0) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public Topic createTopic(String arg0) throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public int getAcknowledgeMode() throws JMSException { + // TODO Auto-generated method stub + return 0; + } + + public MessageListener getMessageListener() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public boolean getTransacted() throws JMSException { + // TODO Auto-generated method stub + return false; + } + + public void recover() throws JMSException { + // TODO Auto-generated method stub + + } + + public void rollback() throws JMSException { + // TODO Auto-generated method stub + + } + + public void run() { + // TODO Auto-generated method stub + + } + + public void setMessageListener(MessageListener arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void unsubscribe(String arg0) throws JMSException { + // TODO Auto-generated method stub + + }}; + } + + public String getClientID() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public ExceptionListener getExceptionListener() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public ConnectionMetaData getMetaData() throws JMSException { + // TODO Auto-generated method stub + return null; + } + + public void setClientID(String arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void setExceptionListener(ExceptionListener arg0) throws JMSException { + // TODO Auto-generated method stub + + } + + public void start() throws JMSException { + // TODO Auto-generated method stub + + } + + public void stop() throws JMSException { + // TODO Auto-generated method stub + + }}; + } + public Connection createConnection(String arg0, String arg1) throws JMSException { + return null; + }}; + } else { + return new Queue(){ + public String getQueueName() throws JMSException { + return null; + }}; + } + } + + public Object lookupLink(Name name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public Object lookupLink(String name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public void rebind(Name name, Object obj) throws NamingException { + // TODO Auto-generated method stub + + } + + public void rebind(String name, Object obj) throws NamingException { + // TODO Auto-generated method stub + + } + + public Object removeFromEnvironment(String propName) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public void rename(Name oldName, Name newName) throws NamingException { + // TODO Auto-generated method stub + + } + + public void rename(String oldName, String newName) throws NamingException { + // TODO Auto-generated method stub + + } + + public void unbind(Name name) throws NamingException { + // TODO Auto-generated method stub + + } + + public void unbind(String name) throws NamingException { + // TODO Auto-generated method stub + + }}; + } + +} diff --git a/java/sca/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java b/java/sca/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java new file mode 100644 index 0000000000..0819e8474f --- /dev/null +++ b/java/sca/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java @@ -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 org.apache.tuscany.sca.binding.jms; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface ClientIface { + + @OneWay + void sayHello(String s); +} diff --git a/java/sca/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/java/sca/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java new file mode 100644 index 0000000000..4467d91f0d --- /dev/null +++ b/java/sca/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java @@ -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 org.apache.tuscany.sca.binding.jms; + +import org.osoa.sca.annotations.Reference; + +/** + * This class implements the OneWay service. + */ +public class ClientImpl implements ClientIface { + + private ClientIface serviceA; + + @Reference + public void setServiceA(ClientIface service) { + this.serviceA = service; + } + + public void sayHello(String name) { + serviceA.sayHello(name); + } + +} diff --git a/java/sca/itest/jms/ttl/src/main/resources/jndi.properties b/java/sca/itest/jms/ttl/src/main/resources/jndi.properties new file mode 100644 index 0000000000..040ec282d7 --- /dev/null +++ b/java/sca/itest/jms/ttl/src/main/resources/jndi.properties @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = itest.MockInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory, ConnectionFactory2 + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic +topic.ServiceTopic = ServiceTopic + +# END SNIPPET: jndi diff --git a/java/sca/itest/jms/ttl/src/main/resources/ttl.composite b/java/sca/itest/jms/ttl/src/main/resources/ttl.composite new file mode 100644 index 0000000000..9065148c0f --- /dev/null +++ b/java/sca/itest/jms/ttl/src/main/resources/ttl.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/java/sca/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java b/java/sca/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java new file mode 100644 index 0000000000..70b945798b --- /dev/null +++ b/java/sca/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java @@ -0,0 +1,63 @@ +/* + * 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.binding.jms; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import itest.MockInitialContextFactory; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + */ +public class TTLTestCase { + + private static SCADomain scaDomain; + + @Before + public void init() { + scaDomain = SCADomain.newInstance("http://localhost", "/", "ttl.composite"); + } + + @Test + public void testSayHello() throws Exception { + ClientIface client1 = scaDomain.getService(ClientIface.class, "Client1"); + + client1.sayHello("petra"); + + synchronized(MockInitialContextFactory.lock) { + if (MockInitialContextFactory.timeToLive == null) { + MockInitialContextFactory.lock.wait(1000); + } + } + + assertNotNull(MockInitialContextFactory.timeToLive); + assertEquals(123, MockInitialContextFactory.timeToLive.longValue()); + } + + @After + public void end() { + if (scaDomain != null) { + scaDomain.close(); + } + } +} -- cgit v1.2.3