Andrew,
I have started working on a testcase for EJBTHREE-1401 (Create Tests for @Remote
pass-by-value within local JVM). I have a failing (simple) test case:
The bean:
@Stateless
| @Remote (SimpleSLSBRemote.class)
| public class SimpleSLSBean implements SimpleSLSBRemote
| {
|
| /**
| * Change the <code>value</code> property of the
<code>simplePojo</code>
| * and return the changed pojo.
| *
| * @param simplePojo
| * @return
| */
| public SimplePojo changeAndReturn(SimplePojo simplePojo)
| {
| if (simplePojo == null) {
| return null;
| }
|
| // change the counter value in the pojo and return the pojo
| simplePojo.setValue(simplePojo.getValue() + 1);
| return simplePojo;
| }
|
| }
|
The testcase:
| public class IntraJvmRemoteInvocationPassByValueTestCase
| {
|
| .....
|
| @Test
| public void testPassByValueForMethodParameters() throws Throwable
| {
| // create slsb
| SessionContainer slsb = Utils.createSlsb(SimpleSLSBean.class);
|
| // bind to jndi
| Ejb3RegistrarLocator.locateRegistrar().bind(slsb.getName(), slsb);
|
| // get metadata
| JBossSessionBeanMetaData metadata = slsb.getMetaData();
|
| // Lookup the remote bean
| Context ctx = new InitialContext();
| SimpleSLSBRemote remote = (SimpleSLSBRemote)
ctx.lookup(metadata.getJndiName());
|
|
| SimplePojo localSimplePojo = new SimplePojo();
| log.info("local is " + localSimplePojo);
| // set some initial value
| int value = 3;
| localSimplePojo.setValue(value);
| // call the method on the bean
| SimplePojo returnedPojo = remote.changeAndReturn(localSimplePojo);
|
| //Check that the returned object and the passed object are not the same
| assertFalse("The object passed to the method of the remote bean and the
object returned from the bean are both the same",localSimplePojo == returnedPojo);
|
| // Check the value in the local object has not changed because of the change
| // to the object passed as the bean param
| assertEquals("The object passed to a method of remote bean was
modified(passed by reference)",localSimplePojo.getValue(),value);
|
| }
|
| ...
| }
|
Here's the failure:
testPassByValueForMethodParameters(org.jboss.ejb3.test.proxy.spec_3_2_1.unit.IntraJvmRemoteInvocationPassByValueTestCase)
Time elapsed: 56.875 sec <<< FAILURE!
| java.lang.AssertionError: The object passed to the method of the remote bean and the
object returned from the bean are both the same
|
I looked into the code to see why this was failing. Looks like the mock SessionContainer
in the proxy module does not take care of marshalling/unmarshalling the parameters. The
code in the actual *SessionContainer in the core module seems to be having this
functionality.
1) Should we be fixing the mock SessionContainer in the proxy?
OR
2) Since we are trying to test the core functionality, should we be having this testcase
within the ejb3-core instead of the proxy module? This would ensure that we are testing
the actual containers and not the mocked ones.
OR
3) Is there some way to get hold of the real containers in the proxy module testcases?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4178314#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...