Package org.apache.tuscany.das.rdb.config

Examples of org.apache.tuscany.das.rdb.config.Config


     */
    public void testAddInsertCommand() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addInsertCommand("insert customer", "insert into customers(ID,NAME) values (?,?)");

        Config config = helper.getConfig();
        List commands = config.getCommand();
        assertEquals(1, commands.size());
        org.apache.tuscany.das.rdb.config.Command cmd = (org.apache.tuscany.das.rdb.config.Command) commands.get(0);
        assertEquals("insert", cmd.getKind());
        assertEquals("insert customer", cmd.getName());
        assertEquals("insert into customers(ID,NAME) values (?,?)", cmd.getSQL());
View Full Code Here


     */
    public void testAddDeleteCommand() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addDeleteCommand("delete customer", "delete from customers where id = ?");

        Config config = helper.getConfig();
        List commands = config.getCommand();
        assertEquals(1, commands.size());
        org.apache.tuscany.das.rdb.config.Command cmd = (org.apache.tuscany.das.rdb.config.Command) commands.get(0);
        assertEquals("delete", cmd.getKind());
        assertEquals("delete customer", cmd.getName());
        assertEquals("delete from customers where id = ?", cmd.getSQL());
View Full Code Here

     */
    public void testDataObjectModel() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.setDataObjectModel("org.apache.tuscany/mytypes");

        Config config = helper.getConfig();
        assertEquals("org.apache.tuscany/mytypes", config.getDataObjectModel());

    }
View Full Code Here

    public void testAddDeleteStatement() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("widgets", "WIDGETS");
        helper.addDeleteStatement(table, "delete from widgets where id = ?", "ID");

        Config cfg = helper.getConfig();
        assertEquals(1, cfg.getTable().size());
        Table widgets = (Table) cfg.getTable().get(0);
        assertEquals("delete from widgets where id = ?", widgets.getDelete().getSql());
        assertEquals("WIDGETS", widgets.getTypeName());
        assertEquals("ID", ConfigUtil.getParameters(widgets.getDelete()));

    }
View Full Code Here

    public void testAddCreateStatement() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("widgets", "WIDGETS");
        helper.addCreateStatement(table, "insert into widgets values (?,?)", "ID NAME");

        Config cfg = helper.getConfig();
        assertEquals(1, cfg.getTable().size());
        Table widgets = (Table) cfg.getTable().get(0);
        assertEquals("insert into widgets values (?,?)", widgets.getCreate().getSql());
        assertEquals("WIDGETS", widgets.getTypeName());
        assertEquals("ID NAME", ConfigUtil.getParameters(widgets.getCreate()));

    }
View Full Code Here

        this(ConfigUtil.loadConfig(stream));

    }

    public DASImpl(Config inConfig) {
        Config cfg = inConfig;
        if (cfg == null) {
            cfg = ConfigFactory.INSTANCE.createConfig();
        }
        this.configWrapper = new MappingWrapper(cfg);
View Full Code Here

        }
        return connection;
    }

    private void initializeConnection() {
        Config config = configWrapper.getConfig();
        if (config == null || config.getConnectionInfo() == null ||
            (config.getConnectionInfo().getDataSource() == null && config.getConnectionInfo().getConnectionProperties() == null)) {
            throw new RuntimeException("No connection has been provided and no data source has been specified");
        }

        if(config.getConnectionInfo().getDataSource() != null && config.getConnectionInfo().getConnectionProperties() != null){
            throw new RuntimeException("Use either dataSource or ConnectionProperties. Can't use both !");
        }

        ConnectionInfo connectionInfo = configWrapper.getConfig().getConnectionInfo();
        if(config.getConnectionInfo().getConnectionProperties() != null){
            initializeDriverManagerConnection(connectionInfo);
        }else{
            initializeDatasourceConnection(connectionInfo);
        }
View Full Code Here

    /**
     * Read
     */
    public void testReadUsingConfigInput() throws Exception {
        Config config = ConfigUtil.loadConfig(getConfig("CustomersOrdersConfig.xml"));
        DAS das = DAS.FACTORY.createDAS(config, getConnection());

        Command read = das.getCommand("all customers");
        DataObject root = read.executeQuery();

View Full Code Here

    }
   
    //<Config> useGetGeneratedKeys set to TRUE - Company
    public void testInsert() throws Exception {
      ConfigHelper helper = new ConfigHelper();
        Config config = helper.getConfig();
        config.setGeneratedKeysSupported("true");
       
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into COMPANY (NAME) values (?)");
        insert.setParameter(1, "AAA Rental");
        insert.execute();
View Full Code Here

    }

    //<Config> useGetGeneratedKeys not set - Company (should work as default TRUE)
    public void testInsert1() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Config config = helper.getConfig();
     
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into COMPANY (NAME) values (?)");
        insert.setParameter(1, "AAA Rental");
        insert.execute();
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.config.Config

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.