Package org.apache.tuscany.das.rdb

Examples of org.apache.tuscany.das.rdb.CommandGroup


    }

    public void testWASDefect330118() throws Exception {

        // Create the group and set common connection
        CommandGroup commandGroup = CommandGroup.FACTORY
                .createCommandGroup(getConfig("CustomersOrdersConfig.xml"));
        commandGroup.setConnection(getConnection());

        // Read all customers and add one
        Command read = commandGroup.getCommand("all customers");
        DataObject root = read.executeQuery();
        int numCustomers = root.getList("CUSTOMER").size();

        DataObject newCust = root.createDataObject("CUSTOMER");
        newCust.set("ID", new Integer(100));
        newCust.set("ADDRESS", "5528 Wells Fargo Drive");
        newCust.set("LASTNAME", "Gerkin");

        // Now delete this new customer
        newCust.delete();

        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);

        // Verify
        root = read.executeQuery();
        assertEquals(numCustomers, root.getList("CUSTOMER").size());
View Full Code Here


    }

    public void testUpdateChildThatHasGeneratedKey() throws Exception {

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

        // Read a specific company based on the known ID
        Command readCust = commandGroup.getCommand("all companies and departments");
        DataObject root = readCust.executeQuery();
        DataObject lastCustomer = root.getDataObject("COMPANY[3]");
        Iterator i = lastCustomer.getList("departments").iterator();
        Random generator = new Random();
        int random = generator.nextInt(1000) + 1;
        DataObject department;
        while (i.hasNext()) {
            department = (DataObject) i.next();
            // System.out.println("Modifying department: " +
            // department.getString("NAME"));
            department.setString("NAME", "Dept-" + random);
            random = random + 1;
        }

        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);

    }
View Full Code Here

    }

    public void testWASDefect330118() throws Exception {

        // Create the group and set common connection
        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CustomersOrdersConfig.xml"));
        commandGroup.setConnection(getConnection());

        // Read all customers and add one
        Command read = commandGroup.getCommand("all customers");
        DataObject root = read.executeQuery();
        int numCustomers = root.getList("CUSTOMER").size();

        DataObject newCust = root.createDataObject("CUSTOMER");
        newCust.set("ID", new Integer(100));
        newCust.set("ADDRESS", "5528 Wells Fargo Drive");
        newCust.set("LASTNAME", "Gerkin");

        // Now delete this new customer
        newCust.delete();

        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);

        // Verify
        root = read.executeQuery();
        assertEquals(numCustomers, root.getList("CUSTOMER").size());
View Full Code Here

     * Try a workaround using CommandGroup
     */
    public void testYingChen12162005Workaraound() throws Exception {

        // Create the group and set common connection
        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CustomerConfig.xml"));
        commandGroup.setConnection(getConnection());

        Command insert = commandGroup.getCommand("insert customer");
        insert.setParameterValue("ID", new Integer(10));
        insert.setParameterValue("LASTNAME", "Williams");
        insert.setParameterValue("ADDRESS", null);
        insert.execute();

        // Verify
        Command select = commandGroup.getCommand("read customer 10");
        DataObject root = select.executeQuery();
        assertEquals(1, root.getList("CUSTOMER").size());
        assertEquals("5528 Wells Fargo Dr", root.get("CUSTOMER[1]/ADDRESS"));

    }
View Full Code Here

    }
   
    public void testUpdateChildThatHasGeneratedKey() throws Exception {

        CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml"));
                       
        //Read a specific company based on the known ID
        Command readCust = commandGroup.getCommand("all companies and departments");
        DataObject root = readCust.executeQuery();      
        DataObject lastCustomer = root.getDataObject("COMPANY[3]");
        Iterator i = lastCustomer.getList("departments").iterator();
        Random generator = new Random();
        int random = generator.nextInt(1000) + 1;
        DataObject department;
        while (i.hasNext()) {
            department = (DataObject)i.next();
            System.out.println("Modifying department: " + department.getString("NAME"));
            department.setString("NAME", "Dept-" + random);
            random = random + 1;
        }
       
        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);
       
   
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.CommandGroup

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.