Sunday, September 23, 2012

ADF Application Programmatic Login for junit cases and test clients

You can use the below code to login into application when using test clients as below or for junits.


        JAASAuthenticationService jas = new JAASAuthenticationService();
        jas.login("test", "welcome1");
        String amDef = "com.adfSpecialists.dataSecurity.model.am.EmployeesAM";
        String config = "EmployeesAMLocal";
        ApplicationModule am =
            Configuration.createRootApplicationModule(amDef, config);
        // Work with your appmodule and view object here
        ViewObjectImpl vo = (ViewObjectImpl)am.findViewObject("EmployeesVO1");
        ViewCriteria vc =  vo.getViewCriteria("DS_DUMMYVC__EmployeeEO__DEPARTMENT_ID");
        vo.applyViewCriteria(vc);
        System.out.println(vo.getQuery());
        vo.executeQuery();
        Configuration.releaseRootApplicationModule(am, true);
        jas.logout();

1 comment:

Related Posts Plugin for WordPress, Blogger...