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

com.evasion.plugin.junit.ejb.AbstractEJBTest Maven / Gradle / Ivy

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.evasion.plugin.junit.ejb;

import com.evasion.plugin.junit.persistence.AbstractPersistentTest;
import javax.naming.NamingException;
import org.apache.commons.lang.StringUtils;
import org.junit.Assert;

/**
 *
 * @author sebastien.glon
 */
public abstract class AbstractEJBTest extends AbstractPersistentTest {
   
        public AbstractEJBTest(String database) {
       super(database);
    }

    public AbstractEJBTest() {
        super();
    }
        
        
    protected  T lookupBy(Class type) throws NamingException {
        return (T) ctx.lookup(StringUtils.uncapitalize(type.getSimpleName()));
    }

    public  T getService(Class type) {
        try {
            return (T) lookupBy(type);
        } catch (NamingException ex) {
            Assert.fail("Can not fin EJB: \n" + ex);
            return null;
        }
    }
    
    public static String getServiceName(Class clazz) {
        return StringUtils.uncapitalize(clazz.getSimpleName());
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy