[
https://issues.apache.org/jira/browse/TUSCANY-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12542206
]
Mark Combellack commented on TUSCANY-1909:
------------------------------------------
I've created a simple addition to the conversations iTest that demonstrates
this problem. I've attached it as a patch.
As the test does not pass, I would not recommend committing it to the iTest at
the moment
The output from this test is shown below:
Running org.apache.tuscany.sca.itest.conversational.ConversationalTestCase
========= First instance tests =========
---> AServiceImpl constructor for [EMAIL PROTECTED]
Conversation ID for [EMAIL PROTECTED] is set to
bb81d21d-c8ac-4f42-88d7-f275f145de31
---> Setting reference to B on [EMAIL PROTECTED] to [Proxy - [EMAIL PROTECTED]
---> BServiceImpl constructor for [EMAIL PROTECTED]
Conversation ID for [EMAIL PROTECTED] is set to
b3312ec3-8044-4deb-a533-feaba0ec566d
========= Second instance tests =========
---> AServiceImpl constructor for [EMAIL PROTECTED]
Conversation ID for [EMAIL PROTECTED] is set to
e2548ae6-34db-4a6e-86a1-92aa0b7e164a
---> Setting reference to B on [EMAIL PROTECTED] to [Proxy - [EMAIL PROTECTED]
Tests run: 67, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.932 sec <<<
FAILURE!
testMultipleConversations(org.apache.tuscany.sca.itest.conversational.ConversationalTestCase)
Time elapsed: 0.053 sec <<< FAILURE!
junit.framework.ComparisonFailure: null expected:<[Initial Value of] B> but
was:<[First Instance - TestCode Set state on] B>
at junit.framework.Assert.assertEquals(Assert.java:81)
at junit.framework.Assert.assertEquals(Assert.java:87)
at
org.apache.tuscany.sca.itest.conversational.ConversationalTestCase.testMultipleConversations(ConversationalTestCase.java:638)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at
org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at
org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at
org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:75)
at
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:36)
at
org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837)
Notice that in the first instance tests, we create an instance of AServiceImpl
and BServiceImpl. However, in the second Instance tests, we only create an
instance of AServiceImpl
The key lines of code of the test are:
// first instance test
// Get reference to AService and set a value on Service B
AService aService = domain.getService(AService.class,
"ConversationalAComponent");
aService.setStateOnB(NEW_B_VALUE);
// Second instance test
// Get another reference to AService
AService aService2 = domain.getService(AService.class,
"ConversationalAComponent");
// FAILS IN THE NEXT ASSERT!!!!
// This is the point it fails, the state on B is not the expected
initial state
// but the state from the first instance test
Assert.assertEquals(Constants.B_INITIAL_VALUE, aService2.getStateOnB());
The assert fails since aService2 is sharing the same instance of BService as
aService.
> Conversational Component referring to another Conversational Component always
> uses the same instance
> ----------------------------------------------------------------------------------------------------
>
> Key: TUSCANY-1909
> URL: https://issues.apache.org/jira/browse/TUSCANY-1909
> Project: Tuscany
> Issue Type: Bug
> Components: Java SCA Core Runtime
> Reporter: Mark Combellack
> Fix For: Java-SCA-Next
>
>
> I've run into a problem with two conversational Services. Consider the
> following scenario:
> AService
> * Has member variable called state
> * Has reference to BService
> * Has set/getState method for setting state on A
> * Has set/getStateOnB method for setting state on B
> BService
> * Has member variable called state
> Calling SCADomain.getService(AService) twice, I am expecting to get:
> AService_1 -> BService_1
> and AService_2 -> BService_2
> However, I am getting:
> AService_1 -> BService_1
> and AService_2 -> BService_1
> i.e a second instance of BService is not being created.
> The first time I get a new instance of AService, a new instance of BService
> is created.
> The second time I get a new instance of AService, the original BService
> instance is shared.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]