package org.mockejb.test;
import javax.naming.*;
import org.mockejb.*;
import org.mockejb.jndi.*;
public class StatefulTest extends OptionalCactusTestCase {
private SampleStatefulServiceHome statefulSampleServiceHome;
public StatefulTest(String name) {
super(name);
}
public void setUp() throws Exception {
if ( !isRunningOnServer() ) {
MockContextFactory.setAsInitial();
MockContainer mockContainer = new MockContainer( new InitialContext() );
SessionBeanDescriptor statefulSampleDescriptor =
new SessionBeanDescriptor( SampleStatefulService.JNDI_NAME,
SampleStatefulServiceHome.class, SampleStatefulService.class, SampleStatefulServiceBean.class );
statefulSampleDescriptor.setStateful( true );
mockContainer.deploy( statefulSampleDescriptor );
}
Context context = new InitialContext( );
statefulSampleServiceHome =
(SampleStatefulServiceHome)context.lookup( SampleStatefulService.JNDI_NAME );
}
public void testStatefulSessionBean() throws Exception {
String someState = "some state";
SampleStatefulService sampleStatefulService = statefulSampleServiceHome.create( someState);
String returnedState = sampleStatefulService.getSampleState();
assertEquals( someState, returnedState );
sampleStatefulService.remove();
}
}