Package org.apache.tuscany.das.rdb

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


        }
    }

    public void testReadOrdersAndDetails2() throws Exception {

        DAS das = DAS.FACTORY.createDAS(getConfig("InvalidConfig1.xml"), getConnection());
        Command read = das.createCommand("SELECT * FROM ANORDER LEFT JOIN ORDERDETAILS "
                + "ON ANORDER.ID = ORDERDETAILS.ORDERID ORDER BY ANORDER.ID");

        try {
            read.executeQuery();
        } catch (Exception ex) {
View Full Code Here


    }

    public void testMismatchedDataObjectModel() throws SQLException {
        SDOUtil.registerStaticTypes(CompanyFactory.class);
        DAS das = DAS.FACTORY.createDAS(getConfig("companyMappingWithConverters.xml"), getConnection());
        Command read = das.createCommand("select * from company");
        try {
            read.executeQuery();
        } catch (RuntimeException ex) {
            assertEquals("Type CompanyType does not contain a property named ID", ex.getMessage());
        }
View Full Code Here

    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testDeleteAndCreate() throws Exception {
        DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMappingWithCUD2.xml"), getConnection());
        // Read customer 1
        Command select = das.createCommand("Select * from CUSTOMER");
        DataObject root = select.executeQuery();

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

        int customerId = customer.getInt("ID");
        // Modify customer
        customer.delete();

        DataObject newCustomer = root.createDataObject("CUSTOMER");
        newCustomer.setInt("ID", 9999);
        newCustomer.setString("LASTNAME", "Jones");

        // Build apply changes command
        das.applyChanges(root);

        // Verify changes
        root = select.executeQuery();
        boolean found = false;
        Iterator i = root.getList("CUSTOMER").iterator();
View Full Code Here

        ConfigHelper helper = new ConfigHelper();
        Table customerTable = helper.addTable("CUSTOMER", "CUSTOMER");
        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ?, ADDRESS = ? "
                + "where ID = ?", "LASTNAME ADDRESS ID");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        // Read customer 1
        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
        DataObject root = select.executeQuery();

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

        // Modify customer
        customer.set("LASTNAME", "Pavick");

        // Build apply changes command
        das.applyChanges(root);

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

View Full Code Here

    /**
     * Read and modify a customer. Provide needed Create/Update/Delete statements via xml file
     */
    public void testReadModifyApply1() throws Exception {

        DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMappingWithCUD.xml"), getConnection());
        // Read customer 1
        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
        DataObject root = select.executeQuery();

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

        // Modify customer
        customer.set("LASTNAME", "Pavick");

        // Build apply changes command
        das.applyChanges(root);

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

View Full Code Here

    /**
     * Same as previous but: Utilizes generated CUD statements Key info provided programatically
     */
    public void testReadModifyApply2() throws Exception {

        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Read customer with particular ID
        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
        DataObject root = select.executeQuery();

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

        // Modify customer
        customer.set("LASTNAME", "Pavick");

        // Build apply changes command
        das.applyChanges(root);

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

View Full Code Here

    /**
     * Builds on previous but: 1. Key info provided via XML file
     */
    public void testReadModifyApply3() throws Exception {
        DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMapping.xml"), getConnection());
        // Read customer with particular ID
        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
        DataObject root = select.executeQuery();

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

        // Modify customer
        customer.set("LASTNAME", "Pavick");

        // Build apply changes command
        das.applyChanges(root);

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

View Full Code Here

     * Test ability to correctly flush heirarchy of objects that have generated
     * keys
     */
    public void testFlushCreateHeirarchy() throws Exception {

        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());
        Command select = das.getCommand("all companies and departments");
        DataObject root = select.executeQuery();

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

        // Create a new Department
        //Do not set ID or CompanyID since these are generated
        DataObject department = root.createDataObject("DEPARTMENT");
        department.setString("NAME", "Do-rite Pest Control");
        department.setString("LOCATION", "The boonies");
        department.setString("DEPNUMBER", "101");

        // Associate the new department with the new company
        company.getList("departments").add(department);

        // Get apply command
        das.applyChanges(root);

        // Save the id
        Integer id = (Integer) company.get("ID");

        // Verify the change

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

    }
View Full Code Here

    /**
     * Test ability to get an empty graph with the Types/Properties intact
     */
    public void testGetEmptyGraph() throws Exception {

        DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());

        Command select = das.getCommand("company by id with departments");
        Integer idOfNoExistingCompany = Integer.valueOf(-1);
        select.setParameter(1, idOfNoExistingCompany);
        DataObject root = select.executeQuery();

        //Will fail if there is no property named "COMPANY"
View Full Code Here

    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testReadTableInfo() throws Exception {
        DAS das = DAS.FACTORY.createDAS(getConnection());
        Command select = das.createCommand("SELECT * from SYSIBM.SYSTABLES WHERE TYPE = 'T'");
        DataObject root = select.executeQuery();

        DataObject table = (DataObject) root.get("SYSTABLES[1]");

        assertEquals('T', table.getChar("TYPE"));
View Full Code Here

TOP

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

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.