Woww… It worked!!… Now EJB module is finding the persistence.xml and
entities from dependency after including the dummy jar. Marina thanks a lot
for your help!! Marina could u pls help me to understand how this worked?.
I just included below code snippet to my testcase.
p.put(EJBContainer.MODULES,new File("target/classes/dummy.jar")); You said
ear will be created after including the dummy jar. Where this ear will be
created? can we see it? Each time when I run the test case I do mvn :clean
and then mvn :test. So when I do mvn:clean target folder will be deleted(also
dummy.jar). But when I run the test case its working fine even though
dummy.jar is not in target/classes. Then I removed this code
p.put(EJBContainer.MODULES,new File("target/classes/dummy.jar")); from my
test case . After this EJBmodule is unable to find the persistence.xml and
entities. So what is the significance of this dummy jar? Updated source
code: import com.papajohns.profit.arch.TransactionContext; import
com.papajohns.profit.businesslayer.OrderServicesLocal; import
org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test;
import javax.ejb.embeddable.EJBContainer; import javax.naming.Context; import
java.io.File; import java.util.HashMap; import java.util.Map; import
static org.junit.Assert.assertNotNull; import static
org.junit.Assert.assertTrue; public class TestOrder { private
static EJBContainer ejbContainer=null; private static Context
ctx=null; private OrderServicesLocal orderservice; private
static TransactionContext tc = new TransactionContext("OrderServices");
@BeforeClass public static void setUp(){
Map<String,Object> p= new HashMap<String,Object>();
p.put(EJBContainer.MODULES,new File("target/classes/dummy.jar"));
p.put(EJBContainer.APP_NAME,"profit");
p.put("org.glassfish.ejb.embedded.glassfish.web.http.port","");
ejbContainer= EJBContainer.createEJBContainer(p);
ctx=ejbContainer.getContext(); }
@AfterClass public static void tearDown(){
ejbContainer.close(); } @Test public void
testCustomerEmail(){ try{
orderservice=(OrderServicesLocal)ctx.lookup("java:global/profit/classes/OrderServicesBean!com.papajohns.profit.businesslayer.OrderServicesLocal");
assertNotNull(orderservice);
boolean result=orderservice.cancelOrder(tc,6426617,"In Person");
System.out.println("Result *****"+result);
assertTrue(result==true);
}catch(Exception e){ System.out.println(e);
} } }
--
[Message sent by forum member 'Gladiator_FZ']
View Post: http://forums.java.net/node/812613