Wednesday, March 19, 2014

How to generate sample test client to test Facade from Session EJB in Oracle ADF Model?

I have explained in the previous post about how to create the session bean based on the JPAs created for EJB based entities.

In this post I shall show how to create a sample test client to test the same


























It will generate the client with sample methods to access the data from sessionEJB. Sample code is as below

public static void main(String [] args) {
    try {
        final Context context = getInitialContext();
        SessionEJB sessionEJB = (SessionEJB)context.lookup("EJBBasedADFAppli-Model-SessionEJB#model.SessionEJB");
        for (Departments departments : (List<Departments>)sessionEJB.getDepartmentsFindAll()) {
            printDepartments(departments);
        }
        for (Employees employees : (List<Employees>)sessionEJB.getEmployeesFindAll()) {
            printEmployees(employees);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}


No comments:

Post a Comment