All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mockrunner.test.ejb.EJBTestCaseAdapterDelegateEnvJNDITest Maven / Gradle / Ivy

Go to download

Mockrunner is a lightweight framework for unit testing applications in the J2EE environment. It supports servlets, filters, tag classes and Struts actions. It includes a JDBC a JMS and a JCA test framework and can be used to test EJB based applications.

The newest version!
package com.mockrunner.test.ejb;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;

import org.mockejb.jndi.MockContextFactory;

import com.mockrunner.ejb.EJBTestCaseAdapter;
import com.mockrunner.test.ejb.TestJNDI.TestContextFactory;

public class EJBTestCaseAdapterDelegateEnvJNDITest extends EJBTestCaseAdapter
{
    protected void setUp() throws Exception
    {
        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, TestContextFactory.class.getName());
        MockContextFactory.setDelegateEnvironment(env);
        super.setUp();
    }
    
    protected void tearDown() throws Exception
    {
        MockContextFactory.setDelegateContext(null);
        MockContextFactory.setDelegateEnvironment(null);
        super.tearDown();
    }

    public void testLookupExternal() throws Exception
    {
        InitialContext context = new InitialContext();
        Object object = context.lookup("test");
        assertEquals("TestObject", object);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy