summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test')
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.componentType23
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.java36
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldService.java27
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldWithFieldProperties.java40
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorld.java26
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorldWithInterface.java28
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountReport.java32
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.java25
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.wsdl78
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java42
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountSummary.java46
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java26
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java48
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java39
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java39
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/StockAccount.java48
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java24
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java28
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl98
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaContextFactoryBuilderTestCase.java112
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilderTestCase.java132
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockHandlerBuilder.java120
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockInterceptorBuilder.java66
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/DifferentInterfaceWireTestCase.java81
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextLifecycleTestCase.java59
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextMetadataInjectionTestCase.java58
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextNegativeMetadataTestCase.java73
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextScopeTestCase.java95
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/MultiplicityTestCase.java77
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProvider.java24
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProviderImpl.java42
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java29
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java61
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCTestCase.java59
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java24
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java61
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java189
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java68
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java53
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/StartStopTestCase.java68
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EPtoExternalServiceTestCase.java99
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java261
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/ExternalServiceProxyInvokeTestCase.java73
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java61
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java741
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/MediationTestCase.java53
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/ScopedPojoInvokerTestCase.java53
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/StaticPojoInvokerTestCase.java154
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java38
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java45
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSource.java25
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSourceImpl.java36
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTarget.java28
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTargetImpl.java39
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/loader/JavaImplementationLoaderTestCase.java134
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java64
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockContextFactory.java92
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockFactory.java819
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockScopeContext.java131
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java58
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java114
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java76
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java37
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointContextFactory.java31
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceContextFactory.java32
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceTargetInvoker.java78
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/AbstractGenericComponent.java296
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadContextPojo.java26
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadNamePojo.java24
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/DataObject.java38
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/GenericComponent.java142
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/HelloWorldClient.java46
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/LocalComponentImpl.java97
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponent.java31
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.componentType32
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.java38
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeDestroyOnlyComponent.java34
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitComponent.java39
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitDestroyComponent.java33
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java37
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java41
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/OtherTarget.java27
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/OtherTargetImpl.java35
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableService.java40
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableServiceImpl.java61
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponent.java28
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponentImpl.java25
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeDestroyOnlyComponent.java36
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeInitDestroyComponent.java36
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeInitOnlyComponent.java37
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponent.java28
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponentImpl.java28
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeDestroyOnlyComponent.java34
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitDestroyComponent.java34
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitOnlyComponent.java35
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/Source.java32
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SourceImpl.java63
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponent.java28
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponentImpl.java25
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/Target.java27
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/TargetImpl.java33
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicModuleScopeTestCase.java139
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicRequestScopeTestCase.java158
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicSessionScopeTestCase.java238
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicStatelessScopeTestCase.java129
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/CompositeScopeTestCase.java188
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/DependencyLifecycleTestCase.java93
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/ModuleScopeLifecycleTestCase.java248
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderException.java38
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedDependentPojo.java34
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedEagerInitPojo.java56
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedInitPojo.java56
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopeLifecycleTestCase.java166
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopedOrderedInitPojo.java56
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/SessionScopeLifecycleTestCase.java176
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/SessionScopedOrderedInitPojo.java56
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworld/example.wsdl23
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworld/sca.module32
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworldmc/sca.module40
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/org/apache/tuscany/container/java/assembly/tests/sca.module54
-rw-r--r--sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/org/apache/tuscany/container/java/config/ModuleComponentLoaderTest1.module24
121 files changed, 9326 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.componentType b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..784d8bf728
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.componentType
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.java.assembly.mock.HelloWorldService" remoteable="true"/>
+ </service>
+ <property name="text" type="xsd:string"/>
+</componentType> \ No newline at end of file
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.java
new file mode 100644
index 0000000000..74f4c658ce
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldImpl.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldImpl implements HelloWorldService {
+
+ private String text;
+
+ private int count;
+
+ public String hello(String name) {
+ ++count;
+ return "Hello " + name;
+ }
+
+ public int count() {
+ return count;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldService.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldService.java
new file mode 100644
index 0000000000..a7d0fe7788
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldService.java
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface HelloWorldService {
+ String hello(String name);
+
+ public int count();
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldWithFieldProperties.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldWithFieldProperties.java
new file mode 100644
index 0000000000..0801c56f44
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/HelloWorldWithFieldProperties.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.mock;
+
+import org.osoa.sca.annotations.Property;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldWithFieldProperties {
+ @Property
+ protected String text;
+
+ @Property(required = true)
+ public Integer text2;
+
+ @Property(name = "foo")
+ public int text3;
+
+ @Property(name = "not exposed")
+ protected int field4;
+
+ public String hello(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorld.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorld.java
new file mode 100644
index 0000000000..2f1ae5d17b
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorld.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NakedHelloWorld {
+ public String hello(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorldWithInterface.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorldWithInterface.java
new file mode 100644
index 0000000000..9d5fe5e969
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/mock/NakedHelloWorldWithInterface.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.mock;
+
+import java.io.Serializable;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NakedHelloWorldWithInterface implements Serializable {
+ public String hello(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountReport.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountReport.java
new file mode 100644
index 0000000000..1770c2b011
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountReport.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.account;
+
+import java.util.List;
+
+/**
+ * @model
+ */
+
+public interface AccountReport {
+
+ /**
+ * @model type="services.account.AccountSummary"
+ */
+
+ List getAccountSummaries();
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.java
new file mode 100644
index 0000000000..1bb938655f
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface AccountService {
+
+ public AccountReport getAccountReport(String customerID);
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.wsdl b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.wsdl
new file mode 100644
index 0000000000..022258f2c5
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountService.wsdl
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/AccountService/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.bigbank.com/AccountService/"
+
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/AccountService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReport"/>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummary" type="tns:AccountSummary" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AccountSummary">
+ <xsd:sequence>
+ <xsd:element name="accountNumber" type="xsd:string"/>
+ <xsd:element name="accountType" type="xsd:string"/>
+ <xsd:element name="balance" type="xsd:float"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="getAccountReportRequest">
+ <wsdl:part element="tns:customerID" name="getAccountReportRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportResponse">
+ <wsdl:part element="tns:getAccountReportResponse" name="getAccountReportResponse"/>
+ </wsdl:message>
+ <wsdl:portType name="AccountService">
+ <wsdl:operation name="getAccountReport">
+ <wsdl:input message="tns:getAccountReportRequest"/>
+ <wsdl:output message="tns:getAccountReportResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="AccountServiceSOAP" type="tns:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/AccountService/getAccountReport"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location="http://localhost:8080/tuscany-container-java/services/AccountService"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..9a5ddb0005
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata.AccountDataService;
+import org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.stockquote.StockQuoteService;
+
+public class AccountServiceImpl implements AccountService {
+
+ @Property
+ public String currency = "USD";
+
+ @Reference
+ public AccountDataService accountDataService;
+ @Reference
+ public StockQuoteService stockQuoteService;
+
+ public AccountServiceImpl() {
+ }
+
+ public AccountReport getAccountReport(String customerID) {
+ return null;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountSummary.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountSummary.java
new file mode 100644
index 0000000000..2b11e23425
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/account/AccountSummary.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.account;
+
+/**
+ * @model
+ */
+
+public interface AccountSummary {
+
+ /**
+ * @model
+ */
+ String getAccountNumber();
+
+ void setAccountNumber(String accountNumber);
+
+ /**
+ * @model
+ */
+ String getAccountType();
+
+ void setAccountType(String accountType);
+
+ /**
+ * @model
+ */
+ float getBalance();
+
+ void setBalance(float balance);
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..56f24ea4ac
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata;
+
+public interface AccountDataService {
+
+ CheckingAccount getCheckingAccount(String customerID);
+
+ SavingsAccount getSavingsAccount(String customerID);
+
+ StockAccount getStockAccount(String customerID);
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..a7a40f954d
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata;
+
+public class AccountDataServiceImpl implements AccountDataService {
+
+ public CheckingAccount getCheckingAccount(String customerID) {
+
+ CheckingAccount checkingAccount = new CheckingAccount();
+ checkingAccount.setAccountNumber(customerID + "_" + "CHA12345");
+ checkingAccount.setBalance(1500.0f);
+
+ return checkingAccount;
+ }
+
+ public SavingsAccount getSavingsAccount(String customerID) {
+
+ SavingsAccount savingsAccount = new SavingsAccount();
+ savingsAccount.setAccountNumber(customerID + "_" + "SAA12345");
+ savingsAccount.setBalance(1500.0f);
+
+ return savingsAccount;
+ }
+
+ public StockAccount getStockAccount(String customerID) {
+
+ StockAccount stockAccount = new StockAccount();
+ stockAccount.setAccountNumber(customerID + "_" + "STA12345");
+ stockAccount.setSymbol("IBM");
+ stockAccount.setQuantity(100);
+
+ return stockAccount;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
new file mode 100644
index 0000000000..ff84e9968a
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata;
+
+public class CheckingAccount {
+
+ private String accountNumber;
+ private float balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
new file mode 100644
index 0000000000..b39d9051de
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata;
+
+public class SavingsAccount {
+
+ private String accountNumber;
+ private float balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/StockAccount.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
new file mode 100644
index 0000000000..bce0821b25
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata;
+
+public class StockAccount {
+
+ private String accountNumber;
+ private String symbol;
+ private int quantity;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..78ece12b41
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.stockquote;
+
+public interface StockQuoteService {
+
+ public float getQuote(String symbol);
+}
+
+ \ No newline at end of file
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
new file mode 100644
index 0000000000..fa180d0ceb
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.stockquote;
+
+/* Dummy'd up StockQuoteService, override webservice for now */
+
+public class StockQuoteServiceImpl implements StockQuoteService {
+
+ public float getQuote(String symbol) {
+ // Just hardcode for now
+ return 83.00f;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
new file mode 100644
index 0000000000..6af61ef80e
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<wsdl:definitions targetNamespace="http://webservice.stockquote" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.stockquote" xmlns:intf="http://webservice.stockquote" xmlns:tns1="http://stockquote" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="stockquote">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="GetQuoteRequest">
+ <sequence>
+ <element name="symbol" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="GetQuoteResponse">
+ <sequence>
+ <element name="price" type="xsd:float"/>
+ </sequence>
+ </complexType>
+ </schema>
+ <schema elementFormDefault="qualified" targetNamespace="http://webservice.stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://stockquote"/>
+ <element name="request" type="tns1:GetQuoteRequest"/>
+ <element name="getQuoteReturn" type="tns1:GetQuoteResponse"/>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getQuoteResponse">
+
+ <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getQuoteRequest">
+
+ <wsdl:part element="impl:request" name="request"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="StockQuoteWebService">
+
+ <wsdl:operation name="getQuote" parameterOrder="request">
+
+ <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/>
+
+ <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockQuoteWebServiceSoapBinding" type="impl:StockQuoteWebService">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getQuote">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getQuoteRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getQuoteResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuoteWebServiceService">
+
+ <wsdl:port binding="impl:StockQuoteWebServiceSoapBinding" name="StockQuoteWebService">
+
+ <wsdlsoap:address location="http://localhost:8123/StockQuoteWebService/services/StockQuoteWebService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaContextFactoryBuilderTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaContextFactoryBuilderTestCase.java
new file mode 100644
index 0000000000..fcfd320e0e
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaContextFactoryBuilderTestCase.java
@@ -0,0 +1,112 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.builder;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponent;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.core.context.ScopeStrategy;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.wire.WireConfiguration;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.Module;
+
+public class JavaContextFactoryBuilderTestCase extends TestCase {
+
+ public JavaContextFactoryBuilderTestCase() {
+ }
+
+ public void testBuilder() throws Exception {
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, true);
+ PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
+ policyRegistry.registerSourceBuilder(interceptorBuilder);
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+
+ JavaTargetWireBuilder javaWireBuilder = new JavaTargetWireBuilder();
+ ScopeStrategy strategy = new DefaultScopeStrategy();
+ DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
+ wireBuilder.addWireBuilder(javaWireBuilder);
+ Module module = MockFactory.createModule();
+ EventContext eCtx = new EventContextImpl();
+ ScopeContext scopeContext = new ModuleScopeContext(eCtx);
+ scopeContext.start();
+ scopeContext.onEvent(new ModuleStart(this));
+ List<Component> components = module.getComponents();
+ Map<String, Component> compMap = new HashMap<String, Component>(components.size());
+
+ for (Component component : components) {
+ compMap.put(component.getName(), component);
+ builder.build(component);
+ ContextFactory contextFactory = (ContextFactory) component.getContextFactory();
+ Assert.assertNotNull(contextFactory);
+ }
+ for (Component component : components) {
+ ContextFactory<Context> source = (ContextFactory<Context>) component.getContextFactory();
+ Assert.assertNotNull(source);
+ for (SourceWireFactory pFactory : source.getSourceWireFactories()) {
+ WireConfiguration pConfig = pFactory.getConfiguration();
+ Component target = compMap.get(pConfig.getTargetName().getPartName());
+
+ if (target != null) {
+ ContextFactory targetConfig = (ContextFactory) target.getContextFactory();
+ boolean downScope = strategy.downScopeReference(source.getScope(), targetConfig.getScope());
+ wireBuilder.connect(pFactory, targetConfig.getTargetWireFactory(pFactory.getConfiguration().getTargetName()
+ .getPortName()), targetConfig.getClass(), downScope, scopeContext);
+ }
+ pFactory.initialize();
+ }
+ scopeContext.registerFactory(source);
+ }
+ for (Component component : components) {
+ ContextFactory config = (ContextFactory) component.getContextFactory();
+ Context context = config.createContext();
+ if ("source".equals(component.getName())) {
+ ModuleScopeComponent source = (ModuleScopeComponent) context.getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent gComp = source.getGenericComponent();
+ gComp.getString();
+ }
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilderTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilderTestCase.java
new file mode 100644
index 0000000000..5a0ee8e14c
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/JavaTargetWireBuilderTestCase.java
@@ -0,0 +1,132 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.builder;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.config.JavaContextFactory;
+import org.apache.tuscany.container.java.invocation.mock.MockHandler;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.invocation.mock.SimpleTarget;
+import org.apache.tuscany.container.java.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.container.java.mock.MockScopeContext;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.wire.MethodHashMap;
+import org.apache.tuscany.core.wire.impl.InvokerInterceptor;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.WireSourceConfiguration;
+import org.apache.tuscany.core.wire.WireTargetConfiguration;
+import org.apache.tuscany.core.wire.SourceInvocationConfiguration;
+import org.apache.tuscany.core.wire.TargetInvocationConfiguration;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+public class JavaTargetWireBuilderTestCase extends TestCase {
+
+ private Method hello;
+
+ public JavaTargetWireBuilderTestCase() {
+ }
+
+ public JavaTargetWireBuilderTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ hello = SimpleTarget.class.getMethod("hello", String.class);
+ }
+
+
+ /**
+ * Tests basic wiring of a source to a target, including handlers and interceptors
+ */
+ public void testInvocation() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ SourceInvocationConfiguration source = new SourceInvocationConfiguration(hello);
+ MockHandler sourceRequestHandler = new MockHandler();
+ MockHandler sourceResponseHandler = new MockHandler();
+ MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
+ source.addRequestHandler(sourceRequestHandler);
+ source.addResponseHandler(sourceResponseHandler);
+ source.addInterceptor(sourceInterceptor);
+
+ SourceWireFactory sourceFactory = new JDKWireFactoryFactory().createSourceWireFactory();
+ Map<Method, SourceInvocationConfiguration> sourceInvocationConfigs = new MethodHashMap<SourceInvocationConfiguration>();
+ sourceInvocationConfigs.put(hello, source);
+ WireSourceConfiguration sourceConfig = new WireSourceConfiguration("foo",new QualifiedName("target/SimpleTarget"),
+ sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ sourceFactory.setConfiguration(sourceConfig);
+ sourceFactory.setBusinessInterface(SimpleTarget.class);
+
+ TargetInvocationConfiguration target = new TargetInvocationConfiguration(hello);
+ MockHandler targetRequestHandler = new MockHandler();
+ MockHandler targetResponseHandler = new MockHandler();
+ MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
+ target.addRequestHandler(targetRequestHandler);
+ target.addResponseHandler(targetResponseHandler);
+ target.addInterceptor(targetInterceptor);
+ target.addInterceptor(new InvokerInterceptor());
+
+ TargetWireFactory targetFactory = new JDKWireFactoryFactory().createTargetWireFactory();
+ Map<Method, TargetInvocationConfiguration> targetInvocationConfigs = new MethodHashMap<TargetInvocationConfiguration>();
+ targetInvocationConfigs.put(hello, target);
+ WireTargetConfiguration targetConfig = new WireTargetConfiguration(new QualifiedName("target/SimpleTarget"),
+ targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
+ targetFactory.setConfiguration(targetConfig);
+ targetFactory.setBusinessInterface(SimpleTarget.class);
+
+ // bootstrap a scope container with the target in it
+ Map<String,Object> instances = new HashMap<String,Object>();
+ SimpleTarget simpleTarget = new SimpleTargetImpl();
+ instances.put("target",simpleTarget);
+ MockScopeContext scopeCtx = new MockScopeContext(instances);
+
+ // connect the source to the target
+ DefaultWireBuilder builder = new DefaultWireBuilder();
+ builder.addWireBuilder(new JavaTargetWireBuilder());
+
+ builder.connect(sourceFactory, targetFactory, JavaContextFactory.class, true, scopeCtx);
+ source.build();
+ target.build();
+ Assert.assertNotNull(source.getTargetInvoker());
+
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ msg.setTargetInvoker(source.getTargetInvoker());
+ Message response = source.getHeadInterceptor().invoke(msg);
+ Assert.assertEquals("foo", response.getBody());
+ Assert.assertEquals(1, sourceRequestHandler.getCount());
+ Assert.assertEquals(1, sourceResponseHandler.getCount());
+ Assert.assertEquals(1, sourceInterceptor.getCount());
+ Assert.assertEquals(1, targetRequestHandler.getCount());
+ Assert.assertEquals(1, targetResponseHandler.getCount());
+ Assert.assertEquals(1, targetInterceptor.getCount());
+ }
+
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockHandlerBuilder.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockHandlerBuilder.java
new file mode 100644
index 0000000000..bd1c13c4ac
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockHandlerBuilder.java
@@ -0,0 +1,120 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.builder;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.SourcePolicyBuilder;
+import org.apache.tuscany.core.builder.TargetPolicyBuilder;
+import org.apache.tuscany.core.wire.InvocationConfiguration;
+import org.apache.tuscany.core.wire.MessageHandler;
+import org.apache.tuscany.core.wire.SourceInvocationConfiguration;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetInvocationConfiguration;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.core.wire.WireSourceConfiguration;
+import org.apache.tuscany.core.wire.WireTargetConfiguration;
+import org.apache.tuscany.model.assembly.AssemblyObject;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+
+import java.util.List;
+
+/**
+ * Adds a handler to a source or target proxy configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockHandlerBuilder implements SourcePolicyBuilder, TargetPolicyBuilder {
+
+
+ private MessageHandler handler;
+
+ private boolean source;
+
+ private boolean request;
+
+ /**
+ * Creates the builder.
+ *
+ * @param handler the handler to add to the source or target proxy configuration
+ * @param source true if the handler should be added on the source side; false if the handler should be added to the target
+ * side
+ * @param request true if the handler is a request handler; false if the handler is a response handler
+ */
+ public MockHandlerBuilder(MessageHandler handler, boolean source, boolean request) {
+ this.handler = handler;
+ this.source = source;
+ this.request = request;
+ }
+
+ public void build(AssemblyObject modelObject) throws BuilderException {
+ if (source) {
+ if (!(modelObject instanceof ConfiguredReference)) {
+ return;
+ } else {
+ ConfiguredReference cref = (ConfiguredReference) modelObject;
+ // /xcv WireFactory pFactory = (WireFactory) cref.getProxyFactory();
+ for (ConfiguredService configuredService : cref.getTargetConfiguredServices()) {
+ SourceWireFactory pFactory = (SourceWireFactory) configuredService.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getConfiguration().getInvocationConfigurations().values()) {
+ if (request) {
+ config.addRequestHandler(handler);
+ } else {
+ config.addResponseHandler(handler);
+ }
+ }
+ }
+ }
+ } else {
+ if (!(modelObject instanceof ConfiguredService)) {
+ return;
+ } else {
+ ConfiguredService cservice = (ConfiguredService) modelObject;
+ TargetWireFactory pFactory = (TargetWireFactory) cservice.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getConfiguration().getInvocationConfigurations().values()) {
+ if (request) {
+ config.addRequestHandler(handler);
+ } else {
+ config.addResponseHandler(handler);
+ }
+ }
+ }
+
+ }
+ }
+
+ public void build(ConfiguredReference reference, List<WireSourceConfiguration> configurations) throws BuilderException {
+ for (WireSourceConfiguration wireSourceConfiguration : configurations) {
+ for (SourceInvocationConfiguration configuration : wireSourceConfiguration.getInvocationConfigurations().values()) {
+ if (request) {
+ configuration.addRequestHandler(handler);
+ } else {
+ configuration.addResponseHandler(handler);
+ }
+
+ }
+
+ }
+ }
+
+ public void build(ConfiguredService service, WireTargetConfiguration configuration) throws BuilderException {
+ for (TargetInvocationConfiguration config : configuration.getInvocationConfigurations().values()) {
+ if (request) {
+ config.addRequestHandler(handler);
+ } else {
+ config.addResponseHandler(handler);
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockInterceptorBuilder.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockInterceptorBuilder.java
new file mode 100644
index 0000000000..d3ad8a53b5
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/MockInterceptorBuilder.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.builder;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.SourcePolicyBuilder;
+import org.apache.tuscany.core.builder.TargetPolicyBuilder;
+import org.apache.tuscany.core.wire.Interceptor;
+import org.apache.tuscany.core.wire.SourceInvocationConfiguration;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetInvocationConfiguration;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.core.wire.WireFactory;
+import org.apache.tuscany.core.wire.WireSourceConfiguration;
+import org.apache.tuscany.core.wire.WireTargetConfiguration;
+import org.apache.tuscany.model.assembly.AssemblyObject;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+
+import java.util.List;
+
+/**
+ * Adds an interceptor to a source or target proxy configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockInterceptorBuilder implements SourcePolicyBuilder, TargetPolicyBuilder {
+
+ private Interceptor interceptor;
+
+ /**
+ * Creates the builder
+ *
+ * @param interceptor the interceptor ot add
+ * @param source true if the interceptor should be added to the source side; false if the interceptor should be added to
+ * the target side
+ */
+ public MockInterceptorBuilder(Interceptor interceptor, boolean source) {
+ this.interceptor = interceptor;
+ }
+
+ public void build(ConfiguredReference reference, List<WireSourceConfiguration> configurations) throws BuilderException {
+ for (WireSourceConfiguration wireSourceConfiguration : configurations) {
+ for (SourceInvocationConfiguration configuration : wireSourceConfiguration.getInvocationConfigurations().values()) {
+ configuration.addInterceptor(interceptor);
+ }
+ }
+ }
+
+ public void build(ConfiguredService service, WireTargetConfiguration configuration) throws BuilderException {
+ for (TargetInvocationConfiguration config : configuration.getInvocationConfigurations().values()) {
+ config.addInterceptor(interceptor);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/DifferentInterfaceWireTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/DifferentInterfaceWireTestCase.java
new file mode 100644
index 0000000000..ed91b9cb9b
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/DifferentInterfaceWireTestCase.java
@@ -0,0 +1,81 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.context;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.builder.JavaTargetWireBuilder;
+import org.apache.tuscany.container.java.mock.MockConfigContext;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.OtherTarget;
+import org.apache.tuscany.container.java.mock.components.Source;
+import org.apache.tuscany.container.java.mock.components.Target;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.AtomicContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.impl.CompositeContextImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests wires that have different interfaces on the source and target side
+ *
+ * @version $Rev$ $Date$
+ */
+public class DifferentInterfaceWireTestCase extends TestCase {
+
+ public void testMultiplicity() throws Exception {
+
+ CompositeContext context = createContext();
+ context.start();
+ context.registerModelObject(MockFactory.createModuleWithWiredComponentsOfDifferentInterface(Scope.MODULE, Scope.MODULE));
+ context.publish(new ModuleStart(this));
+ Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
+ Assert.assertNotNull(source);
+ OtherTarget target = (OtherTarget) ((AtomicContext)context.getContext("target")).getTargetInstance();
+ Assert.assertNotNull(target);
+ // test setter injection
+ List<Target> targets = source.getTargets();
+ Assert.assertEquals(1, targets.size());
+
+ // test field injection
+ targets = source.getTargetsThroughField();
+ Assert.assertEquals(1, targets.size());
+ targets.get(0).setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ }
+
+ private CompositeContext createContext() {
+ CompositeContextImpl context = new CompositeContextImpl();
+ context.setName("system.context");
+ List<ContextFactoryBuilder>builders = MockFactory.createSystemBuilders();
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ builders.add(new JavaContextFactoryBuilder(wireService));
+ List<WireBuilder> wireBuilders = new ArrayList<WireBuilder>();
+ wireBuilders.add(new JavaTargetWireBuilder());
+ context.setConfigurationContext(new MockConfigContext(builders,wireBuilders));
+ return context;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextLifecycleTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextLifecycleTestCase.java
new file mode 100644
index 0000000000..c257a1f892
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextLifecycleTestCase.java
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.context;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitOnlyComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.impl.CompositeContextImpl;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests init and destroy lifecycle callbacks are handled properly
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaAtomicContextLifecycleTestCase extends TestCase {
+
+ public void testComponentNameSet() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("mc");
+ JavaAtomicContext context = MockFactory.createPojoContext("TestServiceInit",
+ ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
+ context.start();
+ ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
+ Assert.assertNotNull(instance);
+ Assert.assertEquals("TestServiceInit", instance.getName());
+ context.stop();
+ }
+
+ public void testModuleContextSet() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("mc");
+ JavaAtomicContext context = MockFactory.createPojoContext("TestServiceInit",
+ ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
+ context.start();
+ ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
+ Assert.assertNotNull(instance);
+ Assert.assertEquals(mc, instance.getModuleContext());
+ context.stop();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextMetadataInjectionTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextMetadataInjectionTestCase.java
new file mode 100644
index 0000000000..a79a04f5ab
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextMetadataInjectionTestCase.java
@@ -0,0 +1,58 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.context;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.impl.CompositeContextImpl;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitOnlyComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests SCA metadata such as <code>@ComponentName</code> and <code>@Context</code> are handled properly
+ *
+ * @version $Rev: 394173 $ $Date: 2006-04-14 11:54:59 -0700 (Fri, 14 Apr 2006) $
+ */
+public class JavaAtomicContextMetadataInjectionTestCase extends TestCase {
+
+ public void testComponentNameSet() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("mc");
+ JavaAtomicContext context = MockFactory.createPojoContext("TestServiceInit",
+ ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
+ context.start();
+ ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
+ Assert.assertNotNull(instance);
+ Assert.assertEquals("TestServiceInit", instance.getName());
+ context.stop();
+ }
+
+ public void testModuleContextSet() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("mc");
+ JavaAtomicContext context = MockFactory.createPojoContext("TestServiceInit",
+ ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
+ context.start();
+ ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
+ Assert.assertNotNull(instance);
+ Assert.assertEquals(mc, instance.getModuleContext());
+ context.stop();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextNegativeMetadataTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextNegativeMetadataTestCase.java
new file mode 100644
index 0000000000..0a4527f405
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextNegativeMetadataTestCase.java
@@ -0,0 +1,73 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.context;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.BadContextPojo;
+import org.apache.tuscany.container.java.mock.components.BadNamePojo;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.impl.CompositeContextImpl;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Performs rudimentary negative testing by using malformed metadata on a POJO
+ *
+ * @version $Rev $Date
+ */
+public class JavaAtomicContextNegativeMetadataTestCase extends TestCase {
+
+ /**
+ * Tests that a pojo with <code>@ComponentName</code> specified on a non-String type generates an error.
+ * <p/>
+ * <strong>NB:</strong> the test assumes an error with a message containing
+ * "@ComponentName" is generated
+ */
+ public void testBadNameType() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("mc");
+ try {
+ MockFactory.createPojoContext("BadNamePojo", BadNamePojo.class, Scope.MODULE, mc);
+ } catch (NoSuchMethodException e) {
+ if (e.getMessage().indexOf("@ComponentName") < 0) {
+ throw e;
+ }
+ }
+
+ }
+
+ /**
+ * Tests that a pojo with <code>@Context</code> specified on a non-ModuleContext type generates an error.
+ * <p/>
+ * <strong>NB:</strong> the test assumes an error with a message containing
+ * "@Context" is generated
+ */
+ public void testContextType() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("mc");
+ try {
+ MockFactory.createPojoContext("BadContextPojo", BadContextPojo.class, Scope.MODULE, mc);
+ } catch (NoSuchMethodException e) {
+ if (e.getMessage().indexOf("@Context") < 0) {
+ throw e;
+ }
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextScopeTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextScopeTestCase.java
new file mode 100644
index 0000000000..96bff0cf2e
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextScopeTestCase.java
@@ -0,0 +1,95 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.context;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.RequestScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.SessionScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.StatelessComponentImpl;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.impl.CompositeContextImpl;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * Tests {@link JavaAtomicContext} to ensure it handles component scopes properly
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaAtomicContextScopeTestCase extends TestCase {
+
+ JavaAssemblyFactory factory = new JavaAssemblyFactoryImpl();
+
+ public void testGetModuleInstance() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("mc");
+ JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<ModuleScopeComponentImpl>(JavaIntrospectionHelper
+ .getDefaultConstructor(ModuleScopeComponentImpl.class), null, null), false, null, null, false);
+ GenericComponent service = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service);
+ service.setString("foo");
+ GenericComponent service2 = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service2);
+ Assert.assertSame(service, service2);
+ }
+
+ public void testGetSessionInstance() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("mc");
+ JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<SessionScopeComponentImpl>(JavaIntrospectionHelper
+ .getDefaultConstructor(SessionScopeComponentImpl.class), null, null), false, null, null, false);
+ GenericComponent service = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service);
+ service.setString("foo");
+ GenericComponent service2 = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service2);
+ Assert.assertSame(service, service2);
+ }
+
+ public void testGetRequestInstance() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("mc");
+ JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<RequestScopeComponentImpl>(JavaIntrospectionHelper
+ .getDefaultConstructor(RequestScopeComponentImpl.class), null, null), false, null, null, false);
+ GenericComponent service = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service);
+ service.setString("foo");
+ GenericComponent service2 = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service2);
+ Assert.assertSame(service, service2);
+ }
+
+ public void testGetStatelessInstance() throws Exception {
+ CompositeContext mc = new CompositeContextImpl();
+ mc.setName("fooContext");
+ JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<StatelessComponentImpl>(JavaIntrospectionHelper
+ .getDefaultConstructor(StatelessComponentImpl.class), null, null), false, null, null, true);
+ GenericComponent service = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service);
+ service.setString("foo");
+ GenericComponent service2 = (GenericComponent) c.getInstance(null);
+ Assert.assertNotNull(service2);
+ Assert.assertTrue(!"foo".equals(service2.getString()));
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/MultiplicityTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/MultiplicityTestCase.java
new file mode 100644
index 0000000000..a22a8dfce2
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/MultiplicityTestCase.java
@@ -0,0 +1,77 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.context;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.builder.JavaTargetWireBuilder;
+import org.apache.tuscany.container.java.mock.MockConfigContext;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.Source;
+import org.apache.tuscany.container.java.mock.components.Target;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.AtomicContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.impl.CompositeContextImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests wires that are configured with a multiplicity
+ *
+ * @version $Rev$ $Date$
+ */
+public class MultiplicityTestCase extends TestCase {
+
+ public void testMultiplicity() throws Exception {
+ CompositeContext context = createContext();
+ context.start();
+ context.registerModelObject(MockFactory.createModuleWithWiredComponents(Scope.MODULE, Scope.MODULE));
+ context.publish(new ModuleStart(this));
+ Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
+ Assert.assertNotNull(source);
+ Target target = (Target) ((AtomicContext)context.getContext("target")).getTargetInstance();
+ Assert.assertNotNull(target);
+ // test setter injection
+ List<Target> targets = source.getTargets();
+ Assert.assertEquals(1, targets.size());
+
+ // test field injection
+ targets = source.getTargetsThroughField();
+ Assert.assertEquals(1, targets.size());
+ }
+
+ private CompositeContext createContext() {
+ CompositeContextImpl context = new CompositeContextImpl();
+ context.setName("system.context");
+ List<ContextFactoryBuilder>builders = MockFactory.createSystemBuilders();
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ builders.add(new JavaContextFactoryBuilder(wireService));
+ List<WireBuilder> wireBuilders = new ArrayList<WireBuilder>();
+ wireBuilders.add(new JavaTargetWireBuilder());
+ context.setConfigurationContext(new MockConfigContext(builders,wireBuilders));
+ return context;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProvider.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProvider.java
new file mode 100644
index 0000000000..58180674b3
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProvider.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface GreetingProvider {
+ String getGreeting(String name, String locale);
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProviderImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProviderImpl.java
new file mode 100644
index 0000000000..fef068c22e
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProviderImpl.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Service(GreetingProvider.class)
+public class GreetingProviderImpl implements GreetingProvider {
+
+ public String greeting;
+
+ @Property
+ public void setGreeting(String greeting) {
+ this.greeting = greeting;
+ }
+
+ public String getGreeting(String name, String locale) {
+ if ("fr".equals(locale)) {
+ return "Bonjour " + name;
+ } else {
+ return greeting + name;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java
new file mode 100644
index 0000000000..9ff58f2d8d
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java
new file mode 100644
index 0000000000..aa5069c232
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+import org.apache.tuscany.core.sdo.helper.SDOHelper;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.DataFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldMCImpl implements HelloWorldService {
+
+ @Property
+ public String locale;
+
+ public String getBar() {
+ return bar;
+ }
+
+ @Property(name= "bar", required=true)
+ public void setXBar(String bar) {
+ this.bar = bar;
+ }
+
+ public String bar;
+
+ @Reference(name="greetingProvider")
+ public void setGreetingProvider(GreetingProvider greetingProvider) {
+ this.greetingProvider2 = greetingProvider;
+ }
+
+ public GreetingProvider greetingProvider2;
+
+ @Reference(required=false)
+ public GreetingProvider foo;
+
+ public String getGreetings(String name) {
+ return greetingProvider2.getGreeting(name, locale);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCTestCase.java
new file mode 100644
index 0000000000..5a73abd45a
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCTestCase.java
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.client.TuscanyRuntime;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldMCTestCase extends TestCase {
+ private ClassLoader oldCL;
+
+ public void testHelloWorld() throws Exception {
+ TuscanyRuntime tuscany = new TuscanyRuntime("test", "foo");
+ tuscany.start();
+ ModuleContext moduleContext = CurrentModuleContext.getContext();
+ assertNotNull(moduleContext);
+ assertEquals("foo", moduleContext.getURI());
+ HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
+ assertNotNull(helloworldService);
+
+ String value = helloworldService .getGreetings("World");
+ assertEquals("Hello World", value);
+ tuscany.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ URL url = getClass().getResource("/helloworldmc/");
+ ClassLoader cl = new URLClassLoader(new URL[]{url}, getClass().getClassLoader());
+ oldCL = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ protected void tearDown() throws Exception {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java
new file mode 100644
index 0000000000..3abb99d7e0
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface HelloWorldService {
+ public String getGreetings(String name);
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java
new file mode 100644
index 0000000000..c714b416e4
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.TestCase;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+
+import org.apache.tuscany.core.client.TuscanyRuntime;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldTestCase extends TestCase {
+ private ClassLoader oldCL;
+
+ public void testHelloWorld() throws Exception {
+ TuscanyRuntime tuscany = new TuscanyRuntime("test", null);
+ tuscany.start();
+ ModuleContext moduleContext = CurrentModuleContext.getContext();
+ assertNotNull(moduleContext);
+
+ HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
+ assertNotNull(helloworldService);
+
+ String value = helloworldService .getGreetings("World");
+ assertEquals("Hello World", value);
+
+ tuscany.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ URL url = getClass().getResource("/helloworld/");
+ ClassLoader cl = new URLClassLoader(new URL[]{url}, getClass().getClassLoader());
+ oldCL = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ protected void tearDown() throws Exception {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java
new file mode 100644
index 0000000000..f7cc2ed149
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java
@@ -0,0 +1,189 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.builder.JavaTargetWireBuilder;
+import org.apache.tuscany.container.java.builder.MockHandlerBuilder;
+import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.java.invocation.mock.MockHandler;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.core.builder.ContextFactoryBuilderRegistry;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
+import org.apache.tuscany.core.client.BootstrapHelper;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.ModuleStop;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+
+/**
+ * Verifies that the composite context implementation and java component builders construct references properly
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaBuilderContextIntegrationTestCase extends TestCase {
+ private ContextFactoryBuilderRegistry builderRegistry;
+ private DefaultWireBuilder defaultWireBuilder;
+ private NullMonitorFactory monitorFactory;
+
+ public JavaBuilderContextIntegrationTestCase(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ monitorFactory = new NullMonitorFactory();
+ builderRegistry = BootstrapHelper.bootstrapContextFactoryBuilders(monitorFactory);
+ defaultWireBuilder = new DefaultWireBuilder();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testRefWithSourceInterceptor() throws Exception {
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, true);
+ PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
+ policyRegistry.registerSourceBuilder(interceptorBuilder);
+ WireFactoryService wireFactory = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
+ JavaContextFactoryBuilder javaBuilder = new JavaContextFactoryBuilder(wireFactory);
+
+ builderRegistry.register(javaBuilder);
+
+ RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, defaultWireBuilder);
+ runtime.addBuilder(new JavaTargetWireBuilder());
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModule());
+ child.publish(new ModuleStart(this));
+ GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ source.getGenericComponent().getString();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ source.getGenericComponent().getString();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+ }
+
+ public void testRefWithSourceInterceptorHandler() throws Exception {
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, true);
+ MockHandler mockHandler = new MockHandler();
+ MockHandlerBuilder handlerBuilder = new MockHandlerBuilder(mockHandler, true, true);
+ PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
+ policyRegistry.registerSourceBuilder(interceptorBuilder);
+ policyRegistry.registerSourceBuilder(handlerBuilder);
+ WireFactoryService wireFactory = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
+ JavaContextFactoryBuilder javaBuilder = new JavaContextFactoryBuilder(wireFactory);
+
+ builderRegistry.register(javaBuilder);
+ RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, defaultWireBuilder);
+ runtime.addBuilder(new JavaTargetWireBuilder());
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModule());
+ child.publish(new ModuleStart(this));
+ GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ source.getGenericComponent().getString();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ Assert.assertEquals(1, mockHandler.getCount());
+ source.getGenericComponent().getString();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ Assert.assertEquals(2, mockHandler.getCount());
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+ }
+
+ public void testRefWithTargetInterceptorHandler() throws Exception {
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ MockHandler mockHandler = new MockHandler();
+ MockHandlerBuilder handlerBuilder = new MockHandlerBuilder(mockHandler, false, true);
+ PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
+ policyRegistry.registerSourceBuilder(interceptorBuilder);
+ policyRegistry.registerSourceBuilder(handlerBuilder);
+ WireFactoryService wireFactory = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
+ JavaContextFactoryBuilder javaBuilder = new JavaContextFactoryBuilder(wireFactory);
+
+ builderRegistry.register(javaBuilder);
+
+ RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, defaultWireBuilder);
+ runtime.addBuilder(new JavaTargetWireBuilder());
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModule());
+ child.publish(new ModuleStart(this));
+ GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ source.getGenericComponent().getString();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ Assert.assertEquals(1, mockHandler.getCount());
+ source.getGenericComponent().getString();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ Assert.assertEquals(2, mockHandler.getCount());
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+ }
+
+ public void testRefWithTargetInterceptor() throws Exception {
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
+ policyRegistry.registerSourceBuilder(interceptorBuilder);
+ WireFactoryService wireFactory = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
+ JavaContextFactoryBuilder javaBuilder = new JavaContextFactoryBuilder(wireFactory);
+
+ builderRegistry.register(javaBuilder);
+
+ RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, defaultWireBuilder);
+ runtime.addBuilder(new JavaTargetWireBuilder());
+
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModule());
+ child.publish(new ModuleStart(this));
+ GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ source.getGenericComponent().getString();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ source.getGenericComponent().getString();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java
new file mode 100644
index 0000000000..a5ec39480f
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java
@@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
+import org.apache.tuscany.core.builder.ContextFactoryBuilderRegistry;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.client.BootstrapHelper;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+
+/**
+ * Integration test that verifies container.java can be used to host components.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaIntegrationTestCase extends TestCase {
+ private JavaAssemblyFactory factory;
+ private RuntimeContext runtime;
+
+ public void testModuleWithOneComponent() throws Exception {
+ Module module = factory.createModule();
+ ModuleComponent moduleComponent = factory.createModuleComponent();
+ moduleComponent.setImplementation(module);
+
+// runtime.registerModelObject(moduleComponent);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Create a factory for model objects
+ factory = new JavaAssemblyFactoryImpl();
+
+ // Create and bootstrap an empty Tuscany runtime
+ MonitorFactory monitorFactory = new NullMonitorFactory();
+ ContextFactoryBuilderRegistry builderRegistry = BootstrapHelper.bootstrapContextFactoryBuilders(monitorFactory);
+ DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
+ runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, wireBuilder);
+ runtime.start();
+ }
+
+ protected void tearDown() throws Exception {
+ runtime.stop();
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java
new file mode 100644
index 0000000000..6a9fca90c9
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Ensures basic runtime with Java support boots properly
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaRuntimeBootstrapTestCase extends TestCase {
+
+ /**
+ * Tests the runtime can be bootstrapped with Java builders and two module-scoped Java-based components can be wired
+ */
+ public void testRuntimeBoot() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD);
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule());
+ testCtx.publish(new ModuleStart(this));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().getString();
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/StartStopTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/StartStopTestCase.java
new file mode 100644
index 0000000000..8b7ed342c4
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/StartStopTestCase.java
@@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.client.TuscanyRuntime;
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.CurrentModuleContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StartStopTestCase extends TestCase {
+ private ClassLoader oldCL;
+
+ public void testHelloWorld() throws Exception {
+ TuscanyRuntime tuscany = new TuscanyRuntime("test", null);
+ tuscany.start();
+ ModuleContext moduleContext = CurrentModuleContext.getContext();
+ assertNotNull(moduleContext);
+
+ HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
+ assertNotNull(helloworldService);
+
+ String value = helloworldService .getGreetings("World");
+ assertEquals("Hello World", value);
+ tuscany.stop();
+ tuscany = new TuscanyRuntime("test", null);
+ tuscany.start();
+ moduleContext = CurrentModuleContext.getContext();
+ assertNotNull(moduleContext);
+ helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
+ assertNotNull(helloworldService);
+ value = helloworldService .getGreetings("World");
+ assertEquals("Hello World", value);
+ tuscany.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ URL url = getClass().getResource("/helloworldmc/");
+ ClassLoader cl = new URLClassLoader(new URL[]{url}, getClass().getClassLoader());
+ oldCL = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ protected void tearDown() throws Exception {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EPtoExternalServiceTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EPtoExternalServiceTestCase.java
new file mode 100644
index 0000000000..17424669bc
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EPtoExternalServiceTestCase.java
@@ -0,0 +1,99 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration.binding;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.ModuleStop;
+import org.apache.tuscany.core.context.event.RequestEnd;
+import org.apache.tuscany.core.context.event.RequestStart;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class EPtoExternalServiceTestCase extends TestCase {
+ private Method hello;
+
+ /**
+ * Tests wiring of an entry point directly to an external service
+ */
+ public void testEPtoESInvocation() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ registry.registerTargetBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPointToExternalService());
+ child.publish(new ModuleStart(this));
+ Object id = new Object();
+ child.publish(new RequestStart(this, id));
+ EntryPointContext ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ InvocationHandler handler = (InvocationHandler) ctx.getHandler();
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Object response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("foo", response);
+ Assert.assertEquals(1, mockInterceptor.getCount());
+
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getHandler();
+ response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("foo", response);
+ child.publish(new RequestEnd(this, id));
+
+ // second request
+ Object id2 = new Object();
+ child.publish(new RequestStart(this, id2));
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getHandler();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("foo", response);
+ Assert.assertEquals(3, mockInterceptor.getCount());
+ child.publish(new RequestEnd(this, id2));
+
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hello = HelloWorldService.class.getMethod("hello", String.class);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java
new file mode 100644
index 0000000000..f8ba1e2192
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java
@@ -0,0 +1,261 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration.binding;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.event.HttpSessionBound;
+import org.apache.tuscany.core.context.event.HttpSessionEnd;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.ModuleStop;
+import org.apache.tuscany.core.context.event.RequestEnd;
+import org.apache.tuscany.core.context.event.RequestStart;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+/**
+ * Tests basic entry point functionality with Java components
+ *
+ * @version $Rev$ $Date$
+ */
+public class EntryPointToJavaTestCase extends TestCase {
+
+ private Method hello;
+
+ public void setUp() throws Exception {
+ hello = HelloWorldService.class.getMethod("hello", String.class);
+ }
+
+ /**
+ * Tests creation and wire of an entry point wired to a module-scoped service offered by a Java component
+ */
+ public void testEPtoJavaModuleScopeInvoke() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
+
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ registry.registerTargetBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.MODULE));
+ child.publish(new ModuleStart(this));
+ Object id = new Object();
+ child.publish(new RequestStart(this, id));
+ EntryPointContext ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ InvocationHandler handler = (InvocationHandler) ctx.getHandler();
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Object response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ Object id2 = new Object();
+ child.publish(new RequestStart(this, id2));
+
+ // second request
+ Object id3 = new Object();
+ child.publish(new RequestStart(this, id3));
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getHandler();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
+ Assert.assertEquals(2, service1.count());
+ child.publish(new RequestEnd(this, id3));
+
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+ }
+
+ /**
+ * Tests creation and wire of an entry point wired to a session-scoped service offered by a Java component
+ */
+ public void testEPtoJavaSessionScopeInvoke() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ registry.registerTargetBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.SESSION));
+ child.publish(new ModuleStart(this));
+
+ // first session
+ Object session = new Object();
+ Object id = new Object();
+ child.publish(new RequestStart(this, id));
+ child.publish(new HttpSessionBound(this, session));
+
+ EntryPointContext ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ InvocationHandler handler = (InvocationHandler) ctx.getHandler();
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Object response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ child.publish(new RequestEnd(this, id));
+
+ Object id2 = new Object();
+ child.publish(new RequestStart(this, id2));
+ child.publish(new HttpSessionBound(this, session));
+ EntryPointContext ctx2 = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx2);
+ response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
+ Assert.assertEquals(2, service1.count());
+ child.publish(new RequestEnd(this, id2));
+ child.publish(new HttpSessionEnd(this, session));
+
+ // second session
+ Object session2 = new Object();
+ child.publish(new RequestStart(this, new Object()));
+ child.publish(new HttpSessionBound(this, session2));
+
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(3, mockInterceptor.getCount());
+ child.publish(new HttpSessionBound(this, session2));
+
+ Object id3 = new Object();
+ child.publish(new RequestStart(this, id3));
+ child.publish(new HttpSessionBound(this, session2));
+ ctx2 = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx2);
+ response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(4, mockInterceptor.getCount());
+ HelloWorldService service2 = (HelloWorldService) child.getContext("target").getInstance(null);
+ Assert.assertEquals(2, service2.count());
+ Assert.assertEquals(2, service1.count()); //ensure sessions not crossed
+ child.publish(new RequestEnd(this, session2));
+ child.publish(new HttpSessionBound(this, session2));
+
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+ }
+
+
+ /**
+ * Tests creation and wire of an entry point wired to a module-scoped service offered by a Java component
+ */
+ public void testEPtoJavaStatelessInvoke() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ registry.registerTargetBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.INSTANCE));
+ child.publish(new ModuleStart(this));
+ Object id = new Object();
+ child.publish(new RequestStart(this, id));
+ EntryPointContext ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ InvocationHandler handler = (InvocationHandler) ctx.getHandler();
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Object response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ child.publish(new RequestEnd(this, id));
+
+ // second request
+ Object id2 = new Object();
+ child.publish(new RequestStart(this, id2));
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getHandler();
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
+ Assert.assertEquals(0, service1.count());
+ child.publish(new RequestEnd(this, id));
+
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+ }
+
+ public void testEPtoJavaRequestInvoke() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ registry.registerTargetBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.REQUEST));
+ child.publish(new ModuleStart(this));
+ Object id = new Object();
+ child.publish(new RequestStart(this, id));
+ EntryPointContext ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ InvocationHandler handler = (InvocationHandler) ctx.getHandler();
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Object response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(1, mockInterceptor.getCount());
+
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getHandler();
+ response = handler.invoke(null, hello, new Object[]{"foo"});
+ HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
+ Assert.assertEquals(2, service1.count());
+
+ child.publish(new RequestEnd(this, id));
+
+ // second request
+ Object id2 = new Object();
+ child.publish(new RequestStart(this, id2));
+ ctx = (EntryPointContext) child.getContext("source");
+ Assert.assertNotNull(ctx);
+ handler = (InvocationHandler) ctx.getHandler();
+ Assert.assertEquals(2, mockInterceptor.getCount());
+ response = handler.invoke(null, hello, new Object[]{"foo"});
+ Assert.assertEquals("Hello foo", response);
+ Assert.assertEquals(3, mockInterceptor.getCount());
+ HelloWorldService service2 = (HelloWorldService) child.getContext("target").getInstance(null);
+ Assert.assertEquals(1, service2.count());
+ child.publish(new RequestEnd(this, id2));
+
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/ExternalServiceProxyInvokeTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/ExternalServiceProxyInvokeTestCase.java
new file mode 100644
index 0000000000..7357f973f7
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/ExternalServiceProxyInvokeTestCase.java
@@ -0,0 +1,73 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration.binding;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.ModuleStop;
+import org.apache.tuscany.core.context.event.RequestEnd;
+import org.apache.tuscany.core.context.event.RequestStart;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class ExternalServiceProxyInvokeTestCase extends TestCase {
+
+ /**
+ * Tests that an external service can be invoked by locating a proxy to it as opposed to invoking it over a wire from another
+ * source such as an entry point or external service.
+ *
+ * @throws Throwable
+ */
+ public void testProxyInvocation() throws Throwable {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
+ .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ registry.registerTargetBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithEntryPointToExternalService());
+ child.publish(new ModuleStart(this));
+ Object id = new Object();
+ child.publish(new RequestStart(this, id));
+ HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
+ Assert.assertEquals("foo", service1.hello("foo"));
+
+ child.publish(new RequestEnd(this, id));
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java
new file mode 100644
index 0000000000..90acb1c591
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration.binding;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.ModuleStop;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+
+/**
+ * Tests basic Java to external service interaction
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaToExternalServiceTestCase extends TestCase {
+
+ /**
+ * Tests an wire of an external service configured with the {@link org.apache.tuscany.container.java.mock.binding.foo.FooBinding}
+ * from a Java component
+ *
+ * @throws Exception
+ */
+ public void testJavaToESInvoke() throws Exception {
+ RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
+ PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(
+ MockFactory.SYSTEM_CHILD)).getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
+ registry.registerTargetBuilder(interceptorBuilder);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
+ CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockFactory.createModuleWithExternalService());
+ child.publish(new ModuleStart(this));
+ HelloWorldService source = (HelloWorldService) child.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ Assert.assertEquals(0, mockInterceptor.getCount());
+ Assert.assertEquals("foo", source.hello("foo"));
+ Assert.assertEquals(1, mockInterceptor.getCount());
+ child.publish(new ModuleStop(this));
+ runtime.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java
new file mode 100644
index 0000000000..89320f60e5
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java
@@ -0,0 +1,741 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.integration.context;
+
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.RequestStart;
+import org.apache.tuscany.core.context.event.HttpSessionBound;
+import org.apache.tuscany.core.context.event.RequestEnd;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Tests scoping is properly handled for service references
+ *
+ * @version $Rev$ $Date$
+ */
+public class ScopeReferenceTestCase extends TestCase {
+
+ /**
+ * Tests a module-to-module scoped wire is setup properly by the runtime
+ */
+ public void testModuleToModule() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule());
+ testCtx.publish(new ModuleStart(this));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().getString();
+ }
+
+ /**
+ * Tests a module-to-session scoped wire is setup properly by the runtime
+ */
+ public void testModuleToSession() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.SESSION));
+ testCtx.publish(new ModuleStart(this));
+
+ // first session
+ Object session = new Object();
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ testCtx.publish(new HttpSessionBound(this,session));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,id));
+
+ //second session
+ Object session2 = new Object();
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ testCtx.publish(new HttpSessionBound(this,session2));
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target2);
+ Assert.assertTrue(!"foo".equals(target2.getString()));
+
+ Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
+ source.getGenericComponent().setString("bar");
+ Assert.assertEquals("bar",target2.getString());
+ Assert.assertEquals("bar",source.getGenericComponent().getString());
+ //testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
+
+ }
+
+ /**
+ * Tests a module-to-request scoped wire is setup properly by the runtime
+ */
+ public void testModuleToRequest() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.REQUEST));
+ testCtx.publish(new ModuleStart(this));
+
+ // first request
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,id));
+
+ //second request
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target2);
+ Assert.assertTrue(!"foo".equals(target2.getString()));
+
+ Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
+ source.getGenericComponent().setString("bar");
+ Assert.assertEquals("bar",target2.getString());
+ Assert.assertEquals("bar",source.getGenericComponent().getString());
+
+ }
+
+ /**
+ * Tests a module-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testModuleToStateless() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.INSTANCE));
+ testCtx.publish(new ModuleStart(this));
+
+ // first request
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertTrue(!"foo".equals(target.getString()));
+ testCtx.publish(new RequestEnd(this,id));
+
+ //second request
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target2);
+ Assert.assertTrue(!"foo".equals(target2.getString()));
+
+ Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
+ source.getGenericComponent().setString("bar");
+ Assert.assertTrue(!"bar".equals(target2.getString()));
+ }
+
+ /**
+ * Tests a session-to-session scoped wire is setup properly by the runtime
+ */
+ public void testSessionToSession() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.SESSION));
+ testCtx.publish(new ModuleStart(this));
+
+ // first session
+ Object session = new Object();
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ testCtx.publish(new HttpSessionBound(this,session));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,id));
+
+ //second session
+ Object session2 = new Object();
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ testCtx.publish(new HttpSessionBound(this,session2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.publish(new RequestEnd(this,id2));
+
+ }
+
+
+ /**
+ * Tests a session-to-module scoped wire is setup properly by the runtime
+ */
+ public void testSessionToModule() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.MODULE));
+ testCtx.publish(new ModuleStart(this));
+
+ // first session
+ Object session = new Object();
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ testCtx.publish(new HttpSessionBound(this,session));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,id));
+
+ //second session
+ Object session2 = new Object();
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ testCtx.publish(new HttpSessionBound(this,session2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals("foo",target2.getString());
+ Assert.assertEquals("foo",source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+ Assert.assertEquals("baz",target.getString());
+
+ testCtx.publish(new RequestEnd(this,session2));
+
+ }
+
+ /**
+ * Tests a session-to-request scoped wire is setup properly by the runtime
+ */
+ public void testSessionToRequest() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.REQUEST));
+ testCtx.publish(new ModuleStart(this));
+
+ // first session
+ Object session = new Object();
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ testCtx.publish(new HttpSessionBound(this,session));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,session));
+
+ //second session
+ Object session2 = new Object();
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ testCtx.publish(new HttpSessionBound(this,session2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",target2.getString());
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,session));
+
+ }
+
+
+ /**
+ * Tests a session-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testSessionToStateless() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.INSTANCE));
+ testCtx.publish(new ModuleStart(this));
+
+ // first session
+ Object session = new Object();
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ testCtx.publish(new HttpSessionBound(this,session));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals(null,target.getString());
+ testCtx.publish(new RequestEnd(this,session));
+
+ //second session
+ Object session2 = new Object();
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ testCtx.publish(new HttpSessionBound(this,session2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals(null,target2.getString()); //Note assumes no pooling
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+
+ Assert.assertEquals(null,target.getString()); //Note assumes no pooling
+ testCtx.publish(new RequestEnd(this,session));
+
+ }
+
+ /**
+ * Tests a request-to-request scoped wire is setup properly by the runtime
+ */
+ public void testRequestToRequest() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.REQUEST));
+ testCtx.publish(new ModuleStart(this));
+
+ // first request
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ //second request
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.publish(new RequestEnd(this,new Object()));
+ }
+
+ /**
+ * Tests a request-to-module scoped wire is setup properly by the runtime
+ */
+ public void testRequestToModule() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.MODULE));
+ testCtx.publish(new ModuleStart(this));
+
+ // first request
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ //second request
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals("foo",target2.getString());
+ Assert.assertEquals("foo",source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+ Assert.assertEquals("baz",target.getString());
+
+ testCtx.publish(new RequestEnd(this,new Object()));
+ }
+
+ /**
+ * Tests a request-to-session scoped wire is setup properly by the runtime
+ */
+ public void testRequestToSession() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.SESSION));
+ testCtx.publish(new ModuleStart(this));
+
+ // first session
+ Object session = new Object();
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ testCtx.publish(new HttpSessionBound(this,session));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ //second request for session
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ testCtx.publish(new HttpSessionBound(this,session));
+ GenericComponent targetR2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertEquals("foo",targetR2.getString());
+ GenericComponent sourceR2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(sourceR2);
+ Assert.assertEquals("foo",sourceR2.getGenericComponent().getString());
+
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ //second session
+ Object session2 = new Object();
+ Object id3 = new Object();
+ testCtx.publish(new RequestStart(this,id3));
+ testCtx.publish(new HttpSessionBound(this,session2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.publish(new RequestEnd(this,session2));
+ Object id4 = new Object();
+ testCtx.publish(new RequestStart(this,id4));
+ testCtx.publish(new HttpSessionBound(this,session));
+ testCtx.publish(new RequestEnd(this,session));
+
+ }
+
+
+ /**
+ * Tests a request-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testRequestToStateless() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.INSTANCE));
+ testCtx.publish(new ModuleStart(this));
+
+ // first request
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals(null,target.getString());
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ //second request
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ Assert.assertEquals(null,target2.getString());
+
+ testCtx.publish(new RequestEnd(this,new Object()));
+ }
+
+
+ /**
+ * Tests a stateless-to-stateless scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToStateless() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.INSTANCE));
+ testCtx.publish(new ModuleStart(this));
+
+ // first request
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals(null,target.getString());
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ //second request
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ Assert.assertEquals(null,target2.getString());
+
+ testCtx.publish(new RequestEnd(this,new Object()));
+ }
+
+ /**
+ * Tests a stateless-to-request scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToRequest() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.REQUEST));
+ testCtx.publish(new ModuleStart(this));
+
+ // first request
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ GenericComponent targetR1 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(targetR1);
+ Assert.assertEquals("foo",target.getString());
+
+ //second request
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.publish(new RequestEnd(this,new Object()));
+ }
+
+ /**
+ * Tests a stateless-to-session scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToSession() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.SESSION));
+ testCtx.publish(new ModuleStart(this));
+
+ // first session
+ Object session = new Object();
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ testCtx.publish(new HttpSessionBound(this,session));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ //second request for session
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ testCtx.publish(new HttpSessionBound(this,session));
+ GenericComponent targetR2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertEquals("foo",targetR2.getString());
+ GenericComponent sourceR2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(sourceR2);
+ Assert.assertEquals("foo",sourceR2.getGenericComponent().getString());
+
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ //second session
+ Object session2 = new Object();
+ Object id3 = new Object();
+ testCtx.publish(new RequestStart(this,id3));
+ testCtx.publish(new HttpSessionBound(this,session2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals(null,target2.getString());
+ Assert.assertEquals(null,source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.publish(new RequestEnd(this,session2));
+ Object id4 = new Object();
+ testCtx.publish(new RequestStart(this,id4));
+ testCtx.publish(new HttpSessionBound(this,session));
+ testCtx.publish(new RequestEnd(this,session));
+
+ }
+
+
+ /**
+ * Tests a stateless-to-module scoped wire is setup properly by the runtime
+ */
+ public void testStatelessToModule() throws Exception{
+ RuntimeContext runtime = MockFactory.createJavaRuntime();
+ Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
+ Assert.assertNotNull(ctx);
+ runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
+ CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
+ Assert.assertNotNull(testCtx);
+ testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.MODULE));
+ testCtx.publish(new ModuleStart(this));
+
+ Object id = new Object();
+ testCtx.publish(new RequestStart(this,id));
+ GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source);
+ GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
+ Assert.assertNotNull(target);
+ source.getGenericComponent().setString("foo");
+ Assert.assertEquals("foo",target.getString());
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ //second session
+ Object id2 = new Object();
+ testCtx.publish(new RequestStart(this,id2));
+ GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
+ Assert.assertNotNull(source2);
+ GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
+
+ Assert.assertNotNull(target2);
+ Assert.assertEquals("foo",target2.getString());
+ Assert.assertEquals("foo",source2.getGenericComponent().getString());
+ source2.getGenericComponent().setString("baz");
+ Assert.assertEquals("baz",source2.getGenericComponent().getString());
+ Assert.assertEquals("baz",target2.getString());
+
+ testCtx.publish(new RequestEnd(this,new Object()));
+
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/MediationTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/MediationTestCase.java
new file mode 100644
index 0000000000..e560af6fd3
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/MediationTestCase.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.invocation;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+
+/**
+ * Tests invoking on a different interface from the one actually implemented by the target
+ *
+ * @version $Rev$ $Date$
+ */
+public class MediationTestCase extends TestCase {
+
+ private Method hello;
+
+ private MessageFactory msgFactory = new MessageFactoryImpl();
+
+ public void setUp() throws Exception {
+ hello = Hello.class.getMethod("hello", String.class);
+ }
+
+ public void testMediation() throws Exception {
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(hello, new SimpleTargetImpl());
+ Message msg = msgFactory.createMessage();
+ msg.setBody("foo");
+ Assert.assertEquals("foo", invoker.invoke(msg).getBody());
+ }
+
+ public interface Hello {
+
+ public String hello(String message) throws Exception;
+
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/ScopedPojoInvokerTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/ScopedPojoInvokerTestCase.java
new file mode 100644
index 0000000000..f4337fe3cb
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/ScopedPojoInvokerTestCase.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.invocation;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.invocation.mock.SimpleTarget;
+import org.apache.tuscany.container.java.mock.MockScopeContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+
+public class ScopedPojoInvokerTestCase extends TestCase {
+
+ private Method echoMethod;
+
+ public ScopedPojoInvokerTestCase() {
+ super();
+ }
+
+ public ScopedPojoInvokerTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ echoMethod = SimpleTarget.class.getDeclaredMethod("echo", String.class);
+ Assert.assertNotNull(echoMethod);
+ }
+
+ public void testScopedInvoke() throws Exception {
+ ScopeContext container = new MockScopeContext();
+ ScopedJavaComponentInvoker invoker = new ScopedJavaComponentInvoker(new QualifiedName("foo"), echoMethod, container,false);
+ Object ret = invoker.invokeTarget("foo");
+ Assert.assertEquals("foo", ret);
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/StaticPojoInvokerTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/StaticPojoInvokerTestCase.java
new file mode 100644
index 0000000000..31e7e3c64e
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/StaticPojoInvokerTestCase.java
@@ -0,0 +1,154 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import static java.lang.Integer.*;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class StaticPojoInvokerTestCase extends TestCase {
+
+ private Method echoMethod;
+ private Method arrayMethod;
+ private Method nullParamMethod;
+ private Method primitiveMethod;
+ private Method checkedMethod;
+ private Method runtimeMethod;
+
+ public StaticPojoInvokerTestCase() {
+
+ }
+
+ public StaticPojoInvokerTestCase(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+ echoMethod = TestBean.class.getDeclaredMethod("echo", String.class);
+ arrayMethod = TestBean.class.getDeclaredMethod("arrayEcho", String[].class);
+ nullParamMethod = TestBean.class.getDeclaredMethod("nullParam", (Class[]) null);
+ primitiveMethod = TestBean.class.getDeclaredMethod("primitiveEcho", TYPE);
+ checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null);
+ runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null);
+ Assert.assertNotNull(echoMethod);
+ Assert.assertNotNull(checkedMethod);
+ Assert.assertNotNull(runtimeMethod);
+ }
+
+ public void testObjectInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(echoMethod, bean);
+ Object ret = invoker.invokeTarget("foo");
+ Assert.assertEquals("foo", ret);
+ }
+
+ public void testArrayInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(arrayMethod, bean);
+ String[] args = new String[]{"foo", "bar"};
+ Object ret = invoker.invokeTarget(new Object[]{args});
+ String[] retA = (String[]) ret;
+ Assert.assertNotNull(retA);
+ Assert.assertEquals(2, retA.length);
+ Assert.assertEquals("foo", retA[0]);
+ Assert.assertEquals("bar", retA[1]);
+ }
+
+ public void testNullInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(nullParamMethod, bean);
+ Object ret = invoker.invokeTarget(null);
+ String retS = (String) ret;
+ Assert.assertEquals("foo", retS);
+ }
+
+ public void testPrimitiveInvoke() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(primitiveMethod, bean);
+ Object ret = invoker.invokeTarget(new Integer[]{1});
+ Integer retI = (Integer) ret;
+ Assert.assertEquals(1, retI.intValue());
+ }
+
+ public void testInvokeCheckedException() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(checkedMethod, bean);
+ try {
+ invoker.invokeTarget(null);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() != null && TestException.class.equals(e.getCause().getClass())) {
+ return;
+ }
+ } catch (Throwable e) {
+ }
+ fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ public void testInvokeRuntimeException() throws Throwable {
+ TestBean bean = new TestBean();
+ StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(runtimeMethod, bean);
+ try {
+ invoker.invokeTarget(null);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() != null && e.getCause() instanceof TestRuntimeException) {
+ return;
+ }
+ }
+ fail(TestException.class.getName() + " should have been thrown");
+ }
+
+ private class TestBean {
+
+ public String echo(String msg) throws Exception {
+ Assert.assertEquals("foo", msg);
+ return msg;
+ }
+
+ public String[] arrayEcho(String[] msg) throws Exception {
+ Assert.assertNotNull(msg);
+ Assert.assertEquals(2, msg.length);
+ Assert.assertEquals("foo", msg[0]);
+ Assert.assertEquals("bar", msg[1]);
+ return msg;
+ }
+
+ public String nullParam() throws Exception {
+ return "foo";
+ }
+
+ public int primitiveEcho(int i) throws Exception {
+ return i;
+ }
+
+ public void checkedException() throws TestException {
+ throw new TestException();
+ }
+
+ public void runtimeException() throws TestRuntimeException {
+ throw new TestRuntimeException();
+ }
+ }
+
+ public class TestException extends Exception {
+ }
+
+ public class TestRuntimeException extends RuntimeException {
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java
new file mode 100644
index 0000000000..cda09e8540
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.invocation.mock;
+
+import org.apache.tuscany.core.wire.MessageHandler;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ *
+ */
+public class MockHandler implements MessageHandler {
+
+ private int count =0;
+
+ public boolean processMessage(Message message) {
+ //System.out.println("Invoking handler");
+ count++;
+ return true;
+ }
+
+ public int getCount(){
+ return count;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java
new file mode 100644
index 0000000000..24b22a641a
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.invocation.mock;
+
+import org.apache.tuscany.core.wire.Interceptor;
+import org.apache.tuscany.core.message.Message;
+
+public class MockSyncInterceptor implements Interceptor {
+
+ private int count;
+
+ private Interceptor next;
+
+ public MockSyncInterceptor() {
+ }
+
+ public Message invoke(Message msg) {
+ ++count;
+ //System.out.println("Invoking interceptor");
+ return next.invoke(msg);
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setNext(Interceptor next) {
+ this.next=next;
+ }
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSource.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSource.java
new file mode 100644
index 0000000000..213caab7e9
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSource.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.invocation.mock;
+
+public interface SimpleSource {
+
+ public void invokeHello() throws Exception;
+
+ public void invokeGoodbye() throws Exception;
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSourceImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSourceImpl.java
new file mode 100644
index 0000000000..2e7bd75f11
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleSourceImpl.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.invocation.mock;
+
+public class SimpleSourceImpl implements SimpleSource {
+
+ private SimpleTarget proxy;
+
+ public SimpleSourceImpl(SimpleTarget proxy) {
+ this.proxy = proxy;
+ }
+
+ public void invokeHello() throws Exception {
+ proxy.hello("hello");
+ }
+
+ public void invokeGoodbye() throws Exception {
+ proxy.goodbye("hello");
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTarget.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTarget.java
new file mode 100644
index 0000000000..cbd3037529
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTarget.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.invocation.mock;
+
+public interface SimpleTarget {
+
+ public String hello(String message) throws Exception;
+
+ public String goodbye(String message) throws Exception;
+
+ public String echo(String message) throws Exception;
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTargetImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTargetImpl.java
new file mode 100644
index 0000000000..18abf6108a
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/SimpleTargetImpl.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.invocation.mock;
+
+public class SimpleTargetImpl implements SimpleTarget {
+
+ public SimpleTargetImpl() {
+ super();
+ }
+
+ public String hello(String message) throws Exception {
+ return message;
+ }
+
+ public String goodbye(String message) throws Exception {
+ return message;
+ }
+
+ public String echo(String message) throws Exception {
+ return message;
+ }
+
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/loader/JavaImplementationLoaderTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/loader/JavaImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..85e79d8780
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/loader/JavaImplementationLoaderTestCase.java
@@ -0,0 +1,134 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.loader;
+
+import java.net.URL;
+import java.util.List;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldImpl;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldWithFieldProperties;
+import org.apache.tuscany.container.java.assembly.mock.NakedHelloWorld;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.loader.StAXElementLoader;
+import org.apache.tuscany.core.loader.StAXLoaderRegistry;
+import org.apache.tuscany.core.loader.LoaderContext;
+import org.apache.tuscany.core.loader.assembly.AssemblyConstants;
+import org.apache.tuscany.model.assembly.AssemblyContext;
+import org.apache.tuscany.model.assembly.AssemblyObject;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaImplementationLoaderTestCase extends TestCase {
+ private JavaImplementationLoader loader;
+ private ComponentType mockType;
+
+ public void testNakedHelloWorld() throws ConfigurationLoadException {
+ ComponentType type = loader.loadComponentTypeByIntrospection(NakedHelloWorld.class);
+ Assert.assertNotNull(type);
+ Assert.assertEquals(1,type.getProperties().size());
+ Assert.assertTrue(type.getReferences().isEmpty());
+ List<Service> services = type.getServices();
+ Assert.assertEquals(1, services.size());
+ Assert.assertEquals("NakedHelloWorld", services.get(0).getName());
+ }
+
+ public void testHelloWorldWithSidefile() throws XMLStreamException, ConfigurationLoadException {
+ StAXLoaderRegistry mockRegistry = new MockRegistry(mockType);
+ loader.setRegistry(mockRegistry);
+ URL sidefile = HelloWorldImpl.class.getResource("HelloWorldImpl.componentType");
+ ComponentType type = loader.loadComponentTypeFromSidefile(sidefile, null);
+ assertSame(mockType, type);
+ }
+
+ public void testHelloWorldWithFieldProperties() throws ConfigurationLoadException {
+ ComponentType type = loader.loadComponentTypeByIntrospection(HelloWorldWithFieldProperties.class);
+ type.initialize(null);
+ Assert.assertNotNull(type);
+ List<Property> props = type.getProperties();
+ Assert.assertEquals(5, props.size());
+
+ Property prop = type.getProperty("text");
+ Assert.assertNotNull(prop);
+ Assert.assertEquals("text", prop.getName());
+ Assert.assertEquals(false, prop.isRequired());
+ Assert.assertEquals(String.class, prop.getType());
+
+ prop = type.getProperty("text2");
+ Assert.assertNotNull(prop);
+ Assert.assertEquals("text2", prop.getName());
+ Assert.assertEquals(true, prop.isRequired());
+ Assert.assertEquals(Integer.class, prop.getType());
+
+ prop = type.getProperty("foo");
+ Assert.assertNotNull(prop);
+ Assert.assertEquals("foo", prop.getName());
+ Assert.assertEquals(false, prop.isRequired());
+ Assert.assertEquals(Integer.TYPE, prop.getType());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ JavaAssemblyFactory factory = new JavaAssemblyFactoryImpl();
+ mockType = factory.createComponentType();
+
+ loader = new JavaImplementationLoader();
+ loader.setFactory(factory);
+ }
+
+ private static class MockRegistry implements StAXLoaderRegistry {
+ private final ComponentType mockType;
+
+ public MockRegistry(ComponentType mockType) {
+ this.mockType = mockType;
+ }
+
+ public AssemblyObject load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
+ assertEquals(AssemblyConstants.COMPONENT_TYPE, reader.getName());
+ return mockType;
+ }
+
+ public <T extends AssemblyObject> void registerLoader(QName element, StAXElementLoader<T> loader) {
+ throw new UnsupportedOperationException();
+ }
+
+ public <T extends AssemblyObject> void unregisterLoader(QName element, StAXElementLoader<T> loader) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ public AssemblyContext getContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ public void setContext(AssemblyContext context) {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java
new file mode 100644
index 0000000000..9cb1998d68
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.builder.impl.AssemblyVisitorImpl;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.model.assembly.AssemblyObject;
+
+/**
+ * A mock configuration context
+ *
+ * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
+ */
+public class MockConfigContext implements ConfigurationContext {
+
+ private List<ContextFactoryBuilder> builders;
+
+ private DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
+
+ public MockConfigContext(List<ContextFactoryBuilder> builders, List<WireBuilder> wireBuilders) {
+ this.builders = (builders == null) ? new ArrayList(1) : builders;
+ if (wireBuilders != null){
+ for (WireBuilder builder : wireBuilders) {
+ wireBuilder.addWireBuilder(builder);
+ }
+ }
+ }
+
+ public void build(AssemblyObject model) throws BuilderConfigException {
+ AssemblyVisitorImpl visitor = new AssemblyVisitorImpl(builders);
+ visitor.start(model);
+ }
+
+ public void connect(SourceWireFactory sourceFactory, TargetWireFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) throws BuilderConfigException {
+ wireBuilder.connect(sourceFactory, targetFactory, targetType, downScope, targetScopeContext);
+ }
+
+ public void completeTargetChain(TargetWireFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException {
+ wireBuilder.completeTargetChain(targetFactory, targetType, targetScopeContext);
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockContextFactory.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockContextFactory.java
new file mode 100644
index 0000000000..4e00e4c236
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockContextFactory.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock;
+
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
+import org.apache.tuscany.container.java.config.JavaContextFactory;
+import org.apache.tuscany.container.java.scopes.OrderedDependentPojo;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.MethodInjector;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.model.assembly.AssemblyContext;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.impl.AssemblyContextImpl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class MockContextFactory {
+
+ private MockContextFactory(){}
+
+ /**
+ * Wires together a source and target
+ * @throws NoSuchMethodException
+ */
+ public static List<ContextFactory<Context>> createWiredContexts(Scope scope, ScopeContext context) throws NoSuchMethodException{
+
+ Constructor constructor = JavaIntrospectionHelper.getDefaultConstructor(OrderedDependentPojo.class);
+ Method getPojo = OrderedDependentPojo.class.getMethod("setPojo",OrderedDependentPojo.class);
+ Method init = OrderedDependentPojo.class.getMethod("init",(Class[])null);
+ EventInvoker<Object> initInvoker = new MethodEventInvoker<Object>(init);
+ Method destroy = OrderedDependentPojo.class.getMethod("destroy",(Class[])null);
+ EventInvoker<Object> destroyInvoker = new MethodEventInvoker<Object>(destroy);
+
+ JavaContextFactory source = new JavaContextFactory("source",constructor,scope);
+ source.setInitInvoker(initInvoker);
+ source.setDestroyInvoker(destroyInvoker);
+ JavaContextFactory target = new JavaContextFactory("target",constructor,scope);
+ target.setInitInvoker(initInvoker);
+ target.setDestroyInvoker(destroyInvoker);
+ List<Injector> injectors = new ArrayList<Injector>();
+ injectors.add(new MethodInjector(getPojo, new MockTargetFactory("target",context)));
+ source.setSetters(injectors);
+ List<ContextFactory<Context>> list = new ArrayList<ContextFactory<Context>>();
+ list.add((ContextFactory)source);
+ list.add((ContextFactory)target);
+ return list;
+ }
+
+ private static class MockTargetFactory implements ObjectFactory{
+
+ private String name;
+ private ScopeContext context;
+
+ public MockTargetFactory (String name, ScopeContext context){
+ this.name = name;
+ this.context = context;
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ return context.getContext(name).getInstance(null);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockFactory.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockFactory.java
new file mode 100644
index 0000000000..3b45352865
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockFactory.java
@@ -0,0 +1,819 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Assert;
+import org.apache.tuscany.common.monitor.MonitorFactory;
+import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
+import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
+import org.apache.tuscany.container.java.assembly.JavaImplementation;
+import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldImpl;
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.builder.JavaTargetWireBuilder;
+import org.apache.tuscany.container.java.context.JavaAtomicContext;
+import org.apache.tuscany.container.java.mock.binding.foo.FooBinding;
+import org.apache.tuscany.container.java.mock.binding.foo.FooBindingBuilder;
+import org.apache.tuscany.container.java.mock.binding.foo.FooBindingWireBuilder;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.container.java.mock.components.HelloWorldClient;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.OtherTarget;
+import org.apache.tuscany.container.java.mock.components.OtherTargetImpl;
+import org.apache.tuscany.container.java.mock.components.Source;
+import org.apache.tuscany.container.java.mock.components.SourceImpl;
+import org.apache.tuscany.container.java.mock.components.Target;
+import org.apache.tuscany.container.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.builder.ContextFactoryBuilderRegistry;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
+import org.apache.tuscany.core.client.BootstrapHelper;
+import org.apache.tuscany.core.config.ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.config.processor.ProcessorUtils;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.SystemCompositeContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.impl.CompositeContextImpl;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.FieldInjector;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.MethodInjector;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.SystemBinding;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.core.system.builder.SystemContextFactoryBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+import org.apache.tuscany.core.system.context.SystemCompositeContextImpl;
+import org.apache.tuscany.core.wire.WireFactoryFactory;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.model.assembly.AssemblyContext;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Multiplicity;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.impl.AssemblyContextImpl;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Generates test components, modules, and runtime artifacts
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockFactory {
+
+ public static final String JAVA_BUILDER = "java.runtime.builder";
+ public static final String MESSAGE_FACTORY = "java.runtime.messageFactory";
+ public static final String PROXY_FACTORY_FACTORY = "java.runtime.wireFactoryFactory";
+ public static final String WIRE_FACTORY_SERVICE = "java.runtime.wireFactoryservice";
+ public static final String JAVA_WIRE_BUILDER = "java.wire.builder";
+ public static final String FOO_BUILDER = "foo.binding.builder";
+ public static final String FOO_WIRE_BUILDER = "foo.binding.wire.builder";
+ public static final String POLICY_BUILDER_REGISTRY = "foo.binding.policy.registry";
+ public static final String SYSTEM_CHILD = "tuscany.system.child";
+
+ private static JavaAssemblyFactory factory = new JavaAssemblyFactoryImpl();
+ private static SystemAssemblyFactory systemFactory = new SystemAssemblyFactoryImpl();
+ private static AssemblyContext assemblyContext = new AssemblyContextImpl(null, null);
+ private static ComponentTypeIntrospector introspector;
+ private static ComponentType systemComponentType;
+ private static ComponentType compositeComponentType;
+
+ public static ComponentType getComponentType() throws ConfigurationLoadException {
+ if (systemComponentType == null) {
+ systemComponentType = getIntrospector().introspect(SystemCompositeContextImpl.class);
+ }
+ return systemComponentType;
+ }
+
+ public static ComponentType getCompositeComponentType() throws ConfigurationLoadException {
+ if (compositeComponentType == null) {
+ compositeComponentType = getIntrospector().introspect(CompositeContextImpl.class);
+ }
+ return compositeComponentType;
+ }
+
+ public static ComponentTypeIntrospector getIntrospector() {
+ if (introspector == null) {
+ introspector = ProcessorUtils.createCoreIntrospector(systemFactory);
+ }
+ return introspector;
+ }
+
+ /**
+ * Creates an initialized simple component
+ *
+ * @param name the component name
+ * @param type the implementation type
+ * @param scope the component scope
+ */
+ public static AtomicComponent createComponent(String name, Class type, Scope scope) throws ConfigurationLoadException {
+ AtomicComponent sc = factory.createSimpleComponent();
+ JavaImplementation impl = factory.createJavaImplementation();
+ impl.setComponentType(getIntrospector().introspect(type));
+ impl.setImplementationClass(type);
+ sc.setImplementation(impl);
+ Service s = factory.createService();
+ JavaServiceContract ji = factory.createJavaServiceContract();
+ ji.setInterface(type);
+ s.setServiceContract(ji);
+ ji.setScope(scope);
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setImplementation(impl);
+ return sc;
+ }
+
+ public static AtomicComponent createNonIntrospectedComponent(String name, Class service, Class type, Scope scope) throws ConfigurationLoadException {
+ AtomicComponent sc = factory.createSimpleComponent();
+ JavaImplementation impl = factory.createJavaImplementation();
+ impl.setComponentType(factory.createComponentType());
+ impl.setImplementationClass(type);
+ sc.setImplementation(impl);
+ Service s = factory.createService();
+ JavaServiceContract ji = factory.createJavaServiceContract();
+ ji.setInterface(service);
+ s.setServiceContract(ji);
+ ji.setScope(scope);
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setImplementation(impl);
+ return sc;
+ }
+
+
+ /**
+ * Creates an composite component with the given name
+ */
+ public static Component createCompositeComponent(String name) throws ConfigurationLoadException {
+ Component sc = systemFactory.createModuleComponent();
+ Module impl = systemFactory.createModule();
+ impl.setName(name);
+ //impl.setImplementationClass(CompositeContextImpl.class);
+ sc.setImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(Scope.AGGREGATE);
+ //impl.setComponentType(systemFactory.createComponentType());
+ impl.setImplementationClass(CompositeContextImpl.class);
+ impl.setComponentType(getCompositeComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setImplementation(impl);
+
+ return sc;
+ }
+
+ /**
+ * Creates a system composite component with the given name
+ */
+ public static Component createSystemCompositeComponent(String name) throws ConfigurationLoadException {
+ Component sc = systemFactory.createModuleComponent();
+ Module impl = systemFactory.createSystemModule();
+ impl.setName(name);
+ //impl.setImplementationClass(SystemCompositeContextImpl.class);
+ sc.setImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(Scope.AGGREGATE);
+ impl.setComponentType(getComponentType());
+ //impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setImplementation(impl);
+ return sc;
+ }
+
+ /**
+ * Creates an external service configured with the 'Foo' test binding
+ */
+ public static ExternalService createFooBindingExternalService(String name, Class interfaz) {
+ ExternalService es = factory.createExternalService();
+ es.setName(name);
+ Service s = factory.createService();
+ JavaServiceContract ji = factory.createJavaServiceContract();
+ ji.setScope(Scope.MODULE);
+ ji.setInterface(interfaz);
+ s.setServiceContract(ji);
+ ConfiguredService configuredService = factory.createConfiguredService();
+ es.setConfiguredService(configuredService);
+
+ FooBinding binding = new FooBinding();
+ es.getBindings().add(binding);
+ return es;
+ }
+
+ /**
+ * Creates an entry point with the given name configured with the given interface and the {@link
+ * FooBinding}
+ */
+ public static EntryPoint createFooBindingEntryPoint(String name, Class interfaz) {
+ EntryPoint ep = factory.createEntryPoint();
+ ep.setName(name);
+ Service s = factory.createService();
+ JavaServiceContract ji = factory.createJavaServiceContract();
+ ji.setScope(Scope.MODULE);
+ ji.setInterface(interfaz);
+ s.setServiceContract(ji);
+ ConfiguredService configuredService = factory.createConfiguredService();
+ configuredService.setPort(s);
+ ep.setConfiguredService(configuredService);
+ FooBinding binding = new FooBinding();
+ ep.getBindings().add(binding);
+ return ep;
+ }
+
+ /**
+ * Creates an external service configured with a {@link SystemBinding}
+ */
+ public static ExternalService createESSystemBinding(String name, String refName) {
+ ExternalService es = systemFactory.createExternalService();
+ es.setName(name);
+ ConfiguredService configuredService = systemFactory.createConfiguredService();
+ es.setConfiguredService(configuredService);
+ SystemBinding binding = systemFactory.createSystemBinding();
+ binding.setTargetName(refName);
+ es.getBindings().add(binding);
+ es.initialize(null);
+ return es;
+ }
+
+ /**
+ * Creates a module with a Java-based "target" module-scoped component wired to a module-scoped "source"
+ */
+ public static Module createModule() throws ConfigurationLoadException {
+ return createModule(Scope.MODULE, Scope.MODULE);
+ }
+
+ /**
+ * Creates a module with a Java-based "target" component wired to a "source"
+ */
+ public static Module createModule(Scope sourceScope, Scope targetScope) throws ConfigurationLoadException {
+ Component sourceComponent = createNonIntrospectedComponent("source", ModuleScopeComponent.class, ModuleScopeComponentImpl.class, sourceScope);
+ Component targetComponent = createNonIntrospectedComponent("target", ModuleScopeComponent.class, ModuleScopeComponentImpl.class, targetScope);
+
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(GenericComponent.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("GenericComponent");
+ targetContract.setScope(targetScope);
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setPort(targetService);
+ cTargetService.initialize(assemblyContext);
+ targetComponent.getConfiguredServices().add(cTargetService);
+ targetComponent.initialize(assemblyContext);
+
+ Reference ref = factory.createReference();
+ ref.setName("setGenericComponent");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(GenericComponent.class);
+ ref.setServiceContract(inter);
+ sourceComponent.getImplementation().getComponentType().getReferences().add(ref);
+
+ ConfiguredReference cref = factory.createConfiguredReference("setGenericComponent", "target");
+ cref.initialize(assemblyContext);
+ sourceComponent.getConfiguredReferences().add(cref);
+ sourceComponent.initialize(assemblyContext);
+
+ Module module = factory.createModule();
+ module.setName("test.module");
+ module.getComponents().add(sourceComponent);
+ module.getComponents().add(targetComponent);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ /**
+ * Creates a module with a Java-based source component wired to a "target" external service configured
+ * with the {@link FooBinding}
+ */
+ public static Module createModuleWithExternalService() throws ConfigurationLoadException {
+ Component sourceComponent = createComponent("source", HelloWorldClient.class, Scope.MODULE);
+ ExternalService targetES = createFooBindingExternalService("target", HelloWorldService.class);
+
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(HelloWorldService.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("HelloWorld");
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setPort(targetService);
+ targetES.setConfiguredService(cTargetService);
+ targetES.initialize(assemblyContext);
+
+ Reference ref = factory.createReference();
+ ref.setName("setHelloWorldService");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(HelloWorldService.class);
+ ref.setServiceContract(inter);
+ sourceComponent.getImplementation().getComponentType().getReferences().add(ref);
+
+ ConfiguredReference cref = factory.createConfiguredReference(ref.getName(), "target");
+ cref.initialize(assemblyContext);
+ sourceComponent.getConfiguredReferences().add(cref);
+ sourceComponent.initialize(assemblyContext);
+
+ Module module = factory.createModule();
+ module.setName("test.module");
+ module.getComponents().add(sourceComponent);
+ module.getExternalServices().add(targetES);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ /**
+ * Creates a module with an entry point named "source" configured with the {@link FooBinding} wired to a
+ * service offered by a Java-based component named "target"
+ *
+ * @param scope the scope of the target service
+ */
+ public static Module createModuleWithEntryPoint(Scope scope) throws ConfigurationLoadException {
+ Component targetComponent = createComponent("target", HelloWorldImpl.class, scope);
+
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(HelloWorldService.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("HelloWorldService");
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setPort(targetService);
+ targetComponent.getConfiguredServices().add(cTargetService);
+ targetComponent.initialize(assemblyContext);
+
+ Reference ref = factory.createReference();
+ ConfiguredReference cref = factory.createConfiguredReference();
+ ref.setName("setHelloWorldService");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(HelloWorldService.class);
+ ref.setServiceContract(inter);
+ cref.setPort(ref);
+ cref.getTargetConfiguredServices().add(cTargetService);
+ cref.initialize(assemblyContext);
+
+ EntryPoint sourceEP = createFooBindingEntryPoint("source", HelloWorldService.class);
+ sourceEP.setConfiguredReference(cref);
+ sourceEP.getConfiguredService().getPort().setName("HelloWorldService");
+ sourceEP.initialize(assemblyContext);
+
+ Module module = factory.createModule();
+ module.setName("test.module");
+ module.getEntryPoints().add(sourceEP);
+ module.getComponents().add(targetComponent);
+ module.setImplementationClass(CompositeContextImpl.class);
+ module.setComponentType(getCompositeComponentType());
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ /**
+ * Creates a module with an entry point wired to a "target" external service configured with the {@link
+ * FooBinding}
+ */
+ public static Module createModuleWithEntryPointToExternalService() {
+ //Component sourceComponent = createComponent("source", HelloWorldClient.class, Scope.MODULE);
+
+ EntryPoint sourceEP = createFooBindingEntryPoint("source", HelloWorldService.class);
+ sourceEP.getConfiguredService().getPort().setName("HelloWorldService");
+ sourceEP.initialize(assemblyContext);
+
+
+ ExternalService targetES = createFooBindingExternalService("target", HelloWorldService.class);
+
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(HelloWorldService.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("HelloWorld");
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setPort(targetService);
+ targetES.setConfiguredService(cTargetService);
+ targetES.initialize(assemblyContext);
+
+ Reference ref = factory.createReference();
+ ref.setName("setHelloWorldService");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(HelloWorldService.class);
+ ref.setServiceContract(inter);
+
+
+ ConfiguredReference cref = factory.createConfiguredReference(ref.getName(), "target");
+ cref.setPort(ref);
+ cref.initialize(assemblyContext);
+ sourceEP.setConfiguredReference(cref);
+ sourceEP.initialize(assemblyContext);
+
+ Module module = factory.createModule();
+ module.setName("test.module");
+ module.getEntryPoints().add(sourceEP);
+ module.getExternalServices().add(targetES);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+
+ /**
+ * Creates a test system module with source and target components wired together.
+ *
+ * @see org.apache.tuscany.core.mock.component.Source
+ * @see org.apache.tuscany.core.mock.component.Target
+ */
+
+ public static Module createModuleWithWiredComponents(Scope sourceScope, Scope targetScope) {
+
+ // create the target component
+ AtomicComponent target = factory.createSimpleComponent();
+ target.setName("target");
+ JavaImplementation targetImpl = factory.createJavaImplementation();
+ targetImpl.setComponentType(factory.createComponentType());
+ targetImpl.setImplementationClass(TargetImpl.class);
+ target.setImplementation(targetImpl);
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(Target.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("Target");
+ targetImpl.getComponentType().getServices().add(targetService);
+ targetContract.setScope(targetScope);
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setPort(targetService);
+ cTargetService.initialize(assemblyContext);
+ target.getConfiguredServices().add(cTargetService);
+ target.initialize(assemblyContext);
+
+ // create the source component
+ AtomicComponent source = factory.createSimpleComponent();
+ ComponentType componentType = factory.createComponentType();
+ source.setName("source");
+ JavaImplementation impl = factory.createJavaImplementation();
+ impl.setComponentType(componentType);
+ impl.setImplementationClass(SourceImpl.class);
+ source.setImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract contract = systemFactory.createJavaServiceContract();
+ contract.setInterface(Source.class);
+ s.setServiceContract(contract);
+ contract.setScope(sourceScope);
+ impl.getComponentType().getServices().add(s);
+ source.setImplementation(impl);
+
+ // wire source to target
+ JavaServiceContract refContract = systemFactory.createJavaServiceContract();
+ refContract.setInterface(Target.class);
+ Reference reference = systemFactory.createReference();
+ reference.setName("setTarget");
+ reference.setServiceContract(refContract);
+ componentType.getReferences().add(reference);
+ ConfiguredReference cReference = systemFactory.createConfiguredReference(reference.getName(), "target");
+ cReference.initialize(assemblyContext);
+ source.getConfiguredReferences().add(cReference);
+
+ // wire multiplicity using a setter
+ JavaServiceContract refContract2 = systemFactory.createJavaServiceContract();
+ refContract2.setInterface(Target.class);
+ Reference reference2 = systemFactory.createReference();
+ reference2.setName("setTargets");
+ reference2.setServiceContract(refContract2);
+ reference2.setMultiplicity(Multiplicity.ONE_N);
+ componentType.getReferences().add(reference2);
+ ConfiguredReference cReference2 = systemFactory.createConfiguredReference(reference2.getName(), "target");
+ cReference2.initialize(assemblyContext);
+ source.getConfiguredReferences().add(cReference2);
+
+ // wire multiplicity using a field
+ JavaServiceContract refContract3 = systemFactory.createJavaServiceContract();
+ refContract3.setInterface(Target.class);
+ Reference reference3 = systemFactory.createReference();
+ reference3.setName("targetsThroughField");
+ reference3.setServiceContract(refContract3);
+ reference3.setMultiplicity(Multiplicity.ONE_N);
+ componentType.getReferences().add(reference3);
+ ConfiguredReference cReference3 = systemFactory.createConfiguredReference(reference3.getName(), "target");
+ cReference3.initialize(assemblyContext);
+ source.getConfiguredReferences().add(cReference3);
+
+ // wire multiplicity using a array
+ JavaServiceContract refContract4 = systemFactory.createJavaServiceContract();
+ refContract4.setInterface(Target.class);
+ Reference reference4 = systemFactory.createReference();
+ reference4.setName("setArrayOfTargets");
+ reference4.setServiceContract(refContract4);
+ reference4.setMultiplicity(Multiplicity.ONE_N);
+ componentType.getReferences().add(reference4);
+ ConfiguredReference cReference4 = systemFactory.createConfiguredReference(reference4.getName(), "target");
+ cReference4.initialize(assemblyContext);
+ source.getConfiguredReferences().add(cReference4);
+
+ source.initialize(assemblyContext);
+
+ Module module = systemFactory.createModule();
+ module.setName("system.module");
+
+ module.getComponents().add(source);
+ module.getComponents().add(target);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+
+ /**
+ * Creates a test system module with source and target components wired together.
+ *
+ * @see org.apache.tuscany.core.mock.component.Source
+ * @see org.apache.tuscany.core.mock.component.Target
+ */
+
+ public static Module createModuleWithWiredComponentsOfDifferentInterface(Scope sourceScope, Scope targetScope) {
+
+ // create the target component
+ AtomicComponent target = factory.createSimpleComponent();
+ target.setName("target");
+ JavaImplementation targetImpl = factory.createJavaImplementation();
+ targetImpl.setComponentType(factory.createComponentType());
+ targetImpl.setImplementationClass(OtherTargetImpl.class);
+ target.setImplementation(targetImpl);
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(OtherTarget.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("Target");
+ targetImpl.getComponentType().getServices().add(targetService);
+ targetContract.setScope(targetScope);
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setPort(targetService);
+ cTargetService.initialize(assemblyContext);
+ target.getConfiguredServices().add(cTargetService);
+ target.initialize(assemblyContext);
+
+ // create the source component
+ AtomicComponent source = factory.createSimpleComponent();
+ ComponentType componentType = factory.createComponentType();
+ source.setName("source");
+ JavaImplementation impl = factory.createJavaImplementation();
+ impl.setComponentType(componentType);
+ impl.setImplementationClass(SourceImpl.class);
+ source.setImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract contract = systemFactory.createJavaServiceContract();
+ contract.setInterface(Source.class);
+ s.setServiceContract(contract);
+ contract.setScope(sourceScope);
+ impl.getComponentType().getServices().add(s);
+ source.setImplementation(impl);
+
+ // wire source to target
+ JavaServiceContract refContract = systemFactory.createJavaServiceContract();
+ refContract.setInterface(Target.class);
+ Reference reference = systemFactory.createReference();
+ reference.setName("setTarget");
+ reference.setServiceContract(refContract);
+ componentType.getReferences().add(reference);
+ ConfiguredReference cReference = systemFactory.createConfiguredReference(reference.getName(), "target");
+ cReference.initialize(assemblyContext);
+ source.getConfiguredReferences().add(cReference);
+
+ // wire multiplicity using a setter
+ JavaServiceContract refContract2 = systemFactory.createJavaServiceContract();
+ refContract2.setInterface(Target.class);
+ Reference reference2 = systemFactory.createReference();
+ reference2.setName("setTargets");
+ reference2.setServiceContract(refContract2);
+ reference2.setMultiplicity(Multiplicity.ONE_N);
+ componentType.getReferences().add(reference2);
+ ConfiguredReference cReference2 = systemFactory.createConfiguredReference(reference2.getName(), "target");
+ cReference2.initialize(assemblyContext);
+ source.getConfiguredReferences().add(cReference2);
+
+ // wire multiplicity using a field
+ JavaServiceContract refContract3 = systemFactory.createJavaServiceContract();
+ refContract3.setInterface(Target.class);
+ Reference reference3 = systemFactory.createReference();
+ reference3.setName("targetsThroughField");
+ reference3.setServiceContract(refContract3);
+ reference3.setMultiplicity(Multiplicity.ONE_N);
+ componentType.getReferences().add(reference3);
+ ConfiguredReference cReference3 = systemFactory.createConfiguredReference(reference3.getName(), "target");
+ cReference3.initialize(assemblyContext);
+ source.getConfiguredReferences().add(cReference3);
+
+ // wire multiplicity using a array
+ JavaServiceContract refContract4 = systemFactory.createJavaServiceContract();
+ refContract4.setInterface(Target.class);
+ Reference reference4 = systemFactory.createReference();
+ reference4.setName("setArrayOfTargets");
+ reference4.setServiceContract(refContract4);
+ reference4.setMultiplicity(Multiplicity.ONE_N);
+ componentType.getReferences().add(reference4);
+ ConfiguredReference cReference4 = systemFactory.createConfiguredReference(reference4.getName(), "target");
+ cReference4.initialize(assemblyContext);
+ source.getConfiguredReferences().add(cReference4);
+
+ source.initialize(assemblyContext);
+
+ Module module = systemFactory.createModule();
+ module.setName("system.module");
+
+ module.getComponents().add(source);
+ module.getComponents().add(target);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+
+ /**
+ * Returns a collection of bootstrap configuration builders
+ */
+ public static List<ContextFactoryBuilder> createSystemBuilders() {
+ List<ContextFactoryBuilder> builders = new ArrayList<ContextFactoryBuilder>();
+ builders.add((new SystemContextFactoryBuilder(null)));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+ return builders;
+ }
+
+ /**
+ * Creates an composite context faxtory
+ *
+ * @param name the name of the component
+ * @throws BuilderException
+ * @see ContextFactory
+ */
+ public static ContextFactory<Context> createCompositeConfiguration(String name
+ ) throws BuilderException, ConfigurationLoadException {
+
+ Component sc = createCompositeComponent(name);
+ SystemContextFactoryBuilder builder = new SystemContextFactoryBuilder(null);
+ builder.build(sc);
+ return (ContextFactory<Context>) sc.getContextFactory();
+ }
+
+ /**
+ * Creates a Java POJO component context
+ *
+ * @param name the name of the context
+ * @param implType the POJO class
+ * @param scope the component scope
+ * @param moduleComponentContext the containing composite context
+ * @throws NoSuchMethodException if the POJO does not have a default noi-args constructor
+ */
+ public static JavaAtomicContext createPojoContext(String name, Class implType, Scope scope,
+ CompositeContext moduleComponentContext) throws NoSuchMethodException, ConfigurationLoadException {
+ AtomicComponent component = createComponent(name, implType, scope);
+
+ Set<Field> fields = JavaIntrospectionHelper.getAllFields(implType);
+ Set<Method> methods = JavaIntrospectionHelper.getAllUniqueMethods(implType);
+ List<Injector> injectors = new ArrayList<Injector>();
+
+ EventInvoker initInvoker = null;
+ boolean eagerInit = false;
+ EventInvoker destroyInvoker = null;
+ for (Field field : fields) {
+ ComponentName compName = field.getAnnotation(ComponentName.class);
+ if (compName != null) {
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory(name));
+ injectors.add(injector);
+ }
+ org.osoa.sca.annotations.Context context = field.getAnnotation(org.osoa.sca.annotations.Context.class);
+ if (context != null) {
+ Injector injector = new FieldInjector(field, new SingletonObjectFactory(moduleComponentContext));
+ injectors.add(injector);
+ }
+ }
+ for (Method method : methods) {
+ // FIXME Java5
+ Init init = method.getAnnotation(Init.class);
+ if (init != null && initInvoker == null) {
+ initInvoker = new MethodEventInvoker(method);
+ eagerInit = init.eager();
+ continue;
+ }
+ Destroy destroy = method.getAnnotation(Destroy.class);
+ if (destroy != null && destroyInvoker == null) {
+ destroyInvoker = new MethodEventInvoker(method);
+ continue;
+ }
+ ComponentName compName = method.getAnnotation(ComponentName.class);
+ if (compName != null) {
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory(name));
+ injectors.add(injector);
+ }
+ org.osoa.sca.annotations.Context context = method.getAnnotation(org.osoa.sca.annotations.Context.class);
+ if (context != null) {
+ Injector injector = new MethodInjector(method, new SingletonObjectFactory(moduleComponentContext));
+ injectors.add(injector);
+ }
+ }
+ boolean stateless = (scope == Scope.INSTANCE);
+ return new JavaAtomicContext("foo", new PojoObjectFactory(JavaIntrospectionHelper
+ .getDefaultConstructor(implType), null, injectors), eagerInit, initInvoker, destroyInvoker, stateless);
+ }
+
+ /**
+ * Creates a default {@link RuntimeContext} configured with support for Java component implementations
+ *
+ * @throws ConfigurationException
+ */
+ public static RuntimeContext createJavaRuntime() throws ConfigurationException {
+ MonitorFactory monitorFactory = new NullMonitorFactory();
+ ContextFactoryBuilderRegistry builderRegistry = BootstrapHelper.bootstrapContextFactoryBuilders(monitorFactory);
+ DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
+ RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, wireBuilder);
+ runtime.start();
+ runtime.getSystemContext().registerModelObject(createSystemCompositeComponent(SYSTEM_CHILD));
+ SystemCompositeContext ctx = (SystemCompositeContext) runtime.getSystemContext().getContext(SYSTEM_CHILD);
+ Component comp = systemFactory.createSystemComponent(POLICY_BUILDER_REGISTRY, PolicyBuilderRegistry.class, DefaultPolicyBuilderRegistry.class, Scope.MODULE);
+ comp.getImplementation().setComponentType(getIntrospector().introspect(DefaultPolicyBuilderRegistry.class));
+ ctx.registerModelObject(comp);
+ comp = systemFactory.createSystemComponent(MESSAGE_FACTORY, MessageFactory.class, MessageFactoryImpl.class, Scope.MODULE);
+ comp.getImplementation().setComponentType(getIntrospector().introspect(MessageFactoryImpl.class));
+ ctx.registerModelObject(comp);
+ comp = systemFactory.createSystemComponent(PROXY_FACTORY_FACTORY, WireFactoryFactory.class, JDKWireFactoryFactory.class, Scope.MODULE);
+ comp.getImplementation().setComponentType(getIntrospector().introspect(JDKWireFactoryFactory.class));
+ ctx.registerModelObject(comp);
+ comp = systemFactory.createSystemComponent(WIRE_FACTORY_SERVICE, org.apache.tuscany.core.wire.service.WireFactoryService.class, DefaultWireFactoryService.class, Scope.MODULE);
+ comp.getImplementation().setComponentType(getIntrospector().introspect(DefaultWireFactoryService.class));
+ ctx.registerModelObject(comp);
+ comp = systemFactory.createSystemComponent(JAVA_BUILDER, ContextFactoryBuilder.class, JavaContextFactoryBuilder.class, Scope.MODULE);
+ comp.getImplementation().setComponentType(getIntrospector().introspect(JavaContextFactoryBuilder.class));
+ ctx.registerModelObject(comp);
+ comp = systemFactory.createSystemComponent(JAVA_WIRE_BUILDER, WireBuilder.class, JavaTargetWireBuilder.class, Scope.MODULE);
+ comp.getImplementation().setComponentType(getIntrospector().introspect(JavaTargetWireBuilder.class));
+ ctx.registerModelObject(comp);
+ ctx.publish(new ModuleStart(new Object()));
+ return runtime;
+ }
+
+ /**
+ * Registers the {@link FooBinding} builders with a given runtime
+ *
+ * @throws ConfigurationException
+ */
+ public static RuntimeContext registerFooBinding(RuntimeContext runtime) throws ConfigurationException {
+ CompositeContext child = (CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD);
+ child.getContext(MockFactory.JAVA_BUILDER).getInstance(null);
+ Component comp = systemFactory.createSystemComponent(FOO_BUILDER, ContextFactoryBuilder.class, FooBindingBuilder.class, Scope.MODULE);
+ comp.getImplementation().setComponentType(getIntrospector().introspect(FooBindingBuilder.class));
+ child.registerModelObject(comp);
+ comp = systemFactory.createSystemComponent(FOO_WIRE_BUILDER, WireBuilder.class, FooBindingWireBuilder.class, Scope.MODULE);
+ comp.getImplementation().setComponentType(getIntrospector().introspect(FooBindingWireBuilder.class));
+ child.registerModelObject(comp);
+ // since the child context is already started, we need to manually retrieve the components to init them
+ Assert.assertNotNull(child.getContext(FOO_BUILDER).getInstance(null));
+ Assert.assertNotNull(child.getContext(FOO_WIRE_BUILDER).getInstance(null));
+ return runtime;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockScopeContext.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockScopeContext.java
new file mode 100644
index 0000000000..fe128f19a7
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockScopeContext.java
@@ -0,0 +1,131 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.java.invocation.mock.SimpleTargetImpl;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.context.AtomicContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.ContextRuntimeException;
+import org.apache.tuscany.core.context.EventFilter;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.RuntimeEventListener;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.ScopeRuntimeException;
+import org.apache.tuscany.core.context.event.Event;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+
+public class MockScopeContext implements ScopeContext {
+
+ Map<String, Object> components;
+
+ public MockScopeContext() {
+ components = new HashMap<String, Object>();
+ components.put("foo", new SimpleTargetImpl());
+ components.put("bar", new SimpleTargetImpl());
+ }
+
+ public MockScopeContext(Map<String,Object> instances) {
+ components = instances;
+ }
+
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public void publish(Event object) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void addListener(RuntimeEventListener listener) throws ContextRuntimeException {
+ }
+
+ public void addListener(EventFilter filter, RuntimeEventListener listener) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void removeListener(RuntimeEventListener listener) throws ContextRuntimeException {
+ }
+
+ public String getName() {
+ return "Mock Scope Container";
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public int[] getEventTypes() {
+ return null;
+ }
+
+ public AtomicContext getContext(String name) {
+ return null;
+ }
+
+ public Object getInstance(QualifiedName name) throws ScopeRuntimeException {
+ return components.get(name.getPartName());
+ }
+
+ public AtomicContext getContextByKey(String name, Object key) {
+ return null;
+ }
+
+ public void setComponent(AtomicComponent component) throws ScopeRuntimeException {
+ }
+
+ public void removeContext(String name) throws ScopeRuntimeException {
+ }
+
+ public void removeContextByKey(String name, Object key) throws ScopeRuntimeException {
+ }
+
+ public AtomicComponent[] getComponents() {
+ return null;
+ }
+
+ public void registerFactories(List<ContextFactory<Context>> configurations) {
+ }
+
+ public void registerFactory(ContextFactory<Context> configuration) {
+ }
+
+ public int getLifecycleState(){
+ return RUNNING;
+ }
+
+
+ public void setLifecycleState(int state) {
+ }
+
+
+ public void setName(String name) {
+ }
+
+
+ public void onEvent(Event event) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java
new file mode 100644
index 0000000000..49c59bc718
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java
@@ -0,0 +1,58 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.binding.foo;
+
+import org.apache.tuscany.model.assembly.AssemblyContext;
+import org.apache.tuscany.model.assembly.AssemblyVisitor;
+import org.apache.tuscany.model.assembly.Binding;
+
+/**
+ * Represents a mock binding that echoes back a single parameter
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooBinding implements Binding {
+
+ public FooBinding() {
+ }
+
+ public String getURI() {
+ return null;
+ }
+
+ public void setURI(String value) {
+ }
+
+ public void initialize(AssemblyContext modelContext) {
+ }
+
+ public void freeze() {
+ }
+
+ public boolean accept(AssemblyVisitor visitor) {
+ return true;
+ }
+
+ private Object contextFactory;
+
+ public void setContextFactory(Object factory) {
+ contextFactory = factory;
+ }
+
+ public Object getContextFactory() {
+ System.out.println("retting");
+ return contextFactory;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java
new file mode 100644
index 0000000000..558a8ce2cf
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java
@@ -0,0 +1,114 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.binding.foo;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactoryBuilder;
+import org.apache.tuscany.core.builder.ContextFactoryBuilderRegistry;
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.extension.EntryPointContextFactory;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.model.assembly.AssemblyObject;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.tuscany.model.assembly.Service;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Creates a <code>ContextFactoryBuilder</code> for an entry point or external service configured with the {@link FooBinding}
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class FooBindingBuilder implements ContextFactoryBuilder {
+ private ContextFactoryBuilderRegistry builderRegistry;
+
+ private MessageFactory messageFactory;
+
+ private WireFactoryService wireFactoryService;
+
+ public FooBindingBuilder(WireFactoryService wireFactoryService) {
+ this.wireFactoryService = wireFactoryService;
+ }
+
+ public FooBindingBuilder() {
+ }
+
+ @Init(eager = true)
+ public void init() {
+ builderRegistry.register(this);
+ }
+
+ @Autowire
+ public void setBuilderRegistry(ContextFactoryBuilderRegistry builderRegistry) {
+ this.builderRegistry = builderRegistry;
+ }
+
+ @Autowire
+ public void setWireFactoryService(WireFactoryService wireFactoryService) {
+ this.wireFactoryService = wireFactoryService;
+ }
+
+
+ /**
+ * Sets the factory used to construct wire messages
+ *
+ * @param msgFactory
+ */
+ @Autowire
+ public void setMessageFactory(MessageFactory msgFactory) {
+ this.messageFactory = msgFactory;
+ }
+
+ public void build(AssemblyObject object) throws BuilderException {
+ if (object instanceof EntryPoint) {
+ EntryPoint ep = (EntryPoint) object;
+ if (ep.getBindings().size() < 1 || !(ep.getBindings().get(0) instanceof FooBinding)) {
+ return;
+ }
+ EntryPointContextFactory contextFactory = new FooEntryPointContextFactory(ep.getName(), messageFactory);
+ ConfiguredService configuredService = ep.getConfiguredService();
+ Service service = configuredService.getPort();
+ SourceWireFactory wireFactory = wireFactoryService.createSourceFactory(ep.getConfiguredReference()).get(0);
+ contextFactory.addSourceWireFactory(service.getName(), wireFactory);
+ ep.setContextFactory(contextFactory);
+ } else if (object instanceof ExternalService) {
+ ExternalService es = (ExternalService) object;
+ if (es.getBindings().size() < 1 || !(es.getBindings().get(0) instanceof FooBinding)) {
+ return;
+ }
+ FooExternalServiceContextFactory contextFactory = new FooExternalServiceContextFactory(es.getName(),
+ new FooClientFactory());
+ ConfiguredService configuredService = es.getConfiguredService();
+ Service service = configuredService.getPort();
+ TargetWireFactory wireFactory = wireFactoryService.createTargetFactory(configuredService);
+ contextFactory.addTargetWireFactory(service.getName(), wireFactory);
+ es.setContextFactory(contextFactory);
+ }
+ }
+
+ private static class FooClientFactory implements ObjectFactory {
+
+ public Object getInstance() throws ObjectCreationException {
+ return new FooClient();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java
new file mode 100644
index 0000000000..e2592024f8
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.binding.foo;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.wire.SourceInvocationConfiguration;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetInvocationConfiguration;
+import org.apache.tuscany.core.wire.TargetInvoker;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.osoa.sca.annotations.Init;
+
+public class FooBindingWireBuilder implements WireBuilder {
+
+ public FooBindingWireBuilder() {
+ super();
+ }
+
+ private RuntimeContext runtimeContext;
+
+ @Autowire
+ public void setRuntimeContext(RuntimeContext context) {
+ runtimeContext = context;
+ }
+
+ @Init(eager = true)
+ public void init() {
+ runtimeContext.addBuilder(this);
+ }
+
+
+ public void connect(SourceWireFactory sourceFactory, TargetWireFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) throws BuilderConfigException {
+ if (!FooExternalServiceContextFactory.class.isAssignableFrom(targetType)) {
+ return;
+ }
+ for (SourceInvocationConfiguration sourceInvocationConfig : sourceFactory.getConfiguration().getInvocationConfigurations()
+ .values()) {
+ FooExternalServiceTargetInvoker invoker = new FooExternalServiceTargetInvoker(sourceFactory.getConfiguration().getTargetName()
+ .getPartName());
+ sourceInvocationConfig.setTargetInvoker(invoker);
+ }
+
+ }
+
+ public void completeTargetChain(TargetWireFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ if (FooExternalServiceContextFactory.class.isAssignableFrom(targetType)) {
+ for (TargetInvocationConfiguration targetInvocationConfig : targetFactory.getConfiguration().getInvocationConfigurations()
+ .values()) {
+ TargetInvoker invoker = new FooExternalServiceTargetInvoker(targetFactory.getConfiguration().getTargetName().getQualifiedName());
+ targetInvocationConfig.setTargetInvoker(invoker);
+ }
+
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java
new file mode 100644
index 0000000000..9f67eb7786
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.binding.foo;
+
+import java.lang.reflect.Array;
+
+import org.apache.tuscany.core.context.TargetException;
+
+/**
+ * A mock client for a transport binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooClient {
+
+ public FooClient() {
+ }
+
+ public Object invoke(Object msg) {
+ if (msg!=null && msg.getClass().isArray() && Array.getLength(msg) == 1){
+ return Array.get(msg,0);
+ }else{
+ throw new TargetException("This binding only understands operations with a single parameter");
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointContextFactory.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointContextFactory.java
new file mode 100644
index 0000000000..69d81f66be
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointContextFactory.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.binding.foo;
+
+import org.apache.tuscany.core.extension.EntryPointContextFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooEntryPointContextFactory extends EntryPointContextFactory {
+
+ public FooEntryPointContextFactory(String name, MessageFactory msgFactory) {
+ super(name, msgFactory);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceContextFactory.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceContextFactory.java
new file mode 100644
index 0000000000..c7f67e2ff2
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceContextFactory.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.binding.foo;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.extension.ExternalServiceContextFactory;
+
+/**
+ * Creates instances of {@link org.apache.tuscany.core.context.ExternalServiceContext} configured with the appropriate
+ * wire chains and bindings. This implementation serves as a marker for
+ * {@link org.apache.tuscany.container.java.mock.binding.foo.FooBindingWireBuilder}
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooExternalServiceContextFactory extends ExternalServiceContextFactory {
+
+ public FooExternalServiceContextFactory(String name, ObjectFactory objectFactory) {
+ super(name, objectFactory);
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceTargetInvoker.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceTargetInvoker.java
new file mode 100644
index 0000000000..ecc9655a10
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceTargetInvoker.java
@@ -0,0 +1,78 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.binding.foo;
+
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.wire.Interceptor;
+import org.apache.tuscany.core.wire.TargetInvoker;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Responsible for invoking a mock transport binding client configured for an external service over a wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class FooExternalServiceTargetInvoker implements TargetInvoker {
+
+ private String name;
+ private ExternalServiceContext context;
+
+ public FooExternalServiceTargetInvoker(String esName) {
+ assert (esName != null) : "No external service name specified";
+ name = esName; // name is not used; it is included for illustration
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ FooClient client = new FooClient();
+ if (payload != null) {
+ return client.invoke(payload);
+ } else {
+ return client.invoke(null);
+ }
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setBody(e);
+ }
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ try {
+ FooExternalServiceTargetInvoker invoker = (FooExternalServiceTargetInvoker) super.clone();
+ invoker.context = this.context;
+ invoker.name = this.name;
+ return invoker;
+ } catch (CloneNotSupportedException e) {
+ return null; // will not happen
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/AbstractGenericComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/AbstractGenericComponent.java
new file mode 100644
index 0000000000..0c9d8172f8
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/AbstractGenericComponent.java
@@ -0,0 +1,296 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import java.util.List;
+import java.util.Map;
+
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * Base test component implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractGenericComponent implements GenericComponent {
+
+ @ComponentName
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ @Context
+ private ModuleContext context;
+
+ public ModuleContext getModuleContext() {
+ return context;
+ }
+
+ //----------------------------------
+ // Collections
+ //----------------------------------
+
+ Map testMap;
+
+ public Map getTestMap() {
+ return testMap;
+ }
+
+ public void setTestMap(Map testMap) {
+ this.testMap = testMap;
+ }
+
+ List testList;
+
+ public List getTestList() {
+ return testList;
+ }
+
+ public void setTestList(List testList) {
+ this.testList = testList;
+ }
+
+ //----------------------------------
+ // Arrays
+ //----------------------------------
+
+ private int[] arrayInt;
+
+ public int[] getArrayInt() {
+ return arrayInt;
+ }
+
+ public void setArrayInt(int[] arrayInt) {
+ this.arrayInt = arrayInt;
+ }
+
+ private float[] arrayFloat;
+
+ public float[] getArrayFloat() {
+ return arrayFloat;
+ }
+
+ public void setArrayFloat(float[] pArrayFloat) {
+ arrayFloat = pArrayFloat;
+ }
+
+ private double[] arrayDouble;
+
+ public double[] getArrayDouble() {
+ return arrayDouble;
+ }
+
+ public void setArrayDouble(double[] pArrayDouble) {
+ arrayDouble = pArrayDouble;
+ }
+
+ private long[] arrayLong;
+
+ public long[] getArrayLong() {
+ return arrayLong;
+ }
+
+ public void setArrayLong(long[] arrayLong) {
+ this.arrayLong = arrayLong;
+ }
+
+ private short[] arrayShort;
+
+ public short[] getArrayShort() {
+ return arrayShort;
+ }
+
+ public void setArrayShort(short[] arrayShort) {
+ this.arrayShort = arrayShort;
+ }
+
+ private boolean[] arrayBoolean;
+
+ public boolean[] getArrayBoolean() {
+ return arrayBoolean;
+ }
+
+ public void setArrayBoolean(boolean[] arrayBoolean) {
+ this.arrayBoolean = arrayBoolean;
+ }
+
+ private String[] arrayString;
+
+ public String[] getArrayString() {
+ return arrayString;
+ }
+
+ public void setArrayString(String[] arrayString) {
+ this.arrayString = arrayString;
+ }
+
+ //----------------------------------
+ // Primitives
+ //----------------------------------
+
+ private boolean mBoolean;
+
+ public boolean getBoolean() {
+ return mBoolean;
+ }
+
+ public void setBoolean(boolean pBoolean) {
+ mBoolean = pBoolean;
+ }
+
+ private short mShort;
+
+ public short getShort() {
+ return mShort;
+ }
+
+ public void setShort(short pShort) {
+ mShort = pShort;
+ }
+
+ private int mInt;
+
+ public int getInt() {
+ return mInt;
+ }
+
+ public void setInt(int pInt) {
+ mInt = pInt;
+ }
+
+ private long mLong;
+
+ public long getLong() {
+ return mLong;
+ }
+
+ public void setLong(long pLong) {
+ mLong = pLong;
+ }
+
+ private double mDouble;
+
+ public double getDouble() {
+ return mDouble;
+ }
+
+ public void setDouble(double pDouble) {
+ mDouble = pDouble;
+ }
+
+ private float mFloat;
+
+ public float getFloat() {
+ return mFloat;
+ }
+
+ public void setFloat(float pFloat) {
+ mFloat = pFloat;
+ }
+
+ private char mChar;
+
+ public char getChar() {
+ return mChar;
+ }
+
+ public void setChar(char pChar) {
+ mChar = pChar;
+ }
+
+ //----------------------------------
+ // Object types
+ //----------------------------------
+
+ private String mString;
+
+ public String getString() {
+ return mString;
+ }
+
+ public void setString(String pString) {
+ mString = pString;
+ }
+
+ private Short mOShort;
+
+ public Short getOShort() {
+ return mOShort;
+ }
+
+ public void setOShort(Short pOShort) {
+ mOShort = pOShort;
+ }
+
+ private Integer mOInteger;
+
+ public Integer getOInteger() {
+ return mOInteger;
+ }
+
+ public void setOInteger(Integer pOInteger) {
+ mOInteger = pOInteger;
+ }
+
+ private Long mOLong;
+
+ public Long getOLong() {
+ return mOLong;
+ }
+
+ public void setOLong(Long pOLong) {
+ mOLong = pOLong;
+ }
+
+ private Float mOFloat;
+
+ public Float getOFloat() {
+ return mOFloat;
+ }
+
+ public void setOFloat(Float pOFloat) {
+ mOFloat = pOFloat;
+ }
+
+ private Double mODouble;
+
+ public Double getODouble() {
+ return mODouble;
+ }
+
+ public void setODouble(Double pODouble) {
+ mODouble = pODouble;
+ }
+
+ @Property(name = "genericComponent")
+ private GenericComponent mGenericComponent;
+
+ public GenericComponent getGenericComponent() {
+ return mGenericComponent;
+ }
+
+ public void setGenericComponent(GenericComponent pGenericComponent) {
+ mGenericComponent = pGenericComponent;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadContextPojo.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadContextPojo.java
new file mode 100644
index 0000000000..7840b57dea
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadContextPojo.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Context;
+
+public class BadContextPojo {
+
+ @Context
+ String moduleContext;
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadNamePojo.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadNamePojo.java
new file mode 100644
index 0000000000..d9753fa9f0
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/BadNamePojo.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.ComponentName;
+
+public class BadNamePojo {
+ @ComponentName
+ private int name;
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/DataObject.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/DataObject.java
new file mode 100644
index 0000000000..695cc2a5a1
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/DataObject.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import java.io.Serializable;
+
+/**
+ * A complex type for testing
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataObject implements Serializable {
+
+ private String stringValue;
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/GenericComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/GenericComponent.java
new file mode 100644
index 0000000000..44f1c02bfd
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/GenericComponent.java
@@ -0,0 +1,142 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import java.util.List;
+import java.util.Map;
+
+import org.osoa.sca.ModuleContext;
+
+/**
+ * Generic test component
+ *
+ * @version $Rev$ $Date$
+ */
+public interface GenericComponent {
+
+ public String getName();
+
+ public ModuleContext getModuleContext();
+
+ // ----------------------------------
+ // Collections
+ // ----------------------------------
+
+ public Map getTestMap();
+
+ public void setTestMap(Map pTestMap);
+
+ public List getTestList();
+
+ public void setTestList(List pTestList);
+
+ // ----------------------------------
+ // Arrays
+ // ----------------------------------
+
+ public int[] getArrayInt();
+
+ public void setArrayInt(int[] pArrayInt);
+
+ public float[] getArrayFloat();
+
+ public void setArrayFloat(float[] pArrayFloat);
+
+ public double[] getArrayDouble();
+
+ public void setArrayDouble(double[] pArrayDouble);
+
+ public long[] getArrayLong();
+
+ public void setArrayLong(long[] pArrayLong);
+
+ public short[] getArrayShort();
+
+ public void setArrayShort(short[] pArrayShort);
+
+ public boolean[] getArrayBoolean();
+
+ public void setArrayBoolean(boolean[] pArrayBoolean);
+
+ public String[] getArrayString();
+
+ public void setArrayString(String[] pArrayString);
+
+ // ----------------------------------
+ // Primitives
+ // ----------------------------------
+
+ public boolean getBoolean();
+
+ public void setBoolean(boolean pBoolean);
+
+ public short getShort();
+
+ public void setShort(short pShort);
+
+ public int getInt();
+
+ public void setInt(int pInt);
+
+ public long getLong();
+
+ public void setLong(long pLong);
+
+ public double getDouble();
+
+ public void setDouble(double pDouble);
+
+ public float getFloat();
+
+ public void setFloat(float pFloat);
+
+ public char getChar();
+
+ public void setChar(char pChar);
+
+ // ----------------------------------
+ // Object types
+ // ----------------------------------
+
+ public String getString();
+
+ public void setString(String pString);
+
+ public Short getOShort();
+
+ public void setOShort(Short pOShort);
+
+ public Integer getOInteger();
+
+ public void setOInteger(Integer pOInteger);
+
+ public Long getOLong();
+
+ public void setOLong(Long pOLong);
+
+ public Float getOFloat();
+
+ public void setOFloat(Float pOFloat);
+
+ public Double getODouble();
+
+ public void setODouble(Double pODouble);
+
+ public GenericComponent getGenericComponent();
+
+ public void setGenericComponent(GenericComponent pGenericComponent);
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/HelloWorldClient.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/HelloWorldClient.java
new file mode 100644
index 0000000000..1e7ca9f36b
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/HelloWorldClient.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldClient implements HelloWorldService{
+
+ private int count;
+
+ public HelloWorldClient() {
+ }
+
+ private HelloWorldService service;
+
+ public void setHelloWorldService(HelloWorldService service){
+ this.service = service;
+ }
+
+ public String hello(String name) {
+ ++count;
+ return service.hello(name);
+ }
+
+ public int count() {
+ return count;
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/LocalComponentImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/LocalComponentImpl.java
new file mode 100644
index 0000000000..4b57c7f301
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/LocalComponentImpl.java
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.ModuleContext;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * A test local service
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class LocalComponentImpl {
+
+ @ComponentName
+ protected String name;
+
+ public String getName() {
+ return name;
+ }
+
+ @Context
+ protected ModuleContext moduleCtx;
+
+ public ModuleContext getModuleContext() {
+ return moduleCtx;
+ }
+
+ @Property(name = "fieldSetter", required = true)
+ private String mfieldSetter;
+
+ public String getfieldSetter() {
+ return mfieldSetter;
+ }
+
+ public void setfieldSetter(String pfieldSetter) throws Exception {
+ throw new Exception("Set method instead of field");
+ }
+
+ private String mMethodSetter;
+ boolean mSetByMethod;
+
+ public String getMethodSetter() throws Exception {
+ if (mSetByMethod) {
+ return mMethodSetter;
+ }
+ throw new Exception("Property method setter failed");
+
+ }
+
+ @Property(required = true)
+ public void setMethodSetter(String pMethodSetter) {
+ mSetByMethod = true;
+ mMethodSetter = pMethodSetter;
+ }
+
+ @Reference(name = "requiredDataObject", required = true)
+ private DataObject mRequiredDataObject;
+
+ public DataObject getRequiredDataObject() {
+ return mRequiredDataObject;
+ }
+
+ public void setRequiredDataObject(DataObject pRequiredDataObject) {
+ mRequiredDataObject = pRequiredDataObject;
+ }
+
+ @Reference(name = "optionalDataObject")
+ private DataObject mOptionalDataObject;
+
+ public DataObject getOptionalDataObject() {
+ return mOptionalDataObject;
+ }
+
+ public void setOptionalDataObject(DataObject pOptionalDataObject) {
+ mOptionalDataObject = pOptionalDataObject;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponent.java
new file mode 100644
index 0000000000..04cbb01de6
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponent.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public interface ModuleScopeComponent extends GenericComponent {
+ public GenericComponent getGenericComponent();
+
+ public String getString();
+ //public boolean isInit();
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.componentType b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.componentType
new file mode 100644
index 0000000000..ca4c633e59
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.componentType
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<!-- remove this once ImplementationImpl is fixed not to requrie this -->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9">
+
+ <service name="ModuleScopeComponent" scope="module">
+ <interface.java interface="janus.test.component.ModuleScopeComponent"/>
+ </service>
+ <!-- Not supported, not in the spec
+ <property.java name="mInt" class="java.lang.Integer" default="default"/>
+ <property.java name="foo" class="java.lang.String" default="default"/>
+ -->
+ <reference name="mGenericComponent" multiplicity="0..1">
+ <interface.java interface="test.org.apache.tuscany.container.java.components.AbstractGenericComponent"/>
+ </reference>
+
+</componentType>
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.java
new file mode 100644
index 0000000000..7981208b9e
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeComponentImpl.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class ModuleScopeComponentImpl extends AbstractGenericComponent implements
+ ModuleScopeComponent {
+
+ private String foo;
+
+ public void setFoo(String foo) {
+ this.foo = foo;
+ }
+
+ public String getFoo() {
+ return foo;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..76218c2d6c
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeDestroyOnlyComponent.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class ModuleScopeDestroyOnlyComponent extends ModuleScopeComponentImpl {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitComponent.java
new file mode 100644
index 0000000000..56a0421f24
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitComponent.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Init;
+
+public class ModuleScopeEagerInitComponent extends ModuleScopeComponentImpl {
+
+ boolean initialized = false;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ // this value tests to ensure introspection can find the init() method even
+ // if a field is named the same. Ultimately, this should be in the
+ // introspection tests
+ private boolean init;
+
+ @Init(eager = true)
+ public void init() {
+ initialized = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitDestroyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitDestroyComponent.java
new file mode 100644
index 0000000000..dae156737a
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeEagerInitDestroyComponent.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class ModuleScopeEagerInitDestroyComponent extends ModuleScopeEagerInitComponent {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..695157612b
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class ModuleScopeInitDestroyComponent extends ModuleScopeInitOnlyComponent {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ if (destroyed){
+ throw new AssertionError("Destroy called more than once");
+ }
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..4945309852
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Init;
+
+public class ModuleScopeInitOnlyComponent extends ModuleScopeComponentImpl {
+
+ boolean initialized = false;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ // this value tests to ensure introspection can find the init() method even
+ // if a field is named the same. Ultimately, this should be in the introspection tests
+ private boolean init;
+
+ @Init
+ public void init() {
+ if (initialized){
+ throw new AssertionError("Init called more than once");
+ }
+ initialized = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/OtherTarget.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/OtherTarget.java
new file mode 100644
index 0000000000..2edc8246db
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/OtherTarget.java
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface OtherTarget {
+
+ public String getString();
+
+ public void setString(String val);
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/OtherTargetImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/OtherTargetImpl.java
new file mode 100644
index 0000000000..08d4d9f720
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/OtherTargetImpl.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+/**
+ * A target used for testing wires with a different source and target interface
+ *
+ * @version $Rev$ $Date$
+ */
+public class OtherTargetImpl implements OtherTarget{
+
+ private String theString;
+
+ public String getString() {
+ return theString;
+ }
+
+ public void setString(String val) {
+ theString = val;
+ }
+
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableService.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableService.java
new file mode 100644
index 0000000000..645fd7f47c
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableService.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Used for testing basic remoting operations
+ *
+ * @version $Rev$ $Date$
+ */
+
+@Remotable
+public interface RemotableService {
+
+ public void syncOneWay(String msg);
+
+ public String syncTwoWay(String msg);
+
+ public DataObject syncTwoWayCustomType(DataObject val);
+
+ public String getString();
+
+ public void setString(String string);
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableServiceImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableServiceImpl.java
new file mode 100644
index 0000000000..34a4273323
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RemotableServiceImpl.java
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import junit.framework.Assert;
+import org.osoa.sca.annotations.Property;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RemotableServiceImpl implements RemotableService {
+
+ // ----------------------------------
+ // Properties
+ // ----------------------------------
+
+ @Property(name = "string", required = true)
+ private String mString;
+
+ public String getString() {
+ return mString;
+ }
+
+ public void setString(String string) {
+ mString = string;
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public void syncOneWay(String msg) {
+ Assert.assertEquals("hello", msg);
+ }
+
+ public String syncTwoWay(String msg) {
+ return "response";
+ }
+
+ public DataObject syncTwoWayCustomType(DataObject val) {
+ Assert.assertEquals("hello", val.getStringValue());
+ DataObject dto = new DataObject();
+ dto.setStringValue("return");
+ return dto;
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponent.java
new file mode 100644
index 0000000000..ac7931bd2c
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponent.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("REQUEST")
+public interface RequestScopeComponent extends GenericComponent {
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponentImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponentImpl.java
new file mode 100644
index 0000000000..5b20519d90
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeComponentImpl.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RequestScopeComponentImpl extends AbstractGenericComponent implements
+ RequestScopeComponent {
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..ae63f761c3
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeDestroyOnlyComponent.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("REQUEST")
+public class RequestScopeDestroyOnlyComponent extends SessionScopeComponentImpl {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeInitDestroyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..67f61df36d
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeInitDestroyComponent.java
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("REQUEST")
+public class RequestScopeInitDestroyComponent extends SessionScopeInitOnlyComponent {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeInitOnlyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..c6c621f518
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/RequestScopeInitOnlyComponent.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("REQUEST")
+public class RequestScopeInitOnlyComponent extends SessionScopeComponentImpl {
+
+ boolean initialized = false;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ @Init
+ public void init() {
+ initialized = true;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponent.java
new file mode 100644
index 0000000000..236e083a2b
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponent.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("SESSION")
+public interface SessionScopeComponent extends GenericComponent {
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponentImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponentImpl.java
new file mode 100644
index 0000000000..265969a450
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeComponentImpl.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("SESSION")
+public class SessionScopeComponentImpl extends AbstractGenericComponent implements
+ SessionScopeComponent {
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeDestroyOnlyComponent.java
new file mode 100644
index 0000000000..be20a23d29
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeDestroyOnlyComponent.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class SessionScopeDestroyOnlyComponent extends SessionScopeComponentImpl {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitDestroyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitDestroyComponent.java
new file mode 100644
index 0000000000..32aa0142a4
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitDestroyComponent.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Destroy;
+
+public class SessionScopeInitDestroyComponent extends SessionScopeInitOnlyComponent {
+
+ boolean destroyed = false;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitOnlyComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitOnlyComponent.java
new file mode 100644
index 0000000000..a518a9b244
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SessionScopeInitOnlyComponent.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Init;
+
+public class SessionScopeInitOnlyComponent extends SessionScopeComponentImpl {
+
+ boolean initialized = false;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ @Init
+ public void init() {
+ initialized = true;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/Source.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/Source.java
new file mode 100644
index 0000000000..1f918590f2
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/Source.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import java.util.List;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Source {
+
+ public Target getTarget();
+
+ public List<Target> getTargets();
+
+ public List<Target> getTargetsThroughField();
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SourceImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SourceImpl.java
new file mode 100644
index 0000000000..a2588bae5e
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/SourceImpl.java
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import java.util.List;
+
+/**
+ * Mock system component implementation used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public class SourceImpl implements Source {
+
+ private Target target;
+
+ private List<Target> targets;
+
+ private List<Target> targetsThroughField;
+
+ public void setTarget(Target target) {
+ this.target = target;
+ }
+
+ public Target getTarget() {
+ return target;
+ }
+
+ public List<Target> getTargets() {
+ return targets;
+ }
+
+ public void setTargets(List<Target> targets) {
+ this.targets = targets;
+ }
+
+ public List<Target> getTargetsThroughField() {
+ return targetsThroughField;
+ }
+
+
+ private Target[] targetsArray;
+
+ public Target[] getArrayOfTargets() {
+ return targetsArray;
+ }
+
+ public void setArrayOfTargets(Target[] targets) {
+ targetsArray = targets;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponent.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponent.java
new file mode 100644
index 0000000000..3fe84dd785
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponent.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("STATELESS")
+public interface StatelessComponent extends GenericComponent {
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponentImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponentImpl.java
new file mode 100644
index 0000000000..8b806d6a2e
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/StatelessComponentImpl.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessComponentImpl extends AbstractGenericComponent implements
+ StatelessComponent {
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/Target.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/Target.java
new file mode 100644
index 0000000000..a56e52c898
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/Target.java
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+/**
+ * Implementations are used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Target {
+
+ public String getString();
+
+ public void setString(String val);
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/TargetImpl.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/TargetImpl.java
new file mode 100644
index 0000000000..5a10bfdbc1
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/TargetImpl.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.mock.components;
+
+/**
+ * Mock system component implementation used in wiring tests
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetImpl implements Target {
+
+ private String theString;
+
+ public String getString() {
+ return theString;
+ }
+
+ public void setString(String val) {
+ theString = val;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicModuleScopeTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicModuleScopeTestCase.java
new file mode 100644
index 0000000000..557f306ad2
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicModuleScopeTestCase.java
@@ -0,0 +1,139 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
+import org.apache.tuscany.core.config.ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.ModuleStop;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Unit tests for the module scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicModuleScopeTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInstanceManagement() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ // first request
+ scope.onEvent(new ModuleStart(this));
+ ModuleScopeComponentImpl comp1 = (ModuleScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ // second request
+ ModuleScopeComponentImpl comp2 = (ModuleScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertSame(comp1, comp2);
+ scope.onEvent(new ModuleStop(this));
+ scope.stop();
+ }
+
+ public void testSetNullComponents() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ scope.onEvent(new ModuleStart(this));
+ scope.onEvent(new ModuleStop(this));
+ scope.stop();
+ }
+
+ public void testRegisterContextBeforeStart() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ scope.registerFactory(createConfiguration("NewTestService"));
+ scope.onEvent(new ModuleStart(this));
+ ModuleScopeInitDestroyComponent comp2 = (ModuleScopeInitDestroyComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertTrue(comp2.isInitialized());
+ scope.onEvent(new ModuleStop(this));
+ Assert.assertTrue(comp2.isDestroyed());
+ scope.stop();
+ }
+
+ public void testRegisterContextAfterStart() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.start();
+ scope.registerFactory(createConfiguration("NewTestService"));
+ scope.onEvent(new ModuleStart(this));
+ scope.registerFactories(createConfigurations());
+ ModuleScopeInitDestroyComponent comp2 = (ModuleScopeInitDestroyComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertTrue(comp2.isInitialized());
+ scope.onEvent(new ModuleStop(this));
+ Assert.assertTrue(comp2.isDestroyed());
+ scope.stop();
+ }
+
+
+ private List<ContextFactory<Context>> createConfigurations() throws BuilderException, ConfigurationLoadException {
+ PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+ AtomicComponent component = MockFactory.createComponent("TestService1", ModuleScopeComponentImpl.class, Scope.MODULE);
+ builder.build(component);
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ configs.add((ContextFactory<Context>) component.getContextFactory());
+ return configs;
+ }
+
+ private ContextFactory<Context> createConfiguration(String name) throws BuilderException, ConfigurationLoadException {
+ PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+ AtomicComponent component = MockFactory.createComponent(name, ModuleScopeInitDestroyComponent.class,
+ Scope.MODULE);
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ComponentType type = introspector.introspect(ModuleScopeInitDestroyComponent.class);
+ component.getImplementation().setComponentType(type);
+ builder.build(component);
+ return (ContextFactory<Context>) component.getContextFactory();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicRequestScopeTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicRequestScopeTestCase.java
new file mode 100644
index 0000000000..e53b9fc9ac
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicRequestScopeTestCase.java
@@ -0,0 +1,158 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.RequestScopeComponent;
+import org.apache.tuscany.container.java.mock.components.RequestScopeComponentImpl;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.event.RequestEnd;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.RequestScopeContext;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+
+/**
+ * Unit tests for the request scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicRequestScopeTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInstanceManagement() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+
+ // first request
+ RequestScopeComponentImpl comp1 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ Object id = new Object();
+ scope.onEvent(new RequestEnd(this,id));
+
+ // second request
+ RequestScopeComponentImpl comp2 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertNotSame(comp1, comp2);
+ Object id2 = new Object();
+ scope.onEvent(new RequestEnd(this,id2));
+
+ scope.stop();
+ }
+
+ public void testRegisterContextBeforeRequest() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.registerFactory(createConfiguration("NewTestService"));
+ scope.start();
+ RequestScopeComponent comp1 = (RequestScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Object id = new Object();
+ scope.onEvent(new RequestEnd(this,id));
+ scope.stop();
+ }
+
+ public void testRegisterContextAfterRequest() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ RequestScopeComponent comp1 = (RequestScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ scope.registerFactory(createConfiguration("NewTestService"));
+ RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Object id = new Object();
+ scope.onEvent(new RequestEnd(this,id));
+ scope.stop();
+ }
+
+ /**
+ * Tests setting no components in the scope
+ */
+ public void testSetNullComponents() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ scope.stop();
+ }
+
+ public void testGetComponentByKey() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+
+ RequestScopeComponentImpl comp1 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ Object id = new Object();
+ scope.onEvent(new RequestEnd(this,id));
+
+ // second request
+ // should be null since the other context (thread) expired w/ onEvent(..)
+ Assert.assertNull(scope.getContextByKey("TestService1", Thread.currentThread()));
+ // Note should test better using concurrent threads to pull the instance
+
+ scope.stop();
+ }
+
+
+ private List<ContextFactory<Context>> createConfigurations() throws BuilderException, ConfigurationLoadException {
+ AtomicComponent component = MockFactory.createComponent("TestService1", RequestScopeComponentImpl.class,
+ Scope.REQUEST);
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+ builder.build(component);
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ configs.add((ContextFactory<Context>) component.getContextFactory());
+ return configs;
+ }
+
+ private ContextFactory<Context> createConfiguration(String name) throws BuilderException, ConfigurationLoadException {
+ AtomicComponent component = MockFactory.createComponent(name, RequestScopeComponentImpl.class,
+ Scope.REQUEST);
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+ builder.build(component);
+ return (ContextFactory<Context>) component.getContextFactory();
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicSessionScopeTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicSessionScopeTestCase.java
new file mode 100644
index 0000000000..8bee9a9741
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicSessionScopeTestCase.java
@@ -0,0 +1,238 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.SessionScopeComponent;
+import org.apache.tuscany.container.java.mock.components.SessionScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.SessionScopeInitDestroyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.config.ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.event.HttpSessionEnd;
+import org.apache.tuscany.core.context.event.HttpSessionEvent;
+import org.apache.tuscany.core.context.event.RequestEnd;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.SessionScopeContext;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Unit tests for the Http session scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicSessionScopeTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInstanceManagement() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ SessionScopeContext scope = new SessionScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ Object session = new Object();
+ Object session2 = new Object();
+ // first request
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session);
+ SessionScopeComponent comp1 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ // second request
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session);
+ SessionScopeComponent comp2 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertSame(comp1, comp2);
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ // third request, different session
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session2);
+ SessionScopeComponent comp3 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp3);
+ Assert.assertNotSame(comp1, comp3); // should be different instances
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ scope.onEvent(new HttpSessionEnd(this, session));
+ scope.onEvent(new HttpSessionEnd(this, session2));
+ scope.stop();
+ }
+
+ /**
+ * Tests setting no components in the scope
+ */
+ public void testSetNullComponents() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ SessionScopeContext scope = new SessionScopeContext(ctx);
+ scope.registerFactories(new ArrayList<ContextFactory<Context>>());
+ scope.start();
+ scope.stop();
+ }
+
+ public void testGetContextByKey() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ SessionScopeContext scope = new SessionScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ Object session = new Object();
+ Object session2 = new Object();
+
+ // first request
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session);
+ SessionScopeComponent comp1 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ // second request, different session
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session2);
+ SessionScopeComponent comp2 = (SessionScopeComponent) scope.getContextByKey("TestService1", session)
+ .getInstance(null);
+ SessionScopeComponent comp3 = (SessionScopeComponent) scope.getContextByKey("TestService1", session)
+ .getInstance(null);
+ Assert.assertNotNull(comp2);
+ Object id = new Object();
+ scope.onEvent(new RequestEnd(this, id));
+ Assert.assertSame(comp1, comp2); // should be same instances
+ Assert.assertSame(comp2, comp3); // should not be same instances
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ // shutdown sessions
+ scope.onEvent(new HttpSessionEnd(this, session));
+ scope.onEvent(new HttpSessionEnd(this, session2));
+
+ scope.stop();
+ }
+
+ public void testRegisterContextBeforeSession() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ SessionScopeContext scope = new SessionScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ Object session = new Object();
+ scope.registerFactory(createConfiguration("NewTestService"));
+
+ // first request
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session);
+
+ SessionScopeInitDestroyComponent comp2 = (SessionScopeInitDestroyComponent) scope.getContext("NewTestService")
+ .getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertTrue(comp2.isInitialized());
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ // second request different session
+ Object session2 = new Object();
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session2);
+ SessionScopeInitDestroyComponent comp3 = (SessionScopeInitDestroyComponent) scope.getContext("NewTestService")
+ .getInstance(null);
+ Assert.assertNotNull(comp3);
+ Assert.assertNotSame(comp2, comp3);
+ Assert.assertTrue(comp3.isInitialized());
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ scope.onEvent(new HttpSessionEnd(this, session));
+ Assert.assertTrue(comp2.isDestroyed());
+
+ scope.onEvent(new HttpSessionEnd(this, session2));
+ Assert.assertTrue(comp3.isDestroyed());
+ scope.stop();
+ }
+
+ /**
+ * Tests runtime context registration
+ */
+ public void testRegisterContextAfterSession() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ SessionScopeContext scope = new SessionScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ Object session = new Object();
+
+ // first request
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session);
+ SessionScopeComponent comp1 = (SessionScopeComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ scope.registerFactory(createConfiguration("NewTestService"));
+
+ // second request
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session);
+ SessionScopeInitDestroyComponent comp2 = (SessionScopeInitDestroyComponent) scope.getContext("NewTestService")
+ .getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertTrue(comp2.isInitialized());
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ // third request different session
+ Object session2 = new Object();
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER, session2);
+ SessionScopeInitDestroyComponent comp3 = (SessionScopeInitDestroyComponent) scope.getContext("NewTestService")
+ .getInstance(null);
+ Assert.assertNotNull(comp3);
+ Assert.assertNotSame(comp2, comp3);
+ Assert.assertTrue(comp3.isInitialized());
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ scope.onEvent(new HttpSessionEnd(this, session));
+ Assert.assertTrue(comp2.isDestroyed());
+
+ scope.onEvent(new HttpSessionEnd(this, session2));
+ Assert.assertTrue(comp3.isDestroyed());
+ scope.stop();
+ }
+
+ private List<ContextFactory<Context>> createConfigurations() throws BuilderException, ConfigurationLoadException {
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+ AtomicComponent component = MockFactory.createComponent("TestService1", SessionScopeComponentImpl.class, Scope.SESSION);
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ComponentType type = introspector.introspect(SessionScopeComponentImpl.class);
+ component.getImplementation().setComponentType(type);
+ builder.build(component);
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ configs.add((ContextFactory<Context>) component.getContextFactory());
+ return configs;
+ }
+
+ private ContextFactory<Context> createConfiguration(String name) throws BuilderException, ConfigurationLoadException {
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+ AtomicComponent component = MockFactory.createComponent(name, SessionScopeInitDestroyComponent.class, Scope.SESSION);
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ComponentType type = introspector.introspect(SessionScopeInitDestroyComponent.class);
+ component.getImplementation().setComponentType(type);
+ builder.build(component);
+ return (ContextFactory<Context>) component.getContextFactory();
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicStatelessScopeTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicStatelessScopeTestCase.java
new file mode 100644
index 0000000000..3765c8bf27
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/BasicStatelessScopeTestCase.java
@@ -0,0 +1,129 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.StatelessComponent;
+import org.apache.tuscany.container.java.mock.components.StatelessComponentImpl;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.StatelessScopeContext;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+
+/**
+ * Unit tests for the module scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicStatelessScopeTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInstanceManagement() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ StatelessScopeContext scope = new StatelessScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ // first request
+ StatelessComponentImpl comp1 = (StatelessComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ // second request
+ StatelessComponentImpl comp2 = (StatelessComponentImpl) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp2);
+ Assert.assertNotSame(comp1, comp2);
+ scope.stop();
+ }
+
+ public void testRegisterContextBeforeRequest() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ StatelessScopeContext scope = new StatelessScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.registerFactory(createConfiguration("NewTestService"));
+ scope.start();
+ StatelessComponent comp1 = (StatelessComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ StatelessComponent comp2 = (StatelessComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ scope.stop();
+ }
+
+ public void testRegisterContextAfterRequest() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ StatelessScopeContext scope = new StatelessScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ StatelessComponent comp1 = (StatelessComponent) scope.getContext("TestService1").getInstance(null);
+ Assert.assertNotNull(comp1);
+ scope.registerFactory(createConfiguration("NewTestService"));
+ StatelessComponent comp2 = (StatelessComponent) scope.getContext("NewTestService").getInstance(null);
+ Assert.assertNotNull(comp2);
+ scope.stop();
+ }
+
+
+ /**
+ * Tests setting no components in the scope
+ */
+ public void testSetNullComponents() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ StatelessScopeContext scope = new StatelessScopeContext(ctx);
+ scope.registerFactories(createConfigurations());
+ scope.start();
+ scope.stop();
+ }
+
+ private List<ContextFactory<Context>> createConfigurations()
+ throws NoSuchMethodException, BuilderException, ConfigurationLoadException {
+ AtomicComponent component = MockFactory.createComponent("TestService1", StatelessComponentImpl.class,
+ Scope.INSTANCE);
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+ builder.build(component);
+ List<ContextFactory<Context>> configs = new ArrayList();
+ configs.add((ContextFactory<Context>) component.getContextFactory());
+ return configs;
+ }
+
+ private ContextFactory<Context> createConfiguration(String name)
+ throws NoSuchMethodException, BuilderException, ConfigurationLoadException {
+ AtomicComponent component = MockFactory.createComponent(name, StatelessComponentImpl.class,
+ Scope.INSTANCE);
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(),new DefaultPolicyBuilderRegistry());
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+ builder.build(component);
+ return (ContextFactory<Context>) component.getContextFactory();
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/CompositeScopeTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/CompositeScopeTestCase.java
new file mode 100644
index 0000000000..d5b5a29e9c
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/CompositeScopeTestCase.java
@@ -0,0 +1,188 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
+ * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.GenericComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeComponentImpl;
+import org.apache.tuscany.container.java.mock.components.SessionScopeComponentImpl;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.RequestStart;
+import org.apache.tuscany.core.context.event.HttpSessionBound;
+import org.apache.tuscany.core.context.event.RequestEnd;
+import org.apache.tuscany.core.context.event.HttpSessionEnd;
+import org.apache.tuscany.core.context.event.ModuleStop;
+import org.apache.tuscany.core.context.impl.CompositeContextImpl;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.CompositeScopeContext;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.model.assembly.Extensible;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+
+/**
+ * Tests component nesting. This test needs to be in the container.java progject since it relies on Java POJOs for scope
+ * testing.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeScopeTestCase extends TestCase {
+
+ /**
+ * Ensures scope events are propagated in an composite scope
+ */
+ public void testCompositeScopePropagation() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ CompositeContext moduleComponentCtx = new CompositeContextImpl();
+ moduleComponentCtx.setName("testMC");
+ moduleComponentCtx.start();
+ CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
+ scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
+ scopeContainer.start();
+ CompositeContext child = (CompositeContext) scopeContainer.getContext("CompositeComponent");
+ List<Extensible> models = createAssembly();
+ for (Extensible model : models) {
+ child.registerModelObject(model);
+ }
+
+ scopeContainer.onEvent(new ModuleStart(this));
+ Object session = new Object();
+ Object id = new Object();
+ //ctx.setIdentifier(EventContext.SESSION,session);
+ scopeContainer.onEvent(new RequestStart(this,id));
+ scopeContainer.onEvent(new HttpSessionBound(this,session));
+ CompositeContext componentCtx = (CompositeContext) scopeContainer.getContext("CompositeComponent");
+ GenericComponent testService1 = (GenericComponent) componentCtx.getContext("TestService1").getInstance(null);
+ GenericComponent testService2 = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
+ GenericComponent testService3 = (GenericComponent) componentCtx.getContext("TestService3").getInstance(null);
+ Assert.assertNotNull(testService1);
+ Assert.assertNotNull(testService2);
+ Assert.assertNotNull(testService3);
+ scopeContainer.onEvent(new RequestEnd(this,id));
+ scopeContainer.onEvent(new RequestStart(this,id));
+ scopeContainer.onEvent(new HttpSessionBound(this,session));
+
+ GenericComponent testService2a = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
+ Assert.assertNotNull(testService2a);
+ GenericComponent testService3a = (GenericComponent) componentCtx.getContext("TestService3").getInstance(null);
+ Assert.assertNotNull(testService3a);
+ Assert.assertEquals(testService2, testService2a);
+ Assert.assertNotSame(testService3, testService3a);
+ scopeContainer.onEvent(new RequestEnd(this,id));
+ scopeContainer.onEvent(new HttpSessionEnd(this,session));
+
+ Object session2 = new Object();
+ Object id2 = new Object();
+ scopeContainer.onEvent(new RequestStart(this,id2));
+ scopeContainer.onEvent(new HttpSessionBound(this,session2));
+ GenericComponent testService2b = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
+ Assert.assertNotNull(testService2b);
+ Assert.assertNotSame(testService2, testService2b);
+
+ scopeContainer.onEvent(new RequestEnd(this,id2));
+ scopeContainer.onEvent(new HttpSessionEnd(this,session2));
+
+ }
+
+ /**
+ * Ensures only child entry points (and not components) are accessible from parents
+ */
+ public void testCompositeNoEntryPoint() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ CompositeContext moduleComponentCtx = new CompositeContextImpl();
+ moduleComponentCtx.setName("testMC");
+ CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
+ scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
+ scopeContainer.start();
+ CompositeContext child = (CompositeContext) scopeContainer.getContext("CompositeComponent");
+ List<Extensible> parts = createAssembly();
+ for (Extensible part : parts) {
+ child.registerModelObject(part);
+ }
+ scopeContainer.onEvent(new ModuleStart(this));
+ scopeContainer.getContext("CompositeComponent");
+ }
+
+ /**
+ * Tests adding a context before its parent has been started
+ */
+ public void testRegisterContextBeforeStart() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ CompositeContext moduleComponentCtx = new CompositeContextImpl();
+ moduleComponentCtx.setName("testMC");
+ CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
+ scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
+ scopeContainer.start();
+ scopeContainer.onEvent(new ModuleStart(this));
+ scopeContainer.getContext("CompositeComponent");
+ scopeContainer.onEvent(new ModuleStop(this));
+ scopeContainer.stop();
+ }
+
+ /**
+ * Tests adding a context after its parent has been started
+ */
+ public void testRegisterContextAfterStart() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ CompositeContext moduleComponentCtx = new CompositeContextImpl();
+ moduleComponentCtx.setName("testMC");
+ CompositeScopeContext scopeContainer = new CompositeScopeContext(ctx);
+ scopeContainer.start();
+
+ scopeContainer.onEvent(new ModuleStart(this));
+ scopeContainer.registerFactory(MockFactory.createCompositeConfiguration("CompositeComponent"));
+ scopeContainer.getContext("CompositeComponent");
+ scopeContainer.onEvent(new ModuleStop(this));
+ scopeContainer.stop();
+ }
+
+ /**
+ * Creats an assembly containing a module-scoped component definition, a session-scoped component definition, and a
+ * request-scoped component definition
+ *
+ */
+ private List<Extensible> createAssembly() throws BuilderException, ConfigurationLoadException {
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);
+ AtomicComponent component = MockFactory.createComponent("TestService1", ModuleScopeComponentImpl.class, Scope.MODULE);
+ AtomicComponent sessionComponent = MockFactory.createComponent("TestService2", SessionScopeComponentImpl.class,
+ Scope.SESSION);
+ AtomicComponent requestComponent = MockFactory.createComponent("TestService3", SessionScopeComponentImpl.class,
+ Scope.REQUEST);
+ builder.build(component);
+ builder.build(sessionComponent);
+ builder.build(requestComponent);
+ List<Extensible> configs = new ArrayList<Extensible>();
+ configs.add(component);
+ configs.add(sessionComponent);
+ configs.add(requestComponent);
+ return configs;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/DependencyLifecycleTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/DependencyLifecycleTestCase.java
new file mode 100644
index 0000000000..dc3fe3efcb
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/DependencyLifecycleTestCase.java
@@ -0,0 +1,93 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.container.java.mock.MockContextFactory;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.ModuleStop;
+import org.apache.tuscany.core.context.event.HttpSessionBound;
+import org.apache.tuscany.core.context.event.HttpSessionEvent;
+import org.apache.tuscany.core.context.event.HttpSessionEnd;
+import org.apache.tuscany.core.context.event.RequestStart;
+import org.apache.tuscany.core.context.event.RequestEnd;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.core.context.scope.SessionScopeContext;
+import org.apache.tuscany.core.context.scope.RequestScopeContext;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Tests that dependencies are initalized and destroyed in the proper order (i.e. LIFO)
+ *
+ * @version $Rev: 393992 $ $Date: 2006-04-13 18:01:05 -0700 (Thu, 13 Apr 2006) $
+ */
+public class DependencyLifecycleTestCase extends TestCase {
+
+
+
+ public void testInitDestroyOrderModuleScope() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerFactories(MockContextFactory.createWiredContexts(Scope.MODULE,scope));
+ scope.start();
+ scope.onEvent(new ModuleStart(this));
+ OrderedDependentPojo source = (OrderedDependentPojo) scope.getContext("source").getInstance(null);
+ assertNotNull(source.getPojo());
+ // expire module
+ assertEquals(2,source.getNumberInstantiated());
+ scope.onEvent(new ModuleStop(this));
+ assertEquals(0,source.getNumberInstantiated());
+ scope.stop();
+ }
+
+ public void testInitDestroyOrderSessionScope() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ SessionScopeContext scope = new SessionScopeContext(ctx);
+ scope.registerFactories(MockContextFactory.createWiredContexts(Scope.SESSION,scope));
+ scope.start();
+ Object session = new Object();
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER,session);
+ scope.onEvent(new HttpSessionBound(this,session));
+ OrderedDependentPojo source = (OrderedDependentPojo) scope.getContext("source").getInstance(null);
+ assertNotNull(source.getPojo());
+ // expire module
+ assertEquals(2,source.getNumberInstantiated());
+ scope.onEvent(new HttpSessionEnd(this,session));
+ assertEquals(0,source.getNumberInstantiated());
+ scope.stop();
+ }
+
+
+ public void testInitDestroyOrderRequestScope() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerFactories(MockContextFactory.createWiredContexts(Scope.REQUEST,scope));
+ scope.start();
+ Object request = new Object();
+ scope.onEvent(new RequestStart(this,request));
+ OrderedDependentPojo source = (OrderedDependentPojo) scope.getContext("source").getInstance(null);
+ assertNotNull(source.getPojo());
+ // expire module
+ assertEquals(2,source.getNumberInstantiated());
+ scope.onEvent(new RequestEnd(this,request));
+ assertEquals(0,source.getNumberInstantiated());
+ scope.stop();
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/ModuleScopeLifecycleTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/ModuleScopeLifecycleTestCase.java
new file mode 100644
index 0000000000..904e218c08
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/ModuleScopeLifecycleTestCase.java
@@ -0,0 +1,248 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeDestroyOnlyComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeEagerInitComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeEagerInitDestroyComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitOnlyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.config.ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.event.ModuleStart;
+import org.apache.tuscany.core.context.event.ModuleStop;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Lifecycle unit tests for the module scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class ModuleScopeLifecycleTestCase extends TestCase {
+
+ JavaContextFactoryBuilder builder;
+
+ public void testInitDestroy() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerFactories(createComponents());
+ scope.start();
+ scope.onEvent(new ModuleStart(this));
+ ModuleScopeInitDestroyComponent initDestroy = (ModuleScopeInitDestroyComponent) scope.getContext(
+ "TestServiceInitDestroy").getInstance(null);
+ Assert.assertNotNull(initDestroy);
+ ModuleScopeInitOnlyComponent initOnly = (ModuleScopeInitOnlyComponent) scope.getContext("TestServiceInitOnly")
+ .getInstance(null);
+ Assert.assertNotNull(initOnly);
+ ModuleScopeDestroyOnlyComponent destroyOnly = (ModuleScopeDestroyOnlyComponent) scope.getContext(
+ "TestServiceDestroyOnly").getInstance(null);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+
+ // expire module
+ scope.onEvent(new ModuleStop(this));
+
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ public void testEagerInit() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerFactories(createEagerInitComponents());
+ scope.start();
+ scope.onEvent(new ModuleStart(this));
+ ModuleScopeEagerInitDestroyComponent initDestroy = (ModuleScopeEagerInitDestroyComponent) scope.getContext(
+ "TestServiceEagerInitDestroy").getInstance(null);
+ Assert.assertNotNull(initDestroy);
+ ModuleScopeEagerInitComponent initOnly = (ModuleScopeEagerInitComponent) scope
+ .getContext("TestServiceEagerInit").getInstance(null);
+ Assert.assertNotNull(initOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+
+ // expire module
+ scope.onEvent(new ModuleStop(this));
+
+ Assert.assertTrue(initDestroy.isDestroyed());
+
+ scope.stop();
+
+ }
+
+ public void testDestroyOrder() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerFactories(createOrderedInitComponents());
+ scope.start();
+ scope.onEvent(new ModuleStart(this));
+ OrderedInitPojo one = (OrderedInitPojo) scope.getContext("one").getInstance(null);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ OrderedInitPojo two = (OrderedInitPojo) scope.getContext("two").getInstance(null);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ OrderedInitPojo three = (OrderedInitPojo) scope.getContext("three").getInstance(null);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // expire module
+ scope.onEvent(new ModuleStop(this));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ public void testEagerInitDestroyOrder() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ ModuleScopeContext scope = new ModuleScopeContext(ctx);
+ scope.registerFactories(createOrderedEagerInitComponents());
+ scope.start();
+ scope.onEvent(new ModuleStart(this));
+ OrderedEagerInitPojo one = (OrderedEagerInitPojo) scope.getContext("one").getInstance(null);
+ Assert.assertNotNull(one);
+
+ OrderedEagerInitPojo two = (OrderedEagerInitPojo) scope.getContext("two").getInstance(null);
+ Assert.assertNotNull(two);
+
+ OrderedEagerInitPojo three = (OrderedEagerInitPojo) scope.getContext("three").getInstance(null);
+ Assert.assertNotNull(three);
+
+ // expire module
+ scope.onEvent(new ModuleStop(this));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+
+ private List<ContextFactory<Context>> createComponents() throws BuilderException, ConfigurationLoadException {
+ AtomicComponent[] ca = new AtomicComponent[3];
+ ca[0] = MockFactory.createComponent("TestServiceInitDestroy", ModuleScopeInitDestroyComponent.class,
+ Scope.MODULE);
+ ca[1] = MockFactory.createComponent("TestServiceInitOnly", ModuleScopeInitOnlyComponent.class,
+ Scope.MODULE);
+ ca[2] = MockFactory.createComponent("TestServiceDestroyOnly", ModuleScopeDestroyOnlyComponent.class,
+ Scope.MODULE);
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ca[0].getImplementation().setComponentType(introspector.introspect(ModuleScopeInitDestroyComponent.class));
+ ca[1].getImplementation().setComponentType(introspector.introspect(ModuleScopeInitOnlyComponent.class));
+ ca[2].getImplementation().setComponentType(introspector.introspect(ModuleScopeDestroyOnlyComponent.class));
+ for (AtomicComponent aCa : ca) {
+ builder.build(aCa);
+ configs.add((ContextFactory<Context>) aCa.getContextFactory());
+
+ }
+ return configs;
+ }
+
+ private List<ContextFactory<Context>> createEagerInitComponents() throws
+ BuilderException, ConfigurationLoadException {
+ AtomicComponent[] ca = new AtomicComponent[2];
+ ca[0] = MockFactory.createComponent("TestServiceEagerInitDestroy", ModuleScopeEagerInitDestroyComponent.class,
+ Scope.MODULE);
+ ca[1] = MockFactory.createComponent("TestServiceEagerInit", ModuleScopeEagerInitComponent.class,
+ Scope.MODULE);
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ComponentType type = introspector.introspect(OrderedInitPojo.class);
+ ca[0].getImplementation().setComponentType(introspector.introspect(ModuleScopeEagerInitDestroyComponent.class));
+ ca[1].getImplementation().setComponentType(introspector.introspect(ModuleScopeEagerInitComponent.class));
+ for (AtomicComponent aCa : ca) {
+ builder.build(aCa);
+ configs.add((ContextFactory<Context>) aCa.getContextFactory());
+ }
+ return configs;
+ }
+
+ private List<ContextFactory<Context>> createOrderedInitComponents() throws
+ BuilderException, ConfigurationLoadException {
+ AtomicComponent[] ca = new AtomicComponent[3];
+ ca[0] = MockFactory.createComponent("one", OrderedInitPojo.class, Scope.MODULE);
+ ca[1] = MockFactory.createComponent("two", OrderedInitPojo.class, Scope.MODULE);
+ ca[2] = MockFactory.createComponent("three", OrderedInitPojo.class, Scope.MODULE);
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ComponentType type = introspector.introspect(OrderedInitPojo.class);
+ ca[0].getImplementation().setComponentType(type);
+ ca[1].getImplementation().setComponentType(type);
+ ca[2].getImplementation().setComponentType(type);
+ for (AtomicComponent aCa : ca) {
+ builder.build(aCa);
+ configs.add((ContextFactory<Context>) aCa.getContextFactory());
+ }
+ return configs;
+ }
+
+ private List<ContextFactory<Context>> createOrderedEagerInitComponents() throws
+ BuilderException, ConfigurationLoadException {
+ AtomicComponent[] ca = new AtomicComponent[3];
+ ca[0] = MockFactory.createComponent("one", OrderedEagerInitPojo.class, Scope.MODULE);
+ ca[1] = MockFactory.createComponent("two", OrderedEagerInitPojo.class, Scope.MODULE);
+ ca[2] = MockFactory.createComponent("three", OrderedEagerInitPojo.class, Scope.MODULE);
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ComponentType type = introspector.introspect(OrderedEagerInitPojo.class);
+ ca[0].getImplementation().setComponentType(type);
+ ca[1].getImplementation().setComponentType(type);
+ ca[2].getImplementation().setComponentType(type);
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ for (AtomicComponent aCa : ca) {
+ builder.build(aCa);
+ configs.add((ContextFactory<Context>) aCa.getContextFactory());
+
+ }
+ return configs;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ builder = new JavaContextFactoryBuilder(wireService);
+ }
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderException.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderException.java
new file mode 100644
index 0000000000..fc5f7c8c58
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderException.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+public class OrderException extends Exception {
+
+ public OrderException() {
+ super();
+ }
+
+ public OrderException(String message) {
+ super(message);
+ }
+
+ public OrderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public OrderException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedDependentPojo.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedDependentPojo.java
new file mode 100644
index 0000000000..f8fe2af7be
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedDependentPojo.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class OrderedDependentPojo extends OrderedInitPojo {
+
+ private OrderedDependentPojo pojo;
+
+ public OrderedDependentPojo getPojo() {
+ return pojo;
+ }
+
+ public void setPojo(OrderedDependentPojo pojo) {
+ this.pojo = pojo;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedEagerInitPojo.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedEagerInitPojo.java
new file mode 100644
index 0000000000..f9aeefccbe
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedEagerInitPojo.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class OrderedEagerInitPojo {
+
+ private static Object lock = new Object();
+ private static int numberInstantied;
+ private int initOrder;
+
+ @Init(eager = true)
+ public void init() {
+ synchronized (lock) {
+ ++numberInstantied;
+ initOrder = numberInstantied;
+ }
+ }
+
+ @Destroy
+ public void destroy() throws OrderException {
+ synchronized (lock) {
+ if (initOrder != numberInstantied) {
+ throw new OrderException("Instance shutdown done out of order");
+ }
+ --numberInstantied;
+ }
+ }
+
+ public int getNumberInstantiated() {
+ return numberInstantied;
+ }
+
+ public int getInitOrder() {
+ return initOrder;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedInitPojo.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedInitPojo.java
new file mode 100644
index 0000000000..b4d4eb03ba
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/OrderedInitPojo.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("MODULE")
+public class OrderedInitPojo {
+
+ private static Object lock = new Object();
+ private static int numberInstantied;
+ private int initOrder;
+
+ @Init
+ public void init() {
+ synchronized (lock) {
+ ++numberInstantied;
+ initOrder = numberInstantied;
+ }
+ }
+
+ @Destroy
+ public void destroy() throws OrderException {
+ synchronized (lock) {
+ if (initOrder != numberInstantied) {
+ throw new OrderException("Instance shutdown done out of order");
+ }
+ --numberInstantied;
+ }
+ }
+
+ public int getNumberInstantiated() {
+ return numberInstantied;
+ }
+
+ public int getInitOrder() {
+ return initOrder;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopeLifecycleTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopeLifecycleTestCase.java
new file mode 100644
index 0000000000..bca1e57cbc
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopeLifecycleTestCase.java
@@ -0,0 +1,166 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.RequestScopeDestroyOnlyComponent;
+import org.apache.tuscany.container.java.mock.components.RequestScopeInitDestroyComponent;
+import org.apache.tuscany.container.java.mock.components.RequestScopeInitOnlyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.config.ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.event.RequestEnd;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.RequestScopeContext;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Lifecycle unit tests for the Http session scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestScopeLifecycleTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInitDestroy() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerFactories(createComponents());
+ scope.start();
+ RequestScopeInitDestroyComponent initDestroy = (RequestScopeInitDestroyComponent) scope.getContext(
+ "TestServiceInitDestroy").getInstance(null);
+ Assert.assertNotNull(initDestroy);
+ RequestScopeInitOnlyComponent initOnly = (RequestScopeInitOnlyComponent) scope.getContext("TestServiceInitOnly")
+ .getInstance(null);
+ Assert.assertNotNull(initOnly);
+ RequestScopeDestroyOnlyComponent destroyOnly = (RequestScopeDestroyOnlyComponent) scope.getContext(
+ "TestServiceDestroyOnly").getInstance(null);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+
+ // end request
+ scope.onEvent(new RequestEnd(this, new Object()));
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ /**
+ * Test instances destroyed in proper (i.e. reverse) order
+ */
+ public void testDestroyOrder() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ RequestScopeContext scope = new RequestScopeContext(ctx);
+ scope.registerFactories(createOrderedInitComponents());
+ scope.start();
+ // request start
+ RequestScopedOrderedInitPojo one = (RequestScopedOrderedInitPojo) scope.getContext("one").getInstance(null);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ RequestScopedOrderedInitPojo two = (RequestScopedOrderedInitPojo) scope.getContext("two").getInstance(null);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ RequestScopedOrderedInitPojo three = (RequestScopedOrderedInitPojo) scope.getContext("three").getInstance(null);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // end request
+ scope.onEvent(new RequestEnd(this, new Object()));
+
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+
+ JavaContextFactoryBuilder builder;
+
+ private List<ContextFactory<Context>> createComponents() throws BuilderException, ConfigurationLoadException {
+ AtomicComponent[] ca = new AtomicComponent[3];
+ ca[0] = MockFactory.createComponent("TestServiceInitDestroy", RequestScopeInitDestroyComponent.class,
+ Scope.REQUEST);
+ ca[1] = MockFactory.createComponent("TestServiceInitOnly", RequestScopeInitOnlyComponent.class,
+ Scope.REQUEST);
+ ca[2] = MockFactory.createComponent("TestServiceDestroyOnly", RequestScopeDestroyOnlyComponent.class,
+ Scope.REQUEST);
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ca[0].getImplementation().setComponentType(introspector.introspect(RequestScopeInitDestroyComponent.class));
+ ca[1].getImplementation().setComponentType(introspector.introspect(RequestScopeInitOnlyComponent.class));
+ ca[2].getImplementation().setComponentType(introspector.introspect(RequestScopeDestroyOnlyComponent.class));
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ for (AtomicComponent aCa : ca) {
+ builder.build(aCa);
+ configs.add((ContextFactory<Context>) aCa.getContextFactory());
+
+ }
+ return configs;
+ }
+
+ private List<ContextFactory<Context>> createOrderedInitComponents() throws
+ BuilderException, ConfigurationLoadException {
+ AtomicComponent[] ca = new AtomicComponent[3];
+ ca[0] = MockFactory.createComponent("one", RequestScopedOrderedInitPojo.class, Scope.REQUEST);
+ ca[1] = MockFactory.createComponent("two", RequestScopedOrderedInitPojo.class, Scope.REQUEST);
+ ca[2] = MockFactory.createComponent("three", RequestScopedOrderedInitPojo.class, Scope.REQUEST);
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ComponentType type = introspector.introspect(RequestScopedOrderedInitPojo.class);
+ ca[0].getImplementation().setComponentType(type);
+ ca[1].getImplementation().setComponentType(type);
+ ca[2].getImplementation().setComponentType(type);
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ for (AtomicComponent aCa : ca) {
+ builder.build(aCa);
+ configs.add((ContextFactory<Context>) aCa.getContextFactory());
+
+ }
+ return configs;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
+ builder = new JavaContextFactoryBuilder(wireService);
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopedOrderedInitPojo.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopedOrderedInitPojo.java
new file mode 100644
index 0000000000..717c7008c9
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/RequestScopedOrderedInitPojo.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Destroy;
+
+@Scope("REQUEST")
+public class RequestScopedOrderedInitPojo {
+
+ private static Object lock = new Object();
+ private static int numberInstantied;
+ private int initOrder;
+
+ @Init
+ public void init() {
+ synchronized (RequestScopedOrderedInitPojo.lock) {
+ ++RequestScopedOrderedInitPojo.numberInstantied;
+ initOrder = RequestScopedOrderedInitPojo.numberInstantied;
+ }
+ }
+
+ @Destroy
+ public void destroy() throws OrderException {
+ synchronized (RequestScopedOrderedInitPojo.lock) {
+ if (initOrder != RequestScopedOrderedInitPojo.numberInstantied) {
+ throw new OrderException("Instance shutdown done out of order");
+ }
+ --RequestScopedOrderedInitPojo.numberInstantied;
+ }
+ }
+
+ public int getNumberInstantiated() {
+ return RequestScopedOrderedInitPojo.numberInstantied;
+ }
+
+ public int getInitOrder() {
+ return initOrder;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/SessionScopeLifecycleTestCase.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/SessionScopeLifecycleTestCase.java
new file mode 100644
index 0000000000..80d8cb71cb
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/SessionScopeLifecycleTestCase.java
@@ -0,0 +1,176 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
+import org.apache.tuscany.container.java.mock.MockFactory;
+import org.apache.tuscany.container.java.mock.components.SessionScopeDestroyOnlyComponent;
+import org.apache.tuscany.container.java.mock.components.SessionScopeInitDestroyComponent;
+import org.apache.tuscany.container.java.mock.components.SessionScopeInitOnlyComponent;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.event.HttpSessionEnd;
+import org.apache.tuscany.core.context.event.HttpSessionEvent;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.SessionScopeContext;
+import org.apache.tuscany.core.wire.service.WireFactoryService;
+import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
+import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.config.ComponentTypeIntrospector;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+import org.apache.tuscany.model.assembly.ComponentType;
+
+/**
+ * Lifecycle unit tests for the Http session scope container
+ *
+ * @version $Rev$ $Date$
+ */
+public class SessionScopeLifecycleTestCase extends TestCase {
+
+ /**
+ * Tests instance identity is properly maintained
+ */
+ public void testInitDestroy() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ SessionScopeContext scope = new SessionScopeContext(ctx);
+ scope.registerFactories(createComponents());
+ scope.start();
+ Object session = new Object();
+ // first request, no need to notify scope container since sessions are
+ // evaluated lazily
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER,session);
+ SessionScopeInitDestroyComponent initDestroy = (SessionScopeInitDestroyComponent) scope.getContext(
+ "TestServiceInitDestroy").getInstance(null);
+ Assert.assertNotNull(initDestroy);
+ SessionScopeInitOnlyComponent initOnly = (SessionScopeInitOnlyComponent) scope.getContext("TestServiceInitOnly")
+ .getInstance(null);
+ Assert.assertNotNull(initOnly);
+ SessionScopeDestroyOnlyComponent destroyOnly = (SessionScopeDestroyOnlyComponent) scope.getContext(
+ "TestServiceDestroyOnly").getInstance(null);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+ // end request
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+ // expire session
+ scope.onEvent(new HttpSessionEnd(this,session));
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ /**
+ * Test instances destroyed in proper (i.e. reverse) order
+ */
+ public void testDestroyOrder() throws Exception {
+ EventContext ctx = new EventContextImpl();
+ SessionScopeContext scope = new SessionScopeContext(ctx);
+ scope.registerFactories(createOrderedInitComponents());
+ scope.start();
+ Object session = new Object();
+ // request start
+ ctx.setIdentifier(HttpSessionEvent.HTTP_IDENTIFIER,session);
+
+ SessionScopedOrderedInitPojo one = (SessionScopedOrderedInitPojo) scope.getContext("one").getInstance(null);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ SessionScopedOrderedInitPojo two = (SessionScopedOrderedInitPojo) scope.getContext("two").getInstance(null);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ SessionScopedOrderedInitPojo three = (SessionScopedOrderedInitPojo) scope.getContext("three").getInstance(null);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // end request
+ ctx.clearIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
+
+ // expire session
+ scope.onEvent(new HttpSessionEnd(this, session));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ JavaContextFactoryBuilder builder;
+
+ private List<ContextFactory<Context>> createComponents() throws BuilderException, ConfigurationLoadException {
+ AtomicComponent[] ca = new AtomicComponent[3];
+ ca[0] = MockFactory.createComponent("TestServiceInitDestroy", SessionScopeInitDestroyComponent.class,
+ Scope.SESSION);
+ ca[1] = MockFactory.createComponent("TestServiceInitOnly", SessionScopeInitOnlyComponent.class, Scope.SESSION);
+ ca[2] = MockFactory.createComponent("TestServiceDestroyOnly", SessionScopeDestroyOnlyComponent.class,
+ Scope.SESSION);
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ca[0].getImplementation().setComponentType(introspector.introspect(SessionScopeInitDestroyComponent.class));
+ ca[1].getImplementation().setComponentType(introspector.introspect(SessionScopeInitOnlyComponent.class));
+ ca[2].getImplementation().setComponentType(introspector.introspect(SessionScopeDestroyOnlyComponent.class));
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ for (AtomicComponent aCa : ca) {
+ builder.build(aCa);
+ configs.add((ContextFactory<Context>) aCa.getContextFactory());
+
+ }
+ return configs;
+ }
+
+ private List<ContextFactory<Context>> createOrderedInitComponents() throws
+ BuilderException, ConfigurationLoadException {
+ AtomicComponent[] ca = new AtomicComponent[3];
+ ca[0] = MockFactory.createComponent("one", SessionScopedOrderedInitPojo.class, Scope.SESSION);
+ ca[1] = MockFactory.createComponent("two", SessionScopedOrderedInitPojo.class, Scope.SESSION);
+ ca[2] = MockFactory.createComponent("three", SessionScopedOrderedInitPojo.class, Scope.SESSION);
+ ComponentTypeIntrospector introspector = MockFactory.getIntrospector();
+ ComponentType type = introspector.introspect(SessionScopedOrderedInitPojo.class);
+ ca[0].getImplementation().setComponentType(type);
+ ca[1].getImplementation().setComponentType(type);
+ ca[2].getImplementation().setComponentType(type);
+ List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>();
+ for (AtomicComponent aCa : ca) {
+ builder.build(aCa);
+ configs.add((ContextFactory<Context>) aCa.getContextFactory());
+
+ }
+ return configs;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(),new DefaultPolicyBuilderRegistry());
+ builder = new JavaContextFactoryBuilder(wireService);
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/SessionScopedOrderedInitPojo.java b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/SessionScopedOrderedInitPojo.java
new file mode 100644
index 0000000000..683247a5c8
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/scopes/SessionScopedOrderedInitPojo.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.container.java.scopes;
+
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Destroy;
+
+@Scope("SESSION")
+public class SessionScopedOrderedInitPojo {
+
+ private static Object lock = new Object();
+ private static int numberInstantied;
+ private int initOrder;
+
+ @Init
+ public void init() {
+ synchronized (SessionScopedOrderedInitPojo.lock) {
+ ++SessionScopedOrderedInitPojo.numberInstantied;
+ initOrder = SessionScopedOrderedInitPojo.numberInstantied;
+ }
+ }
+
+ @Destroy
+ public void destroy() throws OrderException {
+ synchronized (SessionScopedOrderedInitPojo.lock) {
+ if (initOrder != SessionScopedOrderedInitPojo.numberInstantied) {
+ throw new OrderException("Instance shutdown done out of order");
+ }
+ --SessionScopedOrderedInitPojo.numberInstantied;
+ }
+ }
+
+ public int getNumberInstantiated() {
+ return SessionScopedOrderedInitPojo.numberInstantied;
+ }
+
+ public int getInitOrder() {
+ return initOrder;
+ }
+
+}
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworld/example.wsdl b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworld/example.wsdl
new file mode 100644
index 0000000000..3a23e7b717
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworld/example.wsdl
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<wsdl:definitions targetNamespace="http://www.example.org"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ name="example">
+
+ <wsdl:portType name="HelloWorld">
+ </wsdl:portType>
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworld/sca.module b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworld/sca.module
new file mode 100644
index 0000000000..d5bc2cd5f9
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworld/sca.module
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="Helloworld">
+
+ <component name="HelloWorld">
+ <implementation.java class="org.apache.tuscany.container.java.integration.HelloWorldImpl"/>
+ </component>
+
+<!--
+ <import.wsdl wsdlLocation="example.wsdl"/>
+
+ <externalService name="external">
+ <interface.wsdl interface="http://www.example.org#wsdl.interface(HelloWorld)"/>
+ </externalService>
+-->
+
+</module>
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworldmc/sca.module b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworldmc/sca.module
new file mode 100644
index 0000000000..8c590976de
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/helloworldmc/sca.module
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="HelloworldMC">
+
+ <component name="HelloWorld">
+ <implementation.java class="org.apache.tuscany.container.java.integration.HelloWorldMCImpl"/>
+ <references>
+ <!-- <v:greetingProvider>GreetingProvider</v:greetingProvider>-->
+ </references>
+ <properties>
+ <v:bar>bar</v:bar>
+ <v:locale>en</v:locale>
+ </properties>
+ </component>
+ <wire>
+ <source.uri>HelloWorld/greetingProvider</source.uri>
+ <target.uri>GreetingProvider</target.uri>
+ </wire>
+ <component name="GreetingProvider">
+ <implementation.java class="org.apache.tuscany.container.java.integration.GreetingProviderImpl"/>
+ <properties>
+ <v:greeting>Hello </v:greeting>
+ </properties>
+ </component>
+</module>
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/org/apache/tuscany/container/java/assembly/tests/sca.module b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/org/apache/tuscany/container/java/assembly/tests/sca.module
new file mode 100644
index 0000000000..d0f0856225
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/org/apache/tuscany/container/java/assembly/tests/sca.module
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="tuscany.container.java.assembly.tests.bigbank.account">
+
+ <entryPoint name="AccountService">
+ <interface.java interface="org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.account.AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService#wsdl.endpoint(AccountService/AccountServiceSOAP)"/>
+ <reference>AccountServiceComponent</reference>
+ </entryPoint>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.account.AccountServiceImpl"/>
+ <properties>
+ <v:currency overridable="may">EURO</v:currency>
+ </properties>
+ <references>
+ <v:accountDataService>AccountDataServiceComponent</v:accountDataService>
+ <v:stockQuoteService>StockQuoteService</v:stockQuoteService>
+ </references>
+ </component>
+
+ <component name="AccountDataServiceComponent">
+ <implementation.java class="org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.accountdata.AccountDataServiceImpl"/>
+ </component>
+
+ <component name="StockQuoteService">
+ <implementation.java class="org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.stockquote.StockQuoteServiceImpl"/>
+ </component>
+
+ <!--
+ <externalService name="StockQuoteService">
+ <interface.java interface="org.apache.tuscany.container.java.assembly.tests.bigbank.account.services.stockquote"/>
+ <binding.ws port="http://www.quickstockquote.com/StockQuoteService#wsdl.endpoint(StockQuote/StockQuoteServiceSOAP)"/>
+ </externalService>
+ -->
+
+</module>
+
diff --git a/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/org/apache/tuscany/container/java/config/ModuleComponentLoaderTest1.module b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/org/apache/tuscany/container/java/config/ModuleComponentLoaderTest1.module
new file mode 100644
index 0000000000..46169aa304
--- /dev/null
+++ b/sca-java-1.x/branches/java-M1/java/sca/containers/container.java/src/test/resources/org/apache/tuscany/container/java/config/ModuleComponentLoaderTest1.module
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ name="ModuleComponentLoaderTest1">
+
+ <component name="HelloWorldServiceComponent">
+ <implementation.java class="org.apache.tuscany.container.java.assembly.mock.HelloWorldImpl"/>
+ </component>
+</module>