From fa8b02df1b48a33929dfa4ff3eeebc12231de737 Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 23 Mar 2009 08:36:16 +0000 Subject: Copy trunk to test sandbox trunk git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@757348 13f79535-47bb-0310-9956-ffa450edef68 --- .../java-api/annotations/conversational/pom.xml | 46 ++ .../annotations/conversational/AService.java | 30 ++ .../annotations/conversational/B1Service.java | 29 ++ .../annotations/conversational/B2Service.java | 32 ++ .../conversational/impl/AServiceImpl.java | 47 ++ .../conversational/impl/B1ServiceImpl.java | 38 ++ .../conversational/impl/B2ServiceImpl.java | 40 ++ .../src/main/resources/conversation.composite | 40 ++ .../ConversationAnnotationTestCase.java | 91 ++++ .../annotations/conversationattributes/pom.xml | 53 +++ .../conversationattributes/AService.java | 30 ++ .../conversationattributes/B2Service.java | 32 ++ .../conversationattributes/BService.java | 32 ++ .../conversationattributes/CService.java | 30 ++ .../conversationattributes/impl/AServiceImpl.java | 80 ++++ .../conversationattributes/impl/B2ServiceImpl.java | 42 ++ .../conversationattributes/impl/BServiceImpl.java | 42 ++ .../conversationattributes/impl/CServiceImpl.java | 37 ++ .../security/ACallbackHandler.java | 50 +++ .../security/JaasLoginModule.java | 179 ++++++++ .../security/UserPrincipal.java | 66 +++ .../src/main/resources/AJass.config | 3 + .../src/main/resources/conversation.composite | 46 ++ .../src/main/resources/definitions.xml | 34 ++ .../src/main/resources/singleprincipal.composite | 38 ++ .../ConversationAttributesTestCase.java | 93 ++++ .../SinglePricipalTestCase.java | 70 +++ .../vtest/java-api/annotations/destroy/pom.xml | 45 ++ .../javaapi/annotations/destroy/AService.java | 29 ++ .../annotations/destroy/impl/AServiceErr1Impl.java | 39 ++ .../annotations/destroy/impl/AServiceErr2Impl.java | 39 ++ .../annotations/destroy/impl/AServiceErr3Impl.java | 40 ++ .../annotations/destroy/impl/AServiceErr4Impl.java | 39 ++ .../annotations/destroy/impl/AServiceImpl.java | 38 ++ .../src/main/resources/err1/AServiceErr1.composite | 28 ++ .../src/main/resources/err2/AServiceErr2.composite | 28 ++ .../src/main/resources/err3/AServiceErr3.composite | 28 ++ .../src/main/resources/err4/AServiceErr4.composite | 28 ++ .../src/main/resources/proper/AService.composite | 28 ++ .../destroy/DestroyAnnotationTestCase.java | 159 +++++++ .../java-api/annotations/endsconversation/pom.xml | 46 ++ .../annotations/endsconversation/AService.java | 32 ++ .../annotations/endsconversation/BService.java | 37 ++ .../endsconversation/impl/AServiceImpl.java | 70 +++ .../endsconversation/impl/BServiceImpl.java | 59 +++ .../src/main/resources/endsconversation.composite | 35 ++ .../endsconversation/EndsConversationTestCase.java | 112 +++++ .../trunk/vtest/java-api/annotations/init/pom.xml | 45 ++ .../vtest/javaapi/annotations/init/AService.java | 30 ++ .../annotations/init/impl/AServiceErr1Impl.java | 43 ++ .../annotations/init/impl/AServiceErr2Impl.java | 43 ++ .../annotations/init/impl/AServiceErr3Impl.java | 44 ++ .../annotations/init/impl/AServiceErr4Impl.java | 43 ++ .../annotations/init/impl/AServiceImpl.java | 53 +++ .../src/main/resources/err1/AServiceErr1.composite | 28 ++ .../src/main/resources/err2/AServiceErr2.composite | 28 ++ .../src/main/resources/err3/AServiceErr3.composite | 28 ++ .../src/main/resources/err4/AServiceErr4.composite | 28 ++ .../src/main/resources/proper/AService.composite | 33 ++ .../annotations/init/InitAnnotationTestCase.java | 167 ++++++++ .../vtest/java-api/annotations/oneway/pom.xml | 46 ++ .../vtest/javaapi/annotations/oneway/AService.java | 31 ++ .../vtest/javaapi/annotations/oneway/BService.java | 28 ++ .../annotations/oneway/impl/AServiceImpl.java | 37 ++ .../annotations/oneway/impl/BServiceImpl.java | 43 ++ .../oneway/src/main/resources/oneway.composite | 35 ++ .../oneway/OneWayAnnotationTestCase.java | 78 ++++ .../sca/trunk/vtest/java-api/annotations/pom.xml | 69 +++ .../vtest/java-api/annotations/property/pom.xml | 46 ++ .../javaapi/annotations/property/AService.java | 82 ++++ .../annotations/property/AnotherAService.java | 48 +++ .../javaapi/annotations/property/BService.java | 32 ++ .../javaapi/annotations/property/CService.java | 38 ++ .../javaapi/annotations/property/impl/AObject.java | 35 ++ .../annotations/property/impl/AServiceImpl.java | 240 +++++++++++ .../property/impl/AnotherAServiceImpl.java | 116 +++++ .../annotations/property/impl/BServiceImpl.java | 32 ++ .../annotations/property/impl/CServiceImpl1.java | 87 ++++ .../annotations/property/impl/CServiceImpl2.java | 87 ++++ .../annotations/property/impl/CServiceImpl3.java | 87 ++++ .../annotations/property/impl/CServiceImpl4.java | 88 ++++ .../annotations/property/impl/CServiceImpl5.java | 88 ++++ .../annotations/property/impl/CServiceImpl6.java | 88 ++++ .../property/src/main/resources/property.composite | 143 +++++++ .../property/PropertyAnnotationTestCase.java | 299 +++++++++++++ .../vtest/java-api/annotations/reference/pom.xml | 46 ++ .../javaapi/annotations/reference/AService.java | 55 +++ .../javaapi/annotations/reference/BService.java | 31 ++ .../annotations/reference/impl/AServiceImpl.java | 215 ++++++++++ .../reference/impl/AUnannotatedServiceImpl.java | 141 ++++++ .../annotations/reference/impl/BServiceImpl.java | 32 ++ .../reference/src/main/resources/ab.composite | 51 +++ .../reference/ReferenceAnnotationTestCase.java | 229 ++++++++++ .../trunk/vtest/java-api/annotations/scope/pom.xml | 46 ++ .../vtest/javaapi/annotations/scope/AService.java | 29 ++ .../vtest/javaapi/annotations/scope/BService.java | 40 ++ .../vtest/javaapi/annotations/scope/CService.java | 40 ++ .../vtest/javaapi/annotations/scope/DService.java | 43 ++ .../vtest/javaapi/annotations/scope/FService.java | 43 ++ .../vtest/javaapi/annotations/scope/GService.java | 35 ++ .../vtest/javaapi/annotations/scope/HService.java | 36 ++ .../vtest/javaapi/annotations/scope/IService.java | 48 +++ .../vtest/javaapi/annotations/scope/JService.java | 33 ++ .../vtest/javaapi/annotations/scope/KService.java | 33 ++ .../vtest/javaapi/annotations/scope/LService.java | 41 ++ .../vtest/javaapi/annotations/scope/MService.java | 33 ++ .../vtest/javaapi/annotations/scope/NService.java | 33 ++ .../vtest/javaapi/annotations/scope/OService.java | 41 ++ .../annotations/scope/impl/AServiceImpl.java | 32 ++ .../annotations/scope/impl/BServiceImpl.java | 112 +++++ .../annotations/scope/impl/CServiceImpl.java | 114 +++++ .../annotations/scope/impl/DServiceImpl.java | 116 +++++ .../annotations/scope/impl/FServiceImpl.java | 116 +++++ .../annotations/scope/impl/GServiceImpl.java | 75 ++++ .../annotations/scope/impl/HServiceImpl.java | 86 ++++ .../annotations/scope/impl/IServiceImpl.java | 131 ++++++ .../annotations/scope/impl/JServiceImpl.java | 78 ++++ .../annotations/scope/impl/KServiceImpl.java | 80 ++++ .../annotations/scope/impl/LServiceImpl.java | 83 ++++ .../annotations/scope/impl/MServiceImpl.java | 81 ++++ .../annotations/scope/impl/NServiceImpl.java | 85 ++++ .../annotations/scope/impl/OServiceImpl.java | 83 ++++ .../scope/src/main/resources/scope.composite | 110 +++++ .../annotations/scope/ScopeAnnotationTestCase.java | 476 +++++++++++++++++++++ .../vtest/java-api/annotations/service/pom.xml | 46 ++ .../javaapi/annotations/service/AService.java | 34 ++ .../javaapi/annotations/service/BService.java | 33 ++ .../javaapi/annotations/service/CService.java | 31 ++ .../javaapi/annotations/service/DService1.java | 28 ++ .../javaapi/annotations/service/DService2.java | 28 ++ .../javaapi/annotations/service/DService3.java | 28 ++ .../javaapi/annotations/service/EService.java | 30 ++ .../javaapi/annotations/service/FService.java | 30 ++ .../javaapi/annotations/service/GService1.java | 30 ++ .../javaapi/annotations/service/GService2.java | 26 ++ .../javaapi/annotations/service/HService.java | 50 +++ .../javaapi/annotations/service/IService.java | 54 +++ .../javaapi/annotations/service/impl/AObject.java | 33 ++ .../annotations/service/impl/AServiceImpl.java | 37 ++ .../annotations/service/impl/BServiceImpl.java | 111 +++++ .../annotations/service/impl/CServiceImpl.java | 34 ++ .../annotations/service/impl/DServiceImpl.java | 41 ++ .../annotations/service/impl/EServiceImpl.java | 32 ++ .../annotations/service/impl/FServiceImpl.java | 37 ++ .../annotations/service/impl/FServiceImpl2.java | 26 ++ .../annotations/service/impl/GServiceImpl.java | 42 ++ .../annotations/service/impl/HServiceImpl.java | 105 +++++ .../annotations/service/impl/IServiceImpl.java | 107 +++++ .../service/src/main/resources/service.composite | 82 ++++ .../service/ServiceAnnotationTestCase.java | 335 +++++++++++++++ 150 files changed, 9627 insertions(+) create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/B1Service.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/B2Service.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/B1ServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/B2ServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/resources/conversation.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/ConversationAnnotationTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/B2Service.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/BService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/CService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/B2ServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/BServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/CServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/ACallbackHandler.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/JaasLoginModule.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/UserPrincipal.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/AJass.config create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/conversation.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/definitions.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/singleprincipal.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/ConversationAttributesTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/SinglePricipalTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr1Impl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr2Impl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr3Impl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr4Impl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err1/AServiceErr1.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err2/AServiceErr2.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err3/AServiceErr3.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err4/AServiceErr4.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/proper/AService.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/DestroyAnnotationTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/BService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/impl/BServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/resources/endsconversation.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/EndsConversationTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr1Impl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr2Impl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr3Impl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr4Impl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err1/AServiceErr1.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err2/AServiceErr2.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err3/AServiceErr3.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err4/AServiceErr4.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/proper/AService.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/InitAnnotationTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/BService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/impl/BServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/resources/oneway.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/OneWayAnnotationTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/BService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/CService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AObject.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/BServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl1.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl2.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl3.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl4.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl5.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl6.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/resources/property.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/BService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AUnannotatedServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/BServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/resources/ab.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/ReferenceAnnotationTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/BService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/CService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/DService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/FService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/GService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/HService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/IService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/BServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/CServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/DServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/FServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/GServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/HServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/IServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/resources/scope.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/pom.xml create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/AService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/BService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/CService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService1.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService2.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService3.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/EService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/FService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService1.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService2.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/HService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/IService.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AObject.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/BServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/CServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/DServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/EServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl2.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/GServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/HServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/IServiceImpl.java create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/resources/service.composite create mode 100644 sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/ServiceAnnotationTestCase.java (limited to 'sandbox/ant/sca/trunk/vtest/java-api/annotations') diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/pom.xml new file mode 100644 index 0000000000..b9fa0ff9b9 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-conversation + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @Conversation + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/AService.java new file mode 100644 index 0000000000..bc7212f70c --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/AService.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.vtest.javaapi.annotations.conversational; + +/** + * Simple Remotable Service + */ +public interface AService { + + public String setThenGetB1State(String someState); + + public String setThenGetB2State(String someState); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/B1Service.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/B1Service.java new file mode 100644 index 0000000000..76c857126a --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/B1Service.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.vtest.javaapi.annotations.conversational; + +/** + * Simple Local Service + */ +public interface B1Service { + + public void setState(String someState); + public String getState(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/B2Service.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/B2Service.java new file mode 100644 index 0000000000..23791f2ca9 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/B2Service.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.conversational; + +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Local Service + */ +@Conversational +public interface B2Service { + + public void setState(String someState); + public String getState(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/AServiceImpl.java new file mode 100644 index 0000000000..b8e346681c --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/AServiceImpl.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.vtest.javaapi.annotations.conversational.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversational.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversational.B1Service; +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversational.B2Service; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(AService.class) +public class AServiceImpl implements AService { + + @Reference + protected B1Service b1; + + @Reference + protected B2Service b2; + + public String setThenGetB1State(String someState) { + b1.setState(someState); + return b1.getState(); + } + + public String setThenGetB2State(String someState) { + b2.setState(someState); + return b2.getState(); + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/B1ServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/B1ServiceImpl.java new file mode 100644 index 0000000000..75bac4bf18 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/B1ServiceImpl.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.vtest.javaapi.annotations.conversational.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversational.B1Service; +import org.oasisopen.sca.annotation.Service; + +@Service(B1Service.class) +public class B1ServiceImpl implements B1Service { + + String someState; + + public void setState(String someState) { + this.someState = someState; + } + + public String getState() { + return someState; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/B2ServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/B2ServiceImpl.java new file mode 100644 index 0000000000..860d60b0de --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/impl/B2ServiceImpl.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.vtest.javaapi.annotations.conversational.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversational.B2Service; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(B2Service.class) +@Scope("COMPOSITE") +public class B2ServiceImpl implements B2Service { + + String someState; + + public void setState(String someState) { + this.someState = someState; + } + + public String getState() { + return someState; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/resources/conversation.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/resources/conversation.composite new file mode 100644 index 0000000000..4c2de35d52 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/main/resources/conversation.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/ConversationAnnotationTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/ConversationAnnotationTestCase.java new file mode 100644 index 0000000000..c00d5f1c10 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversational/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversational/ConversationAnnotationTestCase.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.conversational; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This test class tests the Service annotation described in section 1.2.1 and + * 1.8.17 + */ +public class ConversationAnnotationTestCase { + + protected static String compositeName = "conversation.composite"; + protected static AService aService = null; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + aService = ServiceFinder.getService(AService.class, "AComponent"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + + } + + /** + * Line 328:
+ *

+ * When "@Conversational" is not specified on a service interface, the + * service contract is stateless.
+ *

+ * Line 394, 395:
+ * A service may be declared as conversational by marking its Java interface + * with "@Conversational". If a service interface is not marked with + * "@Conversational", it is stateless.
+ *

+ * BService has no "@Conversation" annotation so communication from A-> is + * stateless + */ + @Test + public void atConversation1() throws Exception { + String thisState = "This State"; + Assert.assertNotSame(thisState, aService.setThenGetB1State(thisState)); + } + + /** + * Line 325-327:
+ *

+ * Java service interfaces may be annotated to specify whether their + * contract is conversational as described in the Assembly Specification + * by using the "@Conversational" annotation. A conversational service + * indicates that requests to the service are correlated in some way + */ + @Test + public void atConversation2() throws Exception { + String thisState = "This State"; + Assert.assertSame(thisState, aService.setThenGetB2State(thisState)); + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/pom.xml new file mode 100644 index 0000000000..0c0236b440 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-conversationattributes + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @ConversationAttributes + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-policy-security + 2.0-SNAPSHOT + runtime + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/AService.java new file mode 100644 index 0000000000..a3f1f11826 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/AService.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.vtest.javaapi.annotations.conversationattributes; + +/** + * Simple Service + */ +public interface AService { + + public void testMaxAge() throws InterruptedException; + public void testMaxIdle() throws InterruptedException; + public void testSinglePrincipal(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/B2Service.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/B2Service.java new file mode 100644 index 0000000000..7290c31f1a --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/B2Service.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes; + +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Service + */ +@Conversational +public interface B2Service { + + public void setState(String someState); + public String getState(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/BService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/BService.java new file mode 100644 index 0000000000..d38ca0276c --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/BService.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes; + +import org.oasisopen.sca.annotation.Conversational; + +/** + * Simple Service + */ +@Conversational +public interface BService { + + public void setState(String someState); + public String getState(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/CService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/CService.java new file mode 100644 index 0000000000..5db8768398 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/CService.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.vtest.javaapi.annotations.conversationattributes; + +import org.oasisopen.sca.ServiceReference; + +/** + * Simple Service + */ +public interface CService { + + public void testSinglePricipal(ServiceReference bReference); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/AServiceImpl.java new file mode 100644 index 0000000000..a0a654920d --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/AServiceImpl.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.vtest.javaapi.annotations.conversationattributes.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.B2Service; +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.CService; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(AService.class) +public class AServiceImpl implements AService { + + @Reference + protected BService b; + + @Reference + protected B2Service b2; + + @Reference + protected CService c; + + @Context + protected ComponentContext context; + + private void delayForSeconds(int numSeconds) { + try { + Thread.sleep(numSeconds * 1000);// millisecs + } catch (InterruptedException ex) { + throw new Error(ex); + } + } + + public void testMaxAge() { + + String someState = "someState"; + b.setState(someState); + delayForSeconds(2); + b.setState(someState); + + } + + public void testMaxIdle() { + + String someState = "someState"; + b2.setState(someState); + delayForSeconds(2); + b2.setState(someState); + + } + + public void testSinglePrincipal() { + + b.setState("Some state"); + System.out.println("Calling c and passing reference to b"); + c.testSinglePricipal(context.getServiceReference(BService.class, "b")); + + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/B2ServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/B2ServiceImpl.java new file mode 100644 index 0000000000..2f711be74d --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/B2ServiceImpl.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.BService; +import org.oasisopen.sca.annotation.ConversationAttributes; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(BService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxIdleTime="1 seconds") +public class B2ServiceImpl implements BService { + + String someState; + + public void setState(String someState) { + this.someState = someState; + } + + public String getState() { + return someState; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/BServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/BServiceImpl.java new file mode 100644 index 0000000000..f9aa1de8bd --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/BServiceImpl.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.BService; +import org.oasisopen.sca.annotation.ConversationAttributes; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(BService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxAge="1 seconds", singlePrincipal=true) +public class BServiceImpl implements BService { + + String someState; + + public void setState(String someState) { + this.someState = someState; + } + + public String getState() { + return someState; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/CServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/CServiceImpl.java new file mode 100644 index 0000000000..cc1c0d18fd --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/CServiceImpl.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.vtest.javaapi.annotations.conversationattributes.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.CService; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Service; + +@Service(CService.class) +public class CServiceImpl implements CService { + + public void testSinglePricipal(ServiceReference bReference) { + + System.out.println("In C calling set state on passed reference to B"); + bReference.getService().setState("someState"); + + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/ACallbackHandler.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/ACallbackHandler.java new file mode 100644 index 0000000000..3820240ee2 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/ACallbackHandler.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.vtest.javaapi.annotations.conversationattributes.security; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.UnsupportedCallbackException; + +/** + * @version $Rev$ $Date$ + */ +public class ACallbackHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + if (callbacks[i] instanceof NameCallback) { + NameCallback nc = (NameCallback)callbacks[i]; + nc.setName("AUser"); + } else if (callbacks[i] instanceof PasswordCallback) { + PasswordCallback pc = (PasswordCallback)callbacks[i]; + pc.setPassword("AUserPasswd".toCharArray()); + } else { + throw new UnsupportedCallbackException + (callbacks[i], "Unsupported Callback!"); + } + } + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/JaasLoginModule.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/JaasLoginModule.java new file mode 100644 index 0000000000..75573b838d --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/JaasLoginModule.java @@ -0,0 +1,179 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.security; + +import java.security.Principal; +import java.util.Map; + +import javax.security.auth.Subject; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.login.LoginException; +import javax.security.auth.spi.LoginModule; + + +/** + * @version $Rev$ $Date$ + */ +public class JaasLoginModule implements LoginModule { + + private CallbackHandler callbackHandler; + private Subject subject; + private Principal userPrincipal; + private String userId; + private String password; + private boolean succeeded; + private boolean commitSucceeded; + + public void initialize(Subject subject, + CallbackHandler callbackHandler, + Map sharedState, + Map options) { + this.callbackHandler = callbackHandler; + this.subject = subject; + } + + public boolean login() throws LoginException { + Callback[] callbacks = new Callback[2]; + callbacks[0] = new NameCallback("UserId:"); + callbacks[1] = new PasswordCallback("Password:", false); + + try { + callbackHandler.handle(callbacks); + userId = ((NameCallback)callbacks[0]).getName(); + password = new String(((PasswordCallback)callbacks[1]).getPassword()); + + if (userId.equals("CalculatorUser") && password.equals("CalculatorUserPasswd")) { + System.out.println("Successfully AUTHENTICATED!!"); + succeeded = true; + return true; + } else { + System.out.println("Incorrect userId / password! AUTHENTICATION FAILED!!"); + return false; + } + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + *

This method is called if the LoginContext's + * overall authentication succeeded + * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules + * succeeded). + * + *

If this LoginModule's own authentication attempt + * succeeded (checked by retrieving the private state saved by the + * login method), then this method associates a + * UserPrincipal + * with the Subject located in the + * LoginModule. If this LoginModule's own + * authentication attempted failed, then this method removes + * any state that was originally saved. + * + *

+ * + * @exception LoginException if the commit fails. + * + * @return true if this LoginModule's own login and commit + * attempts succeeded, or false otherwise. + */ + public boolean commit() throws LoginException { + if (succeeded == false) { + return false; + } else { + // add a Principal (authenticated identity) to the Subject + + // assume the user we authenticated is the UserPrincipal + userPrincipal = new UserPrincipal(userId); + if (!subject.getPrincipals().contains(userPrincipal)) + subject.getPrincipals().add(userPrincipal); + + // in any case, clean out state + userId = null; + password = null; + commitSucceeded = true; + return true; + } + } + + /** + *

This method is called if the LoginContext's + * overall authentication failed. + * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules + * did not succeed). + * + *

If this LoginModule's own authentication attempt + * succeeded (checked by retrieving the private state saved by the + * login and commit methods), + * then this method cleans up any state that was originally saved. + * + *

+ * + * @exception LoginException if the abort fails. + * + * @return false if this LoginModule's own login and/or commit attempts + * failed, and true otherwise. + */ + public boolean abort() throws LoginException { + if (succeeded == false) { + return false; + } else if (succeeded == true && commitSucceeded == false) { + // login succeeded but overall authentication failed + succeeded = false; + userId = null; + password = null; + userPrincipal = null; + } else { + // overall authentication succeeded and commit succeeded, + // but someone else's commit failed + logout(); + } + return true; + } + + /** + * Logout the user. + * + *

This method removes the SimplePrincipal + * that was added by the commit method. + * + *

+ * + * @exception LoginException if the logout fails. + * + * @return true in all cases since this LoginModule + * should not be ignored. + */ + public boolean logout() throws LoginException { + subject.getPrincipals().remove(userPrincipal); + succeeded = false; + succeeded = commitSucceeded; + userId = null; + if (password != null) + password = null; + userPrincipal = null; + return true; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/UserPrincipal.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/UserPrincipal.java new file mode 100644 index 0000000000..8349e775c5 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/UserPrincipal.java @@ -0,0 +1,66 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.security; + +import java.security.Principal; + +/** + * @version $Rev$ $Date$ + */ +public class UserPrincipal implements Principal { + + private final String name; + + public UserPrincipal(String name) { + if (name == null) + throw new IllegalArgumentException("name cannot be null"); + this.name = name; + } + + public String getName() { + return name; + } + + public String toString() { + return name; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final UserPrincipal other = (UserPrincipal)obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/AJass.config b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/AJass.config new file mode 100644 index 0000000000..9d5aec8ed5 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/AJass.config @@ -0,0 +1,3 @@ +AService { + org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.security.JaasLoginModule required debug=true; +}; diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/conversation.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/conversation.composite new file mode 100644 index 0000000000..49391b3353 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/conversation.composite @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/definitions.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/definitions.xml new file mode 100644 index 0000000000..d3573176a3 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/definitions.xml @@ -0,0 +1,34 @@ + + + + + + + + AService + org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.security.ACallbackHandler + + + + \ No newline at end of file diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/singleprincipal.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/singleprincipal.composite new file mode 100644 index 0000000000..c10369c9bd --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/main/resources/singleprincipal.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/ConversationAttributesTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/ConversationAttributesTestCase.java new file mode 100644 index 0000000000..952194430e --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/ConversationAttributesTestCase.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.vtest.javaapi.annotations.conversationattributes; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.oasisopen.sca.ConversationEndedException; + +/** + * This test class tests the Service annotation described in section 1.2.1 and + * 1.8.17 + */ +public class ConversationAttributesTestCase { + + protected static String compositeName = "conversation.composite"; + protected static AService aService = null; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + aService = ServiceFinder.getService(AService.class, "AComponent"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + + } + + /** + * Line 1665, 1666 + *

+ * maxIdleTime (optional) - The maximum time that can pass between + * operations within a single conversation. If more time than this passes, + * then the container may end the conversation. + */ + @Test(expected = ConversationEndedException.class) + public void maxIdle() throws Exception { + aService.testMaxIdle(); + } + + /** + * Line 1667, 1668 + *

+ * maxAge (optional) - The maximum time that the entire conversation can + * remain active. If more time than this passes, then the container may end + * the conversation. + */ + @Test(expected = ConversationEndedException.class) + public void maxAge() throws Exception { + aService.testMaxAge(); + } + + /** + * Line 1669, 1670 + *

+ * singlePrincipal (optional) – If true, only the principal (the user) that + * started the conversation has authority to continue the conversation. + * The default value is false. + */ + @Ignore("TUSCANY-2608") + @Test(expected = Exception.class) + public void singlePrincipal() throws Exception { + aService.testSinglePrincipal(); + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/SinglePricipalTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/SinglePricipalTestCase.java new file mode 100644 index 0000000000..4ebd667a00 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/conversationattributes/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/SinglePricipalTestCase.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.vtest.javaapi.annotations.conversationattributes; + +import javax.security.auth.login.Configuration; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * + */ +public class SinglePricipalTestCase { + + protected static String compositeName = "singleprincipal.composite"; + protected static AService aService = null; + + @Before + public void init() throws Exception { + try { + Configuration.getConfiguration(); + } catch (java.lang.SecurityException e) { + System.out.println("Caught SecurityException"); + System.setProperty("java.security.auth.login.config", this.getClass().getClassLoader() + .getResource("AJass.config").toString()); + } + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + aService = ServiceFinder.getService(AService.class, "AComponent"); + } + + @After + public void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + + } + + /** + * Line 1669, 1670 + *

+ * singlePrincipal (optional) – If true, only the principal (the user) that + * started the conversation has authority to continue the conversation. The + * default value is false. + */ + @Test(expected = Exception.class) + public void singlePrincipal() throws Exception { + aService.testSinglePrincipal(); + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/pom.xml new file mode 100644 index 0000000000..d0e306867f --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-destroy + + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @Destroy + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/AService.java new file mode 100644 index 0000000000..636e7fd8fc --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/AService.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.vtest.javaapi.annotations.destroy; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * The interface for AService + */ +@Remotable +public interface AService { + public String getGreetings(String name); +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr1Impl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr1Impl.java new file mode 100644 index 0000000000..e790c9e6d2 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr1Impl.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.vtest.javaapi.annotations.destroy.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.destroy.AService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. The implementation has an error since it annotates a protected + * method with "@Destroy". + */ +@Service(AService.class) +public class AServiceErr1Impl implements AService { + + @Destroy + protected void destroy() { + } + + public String getGreetings(String name) { + return "Hello " + name; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr2Impl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr2Impl.java new file mode 100644 index 0000000000..1d874007b2 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr2Impl.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.vtest.javaapi.annotations.destroy.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.destroy.AService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. The implementation has an error since it annotates a private + * method with "@Destroy". + */ +@Service(AService.class) +public class AServiceErr2Impl implements AService { + + @Destroy + private void destroy() { + } + + public String getGreetings(String name) { + return "Hello " + name; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr3Impl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr3Impl.java new file mode 100644 index 0000000000..bf4b0736ca --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr3Impl.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.vtest.javaapi.annotations.destroy.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.destroy.AService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. The implementation has an error since it annotates a + * method with non-void return type with "@Destroy". + */ +@Service(AService.class) +public class AServiceErr3Impl implements AService { + + @Destroy + public String destroy() { + return null; + } + + public String getGreetings(String name) { + return "Hello " + name; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr4Impl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr4Impl.java new file mode 100644 index 0000000000..a320e6b3ff --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceErr4Impl.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.vtest.javaapi.annotations.destroy.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.destroy.AService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. The implementation has an error since it annotates a + * method with arguments with "@Destroy". + */ +@Service(AService.class) +public class AServiceErr4Impl implements AService { + + @Destroy + public void destroy(int x) { + } + + public String getGreetings(String name) { + return "Hello " + name; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceImpl.java new file mode 100644 index 0000000000..4c77104866 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/impl/AServiceImpl.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.vtest.javaapi.annotations.destroy.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.destroy.AService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. + */ +@Service(AService.class) +public class AServiceImpl implements AService { + + @Destroy + public void destroy() { + } + + public String getGreetings(String name) { + return "Hello " + name; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err1/AServiceErr1.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err1/AServiceErr1.composite new file mode 100644 index 0000000000..b03a0defe5 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err1/AServiceErr1.composite @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err2/AServiceErr2.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err2/AServiceErr2.composite new file mode 100644 index 0000000000..93aafdd971 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err2/AServiceErr2.composite @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err3/AServiceErr3.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err3/AServiceErr3.composite new file mode 100644 index 0000000000..eb8f6e59ca --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err3/AServiceErr3.composite @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err4/AServiceErr4.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err4/AServiceErr4.composite new file mode 100644 index 0000000000..296a386876 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/err4/AServiceErr4.composite @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/proper/AService.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/proper/AService.composite new file mode 100644 index 0000000000..4373bc2558 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/main/resources/proper/AService.composite @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/DestroyAnnotationTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/DestroyAnnotationTestCase.java new file mode 100644 index 0000000000..72834a6803 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/destroy/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/destroy/DestroyAnnotationTestCase.java @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.destroy; + +import java.io.File; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.Test; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * This test class tests the "@Destroy" annotation described in section 1.8.8. + */ +public class DestroyAnnotationTestCase { + + /** + * Lines 1225, 1226, 1227
+ * The "@Destroy" annotation type is used to annotate a Java class method + * that will be called when the scope defined for the local service + * implemented by the class ends. The method must have a void return value + * and no arguments. The annotated method must be public. + *

+ * This method tests a proper destroy method. i.e., public, no arguments and + * with void return type. + */ + @Test + public void atDestroyProper() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/proper/AService.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/proper").toURL().toString())); + node.start(); + AService aService = ((SCAClient)node).getService(AService.class, "AComponent"); + Assert.assertEquals("Hello Pandu", aService.getGreetings("Pandu")); + node.stop(); + } + + /** + * Lines 1225, 1226, 1227
+ * The "@Destroy" annotation type is used to annotate a Java class method + * that will be called when the scope defined for the local service + * implemented by the class ends. The method must have a void return value + * and no arguments. The annotated method must be public. + *

+ * This method tests that an exception is thrown when a protected method is + * annotated with "@Destroy". + */ + @Test + public void atDestroyProtectedMethod() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + try { + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err1/AServiceErr1.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/err1").toURL().toString())); + Assert.fail(); + node.stop(); + } catch(ServiceRuntimeException e) { + //expected + Assert.assertNotSame(-1, e.getMessage().indexOf("Destructor must be a public method.")); + } + } + + /** + * Lines 1225, 1226, 1227
+ * The "@Destroy" annotation type is used to annotate a Java class method + * that will be called when the scope defined for the local service + * implemented by the class ends. The method must have a void return value + * and no arguments. The annotated method must be public. + *

+ * This method tests that an exception is thrown when a private method is + * annotated with "@Destroy". + */ + @Test + public void atDestroyPrivateMethod() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + try { + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err2/AServiceErr2.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/err2").toURL().toString())); + Assert.fail(); + node.stop(); + } catch(ServiceRuntimeException e) { + //expected + Assert.assertNotSame(-1, e.getMessage().indexOf("Destructor must be a public method.")); + } + } + + /** + * Lines 1225, 1226, 1227
+ * The "@Destroy" annotation type is used to annotate a Java class method + * that will be called when the scope defined for the local service + * implemented by the class ends. The method must have a void return value + * and no arguments. The annotated method must be public. + *

+ * This method tests that an exception is thrown when a method with non-void + * return type is annotated with "@Destroy". + */ + @Test + public void atDestroyNonVoidReturnType() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + try { + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err3/AServiceErr3.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/err3").toURL().toString())); + Assert.fail(); + node.stop(); + } catch(ServiceRuntimeException e) { + //expected + Assert.assertNotSame(-1, e.getMessage().indexOf("Destructor must return void.")); + } + } + + /** + * Lines 1225, 1226, 1227
+ * The "@Destroy" annotation type is used to annotate a Java class method + * that will be called when the scope defined for the local service + * implemented by the class ends. The method must have a void return value + * and no arguments. The annotated method must be public. + *

+ * This method tests that an exception is thrown when a method with arguments is + * annotated with "@Destroy". + */ + @Test + public void atDestroyMethodWithArgs() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + try { + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err4/AServiceErr4.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/err4").toURL().toString())); + Assert.fail(); + node.stop(); + } catch(ServiceRuntimeException e) { + //expected + Assert.assertNotSame(-1, e.getMessage().indexOf("Destructor must not have argments")); + } + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/pom.xml new file mode 100644 index 0000000000..9c763a1111 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-endsconversation + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @EndsConversation + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/AService.java new file mode 100644 index 0000000000..13bcb1fd51 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/AService.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.endsconversation; + +/** + * Simple Remotable Service + */ +public interface AService { + + public void testAtEndsConversation(); + + public void testSREndConversation(); + + public void testTimedEnd(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/BService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/BService.java new file mode 100644 index 0000000000..01d3ef051e --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/BService.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.vtest.javaapi.annotations.endsconversation; + +import org.oasisopen.sca.annotation.Conversational; +import org.oasisopen.sca.annotation.EndsConversation; + +/** + * Simple Local Service + */ +@Conversational +public interface BService { + + public void setState(String someState); + + public String getConversationId(); + + @EndsConversation + public void endConversation(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/impl/AServiceImpl.java new file mode 100644 index 0000000000..606020cf85 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/impl/AServiceImpl.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.vtest.javaapi.annotations.endsconversation.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.endsconversation.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.endsconversation.BService; +import org.oasisopen.sca.ServiceReference; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.junit.Assert; + +@Service(AService.class) +public class AServiceImpl implements AService { + + @Reference + protected BService b; + + @Reference + protected ServiceReference b2; + + private void delayForSeconds(int numSeconds) { + try { + Thread.sleep(numSeconds * 1000);// millisecs + } catch (InterruptedException ex) { + throw new Error(ex); + } + } + + public void testAtEndsConversation() { + String firstId; + b.setState("SomeState"); + firstId = b.getConversationId(); + b.endConversation(); + b.setState("SomeState");// This should start a new conversation + Assert.assertNotSame(b.getConversationId(), firstId); + } + + public void testSREndConversation() { + String firstId; + b2.getService().setState("SomeState"); + firstId = b2.getService().getConversationId(); + b2.getConversation().end(); + b2.getService().setState("SomeState");// This should start a new conversation + Assert.assertNotSame(b2.getService().getConversationId(), firstId); + } + + public void testTimedEnd() { + b.setState("someState"); + delayForSeconds(2); + b.setState("someState"); // should fail w/ timeout + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/impl/BServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/impl/BServiceImpl.java new file mode 100644 index 0000000000..56644c6967 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/impl/BServiceImpl.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.endsconversation.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.endsconversation.BService; +import org.oasisopen.sca.annotation.ConversationAttributes; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(BService.class) +@Scope("CONVERSATION") +@ConversationAttributes(maxIdleTime="1 seconds") +public class BServiceImpl implements BService { + + String someState; + + protected String conversationId; + + public void setState(String someState) { + this.someState = someState; + } + + @ConversationID + public void setConversationID (String id){ + this.conversationId = id; + System.out.println("BService conversation ID =>" + conversationId); + } + + public String getState() { + return someState; + } + + public String getConversationId() { + return conversationId; + } + + public void endConversation() { + System.out.println("Conversation ended"); + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/resources/endsconversation.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/resources/endsconversation.composite new file mode 100644 index 0000000000..cbc13e380c --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/main/resources/endsconversation.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/EndsConversationTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/EndsConversationTestCase.java new file mode 100644 index 0000000000..61d7e25187 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/endsconversation/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/endsconversation/EndsConversationTestCase.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.vtest.javaapi.annotations.endsconversation; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.oasisopen.sca.ConversationEndedException; + +/** + * This test class tests the Service annotation described in section 1.2.1 and + * 1.8.17 + */ +public class EndsConversationTestCase { + + protected static String compositeName = "endsconversation.composite"; + protected static AService aService = null; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + aService = ServiceFinder.getService(AService.class, "AComponent"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Lines 410,411,412,413: + *

+ * A method of a conversational interface may be marked with an + * "@EndsConversation" annotation. Once a method marked with + * "@EndsConversation" has been called, the conversation between client and + * service provider is at an end, which implies no further methods may be + * called on that service within the *same* conversation. + */ + @Test + public void atEndsConversation1() throws Exception { + aService.testAtEndsConversation(); + } + + /** + * Lines 417,418,419,420: + *

+ * From the errata:
+ * Solution: Replace lines 417-420 at the end of section 1.6.2.2 with the + * following: "If a conversation is ended with an explicit outbound call to + * an "@EndsConversation" method or a call to + * ServiceReference.endConversation(), then any subsequent call to an + * operation on the service reference will start a new conversation. If the + * conversation ends for any other reason (e.g. a timeout occurred), then + * until ServiceReference.getConversation().end() is called, the + * ConversationEndedException will be thrown by any conversational + * operation." + *

+ * This tests the first section of the errata. Up to "start a new + * conversation" + */ + @Test + public void atEndsConversation2() throws Exception { + aService.testSREndConversation(); + } + + /** + * Lines 417,418,419,420: + *

+ * From the errata:
+ * Solution: Replace lines 417-420 at the end of section 1.6.2.2 with the + * following: "If a conversation is ended with an explicit outbound call to + * an "@EndsConversation" method or a call to + * ServiceReference.endConversation(), then any subsequent call to an + * operation on the service reference will start a new conversation. If the + * conversation ends for any other reason (e.g. a timeout occurred), then + * until ServiceReference.getConversation().end() is called, the + * ConversationEndedException will be thrown by any conversational + * operation." + *

+ * This tests the second section of the errata. Starting with .. "If the + * conversation ends for any other reason ..." + */ + @Test(expected = ConversationEndedException.class) + public void atEndsConversation3() throws Exception { + aService.testTimedEnd(); + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/pom.xml new file mode 100644 index 0000000000..9700b6870c --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-init + + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @Init + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/AService.java new file mode 100644 index 0000000000..9f6b9bcffd --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/AService.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.vtest.javaapi.annotations.init; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * The interface for AService + */ +@Remotable +public interface AService { + public String getGreetings(String name); + public boolean isInitProper(); +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr1Impl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr1Impl.java new file mode 100644 index 0000000000..c48b2e2070 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr1Impl.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.vtest.javaapi.annotations.init.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.init.AService; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. The implementation has an error since it annotates a protected + * method with "@Init". + */ +@Service(AService.class) +public class AServiceErr1Impl implements AService { + + @Init + protected void init() { + } + + public String getGreetings(String name) { + return "Hello " + name; + } + + public boolean isInitProper() { + return false; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr2Impl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr2Impl.java new file mode 100644 index 0000000000..532b1d16eb --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr2Impl.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.vtest.javaapi.annotations.init.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.init.AService; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. The implementation has an error since it annotates a private + * method with "@Init". + */ +@Service(AService.class) +public class AServiceErr2Impl implements AService { + + @Init + private void init() { + } + + public String getGreetings(String name) { + return "Hello " + name; + } + + public boolean isInitProper() { + return false; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr3Impl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr3Impl.java new file mode 100644 index 0000000000..b69a2541b0 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr3Impl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.init.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.init.AService; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. The implementation has an error since it annotates a + * method with non-void return type with "@Init". + */ +@Service(AService.class) +public class AServiceErr3Impl implements AService { + + @Init + public String init() { + return null; + } + + public String getGreetings(String name) { + return "Hello " + name; + } + + public boolean isInitProper() { + return false; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr4Impl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr4Impl.java new file mode 100644 index 0000000000..76f905cff0 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceErr4Impl.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.vtest.javaapi.annotations.init.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.init.AService; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. The implementation has an error since it annotates a + * method with arguments with "@Init". + */ +@Service(AService.class) +public class AServiceErr4Impl implements AService { + + @Init + public void init(int x) { + } + + public String getGreetings(String name) { + return "Hello " + name; + } + + public boolean isInitProper() { + return false; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceImpl.java new file mode 100644 index 0000000000..14c0e9c2da --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/impl/AServiceImpl.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.init.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.init.AService; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +/** + * This class implements AService. + */ +@Service(AService.class) +public class AServiceImpl implements AService { + + private boolean initProper; + + @Property + public String someProperty; + + @Reference + public AService someReference; + + @Init + public void init() { + initProper = someProperty != null && someReference != null; + } + + public String getGreetings(String name) { + return "Hello " + name; + } + + public boolean isInitProper() { + return initProper; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err1/AServiceErr1.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err1/AServiceErr1.composite new file mode 100644 index 0000000000..01b8e101e0 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err1/AServiceErr1.composite @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err2/AServiceErr2.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err2/AServiceErr2.composite new file mode 100644 index 0000000000..4ae38d44b6 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err2/AServiceErr2.composite @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err3/AServiceErr3.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err3/AServiceErr3.composite new file mode 100644 index 0000000000..6bc3d8e7fc --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err3/AServiceErr3.composite @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err4/AServiceErr4.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err4/AServiceErr4.composite new file mode 100644 index 0000000000..7ade16e6d3 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/err4/AServiceErr4.composite @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/proper/AService.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/proper/AService.composite new file mode 100644 index 0000000000..35f13a2ae6 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/main/resources/proper/AService.composite @@ -0,0 +1,33 @@ + + + + + + + hello + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/InitAnnotationTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/InitAnnotationTestCase.java new file mode 100644 index 0000000000..6ee7b8de89 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/init/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/init/InitAnnotationTestCase.java @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.init; + +import java.io.File; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.Test; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * This test class tests the "@Init" annotation described in section 1.8.11. + */ +public class InitAnnotationTestCase { + + /** + * Lines 1290, 1291, 1292, 1293
+ * The "@Init" annotation type is used to annotate a Java class method that + * is called when the scope defined for the local service implemented by the + * class starts. The method must have a void return value and no arguments. + * The annotated method must be public. The annotated method is called after + * all property and reference injection is complete. + *

+ * This method tests a proper init method i.e., public, no arguments and with + * void return type.
+ * Expected result: Method must be called. Method must be called after all property + * and reference injection is complete. + */ + @Test + public void atInitProper() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/proper/AService.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/proper").toURL().toString())); + node.start(); + AService aService = ((SCAClient)node).getService(AService.class, "AComponent"); + Assert.assertTrue(aService.isInitProper()); + Assert.assertEquals("Hello Pandu", aService.getGreetings("Pandu")); + node.stop(); + } + + /** + * Lines 1290, 1291, 1292, 1293
+ * The "@Init" annotation type is used to annotate a Java class method that + * is called when the scope defined for the local service implemented by the + * class starts. The method must have a void return value and no arguments. + * The annotated method must be public. The annotated method is called after + * all property and reference injection is complete. + *

+ * This method tests that an exception is thrown when a protected method is + * annotated with "@Init". + */ + @Test + public void atInitProtectedMethod() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + try { + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err1/AServiceErr1.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/err1").toURL().toString())); + Assert.fail(); + node.stop(); + } catch(ServiceRuntimeException e) { + //expected + Assert.assertNotSame(-1, e.getMessage().indexOf("Initializer must be a public method.")); + } + } + + /** + * Lines 1290, 1291, 1292, 1293
+ * The "@Init" annotation type is used to annotate a Java class method that + * is called when the scope defined for the local service implemented by the + * class starts. The method must have a void return value and no arguments. + * The annotated method must be public. The annotated method is called after + * all property and reference injection is complete. + *

+ * This method tests that an exception is thrown when a private method is + * annotated with "@Init". + */ + @Test + public void atInitPrivateMethod() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + try { + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err2/AServiceErr2.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/err2").toURL().toString())); + Assert.fail(); + node.stop(); + } catch(ServiceRuntimeException e) { + //expected + Assert.assertNotSame(-1, e.getMessage().indexOf("Initializer must be a public method.")); + } + } + + /** + * Lines 1290, 1291, 1292, 1293
+ * The "@Init" annotation type is used to annotate a Java class method that + * is called when the scope defined for the local service implemented by the + * class starts. The method must have a void return value and no arguments. + * The annotated method must be public. The annotated method is called after + * all property and reference injection is complete. + *

+ * This method tests that an exception is thrown when a method with non-void + * return type is annotated with "@Init". + */ + @Test + public void atInitNonVoidReturnType() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + try { + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err3/HelloWorldErr3.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/err3").toURL().toString())); + Assert.fail(); + node.stop(); + } catch(ServiceRuntimeException e) { + //expected + Assert.assertNotSame(-1, e.getMessage().indexOf("Initializer must return void.")); + } + } + + /** + * Lines 1290, 1291, 1292, 1293
+ * The "@Init" annotation type is used to annotate a Java class method that + * is called when the scope defined for the local service implemented by the + * class starts. The method must have a void return value and no arguments. + * The annotated method must be public. The annotated method is called after + * all property and reference injection is complete. + *

+ * This method tests that an exception is thrown when a method with arguments is + * annotated with "@Init". + */ + @Test + public void atInitMethodWithArgs() throws Exception { + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + try { + SCANode node = nodeFactory.createSCANode(new File("src/main/resources/err4/HelloWorldErr4.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/err4").toURL().toString())); + Assert.fail(); + node.stop(); + } catch(ServiceRuntimeException e) { + //expected + Assert.assertNotSame(-1, e.getMessage().indexOf("Initializer must not have argments")); + } + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/pom.xml new file mode 100644 index 0000000000..99f1420712 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-oneway + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @OneWay + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/AService.java new file mode 100644 index 0000000000..b68cd53167 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/AService.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.vtest.javaapi.annotations.oneway; + +import org.oasisopen.sca.annotation.OneWay; + +/** + * Simple Remotable Service + */ +public interface AService { + + @OneWay + public void setNameOneWay(String name); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/BService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/BService.java new file mode 100644 index 0000000000..1cb4f3adf5 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/BService.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.vtest.javaapi.annotations.oneway; + +/** + * Simple Local Service + */ +public interface BService { + + public void setNameOneWay(String name); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/impl/AServiceImpl.java new file mode 100644 index 0000000000..d95ea22456 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/impl/AServiceImpl.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.vtest.javaapi.annotations.oneway.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.oneway.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.oneway.BService; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(AService.class) +public class AServiceImpl implements AService { + + @Reference + protected BService b; + + public void setNameOneWay(String name) { + b.setNameOneWay(name); + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/impl/BServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/impl/BServiceImpl.java new file mode 100644 index 0000000000..4f63a23429 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/impl/BServiceImpl.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.vtest.javaapi.annotations.oneway.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.oneway.BService; +import org.oasisopen.sca.annotation.Service; + +@Service(BService.class) +public class BServiceImpl implements BService { + + String name; + + private void delay2Seconds() { + try { + Thread.sleep(2000);// millisecs + } catch (InterruptedException ex) { + throw new Error(ex); + } + } + + public void setNameOneWay(String name) { + delay2Seconds(); + this.name = name; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/resources/oneway.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/resources/oneway.composite new file mode 100644 index 0000000000..47a7a98c7d --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/main/resources/oneway.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/OneWayAnnotationTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/OneWayAnnotationTestCase.java new file mode 100644 index 0000000000..f2fb8d0dc8 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/oneway/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/oneway/OneWayAnnotationTestCase.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.vtest.javaapi.annotations.oneway; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This test class tests the Service annotation described in section 1.2.1 and + * 1.8.17 + */ +public class OneWayAnnotationTestCase { + + protected static String compositeName = "oneway.composite"; + protected static AService aService = null; + protected static BService bService = null; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + aService = ServiceFinder.getService(AService.class, "AComponent"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Line 384,385,386:
+ *

+ * Any method that returns "void" and has no declared exceptions may be + * marked with an "@OneWay" annotation. This means that the method is + * non-blocking and communication with the service provider may use a + * binding that buffers the requests and sends it at some later time. + *

+ * Line 1319, 1320:
+ *

+ * The "@OneWay" annotation type is used to annotate a Java interface method + * to indicate that invocations will be dispatched in a non-blocking fashion + * as described in the section on Asynchronous Programming.
+ *

+ * The serviceMethod on A is annotated with "@OneWay". The A implementation + * delegates to b's method which includes a 2 seconds delay. So, this will + * fail if the call to A is blocking. + */ + @Test(timeout = 500) + public void atOneWay1() throws Exception { + aService.setNameOneWay("Some Name"); + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/pom.xml new file mode 100644 index 0000000000..402ea03f7a --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/pom.xml @@ -0,0 +1,69 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + vtest-java-api + 2.0-SNAPSHOT + ../pom.xml + + java-api-annotations + pom + + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + + + + default + + true + + + reference + service + property + scope + init + destroy + oneway + conversational + conversationattributes + endsconversation + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/pom.xml new file mode 100644 index 0000000000..0c36e98879 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-property + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @Property + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java new file mode 100644 index 0000000000..5cfea1b099 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.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.vtest.javaapi.annotations.property; + +/** + * Simple Service + */ +public interface AService { + + public String getName(); + + public String getP1(); + + public String getP2(); + + public String getP3(); + + public String getP4(); + + public String getP5(); + + public String getP6(); + + public String getP7AString(); + + public int getP7BInt(); + + public String getP8AString(); + + public int getP8BInt(); + + public String getP9AString(); + + public int getP9BInt(); + + public String getP10AString(); + + public int getP10BInt(); + + public String getP11AString(); + + public int getP11BInt(); + + public String getP12AString(); + + public int getP12BInt(); + + public String getP15(); + + public String getP16(); + + public String getP17(); + + public String getP18(); + + public int getP19Size(); + + public String getP20(int i); + + public int getP20Size(); + + public int getP21(int i); + + public int getP21Size(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java new file mode 100644 index 0000000000..5ddc59f8b6 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.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.vtest.javaapi.annotations.property; + +/** + * Simple Service + */ +public interface AnotherAService { + + public String getName(); + + public String getP13(); + + public String getP14(); + + public String getP22(); + + public String getP23(); + + public String getP24(); + + public String getP25(); + + public boolean getP14SetterIsCalled(); + + public boolean getP23SetterIsCalled(); + + public boolean getP24SetterIsCalled(); + + public boolean getP25SetterIsCalled(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/BService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/BService.java new file mode 100644 index 0000000000..c39d4e2504 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/BService.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.property; + +import org.oasisopen.sca.annotation.Remotable; + + +/** + * Simple Service used by another service + */ +@Remotable +public interface BService { + + String getName(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/CService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/CService.java new file mode 100644 index 0000000000..5de3b5fcff --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/CService.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.vtest.javaapi.annotations.property; + + +/** + * Simple Service used by another service + */ +public interface CService { + + String getName(); + + public String getB1Name(); + + public String getP2(); + + public int getP3(); + + public String getP4(); + + public String getConstructor(); +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AObject.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AObject.java new file mode 100644 index 0000000000..f30c4c69fc --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AObject.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +/** + * A simple object to hold a string + */ +public class AObject { + + public String aString; + public int bInt; + + public AObject() { + this.aString = null; + this.bInt = 0; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java new file mode 100644 index 0000000000..6dd91b598d --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java @@ -0,0 +1,240 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +import java.util.List; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.AService; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Property; + +@Service(AService.class) +public class AServiceImpl implements AService { + + @Property + protected String p1; // simple Java type injected via field + + @Property + public String p2; // simple Java type injected via field + + protected String p3; // simple Java type injected via setter + + public String p4; // simple Java type injected via setter + + protected String p5; // simple Java type injected via constructor parameter + + public String p6; // simple Java type injected via constructor parameter + + @Property(required=true) + protected AObject p7; // complex Java type injected via field + + @Property + public AObject p8; // complex Java type injected via field + + protected AObject p9; // complex Java type injected via setter + + public AObject p10; // complex Java type injected via setter + + protected AObject p11; // complex Java type injected via constructor parameter + + public AObject p12; // complex Java type injected via constructor parameter + + @Property(name="pFifteen") + protected String p15; // injected via field with different name + + protected String p16; // injected via setter with different name + + @Property(name="p17", required=false) + public String p17; // injected via field but not defined in composite + + public String p18; // injected via setter but not defined in composite + + @Property(name="p19", required=true) + public List p19; // a List and injected via field with no element + + public List p20; // a List and injected via setter + + @Property(required=false) + public Integer[] p21; // an array and injected via field + + public String getName() { + return "AService"; + } + + public AServiceImpl( + @Property(name = "p5") String p5, + @Property(name = "p6") String p6, + @Property(name = "p11") AObject p11, + @Property(name = "p12") AObject p12 + ) { + super(); + this.p5 = p5; + this.p6 = p6; + this.p11 = p11; + this.p12 = p12; + } + + @Property + public void setP3(String p3) { + this.p3 = p3; + } + + @Property(required=true) + public void setP4(String p4) { + this.p4 = p4; + } + + @Property + public void setP9(AObject p9) { + this.p9 = p9; + } + + @Property + public void setP10(AObject p10) { + this.p10 = p10; + } + + @Property(name="pSixteen") + public void setP16(String p16) { + this.p16 = p16; + } + + @Property(name="p18", required=false) + public void setP18(String p18) { + this.p18 = p18; + } + + @Property(name="p20", required=true) + public void setP20(List p20) { + this.p20 = p20; + } + + public String getP1() { + return p1; + } + + public String getP2() { + return p2; + } + + public String getP3() { + return p3; + } + + public String getP4() { + return p4; + } + + public String getP5() { + return p5; + } + + public String getP6() { + return p6; + } + + public String getP7AString() { + return p7.aString; + } + + public int getP7BInt() { + return p7.bInt; + } + + public String getP8AString() { + return p8.aString; + } + + public int getP8BInt() { + return p8.bInt; + } + + public String getP9AString() { + return p9.aString; + } + + public int getP9BInt() { + return p9.bInt; + } + + public String getP10AString() { + return p10.aString; + } + + public int getP10BInt() { + return p10.bInt; + } + + public String getP11AString() { + return p11.aString; + } + + public int getP11BInt() { + return p11.bInt; + } + + public String getP12AString() { + return p12.aString; + } + + public int getP12BInt() { + return p12.bInt; + } + + public String getP15() { + return p15; + } + + public String getP16() { + return p16; + } + + public String getP17() { + return p17; + } + + public String getP18() { + return p18; + } + + public int getP19Size() { + return p19.size(); + } + + public String getP20(int i) { + return p20.get(i); + } + + public int getP20Size() { + return p20.size(); + } + + public int getP21(int i) { + return p21[i].intValue(); + } + + public int getP21Size() { + return p21.length; + } + +} + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java new file mode 100644 index 0000000000..b6d51ef253 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.AnotherAService; +import org.oasisopen.sca.annotation.Service; + +@Service(AnotherAService.class) +public class AnotherAServiceImpl implements AnotherAService { + + public String p13; // injected via field and un-annotated + + public String p14; // injected via setter and un-annotated + + protected String p22; // unannotated protected field should not be injected + + protected String p23; // un-annotated protected and has protected setter + + protected String p24; // un-annotated protected field and has public setter + + private String p25; // un-annotated private field and has public setter + + public boolean p14SetterIsCalled = false; + + public boolean p23SetterIsCalled = false; + + public boolean p24SetterIsCalled = false; + + public boolean p25SetterIsCalled = false; + + + public String getName() { + return "AService"; + } + + public void setP14(String p14) { + p14SetterIsCalled = true; + this.p14 = p14; + } + + protected void setP23(String p23) { + p23SetterIsCalled = true; + this.p23 = p23; + } + + public void setP24(String p24) { + p24SetterIsCalled = true; + this.p24 = p24; + } + + public void setP25(String p25) { + p25SetterIsCalled = true; + this.p25 = p25; + } + + public String getP13() { + return p13; + } + + public String getP14() { + return p14; + } + + public String getP22() { + return p22; + } + + public String getP23() { + return p23; + } + + public String getP24() { + return p24; + } + + public String getP25() { + return p25; + } + + public boolean getP14SetterIsCalled() { + return p14SetterIsCalled; + } + + + public boolean getP23SetterIsCalled() { + return p23SetterIsCalled; + } + + + public boolean getP24SetterIsCalled() { + return p24SetterIsCalled; + } + + + public boolean getP25SetterIsCalled() { + return p25SetterIsCalled; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/BServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/BServiceImpl.java new file mode 100644 index 0000000000..d6a36f54a9 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/BServiceImpl.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.BService; +import org.oasisopen.sca.annotation.Service; + +@Service(BService.class) +public class BServiceImpl implements BService { + + public String getName() { + return "BService"; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl1.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl1.java new file mode 100644 index 0000000000..ace9da2904 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl1.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.CService; +import org.oasisopen.sca.annotation.Constructor; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(CService.class) +public class CServiceImpl1 implements CService { + + public BService b1; + + public String p2; + + public int p3; + + public String p4; + + public String constructor; + + @Constructor + public CServiceImpl1() { + constructor = "NoArgument"; + } + + public CServiceImpl1(@Reference(name = "bOne") BService b1, @Property(name = "pTwo") String p2, @Property(name = "pThree") int p3, @Property(name = "pFour") String p4) { + this.b1 = b1; + this.p2 = p2; + this.p3 = p3; + this.p4 = p4; + constructor = "AllArguments"; + } + + public CServiceImpl1(BService bOne, String pTwo, int pThree) { + this.b1 = bOne; + this.p2 = pTwo; + this.p3 = pThree; + constructor = "LessArguments"; + } + + public String getName() { + return "BService"; + } + + public String getB1Name() { + if (b1 == null) + return null; + return b1.getName(); + } + + public String getP2() { + return p2; + } + + public int getP3() { + return p3; + } + + public String getConstructor() { + return constructor; + } + + public String getP4() { + return p4; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl2.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl2.java new file mode 100644 index 0000000000..4396b6ce32 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl2.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.CService; +import org.oasisopen.sca.annotation.Constructor; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(CService.class) +public class CServiceImpl2 implements CService { + + public BService b1; + + public String p2; + + public int p3; + + public String p4; + + public String constructor; + + public CServiceImpl2() { + constructor = "NoArgument"; + } + + @Constructor() + public CServiceImpl2(@Reference(name = "bOne") BService b1, @Property(name = "pTwo") String p2, @Property(name = "pThree") int p3, @Property(name = "pFour") String p4) { + this.b1 = b1; + this.p2 = p2; + this.p3 = p3; + this.p4 = p4; + constructor = "AllArguments"; + } + + public CServiceImpl2(BService bOne, String pTwo, int pThree) { + this.b1 = bOne; + this.p2 = pTwo; + this.p3 = pThree; + constructor = "LessArguments"; + } + + public String getName() { + return "BService"; + } + + public String getB1Name() { + if (b1 == null) + return null; + return b1.getName(); + } + + public String getP2() { + return p2; + } + + public int getP3() { + return p3; + } + + public String getConstructor() { + return constructor; + } + + public String getP4() { + return p4; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl3.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl3.java new file mode 100644 index 0000000000..cd459f2dd1 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl3.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.CService; +import org.oasisopen.sca.annotation.Constructor; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(CService.class) +public class CServiceImpl3 implements CService { + + public BService b1; + + public String p2; + + public int p3; + + public String p4; + + public String constructor; + + public CServiceImpl3() { + constructor = "NoArgument"; + } + + @Constructor({"bOne", "pTwo", "pThree", "pFour"}) + public CServiceImpl3(@Reference(name = "bOne") BService b1, @Property(name = "pTwo") String p2, @Property(name = "pThree") int p3, @Property(name = "pFour") String p4) { + this.b1 = b1; + this.p2 = p2; + this.p3 = p3; + this.p4 = p4; + constructor = "AllArguments"; + } + + public CServiceImpl3(BService bOne, String pTwo, int pThree) { + this.b1 = bOne; + this.p2 = pTwo; + this.p3 = pThree; + constructor = "LessArguments"; + } + + public String getName() { + return "BService"; + } + + public String getB1Name() { + if (b1 == null) + return null; + return b1.getName(); + } + + public String getP2() { + return p2; + } + + public int getP3() { + return p3; + } + + public String getConstructor() { + return constructor; + } + + public String getP4() { + return p4; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl4.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl4.java new file mode 100644 index 0000000000..c22ee08f95 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl4.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.CService; +import org.oasisopen.sca.annotation.Constructor; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(CService.class) +public class CServiceImpl4 implements CService { + + public BService b1; + + public String p2; + + public int p3; + + public String p4; + + public String constructor; + + public CServiceImpl4() { + constructor = "NoArgument"; + } + + public CServiceImpl4(@Reference(name = "bOne") BService b1, @Property(name = "pTwo") String p2, @Property(name = "pThree") int p3, @Property(name = "pFour") String p4, int extra) { + this.b1 = b1; + this.p2 = p2; + this.p3 = p3; + this.p4 = p4; + constructor = "ExtraArguments"; + } + + @Constructor({"bOne", "pTwo", "pThree", "pFour"}) + public CServiceImpl4(BService bOne, String pTwo, int pThree, String pFour) { + this.b1 = bOne; + this.p2 = pTwo; + this.p3 = pThree; + this.p4 = pFour; + constructor = "AllArguments"; + } + + public String getName() { + return "BService"; + } + + public String getB1Name() { + if (b1 == null) + return null; + return b1.getName(); + } + + public String getP2() { + return p2; + } + + public int getP3() { + return p3; + } + + public String getConstructor() { + return constructor; + } + + public String getP4() { + return p4; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl5.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl5.java new file mode 100644 index 0000000000..02892ca7f3 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl5.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.CService; +import org.oasisopen.sca.annotation.Constructor; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(CService.class) +public class CServiceImpl5 implements CService { + + public BService b1; + + public String p2; + + public int p3; + + public String p4; + + public String constructor; + + public CServiceImpl5() { + constructor = "NoArgument"; + } + + public CServiceImpl5(@Reference(name = "bOne") BService b1, @Property(name = "pTwo") String p2, @Property(name = "pThree") int p3, @Property(name = "pFour") String p4, int extra) { + this.b1 = b1; + this.p2 = p2; + this.p3 = p3; + this.p4 = p4; + constructor = "ExtraArguments"; + } + + @Constructor({"bOne", "pFour", "pThree", "pTwo"}) + public CServiceImpl5(BService bOne, String pTwo, int pThree, String pFour) { + this.b1 = bOne; + this.p2 = pTwo; + this.p3 = pThree; + this.p4 = pFour; + constructor = "SwitchedValues"; + } + + public String getName() { + return "BService"; + } + + public String getB1Name() { + if (b1 == null) + return null; + return b1.getName(); + } + + public String getP2() { + return p2; + } + + public int getP3() { + return p3; + } + + public String getConstructor() { + return constructor; + } + + public String getP4() { + return p4; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl6.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl6.java new file mode 100644 index 0000000000..ed2c3dc365 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/CServiceImpl6.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.property.CService; +import org.oasisopen.sca.annotation.Constructor; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(CService.class) +public class CServiceImpl6 implements CService { + + public BService b1; + + public String p2; + + public int p3; + + public String p4; + + public String constructor; + + public CServiceImpl6() { + constructor = "NoArgument"; + } + + public CServiceImpl6(@Reference(name = "bOne") BService b1, @Property(name = "pTwo") String p2, @Property(name = "pThree") int p3, @Property(name = "pFour") String p4, int extra) { + this.b1 = b1; + this.p2 = p2; + this.p3 = p3; + this.p4 = p4; + constructor = "ExtraArguments"; + } + + @Constructor({"bOne", "pTwo", "pThree", "pWrong"}) + public CServiceImpl6(BService bOne, String pTwo, int pThree, String pFour) { + this.b1 = bOne; + this.p2 = pTwo; + this.p3 = pThree; + this.p4 = pFour; + constructor = "WrongValues"; + } + + public String getName() { + return "BService"; + } + + public String getB1Name() { + if (b1 == null) + return null; + return b1.getName(); + } + + public String getP2() { + return p2; + } + + public int getP3() { + return p3; + } + + public String getConstructor() { + return constructor; + } + + public String getP4() { + return p4; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/resources/property.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/resources/property.composite new file mode 100644 index 0000000000..f7af170f33 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/main/resources/property.composite @@ -0,0 +1,143 @@ + + + + + + + p1 + p2 + p3 + p4 + p5 + p6 + + + p7.aString + 7 + + + + + p8.aString + 8 + + + + + p9.aString + 9 + + + + + p10.aString + 10 + + + + + p11.aString + 11 + + + + + p12.aString + 12 + + + p15 + p16 + + "p20" + 2 1 21 + + + + + + p2 + 3 + p4 + + + + + + p2 + 3 + p4 + + + + + + p2 + 3 + p4 + + + + + + p2 + 3 + p4 + + + + + + p2 + 3 + p4 + + + + + + p2 + 3 + p4 + + + + + + + + + p13 + p14 + p22 + p23 + p24 + p25 + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java new file mode 100644 index 0000000000..d5fbc568f7 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java @@ -0,0 +1,299 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.property; + +import static org.junit.Assert.fail; +import junit.framework.Assert; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * This test class tests the Property annotation described in section 1.2.3 + * including 1.8.5 and 1.8.13 + */ +public class PropertyAnnotationTestCase { + + protected static String compositeName = "property.composite"; + protected static AService aService = null; + protected static CService cService1 = null; + protected static CService cService2 = null; + protected static CService cService3 = null; + protected static CService cService4 = null; + protected static CService cService5 = null; + protected static CService cService6 = null; + protected static AnotherAService anotherAService = null; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + aService = ServiceFinder.getService(AService.class, "AComponent"); + cService1 = ServiceFinder.getService(CService.class, "CComponent1"); + cService2 = ServiceFinder.getService(CService.class, "CComponent2"); + cService3 = ServiceFinder.getService(CService.class, "CComponent3"); + cService4 = ServiceFinder.getService(CService.class, "CComponent4"); + cService5 = ServiceFinder.getService(CService.class, "CComponent5"); + cService6 = ServiceFinder.getService(CService.class, "CComponent6"); + anotherAService = ServiceFinder.getService(AnotherAService.class, "AnotherAComponent"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + + } + + /** + * Lines 1343 to 1348:
+ * The "@Property" annotation type is used to annotate a Java class field or + * a setter method that is used to inject an SCA property value. The type of + * the property injected, which can be a simple Java type or a complex Java + * type, is defined by the type of the Java class field or the type of the + * setter method input argument.
+ * The "@Property" annotation may be used on protected or public fields and + * on setter methods or on a constructor method.
+ *

+ * p1 - simple Java type injected via field
+ * p2 - simple Java type injected via field
+ * p3 - simple Java type injected via setter
+ * p4 - simple Java type injected via setter and required=true
+ * p5 - simple Java type injected via constructor parameter
+ * p6 - simple Java type injected via constructor parameter
+ * p7 - complex Java type injected via field and required=true
+ * p8 - complex Java type injected via field
+ * p9 - complex Java type injected via setter
+ * p10 - complex Java type injected via setter
+ * p11 - complex Java type injected via constructor parameter
+ * p12 - complex Java type injected via constructor parameter
+ */ + @Test + public void atProperty1() throws Exception { + Assert.assertEquals("p1", aService.getP1()); + Assert.assertEquals("p2", aService.getP2()); + Assert.assertEquals("p3", aService.getP3()); + Assert.assertEquals("p4", aService.getP4()); + Assert.assertEquals("p5", aService.getP5()); + Assert.assertEquals("p6", aService.getP6()); + Assert.assertEquals("p7.aString", aService.getP7AString()); + Assert.assertEquals(7, aService.getP7BInt()); + Assert.assertEquals("p8.aString", aService.getP8AString()); + Assert.assertEquals(8, aService.getP8BInt()); + Assert.assertEquals("p9.aString", aService.getP9AString()); + Assert.assertEquals(9, aService.getP9BInt()); + Assert.assertEquals("p10.aString", aService.getP10AString()); + Assert.assertEquals(10, aService.getP10BInt()); + Assert.assertEquals("p11.aString", aService.getP11AString()); + Assert.assertEquals(11, aService.getP11BInt()); + Assert.assertEquals("p12.aString", aService.getP12AString()); + Assert.assertEquals(12, aService.getP12BInt()); + } + + /** + * Lines 1349 to 1352:
+ * Properties may also be injected via public setter methods even when the + * "@Property" annotation is not present. However, the + * + * @Property annotation must be used in order to inject a property onto a + * non-public field. In the case where there is no "@Property" + * annotation, the name of the property is the same as the name of + * the field or setter.
+ *

+ * p13 is an un-annotated public field which should be injected + * via field
+ */ + @Test + public void atProperty2() throws Exception { + Assert.assertEquals("p13", anotherAService.getP13()); + } + + /** + * Line 1353:
+ * Where there is both a setter method and a field for a property, the + * setter method is used.
+ *

+ * p14 is an un-annotated public field, it should be injected via public + * setter
+ */ + @Test + public void atProperty3() throws Exception { + Assert.assertEquals("p14", anotherAService.getP14()); + Assert.assertTrue(anotherAService.getP14SetterIsCalled()); + } + + /** + * Lines 1355 to 1357:
+ * The "@Property" annotation has the following attributes:
+ *

  • name (optional) – the name of the property, defaults to the name of + * the field of the Java class
  • + *
  • required (optional) – specifies whether injection is required, + * defaults to false
  • + *

    + * p15 - injected via field with different name "pFifteen"
    + * p16 - injected via setter with different name "pSixteen"
    + * p17 - injected via field but not defined in composite
    + * p18 - injected via setter but not defined in composite
    + * + * @TODO - Need to test required=true but not defined in composite (The + * specification does not describe the proper behaviour in this + * situation.) + */ + @Test + public void atProperty4() throws Exception { + Assert.assertEquals("p15", aService.getP15()); + Assert.assertEquals("p16", aService.getP16()); + Assert.assertNull(aService.getP17()); + Assert.assertNull(aService.getP18()); + } + + /** + * Lines 1369 to 1370:
    + * If the property is defined as an array or as a java.util.Collection, then + * the implied component type has a property with a many attribute set to + * true.
    + *

    + * p19 - a List and injected via field with no element
    + * p20 - a List and injected via setter
    + * p21 - an array and injected via field
    + */ + @Test + public void atProperty5() throws Exception { + Assert.assertEquals(0, aService.getP19Size()); + Assert.assertEquals(1, aService.getP20Size()); + Assert.assertEquals("p20", aService.getP20(0)); + Assert.assertEquals(3, aService.getP21Size()); + Assert.assertEquals(2, aService.getP21(0)); + Assert.assertEquals(1, aService.getP21(1)); + Assert.assertEquals(21, aService.getP21(2)); + } + + /** + * Lines 1141 to 1162:
    + * 1.8.5. "@Constructor"
    + * ...
    + * The "@Constructor" annotation is used to mark a particular constructor to + * use when instantiating a Java component implementation.
    + * The "@Constructor" annotation has the following attribute:
    + *

  • value (optional) – identifies the property/reference names that + * correspond to each of the constructor arguments. The position in the + * array determines which of the arguments are being named.
  • + *

    + * cService1 - "@Constructor" without value and constructor arguments
    + * cService2 - "@Constructor" without value but with constructor arguments
    + * cService3 - "@Constructor" with values and constructor arguments
    + * cService4 - "@Constructor" with values and constructor arguments where + * value, property and parameter names are same
    + * cService5 - "@Constructor" with switched values and constructor arguments
    + * cService6 - "@Constructor" with wrong values
    + */ + @Test + public void atProperty6() throws Exception { + Assert.assertNull(cService1.getB1Name()); + Assert.assertNull(cService1.getP2()); + Assert.assertEquals(0, cService1.getP3()); + Assert.assertNull(cService1.getP4()); + Assert.assertEquals("NoArgument", cService1.getConstructor()); + + Assert.assertEquals("BService", cService2.getB1Name()); + Assert.assertEquals("p2", cService2.getP2()); + Assert.assertEquals(3, cService2.getP3()); + Assert.assertEquals("p4", cService2.getP4()); + Assert.assertEquals("AllArguments", cService2.getConstructor()); + + Assert.assertEquals("BService", cService3.getB1Name()); + Assert.assertEquals("p2", cService3.getP2()); + Assert.assertEquals(3, cService3.getP3()); + Assert.assertEquals("p4", cService3.getP4()); + Assert.assertEquals("AllArguments", cService3.getConstructor()); + + Assert.assertEquals("BService", cService4.getB1Name()); + Assert.assertEquals("p2", cService4.getP2()); + Assert.assertEquals(3, cService4.getP3()); + Assert.assertEquals("p4", cService4.getP4()); + Assert.assertEquals("AllArguments", cService4.getConstructor()); + + Assert.assertEquals("BService", cService5.getB1Name()); + Assert.assertEquals("p4", cService5.getP2()); + Assert.assertEquals(3, cService5.getP3()); + Assert.assertEquals("p2", cService5.getP4()); + Assert.assertEquals("SwitchedValues", cService5.getConstructor()); + + try { + System.out.println(cService6.getB1Name()); + fail("Should have failed to call this service"); + } catch (Throwable t) { + } + + } + + /** + * Lines 1349 to 1352:
    + * 1.8.13. "@Property"
    + * ...
    + * Properties may also be injected via public setter methods even when the + * "@Property" annotation is not present. However, the "@Property" + * annotation must be used in order to inject a property onto a non-public + * field. In the case where there is no "@Property" annotation, the name of + * the property is the same as the name of the field or setter. + *

    + * p22 is unannotated protected field which should not be injected p23 is + * un-annotated protected which should not be injected via protected setter
    + */ + @Test + @Ignore("JIRA-2289 - p23 failed") + public void atProperty7() throws Exception { + Assert.assertNull(anotherAService.getP22()); + Assert.assertNull(anotherAService.getP23()); + Assert.assertFalse(anotherAService.getP23SetterIsCalled()); + } + + /** + * Lines 1349 to 1352:
    + * 1.8.13. "@Property"
    + * ...
    + * Properties may also be injected via public setter methods even when the + * "@Property" annotation is not present. However, the "@Property" + * annotation must be used in order to inject a property onto a non-public + * field. In the case where there is no "@Property" annotation, the name of + * the property is the same as the name of the field or setter. + *

    + * p24 is un-annotated protected field which should be injected via public + * setter
    + * p25 is un-annotated private field which should be injected via public + * setter
    + */ + @Test + public void atProperty8() throws Exception { + Assert.assertEquals("p24", anotherAService.getP24()); + Assert.assertTrue(anotherAService.getP24SetterIsCalled()); + Assert.assertEquals("p25", anotherAService.getP25()); + Assert.assertTrue(anotherAService.getP25SetterIsCalled()); + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/pom.xml new file mode 100644 index 0000000000..5e88742f3e --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-reference + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @Reference + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/AService.java new file mode 100644 index 0000000000..b28704a3b4 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/AService.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.vtest.javaapi.annotations.reference; + + +/** + * Simple Service that uses another Service + */ +public interface AService { + + public String getName(); + public String getB1Name(); + public String getB2Name(); + public String getB3Name(); + public String getB4Name(); + public String getB5Name(); + public String getB6Name(); + public String getB7Name(); + public String getB8Name(); + public String getB9Name(); + public String getB10Name(); + public String getB11Name(); + public String getB12Name(); + public String getB13Name(int i); + public String getB14Name(int i); + public String getB15Name(int i); + + public int getB13Size(); + public int getB14Size(); + public int getB15Size(); + + public boolean isB7SetterCalled(); + public boolean isB16Null(); + public boolean isB17Null(); + + public boolean isB4Null(); + public boolean isB5Null(); + public boolean isB6Null(); +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/BService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/BService.java new file mode 100644 index 0000000000..04c0bc377e --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/BService.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.vtest.javaapi.annotations.reference; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service used by another service + */ +@Remotable +public interface BService { + + String getName(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AServiceImpl.java new file mode 100644 index 0000000000..60e2b2408c --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AServiceImpl.java @@ -0,0 +1,215 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.reference.impl; + +import java.util.List; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.BService; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(AService.class) +public class AServiceImpl implements AService { + + @Reference + protected BService b1; // field injection + + protected BService b2; // injected via constructor parameter + + protected BService b3; // setter injection + + public BService b4; // field injection (public, un-annotated) + + protected BService b5; // field injection (non-public, un-annotated) + + public BService b6; // setter injection (public, un-annotated) + + @Reference + protected BService b7; // setter injection (field and setter annotated) + + @Reference(name="b8", required=false) + protected BService bEight; // field injection (different reference and field name) + + protected BService bNine; // setter injection (different reference and field name) + + @Reference(required=false) + protected BService b10; // multiplicity="0..1" and required=false + + @Reference(required=false) + protected BService b11; // multiplicity="1..1" and required=false + + protected BService b12; // multiplicity="1..1" and required=true at setter + + @Reference(required=false) + protected List b13; // multiplicity="0..n" and required=false + + protected List b14; // multiplicity="1..n" and required=false at setter + + @Reference(name="b15", required=true) + protected BService[] b15s; // multiplicity="1..n" and required=true + + @Reference(required=false) + protected BService b16; + + @Reference(required=false) + public BService b17; + + protected boolean b7SetterCalled; + + public AServiceImpl(@Reference(name = "b2") + BService b2) { + super(); + this.b2 = b2; + b7SetterCalled = false; + } + + @Reference + public void setB3(BService b3) { + this.b3 = b3; + } + + public void setB6(BService b6) { + this.b6 = b6; + } + + @Reference + public void setB7(BService b7) { + b7SetterCalled = true; + this.b7 = b7; + } + + @Reference(name="b9", required=false) + public void setB9(BService bNine) { + this.bNine = bNine; + } + + @Reference(required=true) + public void setB12(BService b12) { + this.b12 = b12; + } + + @Reference(required=true) + public void setB14(List b14) { + this.b14 = b14; + } + + public String getName() { + return "AService"; + } + + public String getB1Name() { + return b1.getName(); + } + + public String getB2Name() { + return b2.getName(); + } + + public String getB3Name() { + return b3.getName(); + } + + public String getB4Name() { + return b4.getName(); + } + + public String getB5Name() { + return b5.getName(); + } + + public String getB6Name() { + return b6.getName(); + } + + public String getB7Name() { + return b7.getName(); + } + + public String getB8Name() { + return bEight.getName(); + } + + public String getB9Name() { + return bNine.getName(); + } + + public String getB10Name() { + return b10.getName(); + } + + public String getB11Name() { + return b11.getName(); + } + + public String getB12Name() { + return b12.getName(); + } + + public String getB13Name(int i) { + BService b = (BService) b13.get(i); + return b.getName(); + } + + public String getB14Name(int i) { + BService b = (BService) b14.get(i); + return b.getName(); + } + + public String getB15Name(int i) { + return b15s[i].getName(); + } + + public int getB13Size() { + return b13.size(); + } + + public int getB14Size() { + return b14.size(); + } + + public int getB15Size() { + return b15s.length; + } + + public boolean isB7SetterCalled() { + return b7SetterCalled; + } + + public boolean isB16Null() { + return b16 == null; + } + + public boolean isB17Null() { + return b17 == null; + } + + public boolean isB4Null() { + return b4 == null; + } + + public boolean isB5Null() { + return b5 == null; + } + + public boolean isB6Null() { + return b6 == null; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AUnannotatedServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AUnannotatedServiceImpl.java new file mode 100644 index 0000000000..20fccf807f --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AUnannotatedServiceImpl.java @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.reference.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.BService; +import org.oasisopen.sca.annotation.Service; + +@Service(AService.class) +public class AUnannotatedServiceImpl implements AService { + + public BService b4; // field injection (public, un-annotated) + + protected BService b5; // field injection (non-public, un-annotated) + + public BService b6; // setter injection (public, un-annotated) + + public AUnannotatedServiceImpl() { + } + + public String getName() { + return "AService"; + } + + public String getB4Name() { + return b4.getName(); + } + + public String getB5Name() { + return b5.getName(); + } + + public void setB6(BService b6) { + this.b6 = b6; + } + + public String getB6Name() { + return b6.getName(); + } + + public String getB1Name() { + return null; + } + + public String getB2Name() { + return null; + } + + public String getB3Name() { + return null; + } + + public String getB7Name() { + return null; + } + + public String getB8Name() { + return null; + } + + public String getB9Name() { + return null; + } + + public boolean isB7SetterCalled() { + return false; + } + + public String getB10Name() { + return null; + } + + public String getB11Name() { + return null; + } + + public String getB12Name() { + return null; + } + + public String getB13Name(int i) { + return null; + } + + public int getB13Size() { + return 0; + } + + public String getB14Name(int i) { + return null; + } + + public int getB14Size() { + return 0; + } + + public String getB15Name(int i) { + return null; + } + + public int getB15Size() { + return 0; + } + + public boolean isB16Null() { + return true; + } + + public boolean isB17Null() { + return true; + } + + public boolean isB4Null() { + return b4 == null; + } + + public boolean isB5Null() { + return b5 == null; + } + + public boolean isB6Null() { + return b6 == null; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/BServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/BServiceImpl.java new file mode 100644 index 0000000000..c7fc91e65f --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/BServiceImpl.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.reference.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.BService; +import org.oasisopen.sca.annotation.Service; + +@Service(BService.class) +public class BServiceImpl implements BService { + + public String getName() { + return "BService"; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/resources/ab.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/resources/ab.composite new file mode 100644 index 0000000000..b4ad1e77d5 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/main/resources/ab.composite @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/ReferenceAnnotationTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/ReferenceAnnotationTestCase.java new file mode 100644 index 0000000000..1fe50b4ea7 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/reference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/ReferenceAnnotationTestCase.java @@ -0,0 +1,229 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.reference; + +import static org.junit.Assert.fail; +import junit.framework.Assert; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * This test class tests the "@Reference" annotation described in section 1.8.14 + */ +public class ReferenceAnnotationTestCase { + + protected static String compositeName = "ab.composite"; + protected static AService a; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + a = ServiceFinder.getService(AService.class, "AComponent"); + + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Temporary test unrelated to spec test effort. Remove after resolution of + */ + @Test + @Ignore + // JIRA T-2145 + public void bogusComponentName() throws Exception { + ServiceFinder.init(compositeName); + try { + AService a = ServiceFinder.getService(AService.class, "AReallyBogusComponentName"); + if (a == null) + fail("Should have thrown an exception rather than return null"); + else + fail("Should have thrown an exception rather than return a proxy"); + } finally { + ServiceFinder.cleanup(); + } + + } + + /** + * Lines 1404, 1405, 1406
    + * The "@Reference" annotation type is used to annotate a Java class field + * or a setter method that is used to inject a service that resolves the + * reference. The interface of the service injected is defined by the type + * of the Java class field or the type of the setter method input argument. + *

    + * This tests the use of the three usages of the "@Reference" annotation
    + * B1 is injected via field injection
    + * B2 is injected via constructor parameter
    + * B3 is injected via setter method + */ + @Test + public void atReference1() throws Exception { + + Assert.assertEquals("BService", a.getB1Name()); + Assert.assertEquals("BService", a.getB2Name()); + Assert.assertEquals("BService", a.getB3Name()); + + } + + /** + * Lines 1407, 1408, 1409, 1410
    + * References may also be injected via public setter methods even when the + * "@Reference" annotation is not present. However, the "@Reference" + * annotation must be used in order to inject a reference onto a non public + * field. In the case where there is no "@Reference" annotation, the name of + * the reference is the same as the name of the field or setter. + *

    + * B4 is injected via field injection. Public, Non-annotated
    + * B5 is expected to fail field injection. Non-Public, Non-Annotated
    + * B6 is injected via setter injection. Public, Non-Annotated + */ + @Test + public void atReference2() throws Exception { + AService anotherA = ServiceFinder.getService(AService.class, "AUnannotatedComponent"); + + Assert.assertFalse(anotherA.isB4Null()); + Assert.assertTrue(anotherA.isB5Null()); + Assert.assertFalse(anotherA.isB6Null()); + + Assert.assertEquals("BService", anotherA.getB4Name()); + try { + anotherA.getB5Name(); + fail("getB5Name expected to fail with NPE"); + } catch (NullPointerException e) { + } + Assert.assertEquals("BService", anotherA.getB6Name()); + + } + + /** + * Lines 1411
    + * Where there is both a setter method and a field for a reference, the + * setter method is used. + *

    + * B7 has both field and setter annotated. The setter must be called + */ + @Test + public void atReference3() throws Exception { + Assert.assertTrue(a.isB7SetterCalled()); + } + + /** + * Lines 1413, 1414, 1415
    + * The "@Reference" annotation has the following attributes:
    • name + * (optional) – the name of the reference, defaults to the name of the field + * of the Java class
    + * required (optional) – whether injection of service or services is + * required. Defaults to true. + *

    + * Reference and field have different names
    + * B8 is field injected
    + * B9 is setter injected + */ + @Test + public void atReference4() throws Exception { + Assert.assertEquals("BService", a.getB8Name()); + Assert.assertEquals("BService", a.getB9Name()); + } + + /** + * Lines 1457 to 1459
    + * If the reference is not an array or collection, then the implied + * component type has a reference with a multiplicity of either 0..1 or 1..1 + * depending on the value of the + * + * @Reference required attribute – 1..1 applies if required=true.
    + *

    + * B10 is field injected, required=false, and multiplicity="0..1"
    + * B11 is field injected, required=false, and multiplicity="1..1"
    + * B12 is setter injected, required=true, and multiplicity="1..1" + */ + @Test + public void atReference5() throws Exception { + Assert.assertEquals("BService", a.getB10Name()); + Assert.assertEquals("BService", a.getB11Name()); + Assert.assertEquals("BService", a.getB12Name()); + } + + /** + * Lines 1461 to 1463
    + * If the reference is defined as an array or as a java.util.Collection, + * then the implied component type has a reference with a multiplicity of + * either 1..n or 0..n, depending on whether the required attribute of the + * "@Reference" annotation is set to true or false – 1..n applies if + * required=true.
    + *

    + * B13 is a java.util.List, field injected, required=false, + * multiplicity="0..n", and no target
    + * B14 is a java.util.List, setter injected, required=true, + * multiplicity="1..n", and one target
    + * B15 is an array, field injected, required=true, multiplicity="1..n", and + * two targets + */ + @Test + public void atReference6() throws Exception { + Assert.assertEquals(0, a.getB13Size()); + Assert.assertEquals("BService", a.getB14Name(0)); + Assert.assertEquals(1, a.getB14Size()); + Assert.assertEquals("BService", a.getB15Name(0)); + Assert.assertEquals("BService", a.getB15Name(1)); + Assert.assertEquals(2, a.getB15Size()); + } + + /** + * Lines 1415
    + * required (optional) - whether injection of service or services is + * required. Defaults to true. + *

    + * b16 and b17 is defined as "@Reference(required=false)" and AComponent + * does not define reference for them + */ + @Test + public void atReference7() throws Exception { + Assert.assertTrue(a.isB16Null()); + Assert.assertTrue(a.isB17Null()); + } + + /** + * Java Component Implementation Spec + * Section 1.2.7 + * Line 361 when @Property and @Reference annotations are present + * then unannotated fields are ignored + */ + @Test + public void atReference8() throws Exception { + Assert.assertTrue(a.isB4Null()); + Assert.assertTrue(a.isB5Null()); + Assert.assertTrue(a.isB6Null()); + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/pom.xml new file mode 100644 index 0000000000..8a905a7ebc --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-scope + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @Scope + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/AService.java new file mode 100644 index 0000000000..b7cf3fba71 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/AService.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.vtest.javaapi.annotations.scope; + + +/** + * Simple Service + */ +public interface AService { + + public String getName(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/BService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/BService.java new file mode 100644 index 0000000000..7da9d29424 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/BService.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.vtest.javaapi.annotations.scope; + +/** + * Simple Service + */ +public interface BService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/CService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/CService.java new file mode 100644 index 0000000000..208c6a78b0 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/CService.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.vtest.javaapi.annotations.scope; + +/** + * Simple Service + */ +public interface CService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/DService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/DService.java new file mode 100644 index 0000000000..f9b87ad251 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/DService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface DService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/FService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/FService.java new file mode 100644 index 0000000000..0e4ed9c18d --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/FService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface FService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/GService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/GService.java new file mode 100644 index 0000000000..566dc93e6d --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/GService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface GService { + + public String getName(); + + public int getInitCalledCounter(); + + public int getDestroyCalledCounter(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/HService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/HService.java new file mode 100644 index 0000000000..714b3ce8f4 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/HService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + + +/** + * Simple Service + */ +@Remotable +public interface HService { + + public String getName(); + + public String test(); + + public String testCounters(int n); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/IService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/IService.java new file mode 100644 index 0000000000..88cf95b593 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/IService.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.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Conversational; +import org.oasisopen.sca.annotation.EndsConversation; + +/** + * Simple Service + */ +@Conversational +public interface IService { + + public String getName(); + + public boolean isInitReady(); + + public String getCurrentState(); + + public String getConversationId(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + + @EndsConversation + public void endConversation(); +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java new file mode 100644 index 0000000000..ea974100ab --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/JService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface JService { + + public String getName(); + + public String getFailedReason(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java new file mode 100644 index 0000000000..454009da12 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/KService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface KService { + + public String getName(); + + public String callL1(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java new file mode 100644 index 0000000000..2910b1c81c --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/LService.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface LService { + + public String getName(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java new file mode 100644 index 0000000000..81d0692d7a --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/MService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface MService { + + public String getName(); + + public String getFailedReason(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java new file mode 100644 index 0000000000..3493a88206 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/NService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface NService { + + public String getName(); + + public String callO1(int nthTime); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java new file mode 100644 index 0000000000..982568b236 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/OService.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Service + */ +@Remotable +public interface OService { + + public String getName(); + + public String getCurrentState(); + + public String setCurrentState(String currentState); + + public int getDestroyCalledCounter(); + + public int getInitCalledCounter(); + + public int getInstanceCounter(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/AServiceImpl.java new file mode 100644 index 0000000000..f7a57941dc --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/AServiceImpl.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.oasisopen.sca.annotation.Service; + +@Service(AService.class) +public class AServiceImpl implements AService { + + public String getName() { + return "AService"; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/BServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/BServiceImpl.java new file mode 100644 index 0000000000..29d6284c43 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/BServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.BService; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Destroy; + +@Service(BService.class) +public class BServiceImpl implements BService { + + private static int instanceCounter = 0; + + private static int initCalledCounter = 0; + + private static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + private int currentInstanceId = 0; + + public String currentState = null; + + private boolean isInitReady = false; + + public BServiceImpl() { + currentInstanceId = ++instanceCounter; + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initBService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + } + + @Destroy + public void destroyBService() { + destroyCalledCounter++; + } + + public String getName() { + return "BService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/CServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/CServiceImpl.java new file mode 100644 index 0000000000..037d900176 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/CServiceImpl.java @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.CService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(CService.class) +@Scope("STATELESS") +public class CServiceImpl implements CService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + public int currentInstanceId = 0; + + public String currentState = null; + + public boolean isInitReady = false; + + public CServiceImpl() { + currentInstanceId = ++instanceCounter; + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initCService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + } + + @Destroy + public void destroyCService() { + destroyCalledCounter++; + } + + public String getName() { + return "CService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/DServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/DServiceImpl.java new file mode 100644 index 0000000000..d5f1326086 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/DServiceImpl.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.DService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(DService.class) +@Scope("REQUEST") +public class DServiceImpl implements DService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + public int currentInstanceId = 0; + + public String currentState = null; + + public boolean isInitReady = false; + + public DServiceImpl() { + currentInstanceId = ++instanceCounter; + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initDService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + System.out.println("DService" + currentInstanceId + "->initDService"); + } + + @Destroy + public void destroyDService() { + destroyCalledCounter++; + System.out.println("DService" + currentInstanceId + "->destroyDService"); + } + + public String getName() { + return "DService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = "DService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/FServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/FServiceImpl.java new file mode 100644 index 0000000000..e2bfa3c45a --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/FServiceImpl.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.FService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(FService.class) +@Scope("COMPOSITE") +public class FServiceImpl implements FService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + public int currentInstanceId = 0; + + public String currentState = null; + + public boolean isInitReady = false; + + public FServiceImpl() { + currentInstanceId = ++instanceCounter; + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initFService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + System.out.println("FService" + currentInstanceId + "->initFService"); + } + + @Destroy + public void destroyFService() { + destroyCalledCounter++; + System.out.println("FService" + currentInstanceId + "->destroyFService"); + } + + public String getName() { + return "FService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = "FService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/GServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/GServiceImpl.java new file mode 100644 index 0000000000..28b8bd84b9 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/GServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.GService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.EagerInit; + +@Scope("COMPOSITE") +@EagerInit +public class GServiceImpl implements GService { + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public AService a1; + + public String p1; + + @Init + public void initGService() throws Exception { + initCalledCounter++; + System.out.println("GService->initGService"); + } + + @Destroy + public void destroyGService() { + destroyCalledCounter++; + System.out.println("GService->destroyGService"); + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + public String getName() { + return "GService"; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/HServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/HServiceImpl.java new file mode 100644 index 0000000000..404f329201 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/HServiceImpl.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.IService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.HService; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; + +@Service(HService.class) +public class HServiceImpl implements HService { + + @Reference + public IService i1; + + public String getName() { + return "HService"; + } + + public String test() { + + String serviceName = i1.getName(); + String conversationIdBefore = i1.getConversationId(); + + for (int i = 0; i < 10; i++) { + String newState = "state-" + i; + i1.setCurrentState(newState); + String currentState = i1.getCurrentState(); + if (currentState == null || !currentState.equals(serviceName + "-" + newState)) { + i1.endConversation(); + return "CurrentStateLost - " + currentState; + } + } + + boolean isInitReady = i1.isInitReady(); + + String conversationIdAfter = i1.getConversationId(); + + i1.endConversation(); + + if (!isInitReady) + return "InitNotReady"; + + if (!conversationIdBefore.equals(conversationIdAfter)) + return "DifferentConversationId"; + + return "None"; + } + + public String testCounters(int n) { + int instanceCounter = i1.getInstanceCounter(); + int initCalledCounter = i1.getInitCalledCounter(); + int destroyCalledCounter = i1.getDestroyCalledCounter(); + + System.out.println("instanceCounter=" + instanceCounter); + System.out.println("initCalledCounter=" + initCalledCounter); + System.out.println("destroyCalledCounter=" + destroyCalledCounter); + + if (instanceCounter != n + 1) + return "IncorrectInstanceCounter"; + if (initCalledCounter != n + 1) + return "IncorrectInitCalledCounter"; + if (destroyCalledCounter != n) + return "IncorrectDestroyCalledCounter"; + + return "None"; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/IServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/IServiceImpl.java new file mode 100644 index 0000000000..66d14c2e96 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/IServiceImpl.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.IService; +import org.oasisopen.sca.annotation.ConversationID; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(IService.class) +@Scope("CONVERSATION") +public class IServiceImpl implements IService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + @ConversationID + protected String conversationId; + + public int currentInstanceId = 0; + + public AService a1; + + public String p1; + + public String currentState = null; + + public boolean isInitReady = false; + + public IServiceImpl() { + synchronized (IServiceImpl.class) { + currentInstanceId = ++instanceCounter; + } + isInitReady = false; + } + + @Reference + public void setA1(AService a1) { + this.a1 = a1; + } + + @Property + public void setP1(String p1) { + this.p1 = p1; + } + + @Init + public void initIService() throws Exception { + initCalledCounter++; + if (p1.equals("p1") && a1.getName().equals("AService")) + isInitReady = true; + System.out.println("IService" + currentInstanceId + "->initIService"); + } + + @Destroy + public void destroyIService() { + destroyCalledCounter++; + System.out.println("IService" + currentInstanceId + "->destroyIService"); + } + + public void endConversation() { + System.out.println("IService" + currentInstanceId + "->endConversation"); + } + + public String getName() { + return "IService" + currentInstanceId; + } + + public AService getA1() { + return a1; + } + + public String getP1() { + return p1; + } + + public String getCurrentState() { + return currentState; + } + + public String getConversationId() { + return conversationId; + } + + public String setCurrentState(String currentState) { + this.currentState = "IService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public boolean isInitReady() { + return isInitReady; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.java new file mode 100644 index 0000000000..80546f677c --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/JServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import java.util.Timer; +import java.util.TimerTask; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.KService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.JService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(JService.class) +@Scope("COMPOSITE") +public class JServiceImpl implements JService { + + @Reference + public KService k1; + + public static String failedReason = ""; + + public static Timer aTimer = null; + + @Init + public void initJService() throws Exception { + aTimer = new Timer(); + aTimer.schedule(new JTimerTask(), 1000); + System.out.println("JService->initJService"); + } + + @Destroy + public void destroyJService() { + aTimer.cancel(); + System.out.println("JService->destroyJService"); + } + + public String getName() { + return "JService"; + } + + public String getFailedReason() { + return failedReason; + } + + private class JTimerTask extends TimerTask { + + public boolean cancel() { + return true; + } + + public void run() { + String result = k1.callL1(); + if (!result.equals("None")) + failedReason = failedReason + ";" + result; + } + + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.java new file mode 100644 index 0000000000..022a9d11f6 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/KServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.KService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.LService; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(KService.class) +@Scope("STATELESS") +public class KServiceImpl implements KService { + + public static int instanceCounter = 0; + + public String previousL1Name = null; + + public int currentInstanceId = 0; + + @Reference + public LService l1; + + public KServiceImpl() { + currentInstanceId = ++instanceCounter; + } + + + public String getName() { + return "KService"+currentInstanceId; + } + + public String callL1() { + + for (int i = 1; i < 11; i++) { + System.out.println(getName() + " calls LService " + i + (i == 1 ? "st time:" : (i == 2 ? "nd time:" : (i == 3 ? "rd time:" : "th time")))); + + String serviceName = l1.getName(); + for (int j = 0; j < 10; j++) { + String newState = "state-" + j; + l1.setCurrentState(newState); + String currentState = l1.getCurrentState(); + if (!currentState.equals(serviceName + "-" + newState)) { + return "CurrentStateLost - " + currentState; + } + } + + System.out.print(" Name=" + serviceName); + System.out.print(", #Instance=" + l1.getInstanceCounter()); + System.out.print(", #InitCalled=" + l1.getInitCalledCounter()); + System.out.println(", #DestroyCalled=" + l1.getDestroyCalledCounter()); + + if (previousL1Name == null) { + previousL1Name = serviceName; + } else { + if (!previousL1Name.equals(serviceName)) + return "DifferentLServiceInstance"; + } + } + return "None"; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.java new file mode 100644 index 0000000000..196cd6f39a --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/LServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.LService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(LService.class) +@Scope("REQUEST") +public class LServiceImpl implements LService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public int currentInstanceId = 0; + + public String currentState = null; + + public LServiceImpl() { + currentInstanceId = ++instanceCounter; + } + + @Init + public void initLService() throws Exception { + initCalledCounter++; + System.out.println("LService" + currentInstanceId + "->initLService"); + } + + @Destroy + public void destroyLService() { + destroyCalledCounter++; + System.out.println("LService" + currentInstanceId + "->destroyLService"); + } + + public String getName() { + return "LService" + currentInstanceId; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = "LService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.java new file mode 100644 index 0000000000..acc7d8ca9e --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/MServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import java.util.Timer; +import java.util.TimerTask; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.MService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.NService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(MService.class) +@Scope("COMPOSITE") +public class MServiceImpl implements MService { + + @Reference + public NService n1; + + public static String failedReason = ""; + + public static Timer aTimer = null; + + public static int counter = 0; + + @Init + public void initMService() throws Exception { + aTimer = new Timer(); + aTimer.schedule(new MTimerTask(), 1000, 1000); + System.out.println("MService->initMService"); + } + + @Destroy + public void destroyMService() { + aTimer.cancel(); + System.out.println("MService->destroyMService"); + } + + public String getName() { + return "MService"; + } + + public String getFailedReason() { + return failedReason; + } + + private class MTimerTask extends TimerTask { + + public boolean cancel() { + return true; + } + + public void run() { + counter++; + String result = n1.callO1(counter); + if (!result.equals("None")) + failedReason = failedReason + ";" + result; + } + + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.java new file mode 100644 index 0000000000..b9d799331f --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/NServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.NService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.OService; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(NService.class) +@Scope("STATELESS") +public class NServiceImpl implements NService { + + public static int instanceCounter = 0; + + public String previousL1Name = null; + + public int currentInstanceId = 0; + + @Reference + public OService o1; + + public NServiceImpl() { + currentInstanceId = ++instanceCounter; + } + + + public String getName() { + return "NService"+currentInstanceId; + } + + public String callO1(int nthTime) { + + for (int i = 1; i < 11; i++) { + System.out.println(getName() + " calls OService " + i + (i == 1 ? "st time:" : (i == 2 ? "nd time:" : (i == 3 ? "rd time:" : "th time")))); + + String serviceName = o1.getName(); + for (int j = 0; j < 10; j++) { + String newState = "state-" + j; + o1.setCurrentState(newState); + String currentState = o1.getCurrentState(); + if (!currentState.equals(serviceName + "-" + newState)) { + return "CurrentStateLost - " + currentState; + } + } + + System.out.print(" Name=" + serviceName); + System.out.print(", #Instance=" + o1.getInstanceCounter()); + System.out.print(", #InitCalled=" + o1.getInitCalledCounter()); + System.out.println(", #DestroyCalled=" + o1.getDestroyCalledCounter()); + + if (previousL1Name == null) { + previousL1Name = serviceName; + } else { + if (!previousL1Name.equals(serviceName)) + return "DifferentOServiceInstance"; + } + + } + + if (o1.getInstanceCounter() < nthTime) { + return "SharedSameInstance"; + } + + return "None"; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.java new file mode 100644 index 0000000000..60178ba2a3 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/impl/OServiceImpl.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.vtest.javaapi.annotations.scope.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.scope.OService; +import org.oasisopen.sca.annotation.Destroy; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Scope; + +@Service(OService.class) +@Scope("REQUEST") +public class OServiceImpl implements OService { + + public static int instanceCounter = 0; + + public static int initCalledCounter = 0; + + public static int destroyCalledCounter = 0; + + public int currentInstanceId = 0; + + public String currentState = null; + + public OServiceImpl() { + currentInstanceId = ++instanceCounter; + } + + @Init + public void initOService() throws Exception { + initCalledCounter++; + System.out.println("OService" + currentInstanceId + "->initOService"); + } + + @Destroy + public void destroyOService() { + destroyCalledCounter++; + System.out.println("OService" + currentInstanceId + "->destroyOService"); + } + + public String getName() { + return "OService" + currentInstanceId; + } + + public String getCurrentState() { + return currentState; + } + + public String setCurrentState(String currentState) { + this.currentState = "OService" + currentInstanceId + "-" + currentState; + return this.currentState; + } + + public int getDestroyCalledCounter() { + return destroyCalledCounter; + } + + public int getInitCalledCounter() { + return initCalledCounter; + } + + public int getInstanceCounter() { + return instanceCounter; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/resources/scope.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/resources/scope.composite new file mode 100644 index 0000000000..7c195b2b5d --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/main/resources/scope.composite @@ -0,0 +1,110 @@ + + + + + + + + + + + + p1 + + + + + + p1 + + + + + + p1 + + + + + + p1 + + + + + + p1 + + + + + + + + + + + p1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java new file mode 100644 index 0000000000..6d65416ce8 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/scope/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/scope/ScopeAnnotationTestCase.java @@ -0,0 +1,476 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.scope; + +import java.util.ArrayList; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * This test class tests the Scope annotation described in section 1.2.4 + * including 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.8.11, and 1.8.16
    + *

    + * Check following:
    + *

  • Number of service instances be created
  • + *
  • Init method be called and where all property and reference injection is + * complete.
  • + *
  • Destroy method be called
  • + *
  • State be preserved in request and conversation scopes but not others
  • + */ +public class ScopeAnnotationTestCase { + + protected static String compositeName = "scope.composite"; + + protected static int numDThread = 5; + protected static int numFThread = 5; + protected static int numHThread = 5; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Line 259:
    + *
  • STATELESS
  • + *

    + * Line 284:
    + * For stateless components, there is no implied correlation between + * service requests.
    + *

    + * Line 1589 to 1591:
    + * The default value is 'STATELESS'. For 'STATELESS' implementations, + * a different implementation instance may be used to service each request. + * Implementation instances may be newly created or be drawn from a pool + * of instances.
    + *

    + * BComponent is not defined '@Scope'
    + * CComponent is defined '@Scope("STATELESS")'
    + *

    + */ + @Test + public void atScope1() throws Exception { + System.out.println("atScope1"); + BThread b1 = new BThread("ThreadB1"); + BThread b2 = new BThread("ThreadB2"); + CThread c1 = new CThread("ThreadC1"); + CThread c2 = new CThread("ThreadC2"); + + b1.start(); + b2.start(); + c1.start(); + c2.start(); + b1.join(); + b2.join(); + c1.join(); + c2.join(); + + System.out.println(""); + + Assert.assertEquals("None", b1.failedReason); + Assert.assertEquals("None", b2.failedReason); + Assert.assertEquals("None", c1.failedReason); + Assert.assertEquals("None", c2.failedReason); + } + + /** + * Line 260:
    + *

  • REQUEST
  • + *

    + * Lines 286 to 289:
    + * The lifecycle of request scope extends from the point a request on a + * remotable interface enters the SCA runtime and a thread processes that + * request until the thread completes synchronously processing the request. + * During that time, all service requests will be delegated to the same + * implementation instance of a request-scoped component.
    + *

    + */ + @Test + public void atScope2() throws Exception { + System.out.println("atScope2"); + ArrayList d = new ArrayList(); + for (int i = 0; i < numDThread; i++) + d.add(new DThread("ThreadD"+i)); + for (int i = 0; i < numDThread; i++) + d.get(i).start(); + for (int i = 0; i < numDThread; i++) + d.get(i).join(); + System.out.println(""); + for (int i = 0; i < numDThread; i++) + Assert.assertEquals("None", d.get(i).failedReason); + } + + /** + * Line 262:
    + *

  • COMPOSITE
  • + *

    + * Lines 296 to 298:
    + * All service requests are dispatched to the same implementation instance + * for the lifetime of the containing composite. The lifetime of the + * containing composite is defined as the time it becomes active in the + * runtime to the time it is deactivated, either normally or abnormally.
    + *

    + * Following lines should be found at System out
    + * atScope3 - Cleaning up
    + * FService1->destroyFService + */ + @Test + public void atScope3() throws Exception { + System.out.println("atScope3"); + FService fService = ServiceFinder.getService(FService.class, "FComponent"); + String serviceName = fService.getName(); + boolean isInitReady = fService.isInitReady(); + + ArrayList f = new ArrayList(); + for (int i = 0; i < numFThread; i++) + f.add(new FThread("ThreadF"+i)); + for (int i = 0; i < numFThread; i++) + f.get(i).start(); + for (int i = 0; i < numFThread; i++) + f.get(i).join(); + for (int i = 0; i < numFThread; i++) { + Assert.assertEquals(serviceName, f.get(i).serviceName); + } + + int instanceCounter = fService.getInstanceCounter(); + int initCalledCounter = fService.getInitCalledCounter(); + int destroyCalledCounter = fService.getDestroyCalledCounter(); + System.out.println(""); + + Assert.assertTrue(isInitReady); + Assert.assertEquals(1, instanceCounter); + Assert.assertEquals(1, initCalledCounter); + Assert.assertEquals(0, destroyCalledCounter); + } + + /** + * Lines 299 to 302:
    + * A composite scoped implementation may also specify eager initialization + * using the "@EagerInit" annotation. When marked for eager initialization, + * the composite scoped instance will be created when its containing + * component is started. If a method is marked with the "@Init" annotation, + * it will be called when the instance is created.

    + * Section 1.8.9 "@EagerInit"
    + *

    + * GService is defined as eager initialization. It will be initialized + * when calls SCADomain.newInstance(compositeName), so the + * initCalledCounter is 1. + */ + @Test + public void atScope4() throws Exception { + System.out.println("atScope4"); + + GService gService = ServiceFinder.getService(GService.class, "GComponent"); + int initCalledCounter = gService.getInitCalledCounter(); + int destroyCalledCounter = gService.getDestroyCalledCounter(); + + System.out.println("initCalledCounter="+ initCalledCounter); + System.out.println("destroyCalledCounter="+ destroyCalledCounter); + System.out.println(""); + + Assert.assertEquals(1, initCalledCounter); + Assert.assertEquals(0, destroyCalledCounter); + } + + /** + * Line 261:
    + *

  • CONVERSATION
  • + *

    + * Lines 305 to 310:
    + * A conversation is defined as a series of correlated interactions between + * a client and a target service. A conversational scope starts when the + * first service request is dispatched to an implementation instance + * offering a conversational service. A conversational scope completes + * after an end operation defined by the service contract is called and + * completes processing or the conversation expires. A conversation may be + * long-running and the SCA runtime may choose to passivate implementation + * instances. If this occurs, the runtime must guarantee implementation + * instance state is preserved. + */ + @Test + public void atScope5() throws Exception { + System.out.println("atScope5"); + + ArrayList g = new ArrayList(); + for (int i = 0; i < numHThread; i++) + g.add(new HThread("ThreadH"+i)); + for (int i = 0; i < numHThread; i++) + g.get(i).start(); + for (int i = 0; i < numHThread; i++) + g.get(i).join(); + + HService hService = ServiceFinder.getService(HService.class, "HComponent"); + String failedReason = hService.testCounters(numHThread); + System.out.println(""); + + for (int i = 0; i < numHThread; i++) + Assert.assertEquals("None", g.get(i).failedReason); + Assert.assertEquals("None", failedReason); + } + + /** Lines 290 to 293:
    + * There are times when a local request scoped service is called without + * there being a remotable service earlier in the call stack, such as when + * a local service is called from a non-SCA entity. In these cases, a + * remote request is always considered to be present, but the lifetime of + * the request is implementation dependent. For example, a timer event + * could be treated as a remote request..
    + *

    + * When the composite runs, composite scope service JService kicks off a + * timer by the @Init method. When the timer expires, JService invokes a + * method that calls an operation on the reference to a stateless scope + * sevice KService. KService calls a request scope service LService + * multiple times. The results of the calls to LService should be set up to + * differ depending on whether the same instance is called each time - + * without the interface being declared Conversational.
    + *

    + */ + @Test + public void atScope6() throws Exception { + System.out.println("atScope6"); + + JService jService = ServiceFinder.getService(JService.class, "JComponent"); + jService.getName(); + Thread.sleep(2000); + String failedReason = jService.getFailedReason(); + System.out.println(""); + + Assert.assertEquals("", failedReason); + } + + /** + * Same as atScope6 but the timer triggers KService multiple times.
    + */ + @Test + @Ignore("TUSCANY-2256") + public void atScope7() throws Exception { + System.out.println("atScope7"); + + MService mService = ServiceFinder.getService(MService.class, "MComponent"); + mService.getName(); + Thread.sleep(6000); + String failedReason = mService.getFailedReason(); + System.out.println(""); + + Assert.assertEquals("", failedReason); + } + + private class BThread extends Thread { + private String name = null; + public String failedReason = "Unknown"; + + public BThread(String name) { + super(); + this.name = name; + failedReason = "Unknown"; + } + + @Override + public void run() { + BService bService = ServiceFinder.getService(BService.class, "BComponent"); + bService.setCurrentState(name + "-state-1"); + System.out.println(name + "->" + bService.getName()); + if (!bService.isInitReady()) { + failedReason = "InitNotReady"; + return; + } + if (bService.getCurrentState() != null) { + failedReason = "CurrentStateNotNull"; + return; + } + int counter = bService.getInstanceCounter(); + if (counter < 2) { + failedReason = "OnlyOneInstance - " + counter; + return; + } + counter = bService.getInitCalledCounter(); + if (counter < 2) { + failedReason = "InitBeCalledOnce - " + counter; + return; + } + counter = bService.getDestroyCalledCounter(); + if (counter < 2) { + failedReason = "DestroyBeCalledOnce - " + counter; + return; + } + failedReason = "None"; + } + } + + private class CThread extends Thread { + private String name = null; + public String failedReason = "Unknown"; + + public CThread(String name) { + super(); + this.name = name; + failedReason = "Unknown"; + } + + @Override + public void run() { + CService cService = ServiceFinder.getService(CService.class, "CComponent"); + cService.setCurrentState(name + "-state-1"); + System.out.println(name + "->" + cService.getName()); + if (!cService.isInitReady()) { + failedReason = "InitNotReady"; + return; + } + if (cService.getCurrentState() != null) { + failedReason = "CurrentStateNotNull"; + return; + } + int counter = cService.getInstanceCounter(); + if (counter < 2) { + failedReason = "OnlyOneInstance - " + counter; + return; + } + counter = cService.getInitCalledCounter(); + if (counter < 2) { + failedReason = "InitBeCalledOnce - " + counter; + return; + } + counter = cService.getDestroyCalledCounter(); + if (counter < 2) { + failedReason = "DestroyBeCalledOnce - " + counter; + return; + } + failedReason = "None"; + } + } + + private class DThread extends Thread { + + private String name = null; + public String failedReason = "Unknown"; + + public DThread(String name) { + super(); + this.name = name; + failedReason = "Unknown"; + } + + @Override + public void run() { + DService dService = ServiceFinder.getService(DService.class, "DComponent"); + String serviceName = dService.getName(); + System.out.println(name + "->" + serviceName); + + for (int i = 0; i < 10; i++) { + String newState = name + "-state-" + i; + dService.setCurrentState(newState); + String currentState = dService.getCurrentState(); + if (!currentState.equals(serviceName + "-" + newState)) { + failedReason = "CurrentStateLost - " + currentState; + return; + } + } + + if (!dService.isInitReady()) { + failedReason = "InitNotReady"; + return; + } + + int counter = dService.getInstanceCounter(); + if (counter > numDThread) { + failedReason = "TooMuchInstance - " + counter; + return; + } + + counter = dService.getInitCalledCounter(); + if (counter > numDThread) { + failedReason = "InitBeCalledTooMuch - " + counter; + return; + } + + // JIRA T-2215 + /* Don't know when destroy method be called + counter = dService.getDestroyCalledCounter(); + if (counter > numDThreads) { + failedReason = "DestroyBeCalledTooMuch - " + counter; + return; + } + */ + failedReason = "None"; + } + } + + private class FThread extends Thread { + + private String name = null; + + public String serviceName = null; + + public FThread(String name) { + super(); + this.name = name; + } + + @Override + public void run() { + FService fService = ServiceFinder.getService(FService.class, "FComponent"); + serviceName = fService.getName(); + System.out.println(name + "->" + serviceName); + + for (int i = 0; i < 10; i++) { + String newState = name + "-state-" + i; + fService.setCurrentState(newState); + fService.getCurrentState(); + } + } + } + + private class HThread extends Thread { + + public String failedReason = "Unknown"; + + public HThread(String name) { + super(); + failedReason = "Unknown"; + } + + @Override + public void run() { + HService hService = ServiceFinder.getService(HService.class, "HComponent"); + failedReason = hService.test(); + } + } + +} + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/pom.xml b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/pom.xml new file mode 100644 index 0000000000..4c018607d1 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 2.0-SNAPSHOT + ../pom.xml + + vtest-java-api-annotations-service + Apache Tuscany SCA Java APIs and Annotations Verification Tests - Annotations - @Service + + + + org.apache.tuscany.sca + tuscany-host-embedded + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/AService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/AService.java new file mode 100644 index 0000000000..7b89b31d7f --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/AService.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.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Remotable Service + */ +@Remotable +public interface AService { + + public String getName(); + + public String setAObject(AObject a); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/BService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/BService.java new file mode 100644 index 0000000000..26bcf3b9db --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/BService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; + +/** + * Simple Local Service + */ +public interface BService { + + public String getName(); + + public String setAObject(AObject a); + + public String testServices(); +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/CService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/CService.java new file mode 100644 index 0000000000..4f4f1e80c7 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/CService.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.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; + +/** + * Simple Local Service without defining "@Service" at the implementation class + */ +public interface CService { + + public String getName(); + + public String setAObject(AObject a); +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService1.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService1.java new file mode 100644 index 0000000000..ffabb3619c --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService1.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.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface DService1 { + + public String getName1(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService2.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService2.java new file mode 100644 index 0000000000..83d7980dbc --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService2.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.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface DService2 { + + public String getName2(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService3.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService3.java new file mode 100644 index 0000000000..a416e33de7 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService3.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.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface DService3 { + + public String getName3(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/EService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/EService.java new file mode 100644 index 0000000000..ad44d2b93a --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/EService.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.vtest.javaapi.annotations.service; + +/** + * Simple Local Service which implementation class defines + * + * @Service() with no attributes + */ +public interface EService { + + public String getName(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/FService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/FService.java new file mode 100644 index 0000000000..52886131a1 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/FService.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.vtest.javaapi.annotations.service; + +/** + * Simple Local Service which implementation class defines + * + * @Service with full package name + */ +public interface FService { + + public String getName(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService1.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService1.java new file mode 100644 index 0000000000..bd1a3a5fe6 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService1.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.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface GService1 { + + public String getName(); + + public String getServiceName(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService2.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService2.java new file mode 100644 index 0000000000..0f8c7dabcb --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService2.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.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface GService2 extends GService1 { + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/HService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/HService.java new file mode 100644 index 0000000000..6a80e3023e --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/HService.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.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Remotable Service + */ +@Remotable +public interface HService { + + public String getName(); + + public String setAObject1(AObject a); + + public String setAObject2(AObject a); + + public String getComponentName(); + + public String getAObject1String(); + + public String getAObject2String(); + + public String getAObject3String(); + + public AObject getAObject3(); + + public String getServiceName1(); + + public String getServiceName2(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/IService.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/IService.java new file mode 100644 index 0000000000..cdeb43c4f4 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/IService.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; +import org.oasisopen.sca.annotation.Remotable; + +/** + * Simple Remotable Service + */ +@Remotable +public interface IService { + + public String getName(); + + public String setAObject1(AObject a); + + public String setAObject2(AObject a); + + public void setComponentName1(String componentName1); + + public String getComponentName1(); + + public String getComponentName2(); + + public String getAObject1String(); + + public String getAObject2String(); + + public String getAObject3String(); + + public AObject getAObject3(); + + public String getServiceName1(); + + public String getServiceName2(); + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AObject.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AObject.java new file mode 100644 index 0000000000..0ab2e29194 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AObject.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +/** + * A simple object to hold a string + */ +public class AObject { + + public String aString; + + public AObject() { + this.aString = null; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AServiceImpl.java new file mode 100644 index 0000000000..b9617e5780 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AServiceImpl.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.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.AService; +import org.oasisopen.sca.annotation.Service; + +@Service(AService.class) +public class AServiceImpl implements AService { + + public String getName() { + return "AService"; + } + + public String setAObject(AObject a) { + a.aString = "AService"; + return "AService"; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/BServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/BServiceImpl.java new file mode 100644 index 0000000000..474ca084d6 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/BServiceImpl.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.CService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.HService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.IService; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.Reference; + +@Service(BService.class) +public class BServiceImpl implements BService { + + @Reference(required=false) + public AService aService = null; + + @Reference(required=false) + public CService cService = null; + + @Reference(required=false) + public HService hService = null; + + @Reference(required=false) + public IService iService = null; + + public String getName() { + return "BService"; + } + + public String setAObject(AObject a) { + a.aString = "BService"; + return "BService"; + } + + public String testServices() { + + AObject a = new AObject(); + aService.setAObject(a); + if (a.aString != null) + return "AServiceNotPassByValue"; + + AObject c = new AObject(); + cService.setAObject(c); + if (c.aString == null || !c.aString.equals("CService")) + return "CServiceNotPassByReference"; + + + AObject h1 = new AObject(); + hService.setAObject1(h1); + if (h1.aString == null || !h1.aString.equals("HService")) + return "HServiceSetAObject1NotPassByReference"; + h1.aString = "testServices"; + if (!hService.getAObject1String().equals("testServices")) + return "HServiceGetAObject1NotPassByReference"; + + AObject h2 = new AObject(); + hService.setAObject2(h2); + if (h2.aString != null) + return "HServiceSetAObject2NotPassByValue"; + h2.aString = "testServices"; + if (!hService.getAObject2String().equals("HService")) + return "HServiceGetAObject1NotPassByValue"; + + AObject h3 = hService.getAObject3(); + h3.aString = "testServices"; + if (!hService.getAObject3String().equals("HService")) + return "HServiceGetAObject3NotPassByValue"; + + AObject i1 = new AObject(); + iService.setAObject1(i1); + if (i1.aString == null || !i1.aString.equals("IService")) + return "IServiceSetAObject1NotPassByReference"; + i1.aString = "testServices"; + if (!iService.getAObject1String().equals("testServices")) + return "IServiceGetAObject1NotPassByReference"; + + AObject i2 = new AObject(); + iService.setAObject2(i2); + if (i2.aString == null || !i2.aString.equals("IService")) + return "IServiceSetAObject2NotPassByReference"; + i2.aString = "testServices"; + if (!iService.getAObject2String().equals("testServices")) + return "IServiceGetAObject2NotPassByReference"; + + AObject i3 = iService.getAObject3(); + i3.aString = "testServices"; + if (!iService.getAObject3String().equals("testServices")) + return "IServiceGetAObject3NotPassByReference"; + + return "None"; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/CServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/CServiceImpl.java new file mode 100644 index 0000000000..3fc23d2f68 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/CServiceImpl.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.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.CService; + +public class CServiceImpl implements CService { + + public String getName() { + return "CService"; + } + + public String setAObject(AObject a) { + a.aString = "CService"; + return "CService"; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/DServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/DServiceImpl.java new file mode 100644 index 0000000000..5b3c73ddd8 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/DServiceImpl.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.DService1; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.DService2; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.DService3; +import org.oasisopen.sca.annotation.Service; + +@Service(interfaces = {DService1.class, DService2.class}) +public class DServiceImpl implements DService1, DService2, DService3 { + + public String getName1() { + return "DService1"; + } + + public String getName2() { + return "DService2"; + } + + public String getName3() { + return "DService3"; + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/EServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/EServiceImpl.java new file mode 100644 index 0000000000..321d019932 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/EServiceImpl.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.EService; +import org.oasisopen.sca.annotation.Service; + +@Service() +public class EServiceImpl implements EService { + + public String getName() { + return "EService"; + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl.java new file mode 100644 index 0000000000..f28fa0c3a7 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl.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.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.FService; +import org.oasisopen.sca.RequestContext; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Service; + +@Service(org.apache.tuscany.sca.vtest.javaapi.annotations.service.FService.class) +public class FServiceImpl implements FService { + + @Context + public RequestContext requestContext; + + public String getName() { + return requestContext.getServiceName(); + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl2.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl2.java new file mode 100644 index 0000000000..79051eea8f --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl2.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.vtest.javaapi.annotations.service.impl; + +import org.oasisopen.sca.annotation.Service; + +@Service(FServiceImpl2.class) +public class FServiceImpl2 extends FServiceImpl { +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/GServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/GServiceImpl.java new file mode 100644 index 0000000000..161cbaa620 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/GServiceImpl.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.GService1; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.GService2; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.RequestContext; + +@Service(interfaces = {GService1.class, GService2.class}) +public class GServiceImpl implements GService1 { + + @Context + public RequestContext requestContext; + + public String getName() { + return "GService"; + } + + public String getServiceName() { + return requestContext.getServiceName(); + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/HServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/HServiceImpl.java new file mode 100644 index 0000000000..02e67b645b --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/HServiceImpl.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.HService; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.RequestContext; +import org.oasisopen.sca.annotation.ComponentName; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; +import org.oasisopen.sca.annotation.AllowsPassByReference; + +@Service(HService.class) +@Scope("REQUEST") +public class HServiceImpl implements HService { + + @ComponentName + protected String componentName; + + private AObject aObject1 = null; + + private AObject aObject2 = null; + + private AObject aObject3 = null; + + public RequestContext requestContext; + + public ComponentContext componentContext; + + public String getName() { + return "HService"; + } + + @AllowsPassByReference + public String setAObject1(AObject a) { + a.aString = "HService"; + aObject1 = a; + return "HService"; + } + + public String setAObject2(AObject a) { + a.aString = "HService"; + aObject2 = a; + return "HService"; + } + + @Context + public void setComponentContext(ComponentContext componentContext) { + this.componentContext = componentContext; + } + + @Context + public void setRequestContext(RequestContext requestContext) { + this.requestContext = requestContext; + } + + public String getComponentName() { + return componentName; + } + + public String getAObject1String() { + return aObject1.aString; + } + + public String getAObject2String() { + return aObject2.aString; + } + + public String getAObject3String() { + return aObject3.aString; + } + + public AObject getAObject3() { + aObject3 = new AObject(); + aObject3.aString = "HService"; + return aObject3; + } + + public String getServiceName1() { + return requestContext.getServiceName(); + } + + public String getServiceName2() { + return componentContext.getRequestContext().getServiceName(); + } + +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/IServiceImpl.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/IServiceImpl.java new file mode 100644 index 0000000000..ea08149eaf --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/IServiceImpl.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.IService; +import org.oasisopen.sca.ComponentContext; +import org.oasisopen.sca.RequestContext; +import org.oasisopen.sca.annotation.AllowsPassByReference; +import org.oasisopen.sca.annotation.ComponentName; +import org.oasisopen.sca.annotation.Context; +import org.oasisopen.sca.annotation.Scope; +import org.oasisopen.sca.annotation.Service; + +@Service(IService.class) +@Scope("REQUEST") +@AllowsPassByReference +public class IServiceImpl implements IService { + + @ComponentName + public String componentName1; + + public String componentName2; + + private AObject aObject1 = null; + + private AObject aObject2 = null; + + private AObject aObject3 = null; + + @Context + public RequestContext requestContext; + + @Context + public ComponentContext componentContext; + + public String getName() { + return "IService"; + } + + public String setAObject1(AObject a) { + a.aString = "IService"; + aObject1 = a; + return "IService"; + } + + public String setAObject2(AObject a) { + a.aString = "IService"; + aObject2 = a; + return "IService"; + } + + @ComponentName + public void setComponentName1(String componentName1) { + this.componentName2 = componentName1; + } + + public String getAObject1String() { + return aObject1.aString; + } + + public String getAObject2String() { + return aObject2.aString; + } + + public String getAObject3String() { + return aObject3.aString; + } + + public AObject getAObject3() { + aObject3 = new AObject(); + aObject3.aString = "IService"; + return aObject3; + } + + public String getComponentName1() { + return componentName1; + } + + public String getComponentName2() { + return componentName2; + } + + public String getServiceName1() { + return requestContext.getServiceName(); + } + + public String getServiceName2() { + return componentContext.getRequestContext().getServiceName(); + } +} diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/resources/service.composite b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/resources/service.composite new file mode 100644 index 0000000000..0731986df2 --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/main/resources/service.composite @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/ServiceAnnotationTestCase.java b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/ServiceAnnotationTestCase.java new file mode 100644 index 0000000000..52f7821ebb --- /dev/null +++ b/sandbox/ant/sca/trunk/vtest/java-api/annotations/service/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/ServiceAnnotationTestCase.java @@ -0,0 +1,335 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +import static org.junit.Assert.fail; +import junit.framework.Assert; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.FServiceImpl2; +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This test class tests the Service annotation described in section 1.2.1 + * including 1.3.1, 1.8.1, 1.8.3, 1.8.6, 1.8.15 and 1.8.17
    + * but not..
    + *

  • Lines 1531 to 1534
  • + */ +public class ServiceAnnotationTestCase { + + protected static String compositeName = "service.composite"; + protected static AService aService = null; + protected static BService bService = null; + protected static BService bService1 = null; + protected static HService hService = null; + protected static IService iService = null; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + aService = ServiceFinder.getService(AService.class, "AComponent"); + bService = ServiceFinder.getService(BService.class, "BComponent"); + bService1 = ServiceFinder.getService(BService.class, "BComponent1"); + hService = ServiceFinder.getService(HService.class, "HComponent"); + iService = ServiceFinder.getService(IService.class, "IComponent"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + + } + + /** + * Line 215:
    + *
  • As a Java interface
  • + *

    + * Line 1622 to 1623:
    + * The + * + * @Service annotation type is used on a component implementation class to + * specify the SCA services offered by the implementation.
    + */ + @Test + public void atService1() throws Exception { + Assert.assertEquals("AService", aService.getName()); + } + + /** + * Line 216:
    + *

  • As a Java class
  • + *

    + * Line 1631:
    + *

  • value – A shortcut for the case when the class provides only a + * single service interface.
  • + */ + @Test + public void atService2() throws Exception { + Assert.assertEquals("BService", bService.getName()); + } + + /** + * Lines 222 to 224:
    + * A remotable service is defined using the "@Remotable" annotation on the + * Java interface that defines the service. Remotable services are intended + * to be used for coarse grained services, and the parameters are passed + * by-value.
    + *

    + * Lines 321 to 323:
    + * The "@Remotable" annotation on a Java interface indicates that the + * interface is designed to be used for remote communication. Remotable + * interfaces are intended to be used for coarse grained services. + * Operations parameters and return values are passed by-value.
    + */ + @Test + public void atService3() throws Exception { + AObject o = new AObject(); + Assert.assertEquals("AService", aService.setAObject(o)); + Assert.assertNull(o.aString); + } + + /** + * Lines 227 to 242:
    + * A local service can only be called by clients that are deployed within + * the same address space as the component implementing the local service.
    + * ...
    + * The data exchange semantic for calls to local services is by-reference.
    + * ...
    + * Lines 996 to 1028:
    + * 1.8.1 "@AllowsPassByReference"
    + * ...
    + * Lines 1535 to 1540:
    + * Independent of whether the remotable service is called from outside of + * the composite that contains it or from another component in the same + * composite, the data exchange semantics are by-value.
    + * Implementations of remotable services may modify input data during or + * after an invocation and may modify return data after the invocation. If a + * remotable service is called locally or remotely, the SCA container is + * responsible for making sure that no modification of input data or + * post-invocation modifications to return data are seen by the caller.
    + *

    + * Test under Non-SCA <-> SCA + *

  • BService is local service to test by reference
  • + *
  • HService is remotable service to test "@AllowsPassByReference" at + * method level
  • + *
  • IService is remotable service to test "@AllowsPassByReference" at + * class level
  • + */ + @Test + public void atService4() throws Exception { + AObject b = new AObject(); + Assert.assertEquals("BService", bService.setAObject(b)); + Assert.assertEquals("BService", b.aString); + + AObject h1 = new AObject(); + Assert.assertEquals("HService", hService.setAObject1(h1)); + Assert.assertEquals("HService", h1.aString); + h1.aString = "atService4"; + Assert.assertEquals("atService4", hService.getAObject1String()); + + AObject h2 = new AObject(); + Assert.assertEquals("HService", hService.setAObject2(h2)); + Assert.assertNull(h2.aString); + h2.aString = "atService4"; + Assert.assertEquals("HService", hService.getAObject2String()); + + AObject h3 = hService.getAObject3(); + h3.aString = "atService4"; + Assert.assertEquals("HService", hService.getAObject3String()); + + AObject i1 = new AObject(); + Assert.assertEquals("IService", iService.setAObject1(i1)); + Assert.assertEquals("IService", i1.aString); + i1.aString = "atService4"; + Assert.assertEquals("atService4", iService.getAObject1String()); + + AObject i2 = new AObject(); + Assert.assertEquals("IService", iService.setAObject2(i2)); + Assert.assertEquals("IService", i2.aString); + i2.aString = "atService4"; + Assert.assertEquals("atService4", iService.getAObject2String()); + + AObject i3 = iService.getAObject3(); + i3.aString = "atService4"; + Assert.assertEquals("atService4", iService.getAObject3String()); + } + + /** + * Line 1624 to 1627:
    + * A class used as the implementation of a service is not required to have + * an "@Service" annotation. If a class has no "@Service" annotation, then + * the rules determining which services are offered and what interfaces + * those services have are determined by the specific implementation type. + *
    + */ + @Test + public void atService5() throws Exception { + CService cService = ServiceFinder.getService(CService.class, "CComponent"); + Assert.assertEquals("CService", cService.getName()); + } + + /** + * Line 1623 to 1624:
    + * The class need not be declared as implementing all of the interfaces + * implied by the services, but all methods of the service interfaces must + * be present.
    + *

    + * Line 1629 to 1630:
    + *

  • interfaces – The value is an array of interface or class objects + * that should be exposed as services by this component.
  • + */ + @Test + public void atService6() throws Exception { + DService1 dService1 = ServiceFinder.getService(DService1.class, "DComponent/DService1"); + Assert.assertEquals("DService1", dService1.getName1()); + DService2 dService2 = ServiceFinder.getService(DService2.class, "DComponent/DService2"); + Assert.assertEquals("DService2", dService2.getName2()); + try { + ServiceFinder.getService(DService3.class, "DComponent/DService3"); + fail("Should have failed to get this service"); + } catch (Exception e) { + // Expect an exception + } + } + + /** + * Line 1635 to 1636:
    + * A "@Service" annotation with no attributes is meaningless, it is the same + * as not having the annotation there at all.
    + */ + @Test + public void atService7() throws Exception { + EService eService = ServiceFinder.getService(EService.class, "EComponent"); + Assert.assertEquals("EService", eService.getName()); + } + + /** + * Line 1637 to 1638:
    + * The service names of the defined services default to the names of the + * interfaces or class, without the package name.
    + */ + @Test + public void atService8() throws Exception { + FService fService = ServiceFinder.getService(FService.class, "FComponent"); + Assert.assertEquals("FService", fService.getName()); + FServiceImpl2 fServiceImpl2 = ServiceFinder.getService(FServiceImpl2.class, "FComponent2"); + Assert.assertEquals("FServiceImpl2", fServiceImpl2.getName()); + fService = ServiceFinder.getService(FService.class, "FComponent2"); + Assert.assertEquals("FServiceImpl2", fService.getName()); + } + + /** + * Line 1639 to 1641:
    + * If a Java implementation needs to realize two services with the same + * interface, then this is achieved through subclassing of the interface. + * The subinterface must not add any methods. Both interfaces are listed in + * the "@Service" annotation of the Java implementation class.
    + */ + @Test + public void atService9() throws Exception { + GService1 gService1 = ServiceFinder.getService(GService1.class, "GComponent/GService1"); + GService2 gService2 = ServiceFinder.getService(GService2.class, "GComponent/GService2"); + Assert.assertEquals("GService", gService1.getName()); + Assert.assertEquals("GService1", gService1.getServiceName()); + Assert.assertEquals("GService", gService2.getName()); + Assert.assertEquals("GService2", gService2.getServiceName()); + } + + /** + * Lines 227 to 242:
    + * A local service can only be called by clients that are deployed within + * the same address space as the component implementing the local service.
    + * ...
    + * The data exchange semantic for calls to local services is by-reference.
    + * ...
    + * Lines 996 to 1028:
    + * 1.8.1 "@AllowsPassByReference"
    + * ...
    + * Lines 1535 to 1540:
    + * Independent of whether the remotable service is called from outside of + * the composite that contains it or from another component in the same + * composite, the data exchange semantics are by-value.
    + * Implementations of remotable services may modify input data during or + * after an invocation and may modify return data after the invocation. If a + * remotable service is called locally or remotely, the SCA container is + * responsible for making sure that no modification of input data or + * post-invocation modifications to return data are seen by the caller.
    + *

    + * Test under SCA <-> SCA
    + *

  • AService is remotable service to test by value
  • + *
  • CService is local service to test by-reference
  • + *
  • HService is remotable service to test "@AllowsPassByReference" at + * method level
  • + *
  • IService is remotable service to test "@AllowsPassByReference" at + * class level
  • + */ + @Test + public void atService10() throws Exception { + Assert.assertEquals("None", bService1.testServices()); + } + + /** + * Lines 1095 to 1124:
    + * 1.8.3. "@ComponentName"
    + * ...
    + * The "@ComponentName" annotation type is used to annotate a Java class + * field or setter method that is used to inject the component name.
    + * ...
    + */ + @Test + public void atService11() throws Exception { + Assert.assertEquals("HComponent", hService.getComponentName()); + Assert.assertNull(iService.getComponentName1()); + Assert.assertEquals("IComponent", iService.getComponentName2()); + } + + /** + * Lines 1164 to 1187:
    + * 1.8.6. "@Context"
    + * ...
    + * The "@Context" annotation type is used to annotate a Java class field or + * a setter method that is used to inject a composite context for the + * component. The type of context to be injected is defined by the type of + * the Java class field or type of the setter method input argument, the + * type is either ComponentContext or RequestContext.
    + * ...
    + *

    + * HService - "@Context" is used to annotate setter methods
    + * IService - "@Context" is used to annotate class fields
    + *
    + */ + @Test + public void atService12() throws Exception { + Assert.assertEquals("HService", hService.getServiceName1()); + Assert.assertEquals("HService", hService.getServiceName2()); + Assert.assertEquals("IService", iService.getServiceName1()); + Assert.assertEquals("IService", iService.getServiceName2()); + } +} -- cgit v1.2.3