package org.mockejb.test;
import javax.rmi.PortableRemoteObject;
import javax.naming.*;
import junit.framework.TestCase;
import org.mockejb.*;
import org.mockejb.jndi.*;
public class HelloWorldTest extends TestCase {
private Context context;
public HelloWorldTest(String name) {
super(name);
}
public void setUp() throws Exception {
MockContextFactory.setAsInitial();
context = new InitialContext( );
MockContainer mockContainer = new MockContainer( context );
SessionBeanDescriptor sampleServiceDescriptor =
new SessionBeanDescriptor( SampleService.JNDI_NAME,
SampleServiceHome.class, SampleService.class, new SampleServiceBean() );
mockContainer.deploy( sampleServiceDescriptor );
}
public void testHelloWorld() throws Exception {
Object sampleServiceHomeObj = context.lookup( SampleService.JNDI_NAME );
SampleServiceHome sampleServiceHome =
(SampleServiceHome) PortableRemoteObject.narrow( sampleServiceHomeObj,
SampleServiceHome.class );
SampleService sampleService = sampleServiceHome.create();
String result = sampleService.echoString("HelloWorld");
assertEquals( "HelloWorld", result );
}
}