From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../contrib/itest/bindings/bindingsclient/pom.xml | 64 ++ .../tuscany/sca/itest/SCATestToolService.java | 40 ++ .../src/main/resources/bindingsclient.composite | 47 ++ .../src/main/resources/wsdl/testtool.wsdl | 272 ++++++++ .../bindingsclient/src/main/webapp/SCATestTool.jsp | 130 ++++ .../bindingsclient/src/main/webapp/WEB-INF/web.xml | 31 + .../tuscany/sca/itest/SCATestToolServerTest.java | 45 ++ .../sca/itest/WSBindingsClientTestCase.java | 80 +++ .../tuscany/sca/util/SCATestUtilityServerTest.java | 46 ++ .../itest/bindings/bindingscomposite/pom.xml | 58 ++ .../tuscany/sca/itest/SCADataTypeHelper.java | 341 ++++++++++ .../sca/itest/SCADataTypeHelperException.java | 29 + .../sca/itest/SCATestToolCallbackService.java | 27 + .../tuscany/sca/itest/SCATestToolServer.java | 46 ++ .../tuscany/sca/itest/SCATestToolService.java | 39 ++ .../tuscany/sca/itest/SCATestToolServiceImpl.java | 76 +++ .../tuscany/sca/util/SCATestUtilityService.java | 64 ++ .../resources/bindingscomposite-system.composite | 36 ++ .../src/main/resources/bindingscomposite.composite | 49 ++ .../src/main/resources/wsdl/testtool.wsdl | 272 ++++++++ .../src/main/resources/wsdl/testutility.wsdl | 704 +++++++++++++++++++++ .../sca/itest/SCATestToolServerTestCase.java | 45 ++ .../contrib/itest/bindings/bindingsutility/pom.xml | 59 ++ .../sca/itest/SCATestToolCallbackService.java | 28 + .../tuscany/sca/util/SCATestUtilityServer.java | 46 ++ .../tuscany/sca/util/SCATestUtilityService.java | 64 ++ .../sca/util/SCATestUtilityServiceImpl.java | 157 +++++ .../resources/bindingsutility-system.composite | 36 ++ .../src/main/resources/bindingsutility.composite | 39 ++ .../src/main/resources/wsdl/testutility.wsdl | 704 +++++++++++++++++++++ .../sca/util/SCATestUtilityServerTestCase.java | 45 ++ sandbox/old/contrib/itest/bindings/pom.xml | 41 ++ sandbox/old/contrib/itest/conversations/pom.xml | 45 ++ .../conversational/ConversationalCallback.java | 50 ++ .../itest/conversational/ConversationalClient.java | 48 ++ .../ConversationalReferenceClient.java | 36 ++ .../conversational/ConversationalService.java | 62 ++ .../impl/ConversationAgeComponentImpl.java | 75 +++ .../impl/ConversationIdComponentImpl.java | 47 ++ .../conversational/impl/ConversationIdService.java | 29 + .../impl/ConversationMaxIdleComponentImpl.java | 75 +++ .../impl/ConversationalClientStatefulImpl.java | 249 ++++++++ .../impl/ConversationalClientStatelessImpl.java | 243 +++++++ .../impl/ConversationalReferenceClientImpl.java | 43 ++ .../impl/ConversationalServiceStatefulImpl.java | 117 ++++ .../impl/ConversationalServiceStatelessImpl.java | 121 ++++ .../impl/ConversationalServiceStatelessScope.java | 93 +++ .../apache/tuscany/sca/test/AnotherService.java | 37 ++ .../tuscany/sca/test/AnotherServiceImpl.java | 69 ++ .../tuscany/sca/test/ConversationsCallback.java | 34 + .../tuscany/sca/test/ConversationsClient.java | 31 + .../tuscany/sca/test/ConversationsClient2.java | 30 + .../tuscany/sca/test/ConversationsClientImpl.java | 496 +++++++++++++++ .../sca/test/ConversationsLifeCycleService.java | 38 ++ .../test/ConversationsLifeCycleServiceImpl.java | 97 +++ .../tuscany/sca/test/ConversationsService.java | 43 ++ .../tuscany/sca/test/ConversationsServiceImpl.java | 147 +++++ .../src/main/resources/ConversationAge.composite | 31 + .../src/main/resources/ConversationsTest.composite | 43 ++ .../src/main/resources/conversationId.composite | 27 + .../src/main/resources/conversational.composite | 64 ++ .../conversational/ConversationIdTestCase.java | 55 ++ .../conversational/ConversationalAgeTestCase.java | 95 +++ .../conversational/ConversationalJ2SETestCase.java | 84 +++ .../conversational/ConversationalTestCase.java | 322 ++++++++++ .../sca/test/ConversationsTestCaseFIXME.java | 51 ++ .../old/contrib/itest/interop-xsq-client/pom.xml | 60 ++ .../src/main/resources/META-INF/README.txt | 35 + .../src/test/java/interop/ClientTestCase.java | 77 +++ .../src/test/resources/META-INF/sca/test.scdl | 31 + .../resources/META-INF/tuscany/binding.axis2.scdl | 39 ++ .../META-INF/tuscany/databinding.axiom.scdl | 52 ++ .../META-INF/tuscany/databinding.sdo.scdl | 60 ++ .../resources/META-INF/tuscany/interface.wsdl.scdl | 55 ++ .../META-INF/tuscany/test-extensions.scdl | 29 + .../src/test/resources/wsdl/sq.wsdl | 142 +++++ sandbox/old/contrib/itest/pom.xml.off | 84 +++ sandbox/old/contrib/itest/propertyTest/pom.xml.off | 40 ++ .../tuscany/sca/test/property/ABComponent.java | 29 + .../tuscany/sca/test/property/ABComponentImpl.java | 82 +++ .../tuscany/sca/test/property/CDComponent.java | 30 + .../tuscany/sca/test/property/CDComponentImpl.java | 85 +++ .../sca/test/property/ComplexPropertyBean.java | 69 ++ .../tuscany/sca/test/property/OverrideService.java | 25 + .../sca/test/property/OverrideServiceImpl.java | 24 + .../sca/test/property/PropertyComponent.java | 28 + .../sca/test/property/PropertyComponentImpl.java | 52 ++ .../tuscany/sca/test/property/PropertyService.java | 24 + .../property/primitives/ConstructorPrimitives.java | 90 +++ .../test/property/primitives/PrimitiveService.java | 57 ++ .../primitives/ProtectedFieldPrimitives.java | 72 +++ .../primitives/ProtectedSetterPrimitives.java | 100 +++ .../property/primitives/PublicFieldPrimitives.java | 72 +++ .../primitives/PublicSetterPrimitives.java | 100 +++ .../src/main/resources/META-INF/sca/default.scdl | 117 ++++ .../main/resources/META-INF/sca/fileProperty.txt | 1 + .../main/resources/META-INF/sca/primitives.scdl | 78 +++ .../sca/test/property/PropertyTestComponent.java | 100 +++ .../primitives/PrimitiveTestComponent.java | 68 ++ .../propertyTest/src/test/resources/itest.scdl | 65 ++ sandbox/old/contrib/itest/spec-api/pom.xml | 45 ++ .../apache/tuscany/sca/test/spec/BasicService.java | 26 + .../apache/tuscany/sca/test/spec/MathService.java | 25 + .../tuscany/sca/test/spec/MyListService.java | 28 + .../tuscany/sca/test/spec/MyListServiceByYear.java | 27 + .../apache/tuscany/sca/test/spec/MyService.java | 29 + .../tuscany/sca/test/spec/MyServiceByDate.java | 29 + .../tuscany/sca/test/spec/MyTotalService.java | 23 + .../tuscany/sca/test/spec/SCAComponentService.java | 25 + .../sca/test/spec/impl/BasicServiceImpl.java | 49 ++ .../sca/test/spec/impl/MathServiceImpl.java | 31 + .../sca/test/spec/impl/MyListServiceImpl.java | 73 +++ .../tuscany/sca/test/spec/impl/MyServiceImpl.java | 112 ++++ .../sca/test/spec/impl/MyTotalServiceImpl.java | 78 +++ .../src/main/resources/BasicService.composite | 30 + .../src/main/resources/CompositeTest.composite | 33 + .../src/main/resources/MathService.composite | 29 + .../src/main/resources/myListService.composite | 33 + .../main/resources/myServiceInComposite.composite | 50 ++ .../main/resources/myServiceInRecursive.composite | 50 ++ .../src/main/resources/mySimpleService.composite | 35 + .../resources/mySimpleServiceInRecursive.composite | 45 ++ .../mySimpleServiceInRecursive2.composite | 44 ++ .../src/main/resources/myTotalService.composite | 34 + .../resources/myTotalServiceInComposite.composite | 45 ++ ...erviceInCompositeForReferenceOverride.composite | 88 +++ .../resources/myTotalServiceInRecursive.composite | 64 ++ ...erviceInRecursiveForReferenceOverride.composite | 56 ++ .../src/main/resources/myservice.composite | 52 ++ .../sca/test/spec/ComponentContextTestCase.java | 61 ++ ...ComponentServiceReferenceListTestCaseFIXME.java | 50 ++ .../spec/ComponentServiceReferenceTestCase.java | 64 ++ .../tuscany/sca/test/spec/ComponentTestCase.java | 98 +++ .../CompositeOneService2LevelTestCaseFIXME.java | 106 ++++ .../sca/test/spec/CompositeOneServiceTestCase.java | 60 ++ ...siteServiceReferenceForRefOverrideTestCase.java | 80 +++ .../spec/CompositeServiceReferenceTestCase.java | 92 +++ .../tuscany/sca/test/spec/CompositeTestCase.java | 78 +++ sandbox/old/contrib/itest/specTest/pom.xml.off | 40 ++ .../sca/test/spec/ComponentContextTester.java | 45 ++ .../sca/test/spec/ComponentContextTesterImpl.java | 56 ++ .../sca/test/spec/IdentifiableComponent.java | 34 + .../tuscany/sca/test/spec/IdentityService.java | 26 + .../tuscany/sca/test/spec/MyListService.java | 28 + .../tuscany/sca/test/spec/MyListServiceByYear.java | 26 + .../apache/tuscany/sca/test/spec/MyService.java | 29 + .../tuscany/sca/test/spec/MyServiceByDate.java | 28 + .../tuscany/sca/test/spec/MyTotalService.java | 23 + .../tuscany/sca/test/spec/SCAComponentService.java | 28 + .../sca/test/spec/impl/MyListServiceImpl.java | 73 +++ .../tuscany/sca/test/spec/impl/MyServiceImpl.java | 122 ++++ .../sca/test/spec/impl/MyTotalServiceImpl.java | 83 +++ .../src/main/resources/META-INF/sca/default.scdl | 43 ++ .../main/resources/META-INF/sca/myListService.scdl | 34 + .../META-INF/sca/myServiceInComposite.scdl | 49 ++ .../META-INF/sca/myServiceInRecursive.scdl | 53 ++ .../resources/META-INF/sca/mySimpleService.scdl | 34 + .../META-INF/sca/mySimpleServiceInRecursive.scdl | 44 ++ .../META-INF/sca/mySimpleServiceInRecursive2.scdl | 47 ++ .../resources/META-INF/sca/myTotalService.scdl | 32 + .../META-INF/sca/myTotalServiceInComposite.scdl | 43 ++ ...otalServiceInCompositeForReferenceOverride.scdl | 81 +++ .../META-INF/sca/myTotalServiceInRecursive.scdl | 60 ++ ...otalServiceInRecursiveForReferenceOverride.scdl | 52 ++ .../src/main/resources/META-INF/sca/myservice.scdl | 51 ++ .../test/spec/ComponentContextTestComponent.java | 48 ++ .../spec/ComponentServiceReferenceListTest.java | 39 ++ .../test/spec/ComponentServiceReferenceTest.java | 60 ++ .../tuscany/sca/test/spec/ComponentTest.java | 71 +++ .../test/spec/CompositeOneService2LevelTest.java | 89 +++ .../sca/test/spec/CompositeOneServiceTest.java | 45 ++ ...ompositeServiceReferenceForRefOverrideTest.java | 70 ++ .../test/spec/CompositeServiceReferenceTest.java | 81 +++ .../tuscany/sca/test/spec/CompositeTest.java | 55 ++ .../itest/specTest/src/test/resources/itest.scdl | 30 + 175 files changed, 12788 insertions(+) create mode 100644 sandbox/old/contrib/itest/bindings/bindingsclient/pom.xml create mode 100644 sandbox/old/contrib/itest/bindings/bindingsclient/src/main/java/org/apache/tuscany/sca/itest/SCATestToolService.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingsclient/src/main/resources/bindingsclient.composite create mode 100644 sandbox/old/contrib/itest/bindings/bindingsclient/src/main/resources/wsdl/testtool.wsdl create mode 100644 sandbox/old/contrib/itest/bindings/bindingsclient/src/main/webapp/SCATestTool.jsp create mode 100644 sandbox/old/contrib/itest/bindings/bindingsclient/src/main/webapp/WEB-INF/web.xml create mode 100644 sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/itest/SCATestToolServerTest.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/itest/WSBindingsClientTestCase.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/util/SCATestUtilityServerTest.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/pom.xml create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCADataTypeHelper.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCADataTypeHelperException.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolCallbackService.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolServer.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolService.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolServiceImpl.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityService.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/bindingscomposite-system.composite create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/bindingscomposite.composite create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/wsdl/testtool.wsdl create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/wsdl/testutility.wsdl create mode 100644 sandbox/old/contrib/itest/bindings/bindingscomposite/src/test/java/org/apache/tuscany/sca/itest/SCATestToolServerTestCase.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingsutility/pom.xml create mode 100644 sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/itest/SCATestToolCallbackService.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityServer.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityService.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityServiceImpl.java create mode 100644 sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/bindingsutility-system.composite create mode 100644 sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/bindingsutility.composite create mode 100644 sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/wsdl/testutility.wsdl create mode 100644 sandbox/old/contrib/itest/bindings/bindingsutility/src/test/java/org/apache/tuscany/sca/util/SCATestUtilityServerTestCase.java create mode 100644 sandbox/old/contrib/itest/bindings/pom.xml create mode 100644 sandbox/old/contrib/itest/conversations/pom.xml create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdService.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScope.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/AnotherService.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/AnotherServiceImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsCallback.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClient.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClient2.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClientImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsLifeCycleService.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsLifeCycleServiceImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsService.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsServiceImpl.java create mode 100644 sandbox/old/contrib/itest/conversations/src/main/resources/ConversationAge.composite create mode 100644 sandbox/old/contrib/itest/conversations/src/main/resources/ConversationsTest.composite create mode 100644 sandbox/old/contrib/itest/conversations/src/main/resources/conversationId.composite create mode 100644 sandbox/old/contrib/itest/conversations/src/main/resources/conversational.composite create mode 100644 sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java create mode 100644 sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java create mode 100644 sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java create mode 100644 sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java create mode 100644 sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/test/ConversationsTestCaseFIXME.java create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/pom.xml create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/src/main/resources/META-INF/README.txt create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/src/test/java/interop/ClientTestCase.java create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/sca/test.scdl create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/binding.axis2.scdl create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/databinding.axiom.scdl create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/databinding.sdo.scdl create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/interface.wsdl.scdl create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/test-extensions.scdl create mode 100644 sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/wsdl/sq.wsdl create mode 100644 sandbox/old/contrib/itest/pom.xml.off create mode 100644 sandbox/old/contrib/itest/propertyTest/pom.xml.off create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ABComponent.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ABComponentImpl.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/CDComponent.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/CDComponentImpl.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ComplexPropertyBean.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/OverrideService.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/OverrideServiceImpl.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyComponent.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyComponentImpl.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyService.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ConstructorPrimitives.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PrimitiveService.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ProtectedFieldPrimitives.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ProtectedSetterPrimitives.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PublicFieldPrimitives.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PublicSetterPrimitives.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/default.scdl create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/fileProperty.txt create mode 100644 sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/primitives.scdl create mode 100644 sandbox/old/contrib/itest/propertyTest/src/test/java/org/apache/tuscany/sca/test/property/PropertyTestComponent.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/test/java/org/apache/tuscany/sca/test/property/primitives/PrimitiveTestComponent.java create mode 100644 sandbox/old/contrib/itest/propertyTest/src/test/resources/itest.scdl create mode 100644 sandbox/old/contrib/itest/spec-api/pom.xml create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/BasicService.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/CompositeTest.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/MathService.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/myListService.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/myServiceInComposite.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/myServiceInRecursive.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleService.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleServiceInRecursive.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleServiceInRecursive2.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalService.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInComposite.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInCompositeForReferenceOverride.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInRecursive.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInRecursiveForReferenceOverride.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/main/resources/myservice.composite create mode 100644 sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTestCaseFIXME.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTestCase.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTestCase.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTestCaseFIXME.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTestCase.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTestCase.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTestCase.java create mode 100644 sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTestCase.java create mode 100644 sandbox/old/contrib/itest/specTest/pom.xml.off create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/default.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myListService.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInComposite.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInRecursive.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleService.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive2.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalService.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInComposite.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInCompositeForReferenceOverride.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursive.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursiveForReferenceOverride.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myservice.scdl create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTest.java create mode 100644 sandbox/old/contrib/itest/specTest/src/test/resources/itest.scdl (limited to 'sandbox/old/contrib/itest') diff --git a/sandbox/old/contrib/itest/bindings/bindingsclient/pom.xml b/sandbox/old/contrib/itest/bindings/bindingsclient/pom.xml new file mode 100644 index 0000000000..bdb19eda9d --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsclient/pom.xml @@ -0,0 +1,64 @@ + + + + + + org.apache.tuscany.sca + tuscany-itest + 1.1-incubating-SNAPSHOT + ../../pom.xml + + + 4.0.0 + org.apache.tuscany.testing.bindingstest + itest-bindings-bindingsclient + jar + SCA FVT Bindings Test Tool JSP Client + + + + + org.apache.tuscany.testing.bindingstest + itest-bindings-bindingscomposite + 1.1-incubating-SNAPSHOT + + + + org.apache.tuscany.testing.bindingstest + itest-bindings-bindingsutility + 1.1-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.1-incubating-SNAPSHOT + + + + org.apache.tuscany.sdo + tuscany-sdo-api-r2.1 + 1.0-incubating-SNAPSHOT + runtime + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/java/org/apache/tuscany/sca/itest/SCATestToolService.java b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/java/org/apache/tuscany/sca/itest/SCATestToolService.java new file mode 100644 index 0000000000..44801846f6 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/java/org/apache/tuscany/sca/itest/SCATestToolService.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.itest; + +import org.osoa.sca.annotations.Remotable; + +/** + * SCA Test Tool Service + */ + +@Remotable +public interface SCATestToolService { + + public String doOneHopPing(String input); + + public String doTwoHopPing(String input); + + public String doDataTypeTest(String input); + + public String getCallbackBuffer(); + + public void clearCallbackBuffer(); +} diff --git a/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/resources/bindingsclient.composite b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/resources/bindingsclient.composite new file mode 100644 index 0000000000..ca3ff6494e --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/resources/bindingsclient.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/resources/wsdl/testtool.wsdl b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/resources/wsdl/testtool.wsdl new file mode 100644 index 0000000000..7dc608f063 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/resources/wsdl/testtool.wsdl @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/webapp/SCATestTool.jsp b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/webapp/SCATestTool.jsp new file mode 100644 index 0000000000..eb219e4cef --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/webapp/SCATestTool.jsp @@ -0,0 +1,130 @@ +<%--/* + * 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. + */ + --%> + + +<%-- + * SCATestService.java + * written by Chris Ortiz + * interface class for basic test service + * version .1 9/22/2006 + * + * + --%> + + + + + <%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1" session="true" autoFlush="true" + isThreadSafe="true" isErrorPage="false" + import="org.apache.tuscany.sca.itest.SCATestToolService" + import="java.io.PrintWriter" + import="java.io.StringWriter" + import="org.osoa.sca.CurrentCompositeContext" + import="org.osoa.sca.CompositeContext" + %> + + + SCA FVT Test Service Driver + + + +

SCA FVT Test Tool Client

+ +


Choose Binding type:

+      WS Binding +      EJB Binding +      Default Binding


+
Check Tests to run:

+      Ping First Composite +      Ping Second Composite

+      Data Type Test

+      Async One Way        +      Async Call Back

