Package org.apache.tuscany.das.rdb

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


    public void test1() throws Exception {

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

        Command read = commandGroup.getCommand("get companies with employee of the month");
        DataObject root = read.executeQuery();
        DataObject employee = root.getDataObject("COMPANY[1]/company->employee_opposite");

        assertEquals("Mary Smith", employee.getString("NAME"));
    }
View Full Code Here


    public void test2() throws Exception {

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

        Command read = commandGroup.getCommand("get named employee with company");
        read.setParameterValue("NAME", "Mary Smith");
        DataObject root = read.executeQuery();
        DataObject company = root.getDataObject("EMPLOYEE[1]/company->employee");

        assertEquals("ACME Publishing", company.getString("NAME"));
    }
View Full Code Here

    public void test3() throws Exception {

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

        Command read = commandGroup.getCommand("get companies with employee of the month");
        DataObject root = read.executeQuery();
        DataObject company = root.getDataObject("COMPANY[1]");
        company.setDataObject("company->employee_opposite", null);
        assertNull(company.getDataObject("company->employee_opposite"));
  
        //Flush changes
        commandGroup.getApplyChangesCommand().execute(root);

        //Verify
        root = read.executeQuery();
        company = root.getDataObject("COMPANY[1]");
        assertNull(company.getDataObject("company->employee_opposite"));
    }
View Full Code Here

    public void test4() throws Exception {

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

        Command read = commandGroup.getCommand("get companies with employee of the month");
        DataObject root = read.executeQuery();
        DataObject company = root.getDataObject("COMPANY[1]");
        DataObject employee = company.getDataObject("company->employee_opposite");
        employee.delete();
        assertNull(company.getDataObject("company->employee_opposite"));
  
        //Flush changes
        commandGroup.getApplyChangesCommand().execute(root);

        //Verify
        root = read.executeQuery();
        company = root.getDataObject("COMPANY[1]");
        assertNull(company.getDataObject("company->employee_opposite"));
    }
View Full Code Here

    public void test5() throws Exception {

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

        Command read = commandGroup.getCommand("get companies with employee of the month");
        DataObject root = read.executeQuery();
        DataObject company = root.getDataObject("COMPANY[1]");
       
        //Create a new employee
        DataObject employee = root.createDataObject("EMPLOYEE");
        employee.setString ("NAME", "Joe Hotshot");
       
      //Assigne a EOTM
        //Strangely this statement results in "Could not find relationships" error
        //although "company.setDataObject("company->employee_opposite", null);" dos not  
        company.setDataObject("company->employee_opposite", employee);    
        
        //Flush changes
        commandGroup.getApplyChangesCommand().execute(root);

        //Verify
        root = read.executeQuery();
        company = root.getDataObject("COMPANY[1]");
       
        employee = root.getDataObject("COMPANY[1]/company->employee_opposite");

        assertEquals("Joe Hotshot", employee.getString("NAME"));
View Full Code Here

  }
 
  public void testRead() throws Exception {
    SDOUtil.registerStaticTypes(CustomerFactory.class);
    InputStream mapping = getClass().getClassLoader().getResourceAsStream("basicStaticCustomer.xml");
    Command select = Command.FACTORY.createCommand("Select ID, LASTNAME, ADDRESS from CUSTOMER where LASTNAME = :LASTNAME",mapping);
    select.setConnection(getConnection());
    select.setParameterValue("LASTNAME", "Williams");
    TypeHelper helper = TypeHelper.INSTANCE;
   
    select.setDataObjectModel(helper.getType(DataGraphRoot.class));
   
    DataGraphRoot root = (DataGraphRoot) select.executeQuery();
   
    Collection customers = root.getCustomers();
    assertEquals(4, customers.size());
  }
View Full Code Here

   *
   */
  public void testArbitraryConverter() throws Exception {
   
    //Create and initialize command to read customers
    Command read = Command.FACTORY.createCommand("select * from CUSTOMER where ID = 1", getConfig("CustomerConfigWithConverter.xml"))
    read.setConnection(getConnection());

    String[] columns = { "ID", "LASTNAME", "ADDRESS" };
    String[] tables = { "CUSTOMER", "CUSTOMER", "CUSTOMER" };
    Type[] types = { SDODataTypes.INTEGEROBJECT, SDODataTypes.DATE, SDODataTypes.STRING };
    ResultSetShape shape = new ResultSetShape(tables, columns, types);
    read.setResultSetShape(shape);
           
    //Read
    DataObject root = read.executeQuery();
   
    //Verify
    assertEquals(kbday, root.getDate("CUSTOMER[1]/LASTNAME"));
   
    //Modify
    root.setDate("CUSTOMER[1]/LASTNAME", tbday)
   
    ApplyChangesCommand write = Command.FACTORY.createApplyChangesCommand(getConfig("CustomerConfigWithConverter.xml"));
    write.setConnection(getConnection());
    write.execute(root);
   
    //Read
    root = read.executeQuery();

    //Verify
    assertEquals(tbday, root.getDate("CUSTOMER[1]/LASTNAME"));
   
  }
View Full Code Here

   * Read a specific customer
   */
  public void testReadSingle() throws Exception {

    //Create and initialize command to read customers
    Command readCustomers = Command.FACTORY.createCommand("select * from CUSTOMER where ID = 1")
    readCustomers.setConnection(getConnection());

    //Read
    DataObject root = readCustomers.executeQuery();
   
    //Verify
    assertEquals(1, root.getInt("CUSTOMER[1]/ID"));
  }
View Full Code Here

   * Read a specific customer
   */
  public void testReadSingle2() throws Exception {

    //Create and initialize command to read customers
    Command readCustomers = Command.FACTORY.createCommand("select * from CUSTOMER where ID = 1")
    readCustomers.setConnection(getConnection());

    //Read
    DataObject root = readCustomers.executeQuery();
   
    DataObject cust = root.getDataObject("CUSTOMER[1]");
   
//    int n = (cust.getType().getProperties()).size();
//    for (int i=0; i<n; i++) {
View Full Code Here

   * Same as above but tests tolerance of white space in provided SQL
   */
  public void testReadSingleWithWhiteSpace() throws Exception {

    //Create and initialize command to read customers
    Command readCustomers = Command.FACTORY.createCommand("   select * from CUSTOMER where ID = 1")
    readCustomers.setConnection(getConnection());

    //Read
    DataObject root = readCustomers.executeQuery();
   
    //Verify
    assertEquals(1, root.getInt("CUSTOMER[1]/ID"));
  }
View Full Code Here

TOP

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

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.