title: how to create or simulate ejb 3 SessionContext for writing Junit Test cases
body: <p>I'm trying to test my ejb session bean</p>
  
  <pre><code>myFacadeBean = new MyFacadeBean();
  MyEntity myEntity = myFacadeBean .getMyData("Hello");
  </code></pre>
  
  <p>I m trying to test a method in my session bean. I have created EntityManager using </p>
  
  <pre><code> entityManager = Persistence.createEntityManagerFactory("Test").createEntityManager();
  </code></pre>
  
  <p>I am testing these ejb's outside container. so i configured my persistence.xml as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
      http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
      version="1.0"&gt;
      &lt;persistence-unit name="Test" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
          &lt;class&gt;test.entity.MyEntity&lt;/class&gt;
  
          &lt;properties&gt;
              &lt;property name="eclipselink.target-database" value="Oracle" /&gt;
              &lt;property name="eclipselink.jdbc.driver" value="oracle.jdbc.OracleDriver" /&gt;
              &lt;property name="eclipselink.jdbc.url"
                  value="jdbc:oracle:thin:@127.0.0.1:1521:orcl" /&gt;
              &lt;property name="eclipselink.jdbc.user" value="user" /&gt;
              &lt;property name="eclipselink.jdbc.password" value="pass" /&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>How can i create a SessionContext in this scneario as myFacadeBean is making use of sessionContext to access callerPrincipal().getName();</p>
  
  <p>I dont want to use anything like Ejb3unit</p>