package test.DataAccess.entities;

import junit.framework.*;
import DataAccess.entities.ProjectBean;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import DataAccess.entities.ProjectHome;
import DataAccess.entities.Project;
import DataAccess.ServiceLocator;
import org.apache.log4j.Logger;

/**
 * JUnit TestCase.
 * @testfamily JUnit
 * @testkind testcase
 * @testsetup Default TestCase
 * @testedclass DataAccess.entities.ProjectBean
 */
public class TestProjectBean extends TestCase {
    /** Constructs a test case with the given name. */
    public TestProjectBean(String name) {
        super(name);
    }

    /** Sets up the fixture, for example, open a network connection. This method is called before a test is executed. */
    protected void setUp() {
    }

    /** Tears down the fixture, for example, close a network connection. This method is called after a test is executed. */
    protected void tearDown() {
        // Write your code here
    }

    public void testEjbCreate() {
        try {

			InitialContext initialContext = new InitialContext();
	        Object ref = initialContext.lookup("LCMBasis/ProjectBean");
            ProjectHome projectHome = (DataAccess.entities.ProjectHome)PortableRemoteObject.narrow(ref, ProjectHome.class);
            System.out.println("home interface located");
            Project projectRemote = projectHome.create(new Integer(130));
            System.out.println("got remote interface");
        }
        catch (Exception exception) {
            exception.printStackTrace();
            fail(exception.toString() + " / " + exception.getMessage());
        }
    }

    private ProjectHome homeInterface;
    private Project remoteInterface;
}
