Package org.apache.tuscany.das.rdb

Examples of org.apache.tuscany.das.rdb.Command.executeQuery()


    // Read a customer
    Command select = Command.FACTORY.createCommand(
        "SELECT * FROM CUSTOMER WHERE CUSTOMER.ID = 1", getConfig("customerMapping.xml"));
    select.setConnection(getConnection());

    DataObject root = select.executeQuery();
    DataObject customer = root.getDataObject("Customer[1]");
    assertEquals(1, customer.getInt("id"));
    assertEquals("1212 foobar lane", customer.getString("address"));
    assertEquals("Williams", customer.getString("lastname"));
   
View Full Code Here


        try {

            // Read customer 1
            Command select = Command.FACTORY.createCommand("Select * from CUSTOMER where ID = 1");
            select.setConnection(c);
            DataObject root = select.executeQuery();

            DataObject customer = (DataObject) root.get("CUSTOMER[1]");

            // Modify customer
            customer.set("LASTNAME", "Pavick");
View Full Code Here

            // Flush changes
            apply.execute(root);

            // Verify changes
            root = select.executeQuery();
            assertEquals("Pavick", root.getString("CUSTOMER[1]/LASTNAME"));

            // Since the DAS is not managing tx boundaries, I must
        } catch (Exception e) {
            c.rollback();
View Full Code Here

    //Read list of companies
    public void testReadCompanies() throws Exception {

        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml"));
        Command read = commandGroup.getCommand("all companies");
        DataObject root = read.executeQuery();
        assertEquals(3, root.getList("COMPANY").size());

    }
   
    //Read list of companies
View Full Code Here

    //Read list of companies
    public void testReadCompaniesWithDepartments() throws Exception {

        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml"));
        Command read = commandGroup.getCommand("all companies and departments");
        DataObject root = read.executeQuery();
        DataObject firstCompany = root.getDataObject("COMPANY[1]");
        List departments = firstCompany.getList("departments");
        assertEquals(0, departments.size());

   
View Full Code Here

   
    public void testddDepartmentToFirstCompany() throws Exception {
       
        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml"));
        Command read = commandGroup.getCommand("all companies and departments");
        DataObject root = read.executeQuery();
        DataObject firstCustomer = root.getDataObject("COMPANY[1]");
        int deptCount = firstCustomer.getList("departments").size();
       
        DataObject newDepartment = root.createDataObject("DEPARTMENT");
        firstCustomer.getList("departments").add(newDepartment);
View Full Code Here

       
        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);
       
        //verify
        root = read.executeQuery();
        firstCustomer = root.getDataObject("COMPANY[1]");
        assertEquals (deptCount + 1, firstCustomer.getList("departments").size());
   
   
    /**
 
View Full Code Here

    public void testFlushCreateHeirarchy() throws Exception {

        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml"));
        Command select = commandGroup.getCommand("all companies and departments");
        select.setConnection(getConnection());
        DataObject root = select.executeQuery();

        // Create a new Company
        DataObject company = root.createDataObject("COMPANY");
        company.setString("NAME", "Do-rite Pest Control");
View Full Code Here

        // Verify the change

        select = commandGroup.getCommand("company by id with departments");
        select.setParameterValue("ID", id);
        root = select.executeQuery();
        assertEquals("Do-rite Pest Control", root.getDataObject("COMPANY[1]")
                .getString("NAME"));

    }
   
View Full Code Here

        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml"));

        Command select = commandGroup.getCommand("company by id with departments");
        Integer idOfNoExistingCompany = new Integer(-1);
        select.setParameterValue("ID", idOfNoExistingCompany);
        DataObject root = select.executeQuery();
       
        //Will fail if there is no property named "COMPANY"
        assertEquals(0, root.getList("COMPANY").size());

    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.