Package fr.inouk

Examples of fr.inouk.OpenERPJSONRPCClient


     * java.net.UnknownHostException
     */
    @Test(groups = {"protocol"})
    public void UnknownHost() {
        try {
            OpenERPJSONRPCClient server = new OpenERPJSONRPCClient("http://badserver:" + SERVER_PORT);
        } catch (HttpRequest.HttpRequestException ex) {
            System.out.println("catched HttpRequestException()");
            System.out.println("cause="+ex.getCause());
        }
    }
View Full Code Here


     * java.net.ConnectException
     */
    @Test(groups = {"protocol"})
    public void BadPort() {
        try {
            OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL + ":" + 8099);
        } catch (HttpRequest.HttpRequestException ex) {
            System.out.println("catched HttpRequestException()");
            System.out.println("cause="+ex.getCause());
        }
    }
View Full Code Here

    /**
     * OpenERPJSONRPCCLient.OpenERPServiceOrMethodException
     */
    @Test(groups = {"protocol"})
    public void BadOpenERPServiceOrMethod() {
        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);

        try {
            JSONObject sessionInfo = (JSONObject) server.OEJsonRpc("http://localhost:8069/web/session/get_session_infonas", "call", new JSONObject());
        } catch (OpenERPServiceOrMethodException ex) {
            System.out.println("catched HttpRequestException()");
            System.out.println("cause="+ex.getCause());
        }
    }
View Full Code Here

        }
    }

    @Test(groups = {"protocol"})
    public void testConnection() {
        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);
        System.out.println("Server="+server);

        JSONObject sessionInfo = (JSONObject) server.OEJsonRpc("http://localhost:8069/web/session/get_session_info", "call", new JSONObject());
        System.out.println("session_info"+ sessionInfo.toString());
    }
View Full Code Here

    //*****( 'database' service )**************************************************************************************/

    @Test(groups = {"database"}, dependsOnMethods = {"testConnection"})
    public void databaseGetList() {
        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);

        ArrayList<String> dbList = server.databaseGetList(null);
       System.out.println(dbList);
    }
View Full Code Here

       System.out.println(dbList);
    }

    @Test(groups = {"database"}, dependsOnMethods = {"databaseGetList"})
    public void databaseDrop() {
        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);

        ArrayList<String> dbList = server.databaseGetList(null);
        if( ! dbList.contains("openerp_jsonrpc_client") )
            Assert.fail("Database openerp_jsonrpc_client do not exists !");

        boolean result = server.databaseDrop(MASTER_ADMIN_PASSWORD, "openerp_jsonrpc_client", null);
        System.out.println("databaseDrop() => " + result);
    }
View Full Code Here

        System.out.println("databaseDrop() => " + result);
    }

    @Test(groups = {"database"}, dependsOnMethods = {"databaseDrop"}, alwaysRun = true)
    public void databaseCreate() {
        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);

        ArrayList<String> dbList = server.databaseGetList(null);
        if( dbList.contains("openerp_jsonrpc_client") )
            Assert.fail("Database openerp_jsonrpc_client already exists !");

        System.out.println("Starting database creation ! Be patient...");
        boolean installDemoData = true;
        boolean result = server.databaseCreate(MASTER_ADMIN_PASSWORD, "openerp_jsonrpc_client", installDemoData, "fr_FR", "admin", null);
        System.out.println("databaseCreate() => " + result);
    }
View Full Code Here

    //*****( 'session' service )***************************************************************************************/

    @Test(groups = {"session_service"}, dependsOnMethods = {"databaseCreate"})
    public void sessionAuthenticate() {
        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);

        // Bad database
        try {
            JSONObject sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_clientooooo", "admin", "admin", null, null);
        } catch ( OpenERPJSONRPCClientException exc ) {
           System.out.println(exc);
            Assert.assertEquals("OpenERP Server Error", exc.message, "Authenticate Exception failed");
        }

        // Bad username or password
        try {
            JSONObject sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_client", "admin", "adminisssss", null, null);
            Assert.assertEquals( -1, sessionInfo.getInt("uid"), "Bad Authentication Failure (password) returned value");

            sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_client", "adminisss", "admin", null, null);
            Assert.assertEquals( -1, sessionInfo.getInt("uid"), "Bad Authentication Failure (user) returned value");

        } catch ( OpenERPJSONRPCClientException exc ) {
           System.out.println(exc);
            Assert.assertEquals("OpenERP Server Error", exc.message, "Authenticate Exception failed");
        }

        // Authentication success.
        // User must store sessionInfo as it contains important information
        JSONObject sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_client", "admin", "admin", null, null);
        Assert.assertTrue(sessionInfo instanceof JSONObject, "Login failed");
        System.out.println("login success sessionInfo="+sessionInfo);
    }
View Full Code Here

        System.out.println("login success sessionInfo="+sessionInfo);
    }

    @Test(groups = {"session_service"}, dependsOnMethods = {"sessionAuthenticate"})
    public void sessionGetInfoOnceLogged() {
        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);

        JSONObject sessionInfo = server.sessionGetInfo(null);
        Assert.assertEquals(-1, sessionInfo.get("uid"), "Bad 'No Session' returned value.");

        sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_client", "admin", "admin", null, null);
        Assert.assertEquals(1, sessionInfo.get("uid"), "Admin login failed");

        // We retest GetSessionInfo after login and expect uid = 1 ( 1 = admin user )
        sessionInfo = server.sessionGetInfo(null);
        Assert.assertEquals(1, sessionInfo.get("uid"), "GetSessionInfo() failed as loggedin.");
    }
View Full Code Here

    @Test(groups = {"fill_database"}, dependsOnGroups = {"session_service"})
    public void callkw_fill_res_users() {
        /**
         * We use CallKW to create a user using args postional
         */
        OpenERPJSONRPCClient server = new OpenERPJSONRPCClient(SERVER_URL+":"+SERVER_PORT);
        JSONObject sessionInfo = server.sessionAuthenticate("openerp_jsonrpc_client", "admin", "admin", null, null);

        String[] userNames = {
                "Adeline-Candida LISEHIPOLITO",
                "Alma-Anderson MARCELOHARRIETKAYLA",
                "Alphonse CHERISH",
                "Althea-Daisey NATIVIDADLAVONANGELINE",
                "Amy-Roberto MAUDPARTHENIA",
                "Annice-Arianna JAIMEEJACKIEMIYOKO",
                "Arielle ALBERTINAREGGIECONSUELA",
                "Arminda FLOYDSHARRI",
                "Ashli RONNIE",
                "Audie-Alethia SHEMEKA",
        };

        JSONArray args = null;
        JSONObject values = null;

        int i=0;
        while( i < userNames.length ) {
            args = new JSONArray();
            values = new JSONObject();
            values.put("name", userNames[i]);
            values.put("login", "user" + i + "@" + System.currentTimeMillis()); // timestamp for dirty runs
            values.put("new_password", "user" + i );
            args.put(values);
            System.out.print("Created " + values);
            Object response = server.modelCallKW("res.users", "create", args, null, null);
            Assert.assertTrue( response instanceof Integer, "res.users creation Failure");
            System.out.println(" with id = "+ response);
            i++;
        }
    }
View Full Code Here

TOP

Related Classes of fr.inouk.OpenERPJSONRPCClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.