+ + +
+
+
+ + <% + + String bindingchoice = request.getParameter("bind"); + String[] selected = request.getParameterValues("test"); + + try { + SCATestToolService scaTestTool; + if (bindingchoice.equals("WS")) { + CompositeContext compositeContext = CurrentCompositeContext.getContext(); + scaTestTool = (SCATestToolService) compositeContext.locateService(SCATestToolService.class, "SCATestToolWSReference"); + } else if (bindingchoice.equals("EJB")) { + CompositeContext compositeContext = CurrentCompositeContext.getContext(); + scaTestTool = (SCATestToolService) compositeContext.locateService(SCATestToolService.class, "SCATestToolEJBReference"); + } else { + // assume default binding + CompositeContext compositeContext = CurrentCompositeContext.getContext(); + scaTestTool = (SCATestToolService) compositeContext.locateService(SCATestToolService.class, "SCATestToolSCAReference"); + } + if (selected != null && selected.length != 0) { + for (int i = 0; i < selected.length; i++) { + String value = null; + if (null != selected[i] && selected[i].equals("Ping First Composite")) { + value = scaTestTool.doOneHopPing("brio"); + } else if (null != selected[i] && selected[i].equals("Ping Second Composite")){ + value = scaTestTool.doTwoHopPing("brio"); + } else if (null != selected[i] && selected[i].equals("Data Type Test")){ + value = scaTestTool.doDataTypeTest("brio"); + } else if (null != selected[i] && selected[i].equals("Async One Way")){ + value = "Ut Oh! Test tool not complete for oneway testing"; + } else if (null != selected[i] && selected[i].equals("Async Callback")){ + value = "Ut Oh! Test tool not complete for async testing"; + } else { + value = "Ut Oh! unknown test"; + } + +%> + +
+Results from <%=selected[i]%> test with <%=bindingchoice%> binding: +

<%=value%> + <% + } //for + } //if + + }catch(Exception e){ + e.printStackTrace(); + StringWriter sw= new StringWriter(); + PrintWriter pw= new PrintWriter(sw); + + e.printStackTrace(pw); + pw.flush(); + +%> + Whoops!
+

+    Exception "<%=e.getClass().getName()%>" Exception message: "<%=e.getMessage()%>"
+ <%=sw.toString() %> +
+<% } //catch + +%> + + + \ No newline at end of file diff --git a/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/webapp/WEB-INF/web.xml b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..fd58cb8b0e --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsclient/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,31 @@ + + + + + + SCA Test Service Driver + + SCATestTool.jsp + + diff --git a/sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/itest/SCATestToolServerTest.java b/sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/itest/SCATestToolServerTest.java new file mode 100644 index 0000000000..6cc72c99a2 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/itest/SCATestToolServerTest.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.itest; + + +import java.io.IOException; +import java.net.Socket; + +import junit.framework.TestCase; + +import org.apache.tuscany.api.SCARuntime; + +public class SCATestToolServerTest extends TestCase { + + @Override + protected void setUp() throws Exception { + SCARuntime.start("bindingscomposite-system.composite", "bindingscomposite.composite"); + } + + public void testPing() throws IOException { + new Socket("127.0.0.1", 8085); + } + + @Override + protected void tearDown() throws Exception { + SCARuntime.stop(); + } + +} diff --git a/sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/itest/WSBindingsClientTestCase.java b/sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/itest/WSBindingsClientTestCase.java new file mode 100644 index 0000000000..b5f076b7e8 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/itest/WSBindingsClientTestCase.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.itest; + +import java.lang.reflect.UndeclaredThrowableException; + +import junit.framework.TestCase; + +import org.apache.tuscany.api.SCARuntime; +import org.apache.tuscany.core.test.SCATestCaseRunner; +import org.apache.tuscany.sca.util.SCATestUtilityServerTest; +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +public class WSBindingsClientTestCase extends TestCase { + private SCATestToolService scaTestTool; + + private SCATestCaseRunner toolServer; + private SCATestCaseRunner utilityServer; + + // Hops over one composite + public void testOneHopPing() throws Throwable { + try { + assertTrue(scaTestTool.doOneHopPing("brio").contains("brio")); + } catch (UndeclaredThrowableException e) { + throw (e.getCause()); + } + } + + // Hops over two composites + public void testTwoHopPing() { + assertTrue(scaTestTool.doTwoHopPing("brio").contains("brio")); + } + + protected void setUp() throws Exception { + SCARuntime.start("bindingsclient.composite"); + + toolServer = new SCATestCaseRunner(SCATestToolServerTest.class); + toolServer.setUp(); + utilityServer = new SCATestCaseRunner(SCATestUtilityServerTest.class); + utilityServer.setUp(); + + CompositeContext cc = CurrentCompositeContext.getContext(); + System.out.println("Composite Name = " + cc.getName()); + System.out.println(CurrentCompositeContext.getContext()); + scaTestTool = + (SCATestToolService)CurrentCompositeContext.getContext().locateService(SCATestToolService.class, + "SCATestToolWSReference"); + if (scaTestTool == null) { + System.out.println("Yo Yo It is null"); + } else { + System.out.println("Yo Yo It is not null: " + scaTestTool); + } + + } + + @Override + protected void tearDown() throws Exception { + SCARuntime.stop(); + toolServer.tearDown(); + utilityServer.tearDown(); + } +} diff --git a/sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/util/SCATestUtilityServerTest.java b/sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/util/SCATestUtilityServerTest.java new file mode 100644 index 0000000000..0f6cb912a7 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsclient/src/test/java/org/apache/tuscany/sca/util/SCATestUtilityServerTest.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.util; + + + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.api.SCARuntime; + +import junit.framework.TestCase; + +public class SCATestUtilityServerTest extends TestCase { + + @Override + protected void setUp() throws Exception { + SCARuntime.start("bindingsutility-system.composite", "bindingsutility.composite"); + } + + public void testPing() throws IOException { + new Socket("127.0.0.1", 8081); + } + + @Override + protected void tearDown() throws Exception { + SCARuntime.stop(); + } + +} diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/pom.xml b/sandbox/old/contrib/itest/bindings/bindingscomposite/pom.xml new file mode 100644 index 0000000000..9b99bc8134 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/pom.xml @@ -0,0 +1,58 @@ + + + + + org.apache.tuscany.sca + tuscany-itest + 1.1-incubating-SNAPSHOT + ../../pom.xml + + 4.0.0 + org.apache.tuscany.testing.bindingstest + itest-bindings-bindingscomposite + jar + SCA FVT Bindings Test Tool Service Composite + + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.1-incubating-SNAPSHOT + + + + org.apache.tuscany.sdo + tuscany-sdo-api-r2.1 + 1.0-incubating-SNAPSHOT + runtime + + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubating-SNAPSHOT + runtime + + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCADataTypeHelper.java b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCADataTypeHelper.java new file mode 100644 index 0000000000..efe30c4f4e --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCADataTypeHelper.java @@ -0,0 +1,341 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Random; +import java.util.Vector; + +import org.apache.tuscany.sca.util.SCATestUtilityService; + +public class SCADataTypeHelper { + + Date date; + Random ran; + SCATestUtilityService scaUtil; // change this to be the service provider + + public SCADataTypeHelper(SCATestUtilityService util) { + date = new Date(); + ran = new Random(date.getTime()); + scaUtil = util; + } + + public StringBuffer test_char() throws SCADataTypeHelperException { + + char x = 'a'; + x += ran.nextInt(26); // get a char a-z + StringBuffer rc = new StringBuffer("\nchar datatype test sending ==> " + x); + try { + char y = scaUtil.echo_char(x); + if (x == y) { + rc.append("\nchar successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException(rc + "\nDatatype exception: char ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_char\n" + e.toString()); + } + return rc; + } + + public StringBuffer test_String() throws SCADataTypeHelperException { + + String x = date.toString(); + StringBuffer rc = new StringBuffer("\nString datatype test sending ==> " + x); + try { + String y = scaUtil.echo_String(x); + if (x.equals(y)) { + rc.append("\nString successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException(rc + "\nDatatype exception: String ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_String\n" + e.toString()); + } + return rc; + } + + public StringBuffer test_int() throws SCADataTypeHelperException { + + int x = ran.nextInt(); + StringBuffer rc = new StringBuffer("\nint datatype test sending ==> " + x); + try { + int y = scaUtil.echo_int(x); + if (x == y) { + rc.append("\nint successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException(rc + "\nDatatype exception: int ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_int\n" + e.toString()); + } + return rc; + } + + public StringBuffer test_boolean() throws SCADataTypeHelperException { + + boolean x = ran.nextBoolean(); + StringBuffer rc = new StringBuffer("\nboolean datatype test sending ==> " + x); + try { + boolean y = scaUtil.echo_boolean(x); + if (x == y) { + rc.append("\nboolean successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException(rc + "\nDatatype exception: boolean ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_boolean\n" + e.toString()); + } + return rc; + } + + public StringBuffer test_long() throws SCADataTypeHelperException { + + long x = ran.nextLong(); + StringBuffer rc = new StringBuffer("\nlong datatype test sending ==> " + x); + try { + long y = scaUtil.echo_long(x); + if (x == y) { + rc.append("\nlong successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException(rc + "\nDatatype exception: long ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_long\n" + e.toString()); + } + return rc; + } + + public StringBuffer test_short() throws SCADataTypeHelperException { + + short x = (short)ran.nextInt(); + StringBuffer rc = new StringBuffer("\nshort datatype test sending ==> " + x); + try { + short y = scaUtil.echo_short(x); + if (x == y) { + rc.append("\nshort successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException(rc + "\nDatatype exception: short ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_short\n" + e.toString()); + } + return rc; + } + + public StringBuffer test_float() throws SCADataTypeHelperException { + + float x = ran.nextFloat(); + StringBuffer rc = new StringBuffer("\nfloat datatype test sending ==> " + x); + try { + float y = scaUtil.echo_float(x); + if (x == y) { + rc.append("\nfloat successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException(rc + "\nDatatype exception: float ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_float " + e.toString()); + } + return rc; + } + + public StringBuffer test_double() throws SCADataTypeHelperException { + + double x = ran.nextDouble(); + StringBuffer rc = new StringBuffer("\ndouble datatype test sending ==> " + x); + try { + double y = scaUtil.echo_double(x); + if (x == y) { + rc.append("\ndouble successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException(rc + "\nDatatype exception: double ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_double\n" + e.toString()); + } + return rc; + } + + public StringBuffer test_BigInteger() throws SCADataTypeHelperException { + + BigInteger x = new BigInteger(ran.nextInt(32) + 32, ran); // between + // 32 - 64 + // bitLength + StringBuffer rc = new StringBuffer("\nBigInteger datatype test sending ==> " + x); + try { + BigInteger y = scaUtil.echo_BigInteger(x); + if (x.equals(y)) { + rc.append("\nBigInteger successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException("\n" + rc + "\nDatatype exception: BigInteger ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_BigInteger\n" + e.toString()); + } + return rc; + } + + public StringBuffer test_BigDecimal() throws SCADataTypeHelperException { + + BigDecimal x = new BigDecimal(ran.nextDouble()); + StringBuffer rc = new StringBuffer("\nBigDecimal datatype test sending ==> " + x); + try { + BigDecimal y = scaUtil.echo_BigDecimal(x); + if (x.equals(y)) { + rc.append("\nBigDecimal successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException("\n" + rc + "\nDatatype exception: BigDecimal ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_BigDecimal\n" + e.toString()); + } + return rc; + } + + private StringBuffer test_Vector() throws SCADataTypeHelperException { + + Vector vector = new Vector(); + vector.addElement("DanW"); + vector.addElement(new Float(2000F)); + vector.addElement(new Short((short)11)); + StringBuffer rc = new StringBuffer("\nVector datatype test sending ==> " + vector.toString()); + boolean passed = true; + try { + Vector y = scaUtil.echo_Vector(vector); + if (((String)y.elementAt(0)).equals("DanW")) { + rc.append("\nVector element 0 string " + y.elementAt(0) + " successfully recieved"); + } else { + passed = false; + } + if ((((Float)y.elementAt(1)).equals((Float)vector.elementAt(1)))) { + rc.append("\nVector element 1 Float " + y.elementAt(1) + " successfully recieved"); + } else { + passed = false; + } + if (y.elementAt(2).equals(vector.elementAt(2))) { + rc.append("\nVector element 2 (Short) " + y.elementAt(2) + " successfully received"); + } else { + passed = false; + } + if (!passed) { + // + // one of the tests failed + // + rc.append("\nVector element 0 (String) " + y.elementAt(0) + " should be \"DanW\""); + rc.append("\nVector element 1 (Float) " + y.elementAt(1) + " should be \"2000F\""); + rc.append("\nVector element 2 (Short) " + y.elementAt(2) + " should be \"11\""); + throw new SCADataTypeHelperException("\n" + rc + "\nDataType exception: Vector ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_Vector\n" + e.toString()); + } + return rc; + } + + public StringBuffer test_GregorianCalendar() throws SCADataTypeHelperException { + + GregorianCalendar x = new GregorianCalendar(); + StringBuffer rc = new StringBuffer("\nGregorianCalendar datatype test sending ==> " + x.toString()); + try { + GregorianCalendar y = scaUtil.echo_GregorianCalendar(x); + if (x.equals(y)) { + rc.append("\nGregorianCalendar successfully received ==> " + y); + } else { + throw new SCADataTypeHelperException("\n" + rc + "\nDatatype exception: GregorianCalendar ==> " + y); + } + } catch (Exception e) { + throw new SCADataTypeHelperException("\nRemote exception from scaUtil.echo_GregorianCalendar\n" + e + .toString()); + } + return rc; + } + + public StringBuffer doDataType() { + + StringBuffer rc = new StringBuffer(); + try { + rc.append(test_boolean()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_char()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_String()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_int()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString()); + } + try { + rc.append(test_long()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_short()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_float()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_double()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_BigInteger()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_BigDecimal()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_Vector()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } + try { + rc.append(test_GregorianCalendar()); + } catch (SCADataTypeHelperException e) { + rc.append("\n" + e.toString() + "\n"); + } catch (Exception e) { + rc.append("\n" + e.toString() + "\n"); + } + + return rc; + } +} diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCADataTypeHelperException.java b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCADataTypeHelperException.java new file mode 100644 index 0000000000..074fba8057 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCADataTypeHelperException.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.itest; + +public class SCADataTypeHelperException extends Exception { + + public SCADataTypeHelperException() { + } + + public SCADataTypeHelperException(String msg) { + super(msg); + } +} diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolCallbackService.java b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolCallbackService.java new file mode 100644 index 0000000000..c55e22c905 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolCallbackService.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest; + +/** + * SCA Test Tool Callback Service + */ +public interface SCATestToolCallbackService { + + public void pingCallBack(String reply); +} diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolServer.java b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolServer.java new file mode 100644 index 0000000000..44e799a566 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolServer.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.itest; + + +import java.io.IOException; + +import org.apache.tuscany.api.SCARuntime; + +public class SCATestToolServer { + + /** + * @param args + */ + public static void main(String[] args) { + + SCARuntime.start("bindingscomposite-system.composite", "bindingscomposite.composite"); + + try { + System.out.println("SCATestTool server started"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + SCARuntime.stop(); + System.out.println("SCATestTool server stopped"); + } + +} diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolService.java b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolService.java new file mode 100644 index 0000000000..67b7e8eb64 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolService.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.itest; + +import org.osoa.sca.annotations.Remotable; + +/** + * SCA Test Tool Service + */ + +@Remotable +public interface SCATestToolService { + + public String doOneHopPing(String input); + + public String doTwoHopPing(String input); + + public String doDataTypeTest(String input); + + public String getCallbackBuffer(); + + public void clearCallbackBuffer(); +} diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolServiceImpl.java b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolServiceImpl.java new file mode 100644 index 0000000000..e207a23927 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/itest/SCATestToolServiceImpl.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest; + +import org.apache.tuscany.sca.util.SCATestUtilityService; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * SCA Test Service Implementation + */ + +@Service(SCATestToolService.class) +public class SCATestToolServiceImpl implements SCATestToolService, SCATestToolCallbackService { + @Reference + public SCATestUtilityService scaTestUtil; + + private String callbackBuffer = null; + + public String doOneHopPing(String input) { + System.out.println("Invoking SCATestToolServiceImpl.doOneHopPing()"); + StringBuffer rc = new StringBuffer(); + rc.append("doOneHopPing(): "); + rc.append(input); + return rc.toString(); + } + + public String doTwoHopPing(String input) { + System.out.println("Invoking SCATestToolServiceImpl.doTwoHopPing()"); + StringBuffer rc = new StringBuffer(); + rc.append("doTwoHopPing(): "); + rc.append(input); + rc.append(" --> "); + rc.append(scaTestUtil.ping(input)); + return rc.toString(); + } + + public String doDataTypeTest(String input) { + StringBuffer rc = new StringBuffer(); + rc.append("doDataTypeTest(): "); + rc.append(input); + rc.append(" --> "); + SCADataTypeHelper dataHelper = new SCADataTypeHelper(scaTestUtil); + rc.append(dataHelper.doDataType()); + return rc.toString(); + } + + public void pingCallBack(String reply) { + callbackBuffer = reply; + } + + public String getCallbackBuffer() { + return callbackBuffer; + } + + public void clearCallbackBuffer() { + callbackBuffer = null; + } + +} diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityService.java b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityService.java new file mode 100644 index 0000000000..0ceb553727 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityService.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.util; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Vector; +import java.util.GregorianCalendar; + +import org.apache.tuscany.sca.itest.SCATestToolCallbackService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Remotable; + +/** + * SCA Test Utility Service + */ + +@Remotable +public interface SCATestUtilityService { + public String ping(String input); + + @Callback(SCATestToolCallbackService.class) + public void asyncping(); + + public int echo_int(int input); + + public short echo_short(short input); + + public long echo_long(long input); + + public float echo_float(float input); + + public double echo_double(double input); + + public boolean echo_boolean(boolean input); + + public char echo_char(char input); + + public String echo_String(String input); + + public BigDecimal echo_BigDecimal(BigDecimal input); + + public BigInteger echo_BigInteger(BigInteger input); + + public Vector echo_Vector(Vector input); + + public GregorianCalendar echo_GregorianCalendar(GregorianCalendar input); +} diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/bindingscomposite-system.composite b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/bindingscomposite-system.composite new file mode 100644 index 0000000000..0b894bf701 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/bindingscomposite-system.composite @@ -0,0 +1,36 @@ + + + + + + + + + + 8085 + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/bindingscomposite.composite b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/bindingscomposite.composite new file mode 100644 index 0000000000..9b2bb51b9c --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/bindingscomposite.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + SCATestToolWSServiceComponent + + + + + + SCATestUtilityWSReference + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/wsdl/testtool.wsdl b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/wsdl/testtool.wsdl new file mode 100644 index 0000000000..870af6ac2e --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/wsdl/testtool.wsdl @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/wsdl/testutility.wsdl b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/wsdl/testutility.wsdl new file mode 100644 index 0000000000..32d9050a61 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/main/resources/wsdl/testutility.wsdl @@ -0,0 +1,704 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingscomposite/src/test/java/org/apache/tuscany/sca/itest/SCATestToolServerTestCase.java b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/test/java/org/apache/tuscany/sca/itest/SCATestToolServerTestCase.java new file mode 100644 index 0000000000..727eb2332f --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingscomposite/src/test/java/org/apache/tuscany/sca/itest/SCATestToolServerTestCase.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.itest; + + +import java.io.IOException; +import java.net.Socket; + +import junit.framework.TestCase; + +import org.apache.tuscany.api.SCARuntime; + +public class SCATestToolServerTestCase extends TestCase { + + @Override + protected void setUp() throws Exception { + SCARuntime.start("bindingscomposite-system.composite", "bindingscomposite.composite"); + } + + public void testPing() throws IOException { + new Socket("127.0.0.1", 8085); + } + + @Override + protected void tearDown() throws Exception { + SCARuntime.stop(); + } + +} diff --git a/sandbox/old/contrib/itest/bindings/bindingsutility/pom.xml b/sandbox/old/contrib/itest/bindings/bindingsutility/pom.xml new file mode 100644 index 0000000000..3f63e5d2eb --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsutility/pom.xml @@ -0,0 +1,59 @@ + + + + + org.apache.tuscany.sca + tuscany-itest + 1.1-incubating-SNAPSHOT + ../../pom.xml + + + 4.0.0 + org.apache.tuscany.testing.bindingstest + itest-bindings-bindingsutility + jar + SCA FVT Bindings Test Tool Utility Composite + + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.1-incubating-SNAPSHOT + + + + org.apache.tuscany.sdo + tuscany-sdo-api-r2.1 + 1.0-incubating-SNAPSHOT + runtime + + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubating-SNAPSHOT + runtime + + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/itest/SCATestToolCallbackService.java b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/itest/SCATestToolCallbackService.java new file mode 100644 index 0000000000..664fb06930 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/itest/SCATestToolCallbackService.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.itest; + +/** + * SCA Test Tool Callback Service + */ + +public interface SCATestToolCallbackService { + + public void pingCallBack(String reply); +} diff --git a/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityServer.java b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityServer.java new file mode 100644 index 0000000000..cd967e275a --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityServer.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.util; + + +import java.io.IOException; + +import org.apache.tuscany.api.SCARuntime; + +public class SCATestUtilityServer { + + /** + * @param args + */ + public static void main(String[] args) { + + SCARuntime.start("bindingsutility-system.composite", "bindingsutility.composite"); + + try { + System.out.println("SCATestUtility server started"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + SCARuntime.stop(); + System.out.println("SCATestUtility server stopped"); + } + +} diff --git a/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityService.java b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityService.java new file mode 100644 index 0000000000..0ceb553727 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityService.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.util; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Vector; +import java.util.GregorianCalendar; + +import org.apache.tuscany.sca.itest.SCATestToolCallbackService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Remotable; + +/** + * SCA Test Utility Service + */ + +@Remotable +public interface SCATestUtilityService { + public String ping(String input); + + @Callback(SCATestToolCallbackService.class) + public void asyncping(); + + public int echo_int(int input); + + public short echo_short(short input); + + public long echo_long(long input); + + public float echo_float(float input); + + public double echo_double(double input); + + public boolean echo_boolean(boolean input); + + public char echo_char(char input); + + public String echo_String(String input); + + public BigDecimal echo_BigDecimal(BigDecimal input); + + public BigInteger echo_BigInteger(BigInteger input); + + public Vector echo_Vector(Vector input); + + public GregorianCalendar echo_GregorianCalendar(GregorianCalendar input); +} diff --git a/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityServiceImpl.java b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityServiceImpl.java new file mode 100644 index 0000000000..e752e4d6e6 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/java/org/apache/tuscany/sca/util/SCATestUtilityServiceImpl.java @@ -0,0 +1,157 @@ +/* + * 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.util; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.InetAddress; +import java.util.GregorianCalendar; +import java.util.Properties; +import java.util.Vector; + +import org.osoa.sca.annotations.Service; + +@Service(SCATestUtilityService.class) +public class SCATestUtilityServiceImpl implements SCATestUtilityService { + + // private SCATestToolCallbackService utilCallBack; + + /** + * The setter used by the runtime to set the callback reference + * + * @param myServiceCallback + */ + + // @Callback + // public void setCallback(SCATestToolCallbackService utilCallBack) { + // this.utilCallBack = utilCallBack; + // } + public String ping(String input) { + System.out.println("Invoking SCATestUtilityServiceImpl.ping()"); + StringBuffer rc = new StringBuffer(); + + try { + // get a systems property object + Properties sp = System.getProperties(); + rc.append("Pinged SCA Test Utility Service on: "); + // get operating system info + rc.append(sp.getProperty("os.name")); + rc.append(", " + sp.getProperty("os.version")); + // get network info + rc.append(" - " + InetAddress.getLocalHost().toString()); + } catch (Exception e) { + System.out.println("\nException preparing system infomation for ping service reply\n" + e.toString()); + e.printStackTrace(); + } + return rc.toString(); + } + + public void asyncping() { + + StringBuffer rc = new StringBuffer(); + + try { + // get a systems property object + Properties sp = System.getProperties(); + rc.append("Pinged SCA Test Utility Service on: "); + // get operating system info + rc.append(sp.getProperty("os.name")); + rc.append(", " + sp.getProperty("os.version")); + // get network info + rc.append(" - " + InetAddress.getLocalHost().toString()); + } catch (Exception e) { + System.out.println("\nException preparing system infomation for ping service reply\n" + e.toString()); + e.printStackTrace(); + } + // utilCallBack.pingCallBack(rc.toString()); + } + + public int echo_int(int input) { + int local; + local = input; + return local; + } + + public short echo_short(short input) { + short local; + local = input; + return local; + } + + public long echo_long(long input) { + long local; + local = input; + return local; + } + + public float echo_float(float input) { + float local; + local = input; + return local; + } + + public double echo_double(double input) { + double local; + local = input; + return local; + } + + public boolean echo_boolean(boolean input) { + boolean local; + local = input; + return local; + } + + public char echo_char(char input) { + char local; + local = input; + return local; + } + + public String echo_String(String input) { + String local; + local = input; + return local; + } + + public BigDecimal echo_BigDecimal(BigDecimal input) { + BigDecimal local; + local = input; + return local; + } + + public BigInteger echo_BigInteger(BigInteger input) { + BigInteger local; + local = input; + return local; + } + + public Vector echo_Vector(Vector input) { + Vector local; + local = input; + return local; + } + + public GregorianCalendar echo_GregorianCalendar(GregorianCalendar input) { + GregorianCalendar local; + local = input; + return local; + } + +} diff --git a/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/bindingsutility-system.composite b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/bindingsutility-system.composite new file mode 100644 index 0000000000..7126b78572 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/bindingsutility-system.composite @@ -0,0 +1,36 @@ + + + + + + + + + + 8081 + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/bindingsutility.composite b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/bindingsutility.composite new file mode 100644 index 0000000000..4d3d9bc523 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/bindingsutility.composite @@ -0,0 +1,39 @@ + + + + + + + + + SCATestUtilityWSServiceComponent + + + + + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/wsdl/testutility.wsdl b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/wsdl/testutility.wsdl new file mode 100644 index 0000000000..32d9050a61 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsutility/src/main/resources/wsdl/testutility.wsdl @@ -0,0 +1,704 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/bindings/bindingsutility/src/test/java/org/apache/tuscany/sca/util/SCATestUtilityServerTestCase.java b/sandbox/old/contrib/itest/bindings/bindingsutility/src/test/java/org/apache/tuscany/sca/util/SCATestUtilityServerTestCase.java new file mode 100644 index 0000000000..66246fc006 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/bindingsutility/src/test/java/org/apache/tuscany/sca/util/SCATestUtilityServerTestCase.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.util; + + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.api.SCARuntime; + +import junit.framework.TestCase; + +public class SCATestUtilityServerTestCase extends TestCase { + + @Override + protected void setUp() throws Exception { + SCARuntime.start("bindingsutility-system.composite", "bindingsutility.composite"); + } + + public void testPing() throws IOException { + new Socket("127.0.0.1", 8081); + } + + @Override + protected void tearDown() throws Exception { + SCARuntime.stop(); + } + +} diff --git a/sandbox/old/contrib/itest/bindings/pom.xml b/sandbox/old/contrib/itest/bindings/pom.xml new file mode 100644 index 0000000000..e85f560bf2 --- /dev/null +++ b/sandbox/old/contrib/itest/bindings/pom.xml @@ -0,0 +1,41 @@ + + + + + org.apache.tuscany.sca + tuscany-itest + 1.1-incubating-SNAPSHOT + ../pom.xml + + + 4.0.0 + 1.1-incubating-SNAPSHOT + bindingstest + pom + SCA FVT Test Tool Suite + + + + bindingscomposite + bindingsutility + bindingsclient + + diff --git a/sandbox/old/contrib/itest/conversations/pom.xml b/sandbox/old/contrib/itest/conversations/pom.xml new file mode 100644 index 0000000000..481485efeb --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.1-incubating-SNAPSHOT + ../pom.xml + + itest-conversations + Apache Tuscany SCA Conversations Integration Tests + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.1-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.1-incubating-SNAPSHOT + runtime + + + diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.java new file mode 100644 index 0000000000..640ec22a4f --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalCallback.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.itest.conversational; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + + +/** + * The callback interface used when testing caonversational callbacks + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Remotable +@Conversational +public interface ConversationalCallback { + + public void init(); + + public void destroy(); + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + public void businessException() throws Exception; + + @EndsConversation + public String endConversation(); + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java new file mode 100644 index 0000000000..dbe51bcbea --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalClient.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.conversational; + +import org.osoa.sca.annotations.Remotable; + +/** + * The client for the conversational itest. Is implemented by clients + * offering both stateless and stateful callbacks + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Remotable +public interface ConversationalClient { + + public int runConversationFromInjectedReference(); + public int runConversationFromServiceReference(); + public int runConversationWithUserDefinedConversationId(); + public String runConversationCheckUserDefinedConversationId(); + public int runConversationCheckingScope(); + public int runConversationWithCallback(); + public int runConversationHavingPassedReference(); + public String runConversationBusinessException(); + public String runConversationBusinessExceptionCallback(); + public int runConversationCallingEndedConversation(); + public int runConversationCallingEndedConversationCallback(); + public int runConversationAgeTimeout(); + public int runConversationIdleTimeout(); + public int runConversationPrincipleError(); + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.java new file mode 100644 index 0000000000..8f008fa711 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalReferenceClient.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.itest.conversational; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +/** + * The client that calls into an existing conversation by accepting + * a reference to that conversation + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Remotable +public interface ConversationalReferenceClient { + + public void incrementCount(CallableReference conversationalService); + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.java new file mode 100644 index 0000000000..546382cfd1 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/ConversationalService.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.itest.conversational; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + + +/** + * The service interface used when testing conversations + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Remotable +@Conversational +@Callback(ConversationalCallback.class) +public interface ConversationalService { + + public void init(); + + public void destroy(); + + public void initializeCount(int count); + + public void incrementCount(); + + public int retrieveCount(); + + public void businessException() throws Exception; + + public void initializeCountCallback(int count); + + public void incrementCountCallback(); + + public int retrieveCountCallback(); + + public void businessExceptionCallback() throws Exception; + + @EndsConversation + public String endConversation(); + + public String endConversationCallback(); + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.java new file mode 100644 index 0000000000..9deef312ac --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationAgeComponentImpl.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.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="1 seconds") +public class ConversationAgeComponentImpl implements ConversationalService { + + private int count; + + public void businessException() throws Exception { + } + + public void businessExceptionCallback() throws Exception { + } + + public void destroy() { + } + + public String endConversation() { + return null; + } + + public String endConversationCallback() { + return null; + } + + public void incrementCount() { + } + + public void incrementCountCallback() { + } + + public void init() { + } + + public void initializeCount(int count) { + this.count = count; + } + + public void initializeCountCallback(int count) { + } + + public int retrieveCount() { + return count; + } + + public int retrieveCountCallback() { + return 0; + } + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java new file mode 100644 index 0000000000..1196b6ac0d --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdComponentImpl.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.itest.conversational.impl; + +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationIdService.class) +@Scope("CONVERSATION") +public class ConversationIdComponentImpl implements ConversationIdService { + + @ConversationID + public String cid; + + private String setterCid; + + public String getCIDField() { + return cid; + } + public String getCIDSetter() { + return setterCid; + } + + + @ConversationID + public void setCID(String cid) { + this.setterCid = cid; + } +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdService.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdService.java new file mode 100644 index 0000000000..11d5ea186b --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationIdService.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.itest.conversational.impl; + +import org.osoa.sca.annotations.Conversational; + +@Conversational +public interface ConversationIdService { + + String getCIDField(); + String getCIDSetter(); +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.java new file mode 100644 index 0000000000..1272c7ab7f --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationMaxIdleComponentImpl.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.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxIdleTime="1 seconds") +public class ConversationMaxIdleComponentImpl implements ConversationalService { + + private int count; + + public void businessException() throws Exception { + } + + public void businessExceptionCallback() throws Exception { + } + + public void destroy() { + } + + public String endConversation() { + return null; + } + + public String endConversationCallback() { + return null; + } + + public void incrementCount() { + } + + public void incrementCountCallback() { + } + + public void init() { + } + + public void initializeCount(int count) { + this.count = count; + } + + public void initializeCountCallback(int count) { + } + + public int retrieveCount() { + return count; + } + + public int retrieveCountCallback() { + return 0; + } + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java new file mode 100644 index 0000000000..4e2c721040 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatefulImpl.java @@ -0,0 +1,249 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * The client for the conversational itest which presents a stateful + * callback interface + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Service(interfaces={ConversationalClient.class}) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="10 minutes", + maxIdleTime="5 minutes", + singlePrincipal=false) +public class ConversationalClientStatefulImpl implements ConversationalClient, ConversationalCallback { + + @Context + protected ComponentContext componentContext; + + @Reference + protected ConversationalService conversationalService; + + @Reference + protected ConversationalReferenceClient conversationalReferenceClient; + + private int clientCount = 0; + private int callbackCount = 0; + + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + // From ConversationalClient + public int runConversationFromInjectedReference(){ + calls.append("runConversationFromInjectedReference,"); + conversationalService.initializeCount(1); + conversationalService.incrementCount(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + + return clientCount; + } + public int runConversationFromServiceReference(){ + calls.append("runConversationFromServiceReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + serviceReference.getConversation().end(); + + return clientCount; + } + public int runConversationWithUserDefinedConversationId(){ + calls.append("runConversationWithUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation1"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + serviceReference.getConversation().end(); + + return clientCount; + } + public String runConversationCheckUserDefinedConversationId(){ + calls.append("runConversationCheckUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation2"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + return callableReference.endConversation(); + + } + public int runConversationCheckingScope(){ + calls.append("runConversationCheckingScope,"); + // run a conversation + return runConversationFromInjectedReference(); + + // test will then use a static method to find out how many times + // init/destroy were called + } + public int runConversationWithCallback(){ + calls.append("runConversationWithCallback,"); + callbackCount = 2; + conversationalService.initializeCountCallback(1); + conversationalService.incrementCountCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + + return clientCount; + } + public int runConversationHavingPassedReference(){ + calls.append("runConversationHavingPassedReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + conversationalReferenceClient.incrementCount(serviceReference); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + serviceReference.getConversation().end(); + + return clientCount; + } + public String runConversationBusinessException(){ + calls.append("runConversationbusinessException,"); + try { + conversationalService.initializeCount(1); + conversationalService.businessException(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public String runConversationBusinessExceptionCallback(){ + calls.append("runConversationbusinessExceptionCallback,"); + try { + conversationalService.initializeCountCallback(1); + conversationalService.businessExceptionCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public int runConversationCallingEndedConversation(){ + calls.append("runConversationCallingEndedConversation,"); + conversationalService.initializeCount(1); + conversationalService.endConversation(); + return conversationalService.retrieveCount(); + } + + public int runConversationCallingEndedConversationCallback(){ + calls.append("runConversationCallingEndedConversationCallback,"); + conversationalService.initializeCountCallback(1); + conversationalService.endConversationCallback(); + return conversationalService.retrieveCountCallback(); + } + + public int runConversationAgeTimeout(){ + calls.append("runConversationAgeTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationIdleTimeout(){ + calls.append("runConversationIdleTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationPrincipleError(){ + calls.append("runConversationPrincipleError,"); + // TODO - when policy framework is done + return clientCount; + } + + + // From ConversationalCallback + @Init + public void init(){ + calls.append("init,"); + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + callbackCount += count; + } + + public void incrementCount(){ + calls.append("incrementCount,"); + callbackCount++; + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + return callbackCount; + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public String endConversation(){ + calls.append("endConversation,"); + return null; + } + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java new file mode 100644 index 0000000000..1470c699c0 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalClientStatelessImpl.java @@ -0,0 +1,243 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * The client for the conversational itest which presents a stateful + * callback interface + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Service(interfaces={ConversationalClient.class}) +public class ConversationalClientStatelessImpl implements ConversationalClient, ConversationalCallback { + + @Context + protected ComponentContext componentContext; + + @Reference + protected ConversationalService conversationalService; + + @Reference + protected ConversationalReferenceClient conversationalReferenceClient; + + private int clientCount = 0; + private int callbackCount = 0; + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + // From ConversationalClient + public int runConversationFromInjectedReference(){ + calls.append("runConversationFromInjectedReference,"); + conversationalService.initializeCount(1); + conversationalService.incrementCount(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + + return clientCount; + } + public int runConversationFromServiceReference(){ + calls.append("runConversationFromServiceReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + serviceReference.getConversation().end(); + + return clientCount; + } + public int runConversationWithUserDefinedConversationId(){ + calls.append("runConversationWithUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + serviceReference.getConversation().end(); + + return clientCount; + } + public String runConversationCheckUserDefinedConversationId(){ + calls.append("runConversationCheckUserDefinedConversationId,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + serviceReference.setConversationID("MyConversation2"); + + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + clientCount = callableReference.retrieveCount(); + return callableReference.endConversation(); + + } + public int runConversationCheckingScope(){ + calls.append("runConversationCheckingScope,"); + // run a conversation + return runConversationFromInjectedReference(); + + // test will then use a static method to find out how many times + // init/destroy were called + } + public int runConversationWithCallback(){ + calls.append("runConversationWithCallback,"); + conversationalService.initializeCountCallback(1); + conversationalService.incrementCountCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + + return clientCount; + } + + public int runConversationHavingPassedReference(){ + calls.append("runConversationHavingPassedReference,"); + ServiceReference serviceReference = componentContext.getServiceReference(ConversationalService.class, + "conversationalService"); + ConversationalService callableReference = serviceReference.getService(); + + callableReference.initializeCount(1); + callableReference.incrementCount(); + conversationalReferenceClient.incrementCount(serviceReference); + clientCount = callableReference.retrieveCount(); + callableReference.endConversation(); + + serviceReference.getConversation().end(); + + return clientCount; + } + + public String runConversationBusinessException(){ + calls.append("runConversationbusinessException,"); + try { + conversationalService.initializeCount(1); + conversationalService.businessException(); + clientCount = conversationalService.retrieveCount(); + conversationalService.endConversation(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public String runConversationBusinessExceptionCallback(){ + calls.append("runConversationbusinessExceptionCallback,"); + try { + conversationalService.initializeCountCallback(1); + conversationalService.businessExceptionCallback(); + clientCount = conversationalService.retrieveCountCallback(); + conversationalService.endConversationCallback(); + } catch(Exception ex) { + return ex.getMessage(); + } + + return "No Exception Returned"; + } + + public int runConversationCallingEndedConversation(){ + calls.append("runConversationCallingEndedConversation,"); + conversationalService.initializeCount(1); + conversationalService.endConversation(); + return conversationalService.retrieveCount(); + } + + public int runConversationCallingEndedConversationCallback(){ + calls.append("runConversationCallingEndedConversationCallback,"); + conversationalService.initializeCountCallback(1); + conversationalService.endConversationCallback(); + return conversationalService.retrieveCountCallback(); + } + + public int runConversationAgeTimeout(){ + calls.append("runConversationAgeTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationIdleTimeout(){ + calls.append("runConversationIdleTimeout,"); + // done in other testing + return clientCount; + } + public int runConversationPrincipleError(){ + calls.append("runConversationPrincipleError,"); + // TODO - when policy framework is done + return clientCount; + } + + + // From ConversationalCallback + @Init + public void init(){ + calls.append("init,"); + + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + callbackCount = 0; + } + + public void incrementCount(){ + calls.append("incrementCount,"); + callbackCount++; + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + return callbackCount; + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public String endConversation(){ + calls.append("endConversation,"); + return null; + } + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java new file mode 100644 index 0000000000..8fe7c5b6ba --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalReferenceClientImpl.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalReferenceClient; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Service; + +/** + * A client component that accepts a reference to an ongoing conversation + * and takes part in that conversation + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ + +@Service(interfaces={ConversationalReferenceClient.class}) +public class ConversationalReferenceClientImpl implements ConversationalReferenceClient{ + + public void incrementCount(CallableReference conversationalService){ + ConversationalService callableReference = conversationalService.getService(); + + callableReference.incrementCount(); + } + + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java new file mode 100644 index 0000000000..efcbdff06f --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatefulImpl.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.conversational.impl; + +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +/** + * The service used when testing stateful conversations + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Service(ConversationalService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="10 minutes", + maxIdleTime="5 minutes", + singlePrincipal=false) +public class ConversationalServiceStatefulImpl implements ConversationalService { + + @ConversationID + protected String conversationId; + + @Callback + protected ConversationalCallback conversationalCallback; + + // local count - accumulates during the conversation + private int count = 0; + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + @Init + public void init(){ + calls.append("init,"); + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + this.count = count; + } + + public void incrementCount(){ + calls.append("incrementCount,"); + count++; + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + return count; + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public void initializeCountCallback(int count){ + calls.append("initializeCountCallback,"); + this.count = count; + conversationalCallback.initializeCount(count); + } + + public void incrementCountCallback(){ + calls.append("incrementCountCallback,"); + count++; + conversationalCallback.incrementCount(); + } + + public int retrieveCountCallback(){ + calls.append("retrieveCountCallback,"); + return conversationalCallback.retrieveCount(); + } + + public void businessExceptionCallback() throws Exception { + calls.append("businessExceptionCallback,"); + conversationalCallback.businessException(); + } + + public String endConversation(){ + calls.append("endConversation,"); + count = 0; + return conversationId; + } + + public String endConversationCallback(){ + calls.append("endConversationCallback,"); + return conversationalCallback.endConversation(); + } +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java new file mode 100644 index 0000000000..dca0596b87 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessImpl.java @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.conversational.impl; + +import java.util.HashMap; + +import org.apache.tuscany.sca.itest.conversational.ConversationalCallback; +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Service; + + +/** + * The service used when testing stateful conversations + * + * @version $Rev: 537240 $ $Date: 2007-05-11 18:35:03 +0100 (Fri, 11 May 2007) $ + */ +@Service(ConversationalService.class) +public class ConversationalServiceStatelessImpl implements ConversationalService { + + @ConversationID + protected String conversationId; + + @Callback + protected ConversationalCallback conversationalCallback; + + // static area in which to hold conversational data + private static HashMap conversationalState = new HashMap(); + + // a static member variable that records the number of times this service is called + public static StringBuffer calls = new StringBuffer(); + + @Init + public void init(){ + calls.append("init,"); + } + + @Destroy + public void destroy(){ + calls.append("destroy,"); + } + + public void initializeCount(int count){ + calls.append("initializeCount,"); + Integer conversationalCount = new Integer(count); + conversationalState.put(conversationId, conversationalCount); + } + + public void incrementCount(){ + calls.append("incrementCount,"); + Integer conversationalCount = conversationalState.get(conversationId); + conversationalCount++; + conversationalState.put(conversationId, conversationalCount); + } + + public int retrieveCount(){ + calls.append("retrieveCount,"); + Integer count = conversationalState.get(conversationId); + if (count != null){ + return count.intValue(); + } else { + return -999; + } + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public void initializeCountCallback(int count){ + calls.append("initializeCountCallback,"); + initializeCount(count); + conversationalCallback.initializeCount(count); + } + + public void incrementCountCallback(){ + calls.append("incrementCountCallback,"); + incrementCount(); + conversationalCallback.incrementCount(); + } + + public int retrieveCountCallback(){ + calls.append("retrieveCountCallback,"); + return conversationalCallback.retrieveCount(); + } + + public void businessExceptionCallback() throws Exception { + calls.append("businessExceptionCallback,"); + conversationalCallback.businessException(); + } + + public String endConversation(){ + calls.append("endConversation,"); + conversationalState.remove(conversationId); + return conversationId; + } + + public String endConversationCallback(){ + calls.append("endConversationCallback,"); + return conversationalCallback.endConversation(); + } +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScope.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScope.java new file mode 100644 index 0000000000..b1332833bb --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/itest/conversational/impl/ConversationalServiceStatelessScope.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.itest.conversational.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.sca.itest.conversational.ConversationalService; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Service; + +@Service(ConversationalService.class) +public class ConversationalServiceStatelessScope implements ConversationalService { + + @ConversationID + protected String cid; + + static Map state = new HashMap(); + + public void destroy() { + // TODO Auto-generated method stub + + } + + public String endConversation() { + state.remove(cid); + return cid; + } + + public String endConversationCallback() { + // TODO Auto-generated method stub + return null; + + } + + public void incrementCount() { + state.put(cid, Integer.valueOf(state.get(cid)+1)); + } + + public void businessException() throws Exception { + throw new Exception("Business Exception"); + } + + public void incrementCountCallback() { + // TODO Auto-generated method stub + + } + + public void init() { + // TODO Auto-generated method stub + + } + + public void initializeCount(int count) { + state.put(cid, Integer.valueOf(count)); + } + + public void initializeCountCallback(int count) { + // TODO Auto-generated method stub + + } + + public void businessExceptionCallback() throws Exception { + throw new Exception("Business Exception"); + } + + public int retrieveCount() { + return state.get(cid); + } + + public int retrieveCountCallback() { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/AnotherService.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/AnotherService.java new file mode 100644 index 0000000000..90c674c6ac --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/AnotherService.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.test; + +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Conversational +/** + * + */ +public interface AnotherService { + + public void setService(ServiceReference aServiceReference); + public void add(int anInt); + public int getCount(); + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/AnotherServiceImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/AnotherServiceImpl.java new file mode 100644 index 0000000000..027109787a --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/AnotherServiceImpl.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.test; + +import junit.framework.Assert; + +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(AnotherService.class) +@Scope("CONVERSATION") + +public class AnotherServiceImpl implements AnotherService { + + // This is a simple pass-thru service used to test propogation + // of ServiceReference and maintenance of Session state. + + private ServiceReference aServiceReference; + + public void add(int anInt) { + + Assert.assertNotNull("AnotherServiceImpl - add ", aServiceReference); + ((ConversationsService) aServiceReference).add(anInt); + + } + + + public void initializeCount() { + + Assert.assertNotNull("AnotherServiceImpl - initializeCount ", aServiceReference); + ((ConversationsService) aServiceReference).initializeCount(); + + } + + + public void setService(ServiceReference aRef) { + + Assert.assertNotNull("AnotherServiceImpl - setService ", aRef); + aServiceReference = aRef; + + } + + + public int getCount() { + + Assert.assertNotNull("AnotherServiceImpl - getCount ", aServiceReference); + return ((ConversationsService) aServiceReference).getLocalCount(); + } + + +} + diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsCallback.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsCallback.java new file mode 100644 index 0000000000..18e935e089 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsCallback.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.test; + +import org.osoa.sca.annotations.Conversational; + +@Conversational +/** + * + * + */ +public interface ConversationsCallback { + + public void callBackMessage(String aString); + public void callBackIncrement(String aString); + public void callBackEndSession(); + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClient.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClient.java new file mode 100644 index 0000000000..ff677db74d --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClient.java @@ -0,0 +1,31 @@ +/* + * 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.test; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Conversational +public interface ConversationsClient { + + public void run(); + public int count(); + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClient2.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClient2.java new file mode 100644 index 0000000000..389b1f4d93 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClient2.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.test; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Conversational +public interface ConversationsClient2 { + public String getDateTime(); + + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClientImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClientImpl.java new file mode 100644 index 0000000000..54a437e66a --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsClientImpl.java @@ -0,0 +1,496 @@ +/* + * 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.test; + +import java.io.File; +import java.text.DateFormat; + +import junit.framework.Assert; + +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ConversationEndedException; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(interfaces={ConversationsClient.class,ConversationsClient2.class}) + + +@Scope("CONVERSATION") +@ConversationAttributes(maxIdleTime="10 minutes", + singlePrincipal=false) + + +public class ConversationsClientImpl implements ConversationsClient, ConversationsClient2, ConversationsCallback { + + @Reference + protected ConversationsService aService; + @Reference + protected AnotherService anotherService; + @Reference + protected ConversationsLifeCycleService aLifeCycleService; + @Context + protected ComponentContext myContext; + @ConversationID + protected String conversationID; + + private Object monitor = new Object(); + private int count=0; + private String message; + private String initialState; + private int initialCount = 56; + private String dateTime; + private final static String markerFileName = "target/testConversations_test3_marker"; + + public ConversationsClientImpl() { + System.out.println("xxxxxxxxxx"); + } + + public void run() { + + // This tests various aspects of session lifecycle and maintenance of session state. + // None of these test are working due to various issues. + + /* test0() + This test verifies annotations and API's for ConversationID. + */ + test0(); // - Tuscany-1001. + + /* test1() + Test stateful callbacks. Verify that the client�s state is maintained throughout the execution of + all callback methods. + */ + test1(); // This test is working for MODULE scope. Cant claim succcess because it needs Conversation scope. + + /* test2() + Test each method of starting a session. Test @Init. + */ + test2(); // Tuscany-965, Tuscany-1001 + + /* test3() + Test each method of ending a session. Test @Destroy. + */ + test3(); // Tuscany-965, Tuscany-1001 + + /* test4() + Pass an existing service reference with an active session to another service. Verify the session is maintained + */ + test4(); // Tuscany-964, Tuscant-1001 + + /* test5() + Call the createServiceReferenceForSession() API to get a service reference for the active session. + Pass the service reference to another service. Verify the session is maintained. + */ + test5(); + + /* test6() + * Allow a session to timeout. + */ + test6(); // Tuscany-965, Tuscany-1001 + + + return; + } + + private void test0() + { + + // Verify that conversationID was injected. + Assert.assertNotNull("test0 - conversationID injected", conversationID); + System.out.println("ConversationID: " + conversationID); + + // + // The client may access the ConversationID by calling getConversationID on a Service Reference. + // This also verifies a session was created during injection of this Service Reference. + // + // TODO: this fails as the cid is null as a conversation has not been started yet (which seems expected to me) +// ServiceReference aServiceserviceRef = myContext.getServiceReference(ConversationsService.class, "aService"); +// System.out.println("aServices cid: " + aServiceserviceRef.getConversationID()); +// Assert.assertNotNull("test0 - ConversationID from service reference", aServiceserviceRef.getConversationID()); + + //FIXME Port to the 1.0 spec API + //Object aLifeCycleServicesSessionID =((ServiceReference)aLifeCycleService).getSessionID(); + //Assert.assertNotNull("test0 - ConversationID from LifeCycleService service reference", aLifeCycleServicesSessionID); + + // This will verify the @Init() is working for a session created during injection. See test2(). + aLifeCycleService.knockKnock("Hello"); + + } + + private void test1() + { + + // + // This test verifies that the state of the client is preserved across method calls. Each + // call to the service results in 2 callbacks. One to increment a count and the other to set a string. + // At the end of the test the count should equal 5 and the string should be set. Also the original strings + // values should be preserved. + // + // + initialState = "Initial State"; + + int numCalls = 0; + + for(int i=0; i < 10; i++) + { + aService.knockKnock("Knock Knock " + ++numCalls); + } + + // I want to drive multiple callbacks and then give them time to complete. Don't want to + // force serialization. After 20 seconds check the assertions. + + synchronized(monitor) + { + try + { + monitor.wait(2000L); + } + catch (Exception ex) + {ex.printStackTrace();} + } + + // Here we test for the expected state of several different variables. State needs to be maintained + // across method calls to the service. If the same client instance is used then the state should match + // the following assertions. + + // instance variable count should equal the number of calls to the backend service. count is incremented + // during callback processing. + Assert.assertEquals("Conversations - Test1 count", numCalls, count); + // The returned message should be like the following. + Assert.assertEquals("Conversations - Test1 message", true, message.startsWith("Who's There")); + // any initial state set prior to running the callbacks should be maintained. + Assert.assertEquals("Conversations - Test1 initialState", "Initial State", initialState); + Assert.assertEquals("Conversations - Test1 initialCount", 56, initialCount); + + return; + + } + + private void test2() + { + + // Verify the various methods to create a new Session. + // Sesssions can be started: + // + // 1) When a service reference is injected into a client. This is verified in test0(). + // 2) By the client calling newSession() API with and without a ConversationID. + // + // Verify init() is called prior to any business methods. This is performed in the Service when any + // business methos is called. + + Assert.assertNotNull("current composite context",myContext); + + // This tests creating a conversational session. And that @Init is run prior to business method. + ServiceReference aServRef = null; + //FIXME Port to the 1.0 spec API + //aServRef = myContext.newSession("ConversationsLifeCycleService"); +// Assert.assertNotNull("Conversations - Test2 Service Reference 1 not returned", aServRef); + + //FIXME Port to the 1.0 spec API + //Get the session ID. + //Object aConversationID = aServRef.getSessionID(); + ConversationsLifeCycleService aConversationsLifeCycleService = (ConversationsLifeCycleService) aServRef; + aConversationsLifeCycleService.knockKnock("Hello"); + + //Create a new session this time specifying a session ID. Verify the seesion id is what was specified. + //FIXME Port to the 1.0 spec API + //aServRef = myContext.newSession("ConversationsLifeCycleService","Test2-12345"); + Assert.assertNotNull("Conversations - Test2 Service Reference 2 not returned", aServRef); + //FIXME Port to the 1.0 spec API + //Get the session ID. + //Object aConversationID2 = aServRef.getSessionID(); + //Assert.assertEquals("Conversations - Test2 Session not created with specified ConversationID", "Test2-12345", aConversationID2); + aConversationsLifeCycleService = (ConversationsLifeCycleService) aServRef; + aConversationsLifeCycleService.knockKnock("Hello"); + + //FIXME Port to the 1.0 spec API + //Assert.assertNotSame("Conversations - Test2 sessions are not different", aConversationID, aConversationID2); + + } + + private void test3() + { + + // Note: The @EndSesion and @EndsConversation anotations are not implemented. + // So #1 an #2 cannot be done. + + // + // Verify the various methods to end a session. + // Sesssions can be ended: + // + // 1) Server operation annotated with @EndsConversation. + // 2) Server operation calls an @EndSession annotated callback method. + // 3) Servers conversation lifetime times out. This is test6() so its not implimented in the test3 method. + // 4) The client calls ServiceReference.endSession(); + // + // Verify @Destroy annotated method get called after completion of the business + // method that called the endSession. + // + + ConversationsLifeCycleService aConversationsLifeCycleService; +//FIXME Port to the 1.0 spec API +// Object aConversationID; + Assert.assertNotNull("current composite context",myContext); + ServiceReference aServRef; + this.removeMarkerFile(); + + // + // test3 variation #1 - Cannot be done annotation not implimented yet. 12/15/2006 + // + + //FIXME Port to the 1.0 spec API + //aServRef = myContext.newSession("ConversationsLifeCycleService"); + aServRef = null; + Assert.assertNotNull("Conversations - Test3-1 Service Reference not returned", aServRef); + + aConversationsLifeCycleService = (ConversationsLifeCycleService) aServRef; + aConversationsLifeCycleService.knockKnock("Hello"); + //FIXME Port to the 1.0 spec API + //aConversationID = aServRef.getSessionID(); + //Assert.assertNotNull("Conversations - Test3-1 ConversationID not found", aConversationID); + + //Call the business method annotated with @EndsConversation. + aConversationsLifeCycleService.endThisSession(); // This should also drive @Destroy method. + + // Verify session has ended. The ConversationID should be null; + //FIXME Port to the 1.0 spec API + //aConversationID = aServRef.getSessionID(); + //Assert.assertNull("Conversations - Test3-1 session not null after endSession()", aConversationID); + + // Verify Destroy was run. The baxckend service creates a marker file when @Destroy annotated method is run. + Assert.assertEquals("Conversations - Test3-1 @Destroy method not invoked", true, this.isMarkerFilePresent()); + this.removeMarkerFile(); + + // + // test3 variation #2 - Cannot be done annotation not implimented yet. 12/15/2006 + // + + //FIXME Port to the 1.0 spec API + //aServRef = myContext.newSession("ConversationsLifeCycleService"); + Assert.assertNotNull("Conversations - Test3-2 Service Reference not returned", aServRef); + + aConversationsLifeCycleService = (ConversationsLifeCycleService) aServRef; + aConversationsLifeCycleService.knockKnock("Hello"); + //FIXME Port to the 1.0 spec API + //aConversationID = aServRef.getSessionID(); + //Assert.assertNotNull("Conversations - Test3-2 ConversationID not found", aConversationID); + + //Call the business method that will invoke my @EndSession callback method. + aConversationsLifeCycleService.endThisSessionUsingCallback(); // This should also drive @Destroy method. + + // Verify session has ended. The ConversationID should be null; + //FIXME Port to the 1.0 spec API + //aConversationID = aServRef.getSessionID(); + //Assert.assertNull("Conversations - Test3-2 session not null after endSession()", aConversationID); + + // Verify Destroy was run. The baxckend service creates a marker file when @Destroy annotated method is run. + Assert.assertEquals("Conversations - Test3-2 @Destroy method not invoked", true, this.isMarkerFilePresent()); + this.removeMarkerFile(); + + // + // test3 variation #4 - Client calls endSession() + // + + //FIXME Port to the 1.0 spec API + //aServRef = myContext.newSession("ConversationsLifeCycleService"); + aServRef = null; + Assert.assertNotNull("Conversations - Test3-4 Service Reference not returned", aServRef); + + aConversationsLifeCycleService = (ConversationsLifeCycleService) aServRef; + aConversationsLifeCycleService.knockKnock("Hello"); + //FIXME Port to the 1.0 spec API + //aConversationID = aServRef.getSessionID(); + //Assert.assertNotNull("Conversations - Test3-4 ConversationID not found", aConversationID); + + //Call the endSession() API on the Service Reference. + //FIXME Port to the 1.0 spec API + //aServRef.endSession(); // This should also drive @Destroy method. + + // Verify session has ended. The ConversationID should be null; + //FIXME Port to the 1.0 spec API + //aConversationID = aServRef.getSessionID(); + //Assert.assertNull("Conversations - Test3-4 session not null after endSession()", aConversationID); + + // Verify Destroy was run. The baxckend service creates a marker file when @Destroy annotated method is run. + Assert.assertEquals("Conversations - Test3-4 @Destroy method not invoked", true, this.isMarkerFilePresent()); + this.removeMarkerFile(); + } + + public void test4() + { + + // + // This test uses the injected active session for the ConversationsService. It starts a conversation + // in this method building up state with a counter. It then passes this reference to another backend service adding + // additional state. It then returns and adds more state using original service and then performs the Assertions. + // + + aService.initializeCount(); + aService.add(1); + anotherService.setService((ServiceReference)aService); + anotherService.add(1); + anotherService.add(1); + aService.add(1); + aService.add(1); + int count = anotherService.getCount(); + + Assert.assertEquals("test4 - ConversationsClientImpl ", 5, count); + + return; + } + + + public void test5() + { + + // The first test verifies that the createServiceReferenceForSession(this) API is functioning. + // This is done in the backend serviced as it needs a single interface defined. The 2nd test + // uses the variant of this API when > 1 interfaces are implemented. + // + // The 2nd test obtains a service reference for myself and passes that reference to a backend service. + // The backend service then invokes the count() method on my service reference. It then returns + // the count that it retrieved. The test then asserts that the count returned from the backend + // service matches the client services internal state. + // + + Assert.assertNotNull("current composite context",myContext); + + boolean result = aService.createServiceReferenceForSelf(); + System.out.println("Laa: returned from createServiceReferenceForSelf() " + result); + Assert.assertEquals("test5 - createServiceReferenceForSelf",true,result); + + count = 6; + int returnCount = 0; + //FIXME Port to the 1.0 spec API + //ServiceReference myServiceReference = myContext.createServiceReferenceForSession(this,"ConversationsClient2"); + ServiceReference myServiceReference = null; + Assert.assertNotNull("test5 - createServiceReferenceForSession - myContext.createServiceReferenceForSession(this,ConversationsClient);", myServiceReference); + returnCount = aService.getCount(myServiceReference); + + Assert.assertEquals("test5 - createServiceReferenceForSession(this,ConversationsClient2)",count,returnCount); + String aRemoteDateTime = aService.getDateTime(myServiceReference); + Assert.assertEquals("test5 - createServiceReferenceForSession(this,ConversationsClient2 - dateTime)", dateTime, aRemoteDateTime); + + return; + } + + public void test6() + { + + // + // Create a session and allow it to timeout and verify that it did. + // Invoking a business method on a service that has timed out should result in + // a SessionEndedException. + // + + Assert.assertNotNull("current composite context",myContext); + + // This tests creating a conversational session. This service has a maxAge="5 seconds". + ServiceReference aServRef; + //FIXME Port to the 1.0 spec API + //aServRef = myContext.newSession("ConversationsLifeCycleService"); + aServRef = null; + Assert.assertNotNull("Conversations - Test6 Service Reference not returned", aServRef); + + // Run a business method. + ConversationsLifeCycleService aConversationsLifeCycleService = (ConversationsLifeCycleService) aServRef; + aConversationsLifeCycleService.knockKnock("Hello"); + + // + // wait 10 seconds so session will time out. + // + try { + Thread.sleep(10000L); + } + catch (InterruptedException ex) + { + ex.printStackTrace(); + } + + // Run a busineess method after timeout period has elapsed. + boolean sessionEnded = false; + try + { + aConversationsLifeCycleService.knockKnock("Hello"); + } + catch (ConversationEndedException sex) + { + sessionEnded = true; + } + + Assert.assertEquals("Conversations - Test6 Session did not timeout ", true, sessionEnded); + + return; + } + + + public synchronized void callBackIncrement(String aString) { + + count++; + System.out.println("Laa: callBackIncrement invoked on client. count = " + count); + + } + + public synchronized void callBackMessage(String aString) { + + message = aString; + System.out.println("Laa: callBackIMessage invoked on client. message = " + message); + + } + + // @EndSession - This is for test3() variation #2. + public void callBackEndSession() { + + System.out.println("Laa: callBackEndSession method invoked on client."); + + } + + public int count() + { + return this.count; + } + + public String getDateTime() { + + dateTime = DateFormat.getDateTimeInstance().toString(); + return dateTime; + + } + + private void removeMarkerFile() + { + // Make sure the marker file is not present before starting the test. + File aFile = new File(markerFileName); + if (aFile.exists()) + aFile.delete(); + } + + private boolean isMarkerFilePresent() + { + File aFile = new File(markerFileName); + return aFile.exists(); + } + + + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsLifeCycleService.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsLifeCycleService.java new file mode 100644 index 0000000000..26dfcd9a38 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsLifeCycleService.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.test; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Callback(ConversationsCallback.class) +@Conversational + +/** + * + */ +public interface ConversationsLifeCycleService { + + public String knockKnock(String aString); + public void endThisSession(); + public void endThisSessionUsingCallback(); + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsLifeCycleServiceImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsLifeCycleServiceImpl.java new file mode 100644 index 0000000000..7f38e356f6 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsLifeCycleServiceImpl.java @@ -0,0 +1,97 @@ +/* + * 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.test; + +import java.io.File; + +import junit.framework.Assert; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.ConversationAttributes; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationsLifeCycleService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="5 seconds") + +// This is a short-lived conversational service. + +public class ConversationsLifeCycleServiceImpl implements ConversationsLifeCycleService { + + @Callback + protected ConversationsCallback callback; + + private String state = "NOT READY"; + private final static String markerFileName = "target/testConversations_test3_marker"; + + + public String knockKnock(String aString) { + + // Prior to any business methods being invoked the state must have been set to READY using the @Init. + System.out.println("ConversationsLifeCycleServiceImpl.knockKnock - State = " + state); + Assert.assertEquals("ConversationsLifeCycleServiceImpl.knockKnock - not in READY state ", "READY", state); + + return "Who's There!"; + } + + @Init + public void init() + { + state = "READY"; + System.out.println("ConversationsLifeCycleServiceImpl.init()"); + } + + + @Destroy + public void destroy() + { + state = "DESTROYED"; + + File aFile = new File(markerFileName); + try + { + aFile.createNewFile(); + } + catch (Exception ex) + { + System.out.println("Error Creating " + markerFileName); + ex.printStackTrace(); + } + System.out.println("ConversationsLifeCycleServiceImpl.destroy()"); + } + +// @EndsConversation + public void endThisSession() { + //This method will end the current session by annotation. + System.out.println("ConversationsLifeCycleServiceImpl.endThisSession()"); + + } + + public void endThisSessionUsingCallback() { + + //This method will end the current session by a callback method annotated with @EndSession. + callback.callBackEndSession(); + System.out.println("ConversationsLifeCycleServiceImpl.endThisSessionUsingCallback()"); + } + +} + diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsService.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsService.java new file mode 100644 index 0000000000..f878e22bf8 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsService.java @@ -0,0 +1,43 @@ +/* + * 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.test; + +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Callback(ConversationsCallback.class) +@Conversational + +/** + * + */ +public interface ConversationsService { + + public void knockKnock(String aString); + public void add(int anInt); + public void initializeCount(); + public int getCount(ServiceReference aServiceReference); + public int getLocalCount(); + public String getDateTime(ServiceReference aServiceReference); + public boolean createServiceReferenceForSelf(); + +} diff --git a/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsServiceImpl.java b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsServiceImpl.java new file mode 100644 index 0000000000..45fc68308b --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/java/org/apache/tuscany/sca/test/ConversationsServiceImpl.java @@ -0,0 +1,147 @@ +/* + * 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.test; + +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ConversationsService.class) +@Scope("CONVERSATION") + +public class ConversationsServiceImpl implements ConversationsService { + + @Context + protected ComponentContext context; + + @Callback + protected ConversationsCallback callback; + private int count=0; + + public void knockKnock(String aString) { + + try + { + count++; + //System.out.println("ConversationsServiceImpl message received: " + aString); + callback.callBackMessage("Who's There " + count); + callback.callBackIncrement("Add one please"); + //System.out.println("ConversationsServiceImpl responses sent"); + return; + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + } + + public int getCount(ServiceReference aServiceReference) + { + + // + // Invoke a method on the service reference and return back the result. + // + + int count=0; + try + { + count = ((ConversationsClient) aServiceReference).count(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + return count; + + } + + public int getLocalCount() + { + + // + // Return my localc instance count. This is used for test4. + // + + return count; + + } + + public String getDateTime(ServiceReference aServiceReference) + { + + // + // Invoke a method on the service reference and return back the result. + // + + String dateTime; + dateTime = ((ConversationsClient2) aServiceReference).getDateTime(); + return dateTime; + + } + + public void add(int anInt) { + + count +=anInt; + + } + + public void initializeCount() { + + count =0; + + } + + public boolean createServiceReferenceForSelf() { + + // This is done here because we need to test getting a ServiceReference + // from a component that implements a single interface. The client in this test + // impliments 2 interfaces to test the variant of this that takes interface name as an argumnet. + + boolean aBoolean = false; + + ServiceReference myServiceReference = null; + + try + { + myServiceReference = context.createSelfReference(ConversationsService.class); + System.out.println("Laa: Created Service Reference for Session:" + myServiceReference); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + + if (myServiceReference != null) + { + aBoolean = true; + System.out.println("Laa: Service Reference is not null"); + } + + return aBoolean; + } + + +} + diff --git a/sandbox/old/contrib/itest/conversations/src/main/resources/ConversationAge.composite b/sandbox/old/contrib/itest/conversations/src/main/resources/ConversationAge.composite new file mode 100644 index 0000000000..abd1c35ced --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/resources/ConversationAge.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/conversations/src/main/resources/ConversationsTest.composite b/sandbox/old/contrib/itest/conversations/src/main/resources/ConversationsTest.composite new file mode 100644 index 0000000000..93b44c260f --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/resources/ConversationsTest.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/conversations/src/main/resources/conversationId.composite b/sandbox/old/contrib/itest/conversations/src/main/resources/conversationId.composite new file mode 100644 index 0000000000..e61eb08194 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/resources/conversationId.composite @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/sandbox/old/contrib/itest/conversations/src/main/resources/conversational.composite b/sandbox/old/contrib/itest/conversations/src/main/resources/conversational.composite new file mode 100644 index 0000000000..43259f67c3 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/main/resources/conversational.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java new file mode 100644 index 0000000000..1138d2e1f0 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationIdTestCase.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.itest.conversational; + + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.itest.conversational.impl.ConversationIdService; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ConversationIdTestCase { + + private SCADomain domain; + + @Before + public void setUp() throws Exception { + domain = SCADomain.newInstance("conversationId.composite"); + + } + + @After + public void tearDown() throws Exception { + if (domain != null) { + domain.close(); + } + } + + @Test + public void testConversationId() { + ConversationIdService service = + domain.getService(ConversationIdService.class, "ConversationIdComponent"); + Assert.assertNotNull(service.getCIDField()); + Assert.assertNotNull(service.getCIDSetter()); + } + +} diff --git a/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.java new file mode 100644 index 0000000000..d7c6a0ed41 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalAgeTestCase.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.itest.conversational; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.osoa.sca.ConversationEndedException; + +public class ConversationalAgeTestCase { + + private SCADomain domain; + + @Before + public void setUp() throws Exception { + System.setProperty("org.apache.tuscany.sca.core.scope.ConversationalScopeContainer.ReaperInterval", "2"); + domain = SCADomain.newInstance("ConversationAge.composite"); + + } + + @After + public void tearDown() throws Exception { + System.clearProperty("org.apache.tuscany.sca.core.scope.ConversationalScopeContainer.ReaperInterval"); + if (domain != null) { + domain.close(); + } + } + + @Test + public void testMaxAge() throws InterruptedException { + + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationAgeComponent"); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + conversationalService.initializeCount(42); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Thread.sleep(3100); + Assert.assertEquals(0, conversationalService.retrieveCount()); + } + + @Test + public void testAgeExpired() throws InterruptedException { + + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationAgeComponent"); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + conversationalService.initializeCount(42); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Thread.sleep(1100); + try { + Assert.assertEquals(0, conversationalService.retrieveCount()); + Assert.fail(); + } catch (ConversationEndedException e) { + // expected + } + } + + @Test + public void testMaxIdle() throws InterruptedException { + + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationIdleComponent"); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + conversationalService.initializeCount(42); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Assert.assertEquals(42, conversationalService.retrieveCount()); + Thread.sleep(3100); + Assert.assertEquals(0, conversationalService.retrieveCount()); + } + +} diff --git a/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java new file mode 100644 index 0000000000..8480e04028 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalJ2SETestCase.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.itest.conversational; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ConversationalJ2SETestCase { + + private SCADomain domain; + + @Before + public void setUp() throws Exception { + domain = SCADomain.newInstance("conversational.composite"); + + } + + @After + public void tearDown() throws Exception { + if (domain != null) { + domain.close(); + } + } + + @Test + public void testStatefulConversation() { + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationalServiceStateful"); + + conversationalService.initializeCount(1); + Assert.assertEquals(1, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(2, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + Assert.assertEquals(0, conversationalService.retrieveCount()); + + conversationalService.initializeCount(4); + Assert.assertEquals(4, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(5, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + } + + @Test + public void testStatelessConversation() { + ConversationalService conversationalService = + domain.getService(ConversationalService.class, "ConversationalServiceStateless"); + + conversationalService.initializeCount(1); + Assert.assertEquals(1, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(2, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + conversationalService.initializeCount(4); + Assert.assertEquals(4, conversationalService.retrieveCount()); + conversationalService.incrementCount(); + Assert.assertEquals(5, conversationalService.retrieveCount()); + conversationalService.endConversation(); + + } +} diff --git a/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java new file mode 100644 index 0000000000..245f0a5597 --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/itest/conversational/ConversationalTestCase.java @@ -0,0 +1,322 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.itest.conversational; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatefulImpl; +import org.apache.tuscany.sca.itest.conversational.impl.ConversationalClientStatelessImpl; +import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatefulImpl; +import org.apache.tuscany.sca.itest.conversational.impl.ConversationalServiceStatelessImpl; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ConversationalTestCase { + + private SCADomain domain; + private ConversationalClient conversationalStatelessClientStatelessService; + private ConversationalClient conversationalStatelessClientStatefulService; + private ConversationalClient conversationalStatefulClientStatelessService; + private ConversationalClient conversationalStatefulClientStatefulService; + + @Before + public void setUp() throws Exception { + domain = SCADomain.newInstance("conversational.composite"); + + conversationalStatelessClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatelessService"); + + conversationalStatelessClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatelessClientStatefulService"); + + conversationalStatefulClientStatelessService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatelessService"); + + conversationalStatefulClientStatefulService = domain.getService(ConversationalClient.class, + "ConversationalStatefulClientStatefulService"); + + + // reset the place where we record the sequence of calls passing + // through each component instance + ConversationalServiceStatelessImpl.calls = new StringBuffer(); + ConversationalServiceStatefulImpl.calls = new StringBuffer(); + ConversationalClientStatelessImpl.calls = new StringBuffer(); + ConversationalClientStatefulImpl.calls = new StringBuffer(); + + } + + @After + public void tearDown() throws Exception { + domain.close(); + } + + // stateless client stateful service tests + // ======================================= + @Test + public void testStatelessStatefulConversationFromInjectedReference() { + int count = conversationalStatelessClientStatefulService.runConversationFromInjectedReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatefulConversationFromServiceReference() { + int count = conversationalStatelessClientStatefulService.runConversationFromServiceReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatefulConversationWithUserDefinedConversationId() { + int count = conversationalStatelessClientStatefulService.runConversationWithUserDefinedConversationId(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatefulConversationCheckUserDefinedConversationId() { + String conversationId = conversationalStatelessClientStatefulService.runConversationCheckUserDefinedConversationId(); + Assert.assertEquals("MyConversation2", conversationId); + } + + @Test + public void testStatelessStatefulConversationCheckingScope() { + conversationalStatelessClientStatefulService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,", + ConversationalServiceStatefulImpl.calls.toString()); + } + + @Test + public void testStatelessStatefulConversationWithCallback() { + int count = conversationalStatelessClientStatefulService.runConversationWithCallback(); + Assert.assertEquals(0, count); + + Assert.assertEquals("init,runConversationWithCallback,init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,destroy,", + ConversationalClientStatelessImpl.calls.toString()); + } + + //@Test + public void testStatelessStatefulConversationHavingPassedReference() { + int count = conversationalStatelessClientStatefulService.runConversationHavingPassedReference(); + Assert.assertEquals(3, count); + } + + @Test + public void testStatelessStatefulConversationBusinessException() { + String message = conversationalStatelessClientStatefulService.runConversationBusinessException(); + Assert.assertEquals("Business Exception", message); + } + + @Test + public void testStatelessStatefulConversationBusinessExceptionCallback() { + String message = conversationalStatelessClientStatefulService.runConversationBusinessExceptionCallback(); + Assert.assertEquals("Business Exception", message); + } + + @Test + public void testStatelessStatefulConversationCallingEndedConversation() { + int count = conversationalStatelessClientStatefulService.runConversationCallingEndedConversation(); + Assert.assertEquals(0, count); + } + + @Test + public void testStatelessStatefulConversationCallingEndedConversationCallback() { + int count = conversationalStatelessClientStatefulService.runConversationCallingEndedConversationCallback(); + Assert.assertEquals(0, count); + } + + // stateless client stateless service tests + // ======================================== + @Test + public void testStatelessStatelessConversationFromInjectedReference() { + int count = conversationalStatelessClientStatelessService.runConversationFromInjectedReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatelessConversationFromServiceReference() { + int count = conversationalStatelessClientStatelessService.runConversationFromServiceReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatelessStatelessConversationWithUserDefinedConversationId() { + int count = conversationalStatelessClientStatelessService.runConversationWithUserDefinedConversationId(); + Assert.assertEquals(2, count); + } + @Test + public void testStatelessStatelessConversationCheckUserDefinedConversationId() { + String conversationId = conversationalStatelessClientStatelessService.runConversationCheckUserDefinedConversationId(); + Assert.assertEquals("MyConversation2", conversationId); + } + + @Test + public void testStatelessStatelessConversationCheckingScope() { + conversationalStatelessClientStatelessService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,", + ConversationalServiceStatelessImpl.calls.toString()); + } + + @Test + public void testStatelessStatelessConversationWithCallback() { + int count = conversationalStatelessClientStatelessService.runConversationWithCallback(); + Assert.assertEquals(0, count); + + Assert.assertEquals("init,runConversationWithCallback,init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,destroy,", + ConversationalClientStatelessImpl.calls.toString()); + } + //@Test + public void testStatelessStatelessConversationHavingPassedReference() { + int count = conversationalStatelessClientStatelessService.runConversationHavingPassedReference(); + Assert.assertEquals(3, count); + } + + @Test + public void testStatelessStatelessConversationCallingEndedConversation() { + int count = conversationalStatelessClientStatelessService.runConversationCallingEndedConversation(); + Assert.assertEquals(-999, count); + } + + @Test + public void testStatelessStatelessConversationCallingEndedConversationCallback() { + int count = conversationalStatelessClientStatelessService.runConversationCallingEndedConversationCallback(); + Assert.assertEquals(0, count); + } + + // stateful client stateful service tests + // ====================================== + @Test + public void testStatefulStatefulConversationFromInjectedReference() { + int count = conversationalStatefulClientStatefulService.runConversationFromInjectedReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatefulConversationFromServiceReference() { + int count = conversationalStatefulClientStatefulService.runConversationFromServiceReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatefulConversationWithUserDefinedConversationId() { + int count = conversationalStatefulClientStatefulService.runConversationWithUserDefinedConversationId(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatefulConversationCheckUserDefinedConversationId() { + String conversationId = conversationalStatefulClientStatefulService.runConversationCheckUserDefinedConversationId(); + Assert.assertEquals("MyConversation2", conversationId); + } + + @Test + public void testStatefulStatefulConversationCheckingScope() { + conversationalStatefulClientStatefulService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,incrementCount,retrieveCount,endConversation,destroy,", + ConversationalServiceStatefulImpl.calls.toString()); + } + + @Test + public void testStatefulStatefulConversationWithCallback() { + int count = conversationalStatefulClientStatefulService.runConversationWithCallback(); + Assert.assertEquals(4, count); + + Assert.assertEquals("init,runConversationWithCallback,initializeCount,incrementCount,retrieveCount,endConversation,destroy,", + ConversationalClientStatefulImpl.calls.toString()); + } + + //@Test + public void testStatefulStatefulConversationHavingPassedReference() { + int count = conversationalStatefulClientStatefulService.runConversationHavingPassedReference(); + Assert.assertEquals(3, count); + } + + @Test + public void testStatefulStatefulConversationCallingEndedConversation() { + int count = conversationalStatefulClientStatefulService.runConversationCallingEndedConversation(); + Assert.assertEquals(0, count); + } + + @Test + public void testStatefulStatefulConversationCallingEndedConversationCallback() { + int count = conversationalStatefulClientStatefulService.runConversationCallingEndedConversationCallback(); + Assert.assertEquals(0, count); + } + + // stateful client stateless service tests + // ======================================= + @Test + public void testStatefulStatelessConversationFromInjectedReference() { + int count = conversationalStatefulClientStatelessService.runConversationFromInjectedReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatelessConversationFromServiceReference() { + int count = conversationalStatefulClientStatelessService.runConversationFromServiceReference(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatelessConversationWithUserDefinedConversationId() { + int count = conversationalStatefulClientStatelessService.runConversationWithUserDefinedConversationId(); + Assert.assertEquals(2, count); + } + + @Test + public void testStatefulStatelessConversationCheckUserDefinedConversationId() { + String conversationId = conversationalStatefulClientStatelessService.runConversationCheckUserDefinedConversationId(); + Assert.assertEquals("MyConversation2", conversationId); + } + + @Test + public void testStatefulStatelessConversationCheckingScope() { + conversationalStatefulClientStatelessService.runConversationCheckingScope(); + Assert.assertEquals("init,initializeCount,destroy,init,incrementCount,destroy,init,retrieveCount,destroy,init,endConversation,destroy,", + ConversationalServiceStatelessImpl.calls.toString()); + } + + @Test + public void testStatefulStatelessConversationWithCallback() { + int count = conversationalStatefulClientStatelessService.runConversationWithCallback(); + Assert.assertEquals(4, count); + + Assert.assertEquals("init,runConversationWithCallback,initializeCount,incrementCount,retrieveCount,endConversation,destroy,", + ConversationalClientStatefulImpl.calls.toString()); + } + + //@Test + public void testStatefulStatelessConversationHavingPassedReference() { + int count = conversationalStatefulClientStatelessService.runConversationHavingPassedReference(); + Assert.assertEquals(3, count); + } + + @Test + public void testStatefulStatelessConversationCallingEndedConversation() { + int count = conversationalStatefulClientStatelessService.runConversationCallingEndedConversation(); + Assert.assertEquals(-999, count); + } + + @Test + public void testStatefulStatelessConversationCallingEndedConversationCallback() { + int count = conversationalStatefulClientStatelessService.runConversationCallingEndedConversationCallback(); + Assert.assertEquals(0, count); + } + +} diff --git a/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/test/ConversationsTestCaseFIXME.java b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/test/ConversationsTestCaseFIXME.java new file mode 100644 index 0000000000..fdbb1f9dca --- /dev/null +++ b/sandbox/old/contrib/itest/conversations/src/test/java/org/apache/tuscany/sca/test/ConversationsTestCaseFIXME.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.test; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +//FIXME Fix this test case +public class ConversationsTestCaseFIXME extends TestCase { + + private SCADomain domain; + private ConversationsClient aConversationsClient; + + public void testConversations() { + aConversationsClient.run(); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("ConversationsTest.composite"); + + aConversationsClient = + domain.getService(ConversationsClient.class, + "ConversationsClient/ConversationsClient"); + + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/sandbox/old/contrib/itest/interop-xsq-client/pom.xml b/sandbox/old/contrib/itest/interop-xsq-client/pom.xml new file mode 100644 index 0000000000..c31cce8fc3 --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/pom.xml @@ -0,0 +1,60 @@ + + + + + org.apache.tuscany.testing + tuscany-interop-clients + 0.1-integration-incubating-SNAPSHOT + + 4.0.0 + interop-client-webserviceXSQ + jar + Tuscany Interop Testing - Clients - webserviceXSQ + + axis2 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + always + -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=3720,server=y,suspend=y + + + + + + + + + + org.apache.tuscany.sca.services.idl + tuscany-wsdl + ${sca.version} + provided + + + + + + diff --git a/sandbox/old/contrib/itest/interop-xsq-client/src/main/resources/META-INF/README.txt b/sandbox/old/contrib/itest/interop-xsq-client/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..9b26d1690a --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/src/main/resources/META-INF/README.txt @@ -0,0 +1,35 @@ +Apache Tuscany M1 build (May, 2006) +=================================== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/sandbox/old/contrib/itest/interop-xsq-client/src/test/java/interop/ClientTestCase.java b/sandbox/old/contrib/itest/interop-xsq-client/src/test/java/interop/ClientTestCase.java new file mode 100644 index 0000000000..f2a7b198a1 --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/src/test/java/interop/ClientTestCase.java @@ -0,0 +1,77 @@ +/* + * 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 interop; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.apache.tuscany.test.SCATestCase; +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * This client program shows how to create an SCA runtime, start it, locate a + * simple HelloWorld service component and invoke it. + */ +public class ClientTestCase extends SCATestCase { + private Object serviceProxy; + + // old tc + // public void testGetQuote() throws ConfigurationException, + // SecurityException, NoSuchMethodException, IllegalArgumentException, + // IllegalAccessException, InvocationTargetException { + // + // TuscanyRuntime tuscany = new TuscanyRuntime("getQuote", null); + // tuscany.start(); + // ModuleContext moduleContext = CurrentModuleContext.getContext(); + // + // Object serviceProxy = moduleContext.locateService("webserviceXSQ"); + // Method m = serviceProxy.getClass().getMethod("GetQuote", new Class[] { + // String.class }); + // + // String sqResponse = (String) m.invoke(serviceProxy, "IBM"); + // + // assertTrue(sqResponse.startsWith("IBM")); + // + // tuscany.stop(); + // } + + public void testGetQuote() throws IllegalArgumentException, IllegalAccessException, + InvocationTargetException, SecurityException, NoSuchMethodException { + Method m = serviceProxy.getClass().getMethod("GetQuote", new Class[] {String.class}); + + String sqResponse = (String)m.invoke(serviceProxy, "IBM"); + + assertTrue(sqResponse.startsWith("IBM")); + + } + + @Override + protected void setUp() throws Exception { + setApplicationSCDL(getClass(), "META-INF/sca/test.scdl"); + + addExtension("test.exts", getClass().getClassLoader() + .getResource("META-INF/tuscany/test-extensions.scdl")); + + super.setUp(); + CompositeContext compositeContext = CurrentCompositeContext.getContext(); + serviceProxy = compositeContext.locateService(Object.class, "webserviceXSQ"); + } + +} diff --git a/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/sca/test.scdl b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/sca/test.scdl new file mode 100644 index 0000000000..22b3b90623 --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/sca/test.scdl @@ -0,0 +1,31 @@ + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/binding.axis2.scdl b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/binding.axis2.scdl new file mode 100644 index 0000000000..fb208f56ab --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/binding.axis2.scdl @@ -0,0 +1,39 @@ + + + + + + + axis2 + axis2-kernel + SNAPSHOT + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/databinding.axiom.scdl b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/databinding.axiom.scdl new file mode 100644 index 0000000000..e4fe956e61 --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/databinding.axiom.scdl @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/databinding.sdo.scdl b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/databinding.sdo.scdl new file mode 100644 index 0000000000..61753384b4 --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/databinding.sdo.scdl @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/interface.wsdl.scdl b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/interface.wsdl.scdl new file mode 100644 index 0000000000..84538dab8b --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/interface.wsdl.scdl @@ -0,0 +1,55 @@ + + + + + + + wsdl4j + wsdl4j + 1.5.2 + + + org.apache.ws.commons + XmlSchema + SNAPSHOT + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/test-extensions.scdl b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/test-extensions.scdl new file mode 100644 index 0000000000..355b663a1b --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/META-INF/tuscany/test-extensions.scdl @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/wsdl/sq.wsdl b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/wsdl/sq.wsdl new file mode 100644 index 0000000000..0408a60297 --- /dev/null +++ b/sandbox/old/contrib/itest/interop-xsq-client/src/test/resources/wsdl/sq.wsdl @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get Stock quote for a company Symbol + + + + + + + + Get Stock quote for a company Symbol + + + + + + + + Get Stock quote for a company Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/pom.xml.off b/sandbox/old/contrib/itest/pom.xml.off new file mode 100644 index 0000000000..fd23410e10 --- /dev/null +++ b/sandbox/old/contrib/itest/pom.xml.off @@ -0,0 +1,84 @@ + + + + + org.apache.tuscany + sca + 1.0-incubating + + 4.0.0 + org.apache.tuscany.sca + integration-test + 2.0-alpha-incubating-SNAPSHOT + pom + Apache Tuscany Integration Tests + Integration tests for SCA. + + + specTest + propertyTest + + + + + 1.0 + + + 2.0-alpha-incubating + + + + + + org.osoa + sca-api-r${scaSpecVersion} + 1.0-incubating + provided + + + + junit + junit + 3.8.1 + test + + + + + verify + + + + + org.apache.tuscany + tuscany-itest-plugin + ${kernelVersion} + + + + test + + + + + + + + diff --git a/sandbox/old/contrib/itest/propertyTest/pom.xml.off b/sandbox/old/contrib/itest/propertyTest/pom.xml.off new file mode 100644 index 0000000000..a8af8b28ea --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/pom.xml.off @@ -0,0 +1,40 @@ + + + + + org.apache.tuscany.sca + integration-test + 2.0-alpha-incubating-SNAPSHOT + + 4.0.0 + org.apache.tuscany.sca.integration-test + propertyTest + jar + Integration Test Suite for SCA Properties + + + + + org.apache.tuscany + tuscany-itest-plugin + + + + \ No newline at end of file diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ABComponent.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ABComponent.java new file mode 100644 index 0000000000..7d7360f678 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ABComponent.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.test.property; + +public interface ABComponent { + + String getA(); + String getB(); + String getZ(); + int getIntValue(); + String getF(); +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ABComponentImpl.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ABComponentImpl.java new file mode 100644 index 0000000000..dc45dbf035 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ABComponentImpl.java @@ -0,0 +1,82 @@ +/* + * 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.test.property; + +import org.osoa.sca.annotations.Property; + +public class ABComponentImpl implements ABComponent { + + private String aProperty; + private String bProperty; + private int intValue; + // private Collection manyProp; + private String zProperty; + private String fProperty; + + @Property(name="xpath") + public void setZProperty(final String value) { + this.zProperty = value; + } + +// @Property(name="foobar") +// public void setCollectionProperty(final Collection value) { +// this.manyProp = value; +// } + + @Property + public void setA(final String A) { + this.aProperty = A; + } + + @Property + public void setB(final String B) { + this.bProperty = B; + } + + @Property + public void setF(final String F) { + this.fProperty = F; + } + + @Property + public void setOne(final int value) { + this.intValue = value; + } + + public String getA() { + return this.aProperty; + } + + public String getB() { + return this.bProperty; + } + + public int getIntValue() { + return this.intValue; + } + + public String getZ() { + return this.zProperty; + } + + public String getF() { + return this.fProperty; + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/CDComponent.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/CDComponent.java new file mode 100644 index 0000000000..b2b776346e --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/CDComponent.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.test.property; + +public interface CDComponent { + + String getC(); + String getC2(); + String getD(); + String getNoSource(); + String getFileProperty(); + int getOverrideValue(); +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/CDComponentImpl.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/CDComponentImpl.java new file mode 100644 index 0000000000..f1bf91ef8e --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/CDComponentImpl.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.test.property; + +import org.osoa.sca.annotations.Property; + +public class CDComponentImpl implements CDComponent { + + private String cProperty; + private String dProperty; + private String nosource; + private String fileProperty; + private int overrideNumber; + private String cProperty2; + + @Property(name="nonFileProperty") + public void setC2(final String value) { + this.cProperty2 = value; + } + @Property(name="two") + public void setOverrideNumber(final int value) { + this.overrideNumber = value; + } + + @Property(name="fileProperty") + public void setFileProp(final String value) { + this.fileProperty = value; + } + @Property + public void setC(final String C) { + this.cProperty = C; + } + + @Property + public void setD(final String D) { + this.dProperty = D; + } + + @Property + public void setNosource(final String value) { + this.nosource = value; + } + + public String getFileProperty() { + return this.fileProperty; + } + + public String getC() { + return this.cProperty; + } + + public String getC2() { + return this.cProperty2; + } + + public String getD() { + return this.dProperty; + } + + public String getNoSource() { + return this.nosource; + } + + public int getOverrideValue() { + return this.overrideNumber; + } +} + diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ComplexPropertyBean.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ComplexPropertyBean.java new file mode 100644 index 0000000000..c346b69c30 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/ComplexPropertyBean.java @@ -0,0 +1,69 @@ +package org.apache.tuscany.sca.test.property; + +public class ComplexPropertyBean { + + protected int integerNumber = 25; + public float floatNumber = 50; + public double doubleNumber = 75; + public int[] intArray = null; + public double[] doubleArray = null; + protected String[] stringArray = null; + + ComplexPropertyBean numberSet; + public ComplexPropertyBean[] numberSetArray = null; + + public ComplexPropertyBean() { + + } + + public double getDoubleNumber() { + return doubleNumber; + } + + public void setDoubleNumber(double doubleNumber) { + this.doubleNumber = doubleNumber; + } + + public float getFloatNumber() { + return floatNumber; + } + + public void setFloatNumber(float floatNumber) { + this.floatNumber = floatNumber; + } + + public int getIntegerNumber() { + return integerNumber; + } + + public void setIntegerNumber(int integerNumber) { + this.integerNumber = integerNumber; + } + + public ComplexPropertyBean getNumberSet() { + return numberSet; + } + + public void setNumberSet(ComplexPropertyBean numberSet) { + this.numberSet = numberSet; + } + + public String toString() { + return Double.toString(integerNumber) + " - " + + Double.toString(floatNumber) + " - " + + Double.toString(doubleNumber) + " \n" + + ((intArray == null ) ? "no int array" : intArray[0] + " - " + intArray[1] + " \n " ) + + ((doubleArray == null ) ? "no double array" : doubleArray[0] + " - " + doubleArray[1] + " \n " ) + + ((stringArray == null ) ? "no string array" : stringArray[0] + " - " + stringArray[1] + " \n " ) + + ((numberSetArray == null ) ? "no numberset array" : numberSetArray[0] + " - " + numberSetArray[1] + " \n " ) + + ((numberSet == null ) ? "" : numberSet.toString()); + } + + public String[] getStringArray() { + return stringArray; + } + + public void setStringArray(String[] stringArray) { + this.stringArray = stringArray; + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/OverrideService.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/OverrideService.java new file mode 100644 index 0000000000..7516c61836 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/OverrideService.java @@ -0,0 +1,25 @@ + +/* + * 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.test.property; + +public interface OverrideService { + +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/OverrideServiceImpl.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/OverrideServiceImpl.java new file mode 100644 index 0000000000..f44263c3f4 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/OverrideServiceImpl.java @@ -0,0 +1,24 @@ +/* + * 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.test.property; + +public class OverrideServiceImpl implements OverrideService { + +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyComponent.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyComponent.java new file mode 100644 index 0000000000..3a77c1fe2f --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyComponent.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.test.property; + + +public interface PropertyComponent { + public String getLocation(); + public String getYear(); + public ComplexPropertyBean getComplexPropertyOne(); + public ComplexPropertyBean getComplexPropertyTwo(); +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyComponentImpl.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyComponentImpl.java new file mode 100644 index 0000000000..e2b331f693 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyComponentImpl.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.test.property; + +import org.osoa.sca.annotations.Property; + +public class PropertyComponentImpl implements PropertyComponent { + @Property + protected ComplexPropertyBean complexPropertyOne; + + @Property + protected ComplexPropertyBean complexPropertyTwo; + + @Property(name = "location") + protected String location = "RTP"; + + @Property(name = "year") + protected String year = "2006"; + + public String getLocation(){ + return location; + } + + public String getYear(){ + return year; + } + + public ComplexPropertyBean getComplexPropertyOne() { + return complexPropertyOne; + } + + public ComplexPropertyBean getComplexPropertyTwo() { + return complexPropertyTwo; + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyService.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyService.java new file mode 100644 index 0000000000..6110283c80 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/PropertyService.java @@ -0,0 +1,24 @@ +/* + * 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.test.property; + +public interface PropertyService { + +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ConstructorPrimitives.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ConstructorPrimitives.java new file mode 100644 index 0000000000..e21b31f90d --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ConstructorPrimitives.java @@ -0,0 +1,90 @@ +/* + * 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.test.property.primitives; + +import org.osoa.sca.annotations.Property; + +/** + * Implementation where all primitive properties are passed in the constructor. + * + * @version $Rev$ $Date$ + */ +public class ConstructorPrimitives implements PrimitiveService { + private boolean booleanValue; + + private byte byteValue; + + private short shortValue; + + private int intValue; + + private long longValue; + + private float floatValue; + + private double doubleValue; + + public ConstructorPrimitives(@Property(name = "booleanValue") boolean booleanValue, + @Property(name = "byteValue") byte byteValue, + @Property(name = "shortValue") short shortValue, + @Property(name = "intValue") int intValue, + @Property(name = "longValue") long longValue, + @Property(name = "floatValue") float floatValue, + @Property(name = "doubleValue") double doubleValue) { + this.booleanValue = booleanValue; + this.byteValue = byteValue; + this.shortValue = shortValue; + this.intValue = intValue; + this.longValue = longValue; + this.floatValue = floatValue; + this.doubleValue = doubleValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public byte getByteValue() { + return byteValue; + } + + public short getShortValue() { + return shortValue; + } + + public int getIntValue() { + return intValue; + } + + public long getLongValue() { + return longValue; + } + + public float getFloatValue() { + return floatValue; + } + + public double getDoubleValue() { + return doubleValue; + } + + public String getImplementationName() { + return getClass().getSimpleName(); + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PrimitiveService.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PrimitiveService.java new file mode 100644 index 0000000000..1d599c70a3 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PrimitiveService.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.test.property.primitives; + +/** + * Service interface for primitive property tests. + * This defines the methods and the values typically returned from a test. + * + * @version $Rev$ $Date$ + */ +public interface PrimitiveService { + String getImplementationName(); + + boolean BOOLEAN_VALUE = true; + + boolean isBooleanValue(); + + byte BYTE_VALUE = 123; + + byte getByteValue(); + + short SHORT_VALUE = 12345; + + short getShortValue(); + + int INT_VALUE = 12345678; + + int getIntValue(); + + long LONG_VALUE = 9876543210L; + + long getLongValue(); + + float FLOAT_VALUE = 1.234e12f; + + float getFloatValue(); + + double DOUBLE_VALUE = 1.23456789e87; + + double getDoubleValue(); +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ProtectedFieldPrimitives.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ProtectedFieldPrimitives.java new file mode 100644 index 0000000000..c2cd13b831 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ProtectedFieldPrimitives.java @@ -0,0 +1,72 @@ +/* + * 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.test.property.primitives; + +/** + * Implementation where all primitive properties are private fields. + * + * @version $Rev$ $Date$ + */ +public class ProtectedFieldPrimitives implements PrimitiveService { + protected boolean booleanValue; + + protected byte byteValue; + + protected short shortValue; + + protected int intValue; + + protected long longValue; + + protected float floatValue; + + protected double doubleValue; + + public boolean isBooleanValue() { + return booleanValue; + } + + public byte getByteValue() { + return byteValue; + } + + public short getShortValue() { + return shortValue; + } + + public int getIntValue() { + return intValue; + } + + public long getLongValue() { + return longValue; + } + + public float getFloatValue() { + return floatValue; + } + + public double getDoubleValue() { + return doubleValue; + } + + public String getImplementationName() { + return getClass().getSimpleName(); + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ProtectedSetterPrimitives.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ProtectedSetterPrimitives.java new file mode 100644 index 0000000000..7cbb0c1371 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/ProtectedSetterPrimitives.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.test.property.primitives; + +/** + * Implementation where all primitive properties are passed in using protected setter methods. + * + * @version $Rev$ $Date$ + */ +public class ProtectedSetterPrimitives implements PrimitiveService { + protected boolean booleanValue; + + protected byte byteValue; + + protected short shortValue; + + protected int intValue; + + protected long longValue; + + protected float floatValue; + + protected double doubleValue; + + public void setBooleanValue(boolean booleanValue) { + this.booleanValue = booleanValue; + } + + public void setByteValue(byte byteValue) { + this.byteValue = byteValue; + } + + public void setShortValue(short shortValue) { + this.shortValue = shortValue; + } + + public void setIntValue(int intValue) { + this.intValue = intValue; + } + + public void setLongValue(long longValue) { + this.longValue = longValue; + } + + public void setFloatValue(float floatValue) { + this.floatValue = floatValue; + } + + public void setDoubleValue(double doubleValue) { + this.doubleValue = doubleValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public byte getByteValue() { + return byteValue; + } + + public short getShortValue() { + return shortValue; + } + + public int getIntValue() { + return intValue; + } + + public long getLongValue() { + return longValue; + } + + public float getFloatValue() { + return floatValue; + } + + public double getDoubleValue() { + return doubleValue; + } + + public String getImplementationName() { + return getClass().getSimpleName(); + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PublicFieldPrimitives.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PublicFieldPrimitives.java new file mode 100644 index 0000000000..a38875b82a --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PublicFieldPrimitives.java @@ -0,0 +1,72 @@ +/* + * 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.test.property.primitives; + +/** + * Implementation where all primitive properties are private fields. + * + * @version $Rev$ $Date$ + */ +public class PublicFieldPrimitives implements PrimitiveService { + public boolean booleanValue; + + public byte byteValue; + + public short shortValue; + + public int intValue; + + public long longValue; + + public float floatValue; + + public double doubleValue; + + public boolean isBooleanValue() { + return booleanValue; + } + + public byte getByteValue() { + return byteValue; + } + + public short getShortValue() { + return shortValue; + } + + public int getIntValue() { + return intValue; + } + + public long getLongValue() { + return longValue; + } + + public float getFloatValue() { + return floatValue; + } + + public double getDoubleValue() { + return doubleValue; + } + + public String getImplementationName() { + return getClass().getSimpleName(); + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PublicSetterPrimitives.java b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PublicSetterPrimitives.java new file mode 100644 index 0000000000..e7b527ba63 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/java/org/apache/tuscany/sca/test/property/primitives/PublicSetterPrimitives.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.test.property.primitives; + +/** + * Implementation where all primitive properties are passed in using public setter methods. + * + * @version $Rev$ $Date$ + */ +public class PublicSetterPrimitives implements PrimitiveService { + private boolean booleanValue; + + private byte byteValue; + + private short shortValue; + + private int intValue; + + private long longValue; + + private float floatValue; + + private double doubleValue; + + public void setBooleanValue(boolean booleanValue) { + this.booleanValue = booleanValue; + } + + public void setByteValue(byte byteValue) { + this.byteValue = byteValue; + } + + public void setShortValue(short shortValue) { + this.shortValue = shortValue; + } + + public void setIntValue(int intValue) { + this.intValue = intValue; + } + + public void setLongValue(long longValue) { + this.longValue = longValue; + } + + public void setFloatValue(float floatValue) { + this.floatValue = floatValue; + } + + public void setDoubleValue(double doubleValue) { + this.doubleValue = doubleValue; + } + + public boolean isBooleanValue() { + return booleanValue; + } + + public byte getByteValue() { + return byteValue; + } + + public short getShortValue() { + return shortValue; + } + + public int getIntValue() { + return intValue; + } + + public long getLongValue() { + return longValue; + } + + public float getFloatValue() { + return floatValue; + } + + public double getDoubleValue() { + return doubleValue; + } + + public String getImplementationName() { + return getClass().getSimpleName(); + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/default.scdl b/sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/default.scdl new file mode 100644 index 0000000000..9eb0b0f126 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/default.scdl @@ -0,0 +1,117 @@ + + + + + + + + diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/fileProperty.txt b/sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/fileProperty.txt new file mode 100644 index 0000000000..c530ae892d --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/fileProperty.txt @@ -0,0 +1 @@ +fileValue diff --git a/sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/primitives.scdl b/sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/primitives.scdl new file mode 100644 index 0000000000..9a47ffc74b --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/main/resources/META-INF/sca/primitives.scdl @@ -0,0 +1,78 @@ + + + + + + + true + 123 + 12345 + 12345678 + 9876543210 + 1.234e12 + 1.23456789e87 + + + + + true + 123 + 12345 + 12345678 + 9876543210 + 1.234e12 + 1.23456789e87 + + + + + true + 123 + 12345 + 12345678 + 9876543210 + 1.234e12 + 1.23456789e87 + + + + + true + 123 + 12345 + 12345678 + 9876543210 + 1.234e12 + 1.23456789e87 + + + + + true + 123 + 12345 + 12345678 + 9876543210 + 1.234e12 + 1.23456789e87 + + diff --git a/sandbox/old/contrib/itest/propertyTest/src/test/java/org/apache/tuscany/sca/test/property/PropertyTestComponent.java b/sandbox/old/contrib/itest/propertyTest/src/test/java/org/apache/tuscany/sca/test/property/PropertyTestComponent.java new file mode 100644 index 0000000000..954fd456d7 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/test/java/org/apache/tuscany/sca/test/property/PropertyTestComponent.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.test.property; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +public class PropertyTestComponent extends TestCase { + @Reference + public ABComponent abService; + @Reference + public CDComponent cdService; + @Reference + public PropertyComponent propertyService; + + + public void testA() { + assertEquals("a", abService.getA()); + } + + public void testB() { + assertEquals("b", abService.getB()); + } + + public void testC() { + assertEquals("c", cdService.getC()); + } + + public void testC2() { + assertEquals("c", cdService.getC2()); + } + + public void testD() { + assertEquals("d", cdService.getD()); + } + + public void testF() { + assertEquals("a", abService.getF()); + } + + public void testZ() { + assertEquals("z", abService.getZ()); + } + + + public void testIntValue() { + assertEquals(1, abService.getIntValue()); + } + + public void testDefaultValue() { + assertEquals(1, abService.getIntValue()); + } + + public void testDefaultValueOverride() { + assertEquals(1, cdService.getOverrideValue()); + } + + public void testNoSource() { + assertEquals("aValue", cdService.getNoSource()); + } + + public void testFileProperty() { + assertEquals("fileValue", cdService.getFileProperty()); + } + + public void testDefaultProperty() { + assertEquals("RTP", propertyService.getLocation()); + assertEquals("2006", propertyService.getYear()); + + } + + public void testComplexProperty() { + ComplexPropertyBean propBean = propertyService.getComplexPropertyOne(); + assertNotNull(propBean); + assertEquals("TestString_1", propBean.getStringArray()[0]); + assertEquals(2, propBean.numberSetArray[1].integerNumber); + + propBean = propertyService.getComplexPropertyTwo(); + assertNotNull(propBean); + assertEquals(10, propBean.intArray[0]); + assertEquals((float) 22, propBean.numberSetArray[1].floatNumber); + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/test/java/org/apache/tuscany/sca/test/property/primitives/PrimitiveTestComponent.java b/sandbox/old/contrib/itest/propertyTest/src/test/java/org/apache/tuscany/sca/test/property/primitives/PrimitiveTestComponent.java new file mode 100644 index 0000000000..f26e1d341a --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/test/java/org/apache/tuscany/sca/test/property/primitives/PrimitiveTestComponent.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.test.property.primitives; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Property; +import junit.framework.TestCase; + +/** + * Test component for checking primitive property values. + * + * @version $Rev$ $Date$ + */ +public class PrimitiveTestComponent extends TestCase { + @Reference + public PrimitiveService primitives; + + @Property + public String expectedImplementation; + + public void testExpectedImplementation() { + assertEquals(expectedImplementation, primitives.getImplementationName()); + } + + public void testBoolean() { + assertEquals(PrimitiveService.BOOLEAN_VALUE, primitives.isBooleanValue()); + } + + public void testByte() { + assertEquals(PrimitiveService.BYTE_VALUE, primitives.getByteValue()); + } + + public void testShort() { + assertEquals(PrimitiveService.SHORT_VALUE, primitives.getShortValue()); + } + + public void testInt() { + assertEquals(PrimitiveService.INT_VALUE, primitives.getIntValue()); + } + + public void testLong() { + assertEquals(PrimitiveService.LONG_VALUE, primitives.getLongValue()); + } + + public void testFloat() { + assertEquals(PrimitiveService.FLOAT_VALUE, primitives.getFloatValue()); + } + + public void testDouble() { + assertEquals(PrimitiveService.DOUBLE_VALUE, primitives.getDoubleValue()); + } +} diff --git a/sandbox/old/contrib/itest/propertyTest/src/test/resources/itest.scdl b/sandbox/old/contrib/itest/propertyTest/src/test/resources/itest.scdl new file mode 100644 index 0000000000..cfc9c11351 --- /dev/null +++ b/sandbox/old/contrib/itest/propertyTest/src/test/resources/itest.scdl @@ -0,0 +1,65 @@ + + + + + + + + + + ConstructorPrimitives + + + + + + PublicFieldPrimitives + + + + + + ProtectedFieldPrimitives + + + + + + PublicSetterPrimitives + + + + + + ProtectedSetterPrimitives + + + + diff --git a/sandbox/old/contrib/itest/spec-api/pom.xml b/sandbox/old/contrib/itest/spec-api/pom.xml new file mode 100644 index 0000000000..fa0f618820 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.1-incubating-SNAPSHOT + ../pom.xml + + itest-spec-api + Apache Tuscany SCA Spec API Integration Tests + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.1-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.1-incubating-SNAPSHOT + runtime + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java new file mode 100644 index 0000000000..ba9dd59c46 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.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.test.spec; + +public interface BasicService { + + int negate(int theInt); + int delegateNegate(int theInt); + +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java new file mode 100644 index 0000000000..0f46725adf --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java @@ -0,0 +1,25 @@ +/* + * 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.test.spec; + +public interface MathService { + + int negate(int theInt); + +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java new file mode 100644 index 0000000000..7fe9fa4909 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.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.test.spec; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyListService { + String[] getHolidays(); + + String getYear(); +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java new file mode 100644 index 0000000000..a381fc62dc --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java @@ -0,0 +1,27 @@ +/* + * 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.test.spec; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyListServiceByYear { + //FIXME renaming method due to TUSCANY-1173. Original name getHolidays + String[] getHolidaysByYear(int year); +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java new file mode 100644 index 0000000000..fbb2161df3 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/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.test.spec; + +import java.util.Date; + +public interface MyService extends SCAComponentService { + Date nextHoliday(); + + String getLocation(); + + String getYear(); +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java new file mode 100644 index 0000000000..98490c4e3d --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.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.test.spec; + +import java.util.Date; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyServiceByDate { + //FIXME renaming method due to TUSCANY-1173. Original name nextHoliday + Date nextHolidayByDate(Date date); +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java new file mode 100644 index 0000000000..6a4cfc1f79 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java @@ -0,0 +1,23 @@ +/* + * 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.test.spec; + +public interface MyTotalService extends MyListService, MyListServiceByYear, MyService, MyServiceByDate { + +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java new file mode 100644 index 0000000000..c2d107ef28 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java @@ -0,0 +1,25 @@ +/* + * 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.test.spec; + + +public interface SCAComponentService { + String getComponentName(); + +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java new file mode 100644 index 0000000000..083307234a --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java @@ -0,0 +1,49 @@ +/* + * 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.test.spec.impl; + +import org.apache.tuscany.sca.test.spec.BasicService; +import org.apache.tuscany.sca.test.spec.MathService; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(BasicService.class) +public class BasicServiceImpl implements BasicService { + + @Context + protected ComponentContext context; + + //The reference anntation is used in lieu of a component type definition + //This makes the call to getService redundant since the reference is injected + //but it serves the purpose to demonstrate that getService is working. + @Reference + protected MathService mathServiceReference; + + public int negate(int theInt) { + return -theInt; + } + + public int delegateNegate(int theInt) { + mathServiceReference = context.getService(MathService.class, "mathServiceReference"); + return mathServiceReference.negate(theInt); + } + +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java new file mode 100644 index 0000000000..d3dc1585fc --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java @@ -0,0 +1,31 @@ +/* + * 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.test.spec.impl; + +import org.apache.tuscany.sca.test.spec.MathService; +import org.osoa.sca.annotations.Service; + +@Service(MathService.class) +public class MathServiceImpl implements MathService { + + public int negate(int theInt) { + return -theInt; + } + +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java new file mode 100644 index 0000000000..5170c32cd2 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.test.spec.impl; + +import java.util.List; + +import org.apache.tuscany.sca.test.spec.MyListService; +import org.apache.tuscany.sca.test.spec.MyListServiceByYear; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + + +@Service(interfaces = {MyListService.class, MyListServiceByYear.class}) +public class MyListServiceImpl implements MyListService, MyListServiceByYear { + + // This is multiplicity=1:n + @Reference(name = "myListServiceList", required = false) + public List myListServicesList; + + // This is multiplicity=0:n + @Reference(name = "myListServiceArray", required = false) + public MyListService[] myListServicesArray; + + @Property(name = "serviceYear") + protected String year = "2006"; + + public String[] getHolidays() { + return getHolidaysByYear(new Integer(year).intValue()); + } + + public String[] getHolidaysByYear(int year) { + MyListService myService; + if (myListServicesList != null) { + for (int i = 0; i < myListServicesList.size(); i++) { + myService = myListServicesList.get(i); + if (new Integer(myService.getYear()).intValue() == year) { + return myService.getHolidays(); + } + } + } + if (myListServicesArray != null) { + for (int i = 0; i < myListServicesArray.length; i++) { + myService = myListServicesArray[i]; + if (new Integer(myService.getYear()).intValue() == year) { + return myService.getHolidays(); + } + } + } + return null; + } + + public String getYear() { + return year; + } + +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java new file mode 100644 index 0000000000..b81c2c2120 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.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.test.spec.impl; + +import java.util.Date; + +import org.apache.tuscany.sca.test.spec.MyListService; +import org.apache.tuscany.sca.test.spec.MyListServiceByYear; +import org.apache.tuscany.sca.test.spec.MyService; +import org.apache.tuscany.sca.test.spec.MyServiceByDate; +import org.osoa.sca.annotations.ComponentName; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Service; + + +@Service(interfaces = {MyService.class, MyServiceByDate.class, MyListService.class, MyListServiceByYear.class}) +public class MyServiceImpl implements MyService, MyServiceByDate, MyListService, MyListServiceByYear { + static String[][] holidays = + { + {"2006/01/02", "2006/05/29", "2006/07/03", "2006/07/04", "2006/09/04", "2006/11/23", "2006/11/23", + "2006/11/24", "2006/12/25"}, + {"2007/01/01", "2007/05/28", "2007/07/04", "2007/09/03", "2007/11/22", "2007/11/23", "2007/12/25"}}; + + @Property(name = "location") + protected String location = "RTP"; + + @Property(name = "year") + protected String year = "2006"; + + @ComponentName + private String componentName; + + public MyServiceImpl() { + //System.out.println("creating service instance..."); + } + + public Date nextHoliday() { + + return nextHolidayByDate(new Date()); + } + + @SuppressWarnings("deprecation") + public Date nextHolidayByDate(Date today) { + Date d1; + String[] days = getHolidays(); + for (int j = 0; j < days.length; j++) { + d1 = new Date(days[j]); + if (d1.after(today)) + return d1; + } + return null; + } + + public String[] getHolidaysByYear(int year) { + int index = year - 2006; + if (index >= 0 && index < holidays.length) + return holidays[index]; + return null; + } + + public String[] getHolidays() { + + Integer theYear; + if (year == null || year.length() == 0) + theYear = new Integer("2006"); + else + theYear = new Integer(year); + + return getHolidaysByYear(theYear.intValue()); + } + + @Init + public void start() { + //System.out.println("Start service.."); + } + + @Destroy + public void stop() { + //System.out.println("Stop service.."); + } + + public String getComponentName() { + return componentName; + } + + public String getLocation() { + return location; + } + + public String getYear() { + return year; + } + +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java new file mode 100644 index 0000000000..11767522d6 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java @@ -0,0 +1,78 @@ +/* + * 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.test.spec.impl; + +import java.util.Date; + +import org.apache.tuscany.sca.test.spec.MyListService; +import org.apache.tuscany.sca.test.spec.MyListServiceByYear; +import org.apache.tuscany.sca.test.spec.MyService; +import org.apache.tuscany.sca.test.spec.MyServiceByDate; +import org.apache.tuscany.sca.test.spec.MyTotalService; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + + +@Service(MyTotalService.class) +public class MyTotalServiceImpl implements MyTotalService { + + // This is multiplicity=1:1 + @Reference(required = true) + public MyListService myListService; + + // default required==true so it is 1:1 + @Reference + public MyListServiceByYear myListServiceByYear = new MyServiceImpl(); + + // default required==true so it is 1:1 + @Reference + public MyService myService; + + // This is multiplicity=0:1 + @Reference(required = false) + public MyServiceByDate myServiceByDate = new MyServiceImpl(); + + public String[] getHolidays() { + return myListService.getHolidays(); + } + + public String[] getHolidaysByYear(int year) { + return myListServiceByYear.getHolidaysByYear(year); + } + + public String getComponentName() { + return myService.getComponentName(); + } + + public Date nextHolidayByDate(Date date) { + return myServiceByDate.nextHolidayByDate(date); + } + + public String getLocation() { + return myService.getLocation(); + } + + public String getYear() { + return myService.getYear(); + } + + public Date nextHoliday() { + return myService.nextHoliday(); + } +} diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/BasicService.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/BasicService.composite new file mode 100644 index 0000000000..d650c8ab42 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/BasicService.composite @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/CompositeTest.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/CompositeTest.composite new file mode 100644 index 0000000000..7a5f05b552 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/CompositeTest.composite @@ -0,0 +1,33 @@ + + + + + + + foo:mySimpleServiceInRecursive + foo:myServiceInRecursive + foo:mySimpleServiceInRecursive2 + foo:myTotalServiceInRecursive + foo:myTotalServiceInRecursiveForReferenceOverride + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/MathService.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/MathService.composite new file mode 100644 index 0000000000..59f8fa6981 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/MathService.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/myListService.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/myListService.composite new file mode 100644 index 0000000000..1f0cd97fb4 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/myListService.composite @@ -0,0 +1,33 @@ + + + + + + + + + 2007 + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/myServiceInComposite.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/myServiceInComposite.composite new file mode 100644 index 0000000000..518cb295f9 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/myServiceInComposite.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/myServiceInRecursive.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/myServiceInRecursive.composite new file mode 100644 index 0000000000..f9f7615ec5 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/myServiceInRecursive.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleService.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleService.composite new file mode 100644 index 0000000000..b1ecaced45 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleService.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleServiceInRecursive.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleServiceInRecursive.composite new file mode 100644 index 0000000000..662d67612d --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleServiceInRecursive.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleServiceInRecursive2.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleServiceInRecursive2.composite new file mode 100644 index 0000000000..e059c5b46f --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/mySimpleServiceInRecursive2.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalService.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalService.composite new file mode 100644 index 0000000000..f9076f6811 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalService.composite @@ -0,0 +1,34 @@ + + + + + foo:myservice + + + + + + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInComposite.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInComposite.composite new file mode 100644 index 0000000000..af41baf277 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInComposite.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInCompositeForReferenceOverride.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInCompositeForReferenceOverride.composite new file mode 100644 index 0000000000..e802b469d0 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInCompositeForReferenceOverride.composite @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInRecursive.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInRecursive.composite new file mode 100644 index 0000000000..a69c4cedd4 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInRecursive.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInRecursiveForReferenceOverride.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInRecursiveForReferenceOverride.composite new file mode 100644 index 0000000000..26033aad9f --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/myTotalServiceInRecursiveForReferenceOverride.composite @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/main/resources/myservice.composite b/sandbox/old/contrib/itest/spec-api/src/main/resources/myservice.composite new file mode 100644 index 0000000000..4b5972bcc1 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/main/resources/myservice.composite @@ -0,0 +1,52 @@ + + + + + + + + + + + NC + 2007 + + + + + + + + + + + + + 2006 + + + + + + + diff --git a/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java new file mode 100644 index 0000000000..3f64202f13 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.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.test.spec; + +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 ComponentContextTestCase { + + private SCADomain domain; + + /** + * Test description: Locate a service and invoke a method. + */ + @Test + public void simpleLocate() { + BasicService service = domain.getService(BasicService.class, "BasicServiceComponent"); + assertEquals(-99, service.negate(99)); + } + + /** + * Test description: Locate a service that will then locate another service + * via a defined reference by means of: + * ComponentContext.getService(ClassbusinessInterface, String referenceName); + */ + @Test + public void delegateViaDefinedReference() { + BasicService service = domain.getService(BasicService.class, "BasicServiceComponent"); + assertEquals(-99, service.delegateNegate(99)); + } + + @Before + public void init() throws Exception { + domain = SCADomain.newInstance("http://localhost", "/", "BasicService.composite", "MathService.composite"); + } + + @After + public void destroy() throws Exception { + domain.close(); + } +} diff --git a/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTestCaseFIXME.java b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTestCaseFIXME.java new file mode 100644 index 0000000000..6a96326fbf --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTestCaseFIXME.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.test.spec; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class ComponentServiceReferenceListTestCaseFIXME extends TestCase { + private MyListService myListService; + private MyListServiceByYear myListServiceByYear; + + private SCADomain domain; + + public void testDefaultProperty() { + assertEquals("2007", myListService.getYear()); + + } + + public void testDefaultService() { + assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidaysByYear(2007)[0]); + + } + + protected void setUp() throws Exception { + domain = SCADomain.newInstance("CompositeTest.composite"); + myListService = domain.getService(MyListService.class, "MyNewListService"); + myListServiceByYear = domain.getService(MyListServiceByYear.class, "MyNewListService"); + } + + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTestCase.java b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTestCase.java new file mode 100644 index 0000000000..b5c6a0d7b5 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTestCase.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.test.spec; + +import java.util.Date; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class ComponentServiceReferenceTestCase extends TestCase { + private MyTotalService myService; + private SCADomain domain; + + public void testDefaultProperty() { + assertEquals("NC", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testDefaultService() { + assertNotSame(myService.nextHoliday(), myService.nextHolidayByDate(new Date())); + assertEquals(myService.getHolidays()[0], myService.getHolidaysByYear(2007)[0]); + + } + + public void testContext() { + //FIXME TUSCANY-1174 - Need support for @ComponentName + /* + assertNotNull("Service component name is null", myService.getComponentName()); + assertNotNull("service context is null", myService.getContext()); + + System.out.println("Service component name :" + myService.getComponentName()); + System.out.println("service context :" + myService.getContext()); + + test(context); + */ + } + + protected void setUp() throws Exception { + domain = SCADomain.newInstance("CompositeTest.composite"); + myService = domain.getService(MyTotalService.class, "MyTotalService"); + } + + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTestCase.java b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTestCase.java new file mode 100644 index 0000000000..d136530412 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTestCase.java @@ -0,0 +1,98 @@ +/* + * 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.test.spec; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertFalse; + +import java.util.Date; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class ComponentTestCase { + private static MyService myService; + private static MyServiceByDate myServiceByDate; + private static MyListService myListService; + private static MyListServiceByYear myListServiceByYear; + private static MyService myNCService; + private static MyListService myListServiceFor2006; + + private static SCADomain domain; + + @Test + public void testDefaultProperty() { + assertEquals("RTP", myService.getLocation()); + assertEquals("2006", myService.getYear()); + + } + + @Test + public void testDefaultService() { + assertEquals(myService.nextHoliday(), myServiceByDate.nextHolidayByDate(new Date())); + assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidaysByYear(2006)[0]); + + } + + @Test + public void testOverrideProperty() { + assertEquals("NC", myNCService.getLocation()); + assertEquals("2007", myNCService.getYear()); + } + + @Test + public void testServiceWithOverrideProperty() { + assertFalse(myNCService.nextHoliday() == myService.nextHoliday()); + assertEquals(myListServiceFor2006.getHolidays()[0], myListServiceByYear.getHolidaysByYear(2006)[0]); + + } + + @Test + public void testContext() { + //FIXME TUSCANY-1174 - Need support for @ComponentName + /* + assertNotNull("Service component name is null", myService.getComponentName()); + assertNotNull("service context is null", myService.getContext()); + + System.out.println("Service component name :" + myService.getComponentName()); + System.out.println("service context :" + myService.getContext()); + + test(context); + */ + } + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("CompositeTest.composite"); + myService = domain.getService(MyService.class, "MyService"); + myServiceByDate = domain.getService(MyServiceByDate.class, "MyServiceByDate"); + myListService = domain.getService(MyListService.class, "MyListService"); + myListServiceByYear = domain.getService(MyListServiceByYear.class, "MyListServiceByYear"); + myNCService = domain.getService(MyService.class, "MyNCService"); + myListServiceFor2006 = domain.getService(MyListService.class, "MyListServiceFor2006"); + } + + @AfterClass + public static void destroy() throws Exception { + domain.close(); + } + +} diff --git a/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTestCaseFIXME.java b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTestCaseFIXME.java new file mode 100644 index 0000000000..5e54b5dcfa --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTestCaseFIXME.java @@ -0,0 +1,106 @@ +/* + * 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.test.spec; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +@SuppressWarnings("deprecation") +public class CompositeOneService2LevelTestCaseFIXME extends TestCase { + private MyService myService; + private MyService myServiceDefault; + private MyService myServiceNo; + private MyService myServiceMay; + private MyService myServiceMust; + + private SCADomain domain; + + public void testPropertyFromComponent() { + assertEquals("CARY", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testPropertyFromServiceDefault() { + assertEquals("CARY", myServiceDefault.getLocation()); + assertEquals("2007", myServiceDefault.getYear()); + + } + + public void testServiceDefault() { + assertEquals(myService.nextHoliday(), myServiceDefault.nextHoliday()); + } + + public void testPropertyFromServiceNo() { + assertEquals("CARY", myServiceNo.getLocation()); + assertEquals("2007", myServiceNo.getYear()); + + } + + public void testServiceNo() { + assertEquals(myService.nextHoliday(), myServiceNo.nextHoliday()); + } + + public void testPropertyFromServiceMay() { + assertEquals("CARY", myServiceMay.getLocation()); + assertEquals("2007", myServiceMay.getYear()); + + } + + public void testServiceMay() { + assertEquals(myService.nextHoliday(), myServiceMay.nextHoliday()); + } + + public void testPropertyFromServiceMust() { + assertEquals("CARY", myServiceMust.getLocation()); + assertEquals("2007", myServiceMust.getYear()); + + } + + public void testServiceMust() { + assertEquals(myService.nextHoliday(), myServiceMust.nextHoliday()); + } + + public void testContext() { + //FIXME TUSCANY-1174 - Need support for @ComponentName + /* + assertNotNull("Service component name is null", myService.getComponentName()); + assertNotNull("service context is null", myService.getContext()); + + System.out.println("Service component name :" + myService.getComponentName()); + System.out.println("service context :" + myService.getContext()); + + test(context); + */ + } + + protected void setUp() throws Exception { + domain = SCADomain.newInstance("CompositeTest.composite"); + myService = domain.getService(MyService.class, "MySimpleServiceInRecursiveComponent"); + myServiceDefault = domain.getService(MyService.class, "MySimpleServiceDefault"); + myServiceNo = domain.getService(MyService.class, "MySimpleServiceNo"); + myServiceMay = domain.getService(MyService.class, "MySimpleServiceMay"); + myServiceMust = domain.getService(MyService.class, "MySimpleServiceMust"); + } + + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTestCase.java b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTestCase.java new file mode 100644 index 0000000000..c29e9e72b3 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTestCase.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.test.spec; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class CompositeOneServiceTestCase extends TestCase { + private MyService myService; + private SCADomain domain; + + public void testOverrideProperty() { + assertEquals("CARY", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testDefaultService() { + assertNotNull(myService.nextHoliday()); + } + + public void testContext() { + //FIXME TUSCANY-1174 - Need support for @ComponentName + /* + assertNotNull("Service component name is null", myService.getComponentName()); + assertNotNull("service context is null", myService.getContext()); + + System.out.println("Service component name :" + myService.getComponentName()); + System.out.println("service context :" + myService.getContext()); + + test(context); + */ + } + + protected void setUp() throws Exception { + domain = SCADomain.newInstance("CompositeTest.composite"); + myService = domain.getService(MyService.class, "MySimpleServiceInRecursive"); + } + + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTestCase.java b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTestCase.java new file mode 100644 index 0000000000..eb846ddb71 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTestCase.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.test.spec; + +import java.util.Date; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class CompositeServiceReferenceForRefOverrideTestCase extends TestCase { + private MyTotalService myService1; + private MyTotalService myService2; + private MyTotalService myService3; + private SCADomain domain; + + public void testPropertyWithServiceFromReferenceNo() { + assertEquals("CARY", myService1.getLocation()); + assertEquals("2007", myService1.getYear()); + } + + public void testPropertyWithServiceFromReferenceMay() { + assertEquals("CARY", myService2.getLocation()); + assertEquals("2007", myService2.getYear()); + + } + + public void testPropertyWithServiceFromReferenceMust() { + assertEquals("CARY", myService3.getLocation()); + assertEquals("2007", myService3.getYear()); + } + + public void testServiceFromReferenceNo() { + System.out.println("nextHolday()" + myService1.nextHoliday()); + System.out.println("nextHolday(Date)" + myService1.nextHolidayByDate(new Date())); + System.out.println("myService1.getHolidays()[0]" + myService1.getHolidays()[0]); + System.out.println("myService1.getHolidays(2007)[0]" + myService1.getHolidaysByYear(2007)[0]); + assertNotSame(myService1.nextHoliday(), myService1.nextHolidayByDate(new Date())); + assertEquals(myService1.getHolidays()[0], myService1.getHolidaysByYear(2007)[0]); + } + + public void testServiceFromReferenceMay() { + assertEquals(myService2.getHolidays()[0], myService2.getHolidaysByYear(2007)[0]); + assertNotSame(myService2.nextHoliday(), myService2.nextHolidayByDate(new Date())); + + } + + public void testServiceFromReferenceMust() { + assertEquals(myService3.getHolidays()[0], myService3.getHolidaysByYear(2007)[0]); + assertNotSame(myService3.nextHoliday(), myService3.nextHolidayByDate(new Date())); + + } + + protected void setUp() throws Exception { + domain = SCADomain.newInstance("CompositeTest.composite"); + myService1 = domain.getService(MyTotalService.class, "MyTotalServiceNo"); + myService2 = domain.getService(MyTotalService.class, "MyTotalServiceMay"); + myService3 = domain.getService(MyTotalService.class, "MyTotalServiceMust"); + } + + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTestCase.java b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTestCase.java new file mode 100644 index 0000000000..60ee8b2011 --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTestCase.java @@ -0,0 +1,92 @@ +/* + * 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.test.spec; + +import java.util.Date; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class CompositeServiceReferenceTestCase extends TestCase { + private MyTotalService myService1; + private MyTotalService myService2; + private MyTotalService myService3; + private MyTotalService myService4; + private MyTotalService myService5; + private SCADomain domain; + + public void FIXMEtestPropertyWithServiceFromRecursive() { + assertEquals("CARY", myService1.getLocation()); + assertEquals("2007", myService1.getYear()); + } + + public void testPropertyWithServiceInCompositeFromRecursive() { + assertEquals("CARY", myService2.getLocation()); + assertEquals("2007", myService2.getYear()); + + } + + public void testPropertyWithServiceInCompositeFromComponent() { + assertEquals("CARY", myService3.getLocation()); + assertEquals("2007", myService3.getYear()); + } + + public void FIXMEtestServiceFromRecursive() { + assertNotSame(myService1.nextHoliday(), myService1.nextHolidayByDate(new Date())); + assertEquals(myService1.getHolidays()[0], myService1.getHolidaysByYear(2007)[0]); + + } + + public void testServiceReferenceFromRecursive() { + assertEquals(myService2.getHolidays()[0], myService2.getHolidaysByYear(2007)[0]); + assertNotSame(myService2.nextHoliday(), myService2.nextHolidayByDate(new Date())); + + } + + public void testServiceReferenceFromRecursiveUseService() { + assertNotSame(myService4.nextHoliday(), myService4.nextHolidayByDate(new Date())); + assertEquals(myService4.getHolidays()[0], myService4.getHolidaysByYear(2007)[0]); + } + + public void testServiceReferenceFromComponent() { + assertEquals(myService3.getHolidays()[0], myService3.getHolidaysByYear(2007)[0]); + assertNotSame(myService3.nextHoliday(), myService3.nextHolidayByDate(new Date())); + + } + + public void testServiceReferenceFromComponentUseService() { + assertNotSame(myService5.nextHoliday(), myService5.nextHolidayByDate(new Date())); + assertEquals(myService5.getHolidays()[0], myService5.getHolidaysByYear(2007)[0]); + } + + protected void setUp() throws Exception { + domain = SCADomain.newInstance("CompositeTest.composite"); + myService1 = domain.getService(MyTotalService.class, "MyTotalServiceFromRecursive"); + myService2 = domain.getService(MyTotalService.class, "MyTotalServiceInCompositeWithRecursive"); + myService3 = domain.getService(MyTotalService.class, "MyTotalServiceInCompositeWithComponentService"); + myService4 = domain.getService(MyTotalService.class, "MyTotalServiceInCompositeWithRecursiveUseService"); + myService5 = + domain.getService(MyTotalService.class, "MyTotalServiceInCompositeWithComponentServiceUseService"); + } + + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTestCase.java b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTestCase.java new file mode 100644 index 0000000000..d9c2a73f7e --- /dev/null +++ b/sandbox/old/contrib/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTestCase.java @@ -0,0 +1,78 @@ +/* + * 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.test.spec; + +import static junit.framework.Assert.assertEquals; + +import java.util.Date; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class CompositeTestCase { + private static MyService myService; + private static MyServiceByDate myServiceByDate; + private static MyListService myListService; + private static MyListServiceByYear myListServiceByYear; + + private static SCADomain domain; + + @Test + public void testOverrideProperty() { + assertEquals("CARY", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + @Test + public void testDefaultService() { + assertEquals(myService.nextHoliday(), myServiceByDate.nextHolidayByDate(new Date())); + assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidaysByYear(2007)[0]); + + } + + @Test + public void testContext() { + // FIXME TUSCANY-1174 - Need support for @ComponentName + /* + * assertNotNull("Service component name is null", + * myService.getComponentName()); assertNotNull("service context is + * null", myService.getContext()); System.out.println("Service component + * name :" + myService.getComponentName()); System.out.println("service + * context :" + myService.getContext()); test(context); + */ + } + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("CompositeTest.composite"); + myService = domain.getService(MyService.class, "MyServiceInRecursiveMyService"); + myServiceByDate = domain.getService(MyServiceByDate.class, "MyServiceInRecursiveMyServiceByDate"); + myListService = domain.getService(MyListService.class, "MyServiceInRecursiveMyListService"); + myListServiceByYear = domain.getService(MyListServiceByYear.class, + "MyServiceInRecursiveMyListServiceByYear"); + } + + @AfterClass + public static void destroy() throws Exception { + domain.close(); + } +} diff --git a/sandbox/old/contrib/itest/specTest/pom.xml.off b/sandbox/old/contrib/itest/specTest/pom.xml.off new file mode 100644 index 0000000000..66d1127a0f --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/pom.xml.off @@ -0,0 +1,40 @@ + + + + + org.apache.tuscany.sca + integration-test + 2.0-alpha-incubating-SNAPSHOT + + 4.0.0 + org.apache.tuscany.sca.integration-test + specTest + jar + Integration Test Suite for SCA Spec APIs + + + + + org.apache.tuscany + tuscany-itest-plugin + + + + \ No newline at end of file diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.java new file mode 100644 index 0000000000..6e1b8dc612 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTester.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.test.spec; + +/** + * @version $Rev$ $Date$ + */ +public interface ComponentContextTester extends IdentityService { + /** + * Returns true if the ComponentContext was injected + * @return true if the ComponentContext was injected + */ + boolean isContextInjected(); + + /** + * Looks up a reference with the supplied name and returns the identity of the referenced component. + * @param name the name of a reference + * @return the identity of the referenced component + */ + String getServiceIdentity(String name); + + /** + * Looks up a reference with the supplied name using a ServiceReference + * and returns the identity of the referenced component. + * @param name the name of a reference + * @return the identity of the referenced component + */ + String getServiceReferenceIdentity(String name); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java new file mode 100644 index 0000000000..df6366dbef --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/ComponentContextTesterImpl.java @@ -0,0 +1,56 @@ +/* + * 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.test.spec; + +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; + +/** + * Component that tests ComponentContext functions. + * + * @version $Rev$ $Date$ + */ +public class ComponentContextTesterImpl implements ComponentContextTester { + @Context + public ComponentContext context; + + @Reference + public IdentityService getServiceTest; + + public boolean isContextInjected() { + return context != null; + } + + public String getURI() { + return context.getURI(); + } + + public String getServiceIdentity(String name) { + IdentityService service = context.getService(IdentityService.class, name); + return service.getURI(); + } + + public String getServiceReferenceIdentity(String name) { + ServiceReference ref = context.getServiceReference(IdentityService.class, name); + IdentityService service = ref.getService(); + return service.getURI(); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.java new file mode 100644 index 0000000000..cab690eafd --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentifiableComponent.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.test.spec; + +import org.osoa.sca.annotations.Context; +import org.osoa.sca.ComponentContext; + +/** + * @version $Rev$ $Date$ + */ +public class IdentifiableComponent implements IdentityService { + @Context + public ComponentContext context; + + public String getURI() { + return context.getURI(); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.java new file mode 100644 index 0000000000..25435a3cc4 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/IdentityService.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.test.spec; + +/** + * @version $Rev$ $Date$ + */ +public interface IdentityService { + String getURI(); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.java new file mode 100644 index 0000000000..7fe9fa4909 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListService.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.test.spec; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyListService { + String[] getHolidays(); + + String getYear(); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.java new file mode 100644 index 0000000000..28a26dddde --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyListServiceByYear.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.test.spec; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyListServiceByYear { + String[] getHolidays(int year); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyService.java new file mode 100644 index 0000000000..fbb2161df3 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/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.test.spec; + +import java.util.Date; + +public interface MyService extends SCAComponentService { + Date nextHoliday(); + + String getLocation(); + + String getYear(); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.java new file mode 100644 index 0000000000..892b36e1a1 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyServiceByDate.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.test.spec; + +import java.util.Date; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface MyServiceByDate { + Date nextHoliday(Date date); +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java new file mode 100644 index 0000000000..6a4cfc1f79 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/MyTotalService.java @@ -0,0 +1,23 @@ +/* + * 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.test.spec; + +public interface MyTotalService extends MyListService, MyListServiceByYear, MyService, MyServiceByDate { + +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.java new file mode 100644 index 0000000000..2ba1cb41cb --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/SCAComponentService.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.test.spec; + +import org.osoa.sca.ComponentContext; + +public interface SCAComponentService { + String getComponentName(); + + ComponentContext getContext(); + +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java new file mode 100644 index 0000000000..6f3f761432 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyListServiceImpl.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.test.spec.impl; + +import java.util.List; + +import org.apache.tuscany.sca.test.spec.MyListService; +import org.apache.tuscany.sca.test.spec.MyListServiceByYear; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + + +@Service(interfaces = {MyListService.class, MyListServiceByYear.class}) +public class MyListServiceImpl implements MyListService, MyListServiceByYear { + + // This is multiplicity=1:n + @Reference(name = "myListServiceList", required = false) + public List myListServicesList; + + // This is multiplicity=0:n + @Reference(name = "myListServiceArray", required = false) + public MyListService[] myListServicesArray; + + @Property(name = "serviceYear") + protected String year = "2006"; + + public String[] getHolidays() { + return getHolidays(Integer.parseInt(year)); + } + + public String[] getHolidays(int year) { + MyListService myService; + if (myListServicesList != null) { + for (MyListService aMyListServicesList : myListServicesList) { + myService = aMyListServicesList; + if (Integer.parseInt(myService.getYear()) == year) { + return myService.getHolidays(); + } + } + } + if (myListServicesArray != null) { + for (MyListService aMyListServicesArray : myListServicesArray) { + myService = aMyListServicesArray; + if (Integer.parseInt(myService.getYear()) == year) { + return myService.getHolidays(); + } + } + } + return null; + } + + public String getYear() { + return year; + } + +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java new file mode 100644 index 0000000000..3aa2c2a136 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyServiceImpl.java @@ -0,0 +1,122 @@ +/* + * 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.test.spec.impl; + +import java.util.Date; + +import org.apache.tuscany.sca.test.spec.MyListService; +import org.apache.tuscany.sca.test.spec.MyListServiceByYear; +import org.apache.tuscany.sca.test.spec.MyService; +import org.apache.tuscany.sca.test.spec.MyServiceByDate; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.ComponentName; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Service; + + +@Service(interfaces = {MyService.class, MyServiceByDate.class, MyListService.class, MyListServiceByYear.class}) +public class MyServiceImpl implements MyService, MyServiceByDate, MyListService, MyListServiceByYear { + static String[][] holidays = + { + {"2006/01/02", "2006/05/29", "2006/07/03", "2006/07/04", "2006/09/04", "2006/11/23", "2006/11/23", + "2006/11/24", "2006/12/25"}, + {"2007/01/01", "2007/05/28", "2007/07/04", "2007/09/03", "2007/11/22", "2007/11/23", "2007/12/25"}}; + + @Property(name = "location") + protected String location = "RTP"; + + @Property(name = "year") + protected String year = "2006"; + + @ComponentName + protected String componentName; + + @Context + protected ComponentContext context; + + public MyServiceImpl() { + System.out.println("creating service instance..."); + } + + public Date nextHoliday() { + + return nextHoliday(new Date()); + } + + @SuppressWarnings("deprecation") + public Date nextHoliday(Date today) { + Date d1; + String[] days = getHolidays(); + for (String day : days) { + d1 = new Date(day); + if (d1.after(today)) + return d1; + } + return null; + } + + public String[] getHolidays(int year) { + int index = year - 2006; + if (index >= 0 && index < holidays.length) + return holidays[index]; + return null; + } + + public String[] getHolidays() { + + Integer theYear; + if (year == null || year.length() == 0) + theYear = new Integer("2006"); + else + theYear = new Integer(year); + + return getHolidays(theYear.intValue()); + } + + @Init + public void start() { + System.out.println("Start service.."); + } + + @Destroy + public void stop() { + System.out.println("Stop service.."); + + } + + public String getComponentName() { + return componentName; + } + + public ComponentContext getContext() { + return context; + } + + public String getLocation() { + return location; + } + + public String getYear() { + return year; + } + +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java new file mode 100644 index 0000000000..d56e9aede4 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/java/org/apache/tuscany/sca/test/spec/impl/MyTotalServiceImpl.java @@ -0,0 +1,83 @@ +/* + * 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.test.spec.impl; + +import java.util.Date; + +import org.apache.tuscany.sca.test.spec.MyListService; +import org.apache.tuscany.sca.test.spec.MyListServiceByYear; +import org.apache.tuscany.sca.test.spec.MyService; +import org.apache.tuscany.sca.test.spec.MyServiceByDate; +import org.apache.tuscany.sca.test.spec.MyTotalService; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + + +@Service(MyTotalService.class) +public class MyTotalServiceImpl implements MyTotalService { + + // This is multiplicity=1:1 + @Reference(required = true) + public MyListService myListService; + + // default required==true so it is 1:1 + @Reference + public MyListServiceByYear myListServiceByYear = new MyServiceImpl(); + + // default required==true so it is 1:1 + @Reference + public MyService myService; + + // This is multiplicity=0:1 + @Reference(required = false) + public MyServiceByDate myServiceByDate = new MyServiceImpl(); + + public String[] getHolidays() { + return myListService.getHolidays(); + } + + public String[] getHolidays(int year) { + return myListServiceByYear.getHolidays(year); + } + + public String getComponentName() { + return myService.getComponentName(); + } + + public ComponentContext getContext() { + return myService.getContext(); + } + + public Date nextHoliday(Date date) { + return myServiceByDate.nextHoliday(date); + } + + public String getLocation() { + return myService.getLocation(); + } + + public String getYear() { + return myService.getYear(); + } + + public Date nextHoliday() { + return myService.nextHoliday(); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/default.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/default.scdl new file mode 100644 index 0000000000..0f09f102b9 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/default.scdl @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myListService.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myListService.scdl new file mode 100644 index 0000000000..55293b00f1 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myListService.scdl @@ -0,0 +1,34 @@ + + + + + + + + 2007 + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInComposite.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInComposite.scdl new file mode 100644 index 0000000000..14b1261604 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInComposite.scdl @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInRecursive.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInRecursive.scdl new file mode 100644 index 0000000000..5d13f75970 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myServiceInRecursive.scdl @@ -0,0 +1,53 @@ + + + + + + + MyServiceInRecursive/MyService + + + + + + MyServiceInRecursive/MyListService + + + + + + MyServiceInRecursive/MyListServiceByYear + + + + + + MyServiceInRecursive/MyServiceByDate + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleService.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleService.scdl new file mode 100644 index 0000000000..700ae21b25 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleService.scdl @@ -0,0 +1,34 @@ + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive.scdl new file mode 100644 index 0000000000..1354fc2ba4 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive.scdl @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive2.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive2.scdl new file mode 100644 index 0000000000..79287745b7 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/mySimpleServiceInRecursive2.scdl @@ -0,0 +1,47 @@ + + + + + + + MySimpleServiceInRecursiveComponent/MySimpleService + + + + + MySimpleServiceInRecursiveComponent/MySimpleServiceNo + + + + + MySimpleServiceInRecursiveComponent/MySimpleServiceMay + + + + + MySimpleServiceInRecursiveComponent/MySimpleServiceMust + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalService.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalService.scdl new file mode 100644 index 0000000000..8e676fedf8 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalService.scdl @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInComposite.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInComposite.scdl new file mode 100644 index 0000000000..825e3777b6 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInComposite.scdl @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInCompositeForReferenceOverride.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInCompositeForReferenceOverride.scdl new file mode 100644 index 0000000000..29bfa3cd23 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInCompositeForReferenceOverride.scdl @@ -0,0 +1,81 @@ + + + + + + + MyTotalServiceComponentNo + + + + + + + + + + + + + + + + + + + MyTotalServiceComponentMay + + + + + + + + + + + + + + + + + + + MyTotalServiceComponentMust + + + + + + + + + + + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursive.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursive.scdl new file mode 100644 index 0000000000..98c19b6116 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursive.scdl @@ -0,0 +1,60 @@ + + + + + + + + + + + + MyServiceInComposite/MyListService + + + + + + + + + + + + + + + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursiveForReferenceOverride.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursiveForReferenceOverride.scdl new file mode 100644 index 0000000000..51cd181b00 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myTotalServiceInRecursiveForReferenceOverride.scdl @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CARY + 2007 + + + diff --git a/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myservice.scdl b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myservice.scdl new file mode 100644 index 0000000000..845cbbf9fd --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/main/resources/META-INF/sca/myservice.scdl @@ -0,0 +1,51 @@ + + + + + + + + + + + NC + 2007 + + + + + + + + + + + + + 2006 + + + + + + + diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java new file mode 100644 index 0000000000..c7bce6e65f --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestComponent.java @@ -0,0 +1,48 @@ +/* + * 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.test.spec; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +/** + * @version $Rev$ $Date$ + */ +public class ComponentContextTestComponent extends TestCase { + @Reference + public ComponentContextTester tester; + + public void testContextWasInjected() { + assertTrue(tester.isContextInjected()); + } + + public void testComponentURI() { + assertEquals("itest://localhost/testDomain/testHarness/ComponentContextTester", tester.getURI()); + } + + public void testGetService() { + assertEquals("itest://localhost/testDomain/testHarness/ReferencedService", + tester.getServiceIdentity("getServiceTest")); + } + + public void testGetServiceReference() { + assertEquals("itest://localhost/testDomain/testHarness/ReferencedService", + tester.getServiceReferenceIdentity("getServiceTest")); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTest.java new file mode 100644 index 0000000000..c06ce947ea --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceListTest.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.test.spec; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +public class ComponentServiceReferenceListTest extends TestCase { + @Reference + public MyListService myListService; + @Reference + public MyListServiceByYear myListServiceByYear; + + public void testDefaultProperty() { + assertEquals("2007", myListService.getYear()); + + } + + public void testDefaultService() { + assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidays(2007)[0]); + + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTest.java new file mode 100644 index 0000000000..30a4959d8f --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentServiceReferenceTest.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.test.spec; + +import java.util.Date; + +import junit.framework.TestCase; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; + +public class ComponentServiceReferenceTest extends TestCase { + @Reference + public MyTotalService myService; + + @Context + public ComponentContext context; + + public void testDefaultProperty() { + assertEquals("NC", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testDefaultService() { + assertNotSame(myService.nextHoliday(), myService.nextHoliday(new Date())); + assertEquals(myService.getHolidays()[0], myService.getHolidays(2007)[0]); + + } + + public void testMyServiceContext() { + assertNotNull("Service component name is null", myService.getComponentName()); + assertNotNull("service context is null", myService.getContext()); + + System.out.println("Service component name :" + myService.getComponentName()); + System.out.println("service context :" + myService.getContext()); + + } + + public void testContext() { + assertNotNull("service context is null", context); + + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTest.java new file mode 100644 index 0000000000..d039a066a7 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/ComponentTest.java @@ -0,0 +1,71 @@ +/* + * 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.test.spec; + +import java.util.Date; + +import org.osoa.sca.annotations.Reference; + +import junit.framework.TestCase; + +public class ComponentTest extends TestCase { + @Reference + public MyService myService; + @Reference + public MyServiceByDate myServiceByDate; + @Reference + public MyListService myListService; + @Reference + public MyListServiceByYear myListServiceByYear; + @Reference + public MyService myNCService; + @Reference + public MyListService myListServiceFor2006; + + public void testDefaultProperty() { + assertEquals("RTP", myService.getLocation()); + assertEquals("2006", myService.getYear()); + + } + + public void testDefaultService() { + assertEquals(myService.nextHoliday(), myServiceByDate.nextHoliday(new Date())); + assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidays(2006)[0]); + + } + + public void testOverrideProperty() { + assertEquals("NC", myNCService.getLocation()); + assertEquals("2007", myNCService.getYear()); + } + + public void testServiceWithOverrideProperty() { + assertFalse(myNCService.nextHoliday() == myService.nextHoliday()); + assertEquals(myListServiceFor2006.getHolidays()[0], myListServiceByYear.getHolidays(2006)[0]); + + } + + public void testContext() { + assertNotNull("Service component name is null", myService.getComponentName()); + assertNotNull("service context is null", myService.getContext()); + + System.out.println("Service component name :" + myService.getComponentName()); + System.out.println("service context :" + myService.getContext()); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTest.java new file mode 100644 index 0000000000..2a50cdc8df --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneService2LevelTest.java @@ -0,0 +1,89 @@ +/* + * 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.test.spec; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +public class CompositeOneService2LevelTest extends TestCase { + @Reference + public MyService myService; + @Reference + public MyService myServiceDefault; + @Reference + public MyService myServiceNo; + @Reference + public MyService myServiceMay; + @Reference + public MyService myServiceMust; + + public void testPropertyFromComponent() { + assertEquals("CARY", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testPropertyFromServiceDefault() { + assertEquals("CARY", myServiceDefault.getLocation()); + assertEquals("2007", myServiceDefault.getYear()); + + } + + public void testServiceDefault() { + assertEquals(myService.nextHoliday(), myServiceDefault.nextHoliday()); + } + + public void testPropertyFromServiceNo() { + assertEquals("CARY", myServiceNo.getLocation()); + assertEquals("2007", myServiceNo.getYear()); + + } + + public void testServiceNo() { + assertEquals(myService.nextHoliday(), myServiceNo.nextHoliday()); + } + + public void testPropertyFromServiceMay() { + assertEquals("CARY", myServiceMay.getLocation()); + assertEquals("2007", myServiceMay.getYear()); + + } + + public void testServiceMay() { + assertEquals(myService.nextHoliday(), myServiceMay.nextHoliday()); + } + + public void testPropertyFromServiceMust() { + assertEquals("CARY", myServiceMust.getLocation()); + assertEquals("2007", myServiceMust.getYear()); + + } + + public void testServiceMust() { + assertEquals(myService.nextHoliday(), myServiceMust.nextHoliday()); + } + + public void testContext() { + assertNotNull("Service component name is null", myService.getComponentName()); + assertNotNull("service context is null", myService.getContext()); + + System.out.println("Service component name :" + myService.getComponentName()); + System.out.println("service context :" + myService.getContext()); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTest.java new file mode 100644 index 0000000000..27deb92012 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeOneServiceTest.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.test.spec; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +public class CompositeOneServiceTest extends TestCase { + @Reference + public MyService myService; + + public void testOverrideProperty() { + assertEquals("CARY", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testDefaultService() { + assertNotNull(myService.nextHoliday()); + } + + public void testContext() { + assertNotNull("Service component name is null", myService.getComponentName()); + assertNotNull("service context is null", myService.getContext()); + + System.out.println("Service component name :" + myService.getComponentName()); + System.out.println("service context :" + myService.getContext()); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTest.java new file mode 100644 index 0000000000..b312fd1e36 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceForRefOverrideTest.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.test.spec; + +import java.util.Date; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +public class CompositeServiceReferenceForRefOverrideTest extends TestCase { + @Reference + public MyTotalService myService1; + @Reference + public MyTotalService myService2; + @Reference + public MyTotalService myService3; + + public void testPropertyWithServiceFromReferenceNo() { + assertEquals("CARY", myService1.getLocation()); + assertEquals("2007", myService1.getYear()); + } + + public void testPropertyWithServiceFromReferenceMay() { + assertEquals("CARY", myService2.getLocation()); + assertEquals("2007", myService2.getYear()); + + } + + public void testPropertyWithServiceFromReferenceMust() { + assertEquals("CARY", myService3.getLocation()); + assertEquals("2007", myService3.getYear()); + } + + public void testServiceFromReferenceNo() { + System.out.println("nextHolday()" + myService1.nextHoliday()); + System.out.println("nextHolday(Date)" + myService1.nextHoliday(new Date())); + System.out.println("myService1.getHolidays()[0]" + myService1.getHolidays()[0]); + System.out.println("myService1.getHolidays(2007)[0]" + myService1.getHolidays(2007)[0]); + assertNotSame(myService1.nextHoliday(), myService1.nextHoliday(new Date())); + assertEquals(myService1.getHolidays()[0], myService1.getHolidays(2007)[0]); + } + + public void testServiceFromReferenceMay() { + assertEquals(myService2.getHolidays()[0], myService2.getHolidays(2007)[0]); + assertNotSame(myService2.nextHoliday(), myService2.nextHoliday(new Date())); + + } + + public void testServiceFromReferenceMust() { + assertEquals(myService3.getHolidays()[0], myService3.getHolidays(2007)[0]); + assertNotSame(myService3.nextHoliday(), myService3.nextHoliday(new Date())); + + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTest.java new file mode 100644 index 0000000000..edf8d05512 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeServiceReferenceTest.java @@ -0,0 +1,81 @@ +/* + * 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.test.spec; + +import java.util.Date; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +public class CompositeServiceReferenceTest extends TestCase { + @Reference + public MyTotalService myService1; + @Reference + public MyTotalService myService2; + @Reference + public MyTotalService myService3; + @Reference + public MyTotalService myService4; + @Reference + public MyTotalService myService5; + + public void testPropertyWithServiceFromRecursive() { + assertEquals("CARY", myService1.getLocation()); + assertEquals("2007", myService1.getYear()); + } + + public void testPropertyWithServiceInCompositeFromRecursive() { + assertEquals("CARY", myService2.getLocation()); + assertEquals("2007", myService2.getYear()); + + } + + public void testPropertyWithServiceInCompositeFromComponent() { + assertEquals("CARY", myService3.getLocation()); + assertEquals("2007", myService3.getYear()); + } + + public void testServiceFromRecursive() { + assertNotSame(myService1.nextHoliday(), myService1.nextHoliday(new Date())); + assertEquals(myService1.getHolidays()[0], myService1.getHolidays(2007)[0]); + + } + + public void testServiceReferenceFromRecursive() { + assertEquals(myService2.getHolidays()[0], myService2.getHolidays(2007)[0]); + assertNotSame(myService2.nextHoliday(), myService2.nextHoliday(new Date())); + + } + + public void testServiceReferenceFromRecursiveUseService() { + assertNotSame(myService4.nextHoliday(), myService4.nextHoliday(new Date())); + assertEquals(myService4.getHolidays()[0], myService4.getHolidays(2007)[0]); + } + + public void testServiceReferenceFromComponent() { + assertEquals(myService3.getHolidays()[0], myService3.getHolidays(2007)[0]); + assertNotSame(myService3.nextHoliday(), myService3.nextHoliday(new Date())); + + } + + public void testServiceReferenceFromComponentUseService() { + assertNotSame(myService5.nextHoliday(), myService5.nextHoliday(new Date())); + assertEquals(myService5.getHolidays()[0], myService5.getHolidays(2007)[0]); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTest.java b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTest.java new file mode 100644 index 0000000000..98c368fdba --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/java/org/apache/tuscany/sca/test/spec/CompositeTest.java @@ -0,0 +1,55 @@ +/* + * 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.test.spec; + +import java.util.Date; + +import junit.framework.TestCase; +import org.osoa.sca.annotations.Reference; + +public class CompositeTest extends TestCase { + @Reference + public MyService myService; + @Reference + public MyServiceByDate myServiceByDate; + @Reference + public MyListService myListService; + @Reference + public MyListServiceByYear myListServiceByYear; + + public void testOverrideProperty() { + assertEquals("CARY", myService.getLocation()); + assertEquals("2007", myService.getYear()); + + } + + public void testDefaultService() { + assertEquals(myService.nextHoliday(), myServiceByDate.nextHoliday(new Date())); + assertEquals(myListService.getHolidays()[0], myListServiceByYear.getHolidays(2007)[0]); + + } + + public void testContext() { + assertNotNull("Service component name is null", myService.getComponentName()); + assertNotNull("service context is null", myService.getContext()); + + System.out.println("Service component name :" + myService.getComponentName()); + System.out.println("service context :" + myService.getContext()); + } +} diff --git a/sandbox/old/contrib/itest/specTest/src/test/resources/itest.scdl b/sandbox/old/contrib/itest/specTest/src/test/resources/itest.scdl new file mode 100644 index 0000000000..62c5cece94 --- /dev/null +++ b/sandbox/old/contrib/itest/specTest/src/test/resources/itest.scdl @@ -0,0 +1,30 @@ + + + + + + + + + + + -- cgit v1.2.3