You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by Luciano Resende <lu...@gmail.com> on 2007/09/04 19:58:41 UTC

[DAS] Changes from Tuscany-1466, was Re: svn commit: r572735 - in /incubator/tuscany/java/das/rdb/src: main/java/org/apache/tuscany/das/rdb/ main/java/org/apache/tuscany/das/rdb/impl/ test/java/org/apache/tuscany/das/rdb/test/ test/java/org/apache/tu

I don't think it's a good idea to expose the Connection trough DAS API
as I already mentioned in previous discussions. First, in a managed
environment, there is no need for DAS to expose the connection, as
there is transaction manager handling the transactions and JDBC knows
how to participate on them. Also, exposing the Connection on the DAS
API also makes it RDB centric, and I would like to avoid it.

Amita is doing some tests with a real managed transaction env (using
JOTM and Tomcat) and I'd like to hold any changes on this area untill
she comes up with concrete results from the proper env.So, could you
please revert these changes until we hear back from Amita.

Thanks, and sorry for the inconvenience.

On 9/4/07, adrianocrestani@apache.org <ad...@apache.org> wrote:
> Author: adrianocrestani
> Date: Tue Sep  4 09:50:19 2007
> New Revision: 572735
>
> URL: http://svn.apache.org/viewvc?rev=572735&view=rev
> Log:
> applying patch from JIRA-1466
>
> Added:
>     incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/BankAccountData.java
>     incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DepartmentsData.java
>     incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/EmployeesData.java
>     incubator/tuscany/java/das/rdb/src/test/resources/extTxWithExtConnection.xml
>     incubator/tuscany/java/das/rdb/src/test/resources/extTxWithIntConnection.xml
>     incubator/tuscany/java/das/rdb/src/test/resources/extTxnIntConnectionRollback.xml
> Modified:
>     incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DAS.java
>     incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java
>     incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TransactionTests.java
>     incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java
>
> Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DAS.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DAS.java?rev=572735&r1=572734&r2=572735&view=diff
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DAS.java (original)
> +++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/DAS.java Tue Sep  4 09:50:19 2007
> @@ -18,6 +18,8 @@
>   */
>  package org.apache.tuscany.das.rdb;
>
> +import java.sql.Connection;
> +
>  import org.apache.tuscany.das.rdb.impl.DASFactoryImpl;
>
>  import commonj.sdo.DataObject;
> @@ -64,4 +66,9 @@
>       */
>      Command createCommand(String sql);
>
> +    /**
> +     * Make connection available for user to control transaction externally
> +     * @return
> +     */
> +    Connection getConnection();
>  }
>
> Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java?rev=572735&r1=572734&r2=572735&view=diff
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java (original)
> +++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java Tue Sep  4 09:50:19 2007
> @@ -87,8 +87,7 @@
>                  throw new RuntimeException("Invalid kind of command: " + kind);
>              }
>
> -        }
> -
> +        }
>      }
>
>      public DASImpl(Config inConfig, Connection inConnection) {
> @@ -111,7 +110,7 @@
>       * @see org.apache.tuscany.das.rdb.CommandGroup#getApplyChangesCommand()
>       */
>      public ApplyChangesCommandImpl getApplyChangesCommand() {
> -        ApplyChangesCommandImpl cmd = new ApplyChangesCommandImpl(configWrapper, getConnection());
> +        ApplyChangesCommandImpl cmd = new ApplyChangesCommandImpl(configWrapper, getConnectionFromConfig());
>          return cmd;
>      }
>
> @@ -125,7 +124,7 @@
>              throw new RuntimeException("CommandGroup has no command named: " + name);
>          }
>          CommandImpl cmd = (CommandImpl) commands.get(name);
> -        cmd.setConnection(getConnection(), configWrapper.getConfig());
> +        cmd.setConnection(getConnectionFromConfig(), configWrapper.getConfig());
>          return cmd;
>      }
>
> @@ -133,7 +132,7 @@
>          this.connection = connection;
>      }
>
> -    public Connection getConnection() {
> +    private Connection getConnectionFromConfig() {
>          if (connection == null) {
>              initializeConnection();
>          }
> @@ -142,6 +141,7 @@
>
>      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");
> @@ -258,15 +258,15 @@
>      }
>
>      /**
> -     * If the config has connection properties then we are "managing" the connection via DataSource
> +     * If the DAS is managing connection, let it close it, else not
>       */
>      private boolean managingConnections() {
>
> -        if (configWrapper.getConfig().getConnectionInfo().getDataSource() == null) {
> -            return false;
> +        if (configWrapper.getConfig().getConnectionInfo().isManagedtx()) {
> +            return true;
>          }
>
> -        return true;
> +        return false;
>
>      }
>
> @@ -302,7 +302,7 @@
>                  throw new RuntimeException("SQL => " + sql + " is not valid");
>          }
>
> -        returnCmd.setConnection(getConnection(), config.getConfig());
> +        returnCmd.setConnection(getConnectionFromConfig(), config.getConfig());
>          return returnCmd;
>      }
>
> @@ -310,4 +310,24 @@
>          getApplyChangesCommand().execute(root);
>      }
>
> -}
> \ No newline at end of file
> +    public Connection getConnection() {
> +       getConnectionFromConfig();
> +       //connection created from DAS but tx management by client
> +       if(this.configWrapper.getConfig() != null &&
> +          this.configWrapper.getConfig().getConnectionInfo() != null &&
> +          !this.configWrapper.getConfig().getConnectionInfo().isManagedtx()){
> +               return this.connection;
> +       }
> +       //connection from client
> +       else if(this.configWrapper.getConfig() == null ||
> +                       this.configWrapper.getConfig().getConnectionInfo() == null ||
> +                       (this.configWrapper.getConfig().getConnectionInfo().getDataSource()==null &&
> +                        this.configWrapper.getConfig().getConnectionInfo().getConnectionProperties()==null)){
> +               return this.connection;
> +       }
> +       //connection from DAS and tx management by DAS
> +       else{
> +               throw new RuntimeException("DAS is controlling transaction, can not expose Connection!");
> +       }
> +    }
> +}
>
> Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TransactionTests.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TransactionTests.java?rev=572735&r1=572734&r2=572735&view=diff
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TransactionTests.java (original)
> +++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TransactionTests.java Tue Sep  4 09:50:19 2007
> @@ -27,16 +27,28 @@
>
>  import org.apache.tuscany.das.rdb.Command;
>  import org.apache.tuscany.das.rdb.DAS;
> +import org.apache.tuscany.das.rdb.impl.DASImpl;
> +import org.apache.tuscany.das.rdb.test.data.BankAccountData;
>  import org.apache.tuscany.das.rdb.test.data.CustomerData;
> +import org.apache.tuscany.das.rdb.test.data.DepartmentsData;
> +import org.apache.tuscany.das.rdb.test.data.EmployeesData;
>  import org.apache.tuscany.das.rdb.test.framework.DasTest;
>
> +import java.sql.Connection;
> +import java.sql.SQLException;
> +import java.util.Iterator;
> +
>  import commonj.sdo.DataObject;
> +import commonj.sdo.helper.XMLHelper;
>
>  public class TransactionTests extends DasTest {
>
>      protected void setUp() throws Exception {
>          super.setUp();
>          new CustomerData(getAutoConnection()).refresh();
> +        new DepartmentsData(getAutoConnection()).refresh();
> +        new EmployeesData(getAutoConnection()).refresh();
> +        new BankAccountData(getAutoConnection()).refresh();
>      }
>
>      protected void tearDown() throws Exception {
> @@ -84,4 +96,125 @@
>
>      }
>
> +    /**
> +     * Demonstrate that DAS allows external control of transaction when using
> +     * external connection. i.e. ConnectionInfo with only managedtx=false
> +     */
> +    public void testAbleToControlExternallyInitedTransaction() throws Exception {
> +        // Create and initialize a DAS connection and initialize for externally
> +        // managed transaction boundaries.
> +        java.sql.Connection c = getConnection();
> +
> +        //"John Jones" is in "Advanced Technologies"(Department1)
> +        DAS das = DAS.FACTORY.createDAS(getConfig("extTxWithExtConnection.xml"),c);
> +        Command selEmpForDep1 = das.getCommand("SelectEmployeesFromDepartment1");
> +        DataObject root1 = selEmpForDep1.executeQuery();
> +        DataObject department1 = (DataObject)root1.getList("DEPARTMENTS").get(0);
> +        assertEquals("Advanced Technologies", department1.getString("NAME"));
> +        DataObject employee1 = (DataObject)department1.getList("employed").get(0);
> +        assertEquals("John Jones", employee1.getString("NAME"));
> +
> +        //remove "John Jones" from "Advanced Technologies"(Department1)
> +        employee1.delete();
> +        das.applyChanges(root1);
> +
> +        //user decided to revert the decision to remove and thus issues rollback
> +        c.rollback();
> +
> +        //user wants to ensure that "John Jones" is still in Department1
> +        root1 = selEmpForDep1.executeQuery();
> +        department1 = (DataObject)root1.getList("DEPARTMENTS").get(0);
> +        assertEquals("Advanced Technologies", department1.getString("NAME"));
> +        boolean employeeRetained = isEmployeeInDepartment(root1, "John Jones");
> +        assertEquals(true, employeeRetained);//this shows that employee is not removed due to rollback
> +        //so proves that user is managing tx and not DAS
> +    }
> +
> +    private boolean isEmployeeInDepartment(DataObject root, String employeeName){
> +        //iterate for all employees in department1 is ensure that employeeName is there
> +        Iterator itr = ((DataObject)root.getList("DEPARTMENTS").get(0)).getList("employed").iterator();
> +        boolean employeeRetained = false;
> +        while(itr.hasNext()){
> +               DataObject employee = (DataObject)itr.next();
> +               if(employee.getString("NAME").equals(employeeName)){
> +                       employeeRetained = true;
> +               }
> +        }
> +        return employeeRetained;
> +    }
> +
> +    /**
> +     * Demonstrate that user can control tx when connection is from DAS for single command
> +     */
> +    public void testAbleToCommitTransaction() throws Exception {
> +        //"John Jones" is in "Advanced Technologies"(Department1)
> +        DAS das = DAS.FACTORY.createDAS(getConfig("extTxWithIntConnection.xml"));
> +        Connection conn = ((DASImpl)das).getConnection();
> +        //connection is created from config, not passed by user.
> +        Command selEmpForDep1 = das.getCommand("SelectEmployeesFromDepartment1");
> +        DataObject root1 = selEmpForDep1.executeQuery();
> +        DataObject department1 = (DataObject)root1.getList("DEPARTMENTS").get(0);
> +        assertEquals("Advanced Technologies", department1.getString("NAME"));
> +        DataObject employee1 = (DataObject)department1.getList("employed").get(0);
> +        assertEquals("John Jones", employee1.getString("NAME"));
> +        //remove "John Jones" from "Advanced Technologies"(Department1)
> +        employee1.delete();
> +        das.applyChanges(root1);
> +        conn.commit();
> +        //now open a fresh connection and check data in database
> +        java.sql.Connection c = getConnection();
> +        DAS dasFresh = DAS.FACTORY.createDAS(getConfig("extTxWithExtConnection.xml"),c);
> +        Command selEmpForDepFresh1 = dasFresh.getCommand("SelectEmployeesFromDepartment1");
> +        DataObject rootFresh1 = selEmpForDepFresh1.executeQuery();
> +        boolean employeeRetained1 = isEmployeeInDepartment(rootFresh1, "John Jones");
> +
> +        assertEquals(false, employeeRetained1);
> +    }
> +
> +    /**
> +     * Demonstrate that user can control tx for group of commands when connection is created in DAS
> +     */
> +    public void testDataIntegrity() throws Exception {
> +        //remove $200 from account1 and add $200 to account2
> +       //when doing add to account2 operation user rolls back
> +       //account1 and account2 both should have original balance.
> +        DAS das = DAS.FACTORY.createDAS(getConfig("extTxnIntConnectionRollback.xml"));
> +        //connection is created from config, not passed by user.
> +
> +        //check original balance from account1
> +        Command SelectBalanceFromAccount1 = das.getCommand("SelectBalanceFromAccount1");
> +        DataObject root1 = SelectBalanceFromAccount1.executeQuery();
> +        DataObject bankAccount1 = (DataObject)root1.getList("BANKACCOUNT").get(0);
> +        assertEquals(10000, bankAccount1.getInt("BALANCE"));
> +
> +        //remove $200 from account1
> +        bankAccount1.setInt("BALANCE", (bankAccount1.getInt("BALANCE")-200));
> +        das.applyChanges(root1);
> +
> +        //check original balance from account2
> +        Command SelectBalanceFromAccount2 = das.getCommand("SelectBalanceFromAccount2");
> +        DataObject root2 = SelectBalanceFromAccount2.executeQuery();
> +        DataObject bankAccount2 = (DataObject)root2.getList("BANKACCOUNT").get(0);
> +        assertEquals(5000, bankAccount2.getInt("BALANCE"));
> +
> +        //add  "$200"  to  account2
> +        bankAccount2.setInt("BALANCE", (bankAccount2.getInt("BALANCE")+200));
> +               das.applyChanges(root2);
> +               das.getConnection().rollback();//say user may get exception here in a try-catch and decides to rollback
> +
> +        //now open a fresh DAS and check data in database
> +        DAS dasFresh = DAS.FACTORY.createDAS(getConfig("extTxnIntConnectionRollback.xml"));
> +
> +        Command SelectBalanceFromAccount1Fresh = dasFresh.getCommand("SelectBalanceFromAccount1");
> +               DataObject rootFresh1 = SelectBalanceFromAccount1Fresh.executeQuery();
> +               DataObject bankAccount1Fresh = (DataObject)rootFresh1.getList("BANKACCOUNT").get(0);
> +               assertEquals(10000, bankAccount1Fresh.getInt("BALANCE"));//this shows $200 is not removed from account1, expected,
> +        //as rollbacked
> +
> +        Command SelectBalanceFromAccount2Fresh = dasFresh.getCommand("SelectBalanceFromAccount2");
> +               DataObject rootFresh2 = SelectBalanceFromAccount2Fresh.executeQuery();
> +               DataObject bankAccount2Fresh = (DataObject)rootFresh2.getList("BANKACCOUNT").get(0);
> +        assertEquals(5000, bankAccount2Fresh.getInt("BALANCE"));//this shows $200 is not added to account2, expected,
> +        //as have rollbacked
> +    }
>  }
>
> Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/BankAccountData.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/BankAccountData.java?rev=572735&view=auto
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/BankAccountData.java (added)
> +++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/BankAccountData.java Tue Sep  4 09:50:19 2007
> @@ -0,0 +1,43 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +package org.apache.tuscany.das.rdb.test.data;
> +
> +import java.sql.Connection;
> +import java.sql.Types;
> +
> +import org.apache.tuscany.das.rdb.test.framework.TestDataWithExplicitColumns;
> +
> +public class BankAccountData extends TestDataWithExplicitColumns {
> +
> +    private static int[] bankAccountTypes = {Types.INTEGER, Types.INTEGER, Types.INTEGER};
> +
> +    private static Object[][] bankAccountData = {{new Integer(1), new Integer(564026354),new Integer(10000)},
> +       {new Integer(2), new Integer(564026354),new Integer(5000)}};
> +
> +    private static String[] bankAccountColumns = {"ID", "SSN", "BALANCE"};
> +
> +    public BankAccountData(Connection connection) {
> +        super(connection, bankAccountData, bankAccountColumns, bankAccountTypes);
> +    }
> +
> +    public String getTableName() {
> +        return "BANKACCOUNT";
> +    }
> +
> +}
>
> Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DepartmentsData.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DepartmentsData.java?rev=572735&view=auto
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DepartmentsData.java (added)
> +++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DepartmentsData.java Tue Sep  4 09:50:19 2007
> @@ -0,0 +1,44 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +package org.apache.tuscany.das.rdb.test.data;
> +
> +import java.sql.Connection;
> +import java.sql.Types;
> +
> +import org.apache.tuscany.das.rdb.test.framework.TestDataWithExplicitColumns;
> +
> +
> +public class DepartmentsData extends TestDataWithExplicitColumns {
> +
> +    private static int[] columnTypes = {Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER};
> +
> +    private static Object[][] deptData = {{Integer.valueOf(1),"Advanced Technologies", "NY", "123", new Integer(1) },
> +                                          {Integer.valueOf(2),"New Technologies", "CA", "125", new Integer(2) }};
> +
> +    private static String[] deptColumns = {"ID", "NAME", "LOCATION", "DEPNUMBER", "COMPANYID"};
> +
> +    public DepartmentsData(Connection connection) {
> +        super(connection, deptData, deptColumns, columnTypes);
> +    }
> +
> +    public String getTableName() {
> +        return "DEPARTMENTS";
> +    }
> +
> +}
>
> Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/EmployeesData.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/EmployeesData.java?rev=572735&view=auto
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/EmployeesData.java (added)
> +++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/EmployeesData.java Tue Sep  4 09:50:19 2007
> @@ -0,0 +1,46 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +package org.apache.tuscany.das.rdb.test.data;
> +
> +import java.sql.Connection;
> +import java.sql.Types;
> +
> +import org.apache.tuscany.das.rdb.test.framework.TestDataWithExplicitColumns;
> +
> +public class EmployeesData extends TestDataWithExplicitColumns {
> +
> +    private static int[] columnTypes = {Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.INTEGER};
> +
> +    private static Object[][] employeeData = {{"John Jones", "E0001", Boolean.valueOf(false), Integer.valueOf(1)},
> +        {"Mary Smith", "E0002", Boolean.valueOf(true), Integer.valueOf(1)},
> +        {"Jane Doe", "E0003", Boolean.valueOf(false), Integer.valueOf(2)},
> +        {"Al Smith", "E0004", Boolean.valueOf(true), Integer.valueOf(2)},
> +        {"John Smith", "E0005", Boolean.valueOf(false), Integer.valueOf(2)}};
> +
> +    private static String[] employeeColumns = {"NAME", "SN", "MANAGER","DEPARTMENTID"};
> +
> +    public EmployeesData(Connection connection) {
> +        super(connection, employeeData, employeeColumns, columnTypes);
> +    }
> +
> +    public String getTableName() {
> +        return "EMPLOYEES";
> +    }
> +
> +}
>
> Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java?rev=572735&r1=572734&r2=572735&view=diff
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java (original)
> +++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java Tue Sep  4 09:50:19 2007
> @@ -164,6 +164,9 @@
>              "DROP TABLE DASTEST3.ORDERDETAILSDESC", "DROP TABLE DASTEST1.ORDERDETAILS",
>              "DROP TABLE DASTEST1.EMPLOYEE",
>              "DROP TABLE SINGER",
> +            "DROP TABLE BANKACCOUNT",
> +            "DROP TABLE DEPARTMENTS",
> +            "DROP TABLE EMPLOYEES",
>              "DROP TABLE SONG",
>              "DROP TABLE DASTEST1.EMPLOYEE",
>              "DROP TABLE DOCUMENTS_IMAGES"
> @@ -274,7 +277,10 @@
>              s.execute(getCreateDASTEST3OrderDetailsDesc());
>              //JIRA-952 end
>              s.execute(getCreateSinger());
> -            s.execute(getCreateSong());
> +            s.execute(getCreateSong());
> +            s.execute(getCreateDepartments());
> +            s.execute(getCreateBankAccount());
> +            s.execute(getCreateEmployees());
>              s.execute(getCreateDocumentsImages());
>
>          } catch (SQLException e) {
> @@ -354,6 +360,13 @@
>                  + getIntegerColumn("DEPARTMENTID") + ")";
>      }
>
> +    protected String getCreateEmployees() {
> +        return "CREATE TABLE EMPLOYEES (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL "
> +            + getGeneratedKeyClause() + ","
> +                + getStringColumn("NAME", 30) + "," + getStringColumn("SN", 10) + ", MANAGER SMALLINT, "
> +                + getIntegerColumn("DEPARTMENTID") + ")";
> +    }
> +
>      protected String getCreateDepartment() {
>          return "CREATE TABLE DEPARTMENT (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL "
>              + getGeneratedKeyClause() + ", "
> @@ -362,6 +375,13 @@
>                  + getIntegerColumn("COMPANYID") + ")";
>      }
>
> +    protected String getCreateDepartments() {
> +        return "CREATE TABLE DEPARTMENTS (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL , "
> +                + getStringColumn("NAME", 30) + "," + getStringColumn("LOCATION", 30) + ", "
> +                + getStringColumn("DEPNUMBER", 10) + ","
> +                + getIntegerColumn("COMPANYID") + ")";
> +    }
> +
>      protected String getCreateBook() {
>          return "CREATE TABLE BOOK (" + getIntegerColumn("BOOK_ID") + " PRIMARY KEY NOT NULL, "
>              + getStringColumn("NAME", 50) + ","
> @@ -513,7 +533,12 @@
>
>
>
> -
> +    protected String getCreateBankAccount() {
> +       return "CREATE TABLE BANKACCOUNT ("+ getIntegerColumn("ID") + " , " +
> +               getIntegerColumn("SSN") + ", "+
> +               getIntegerColumn("BALANCE") + " )";
> +    }
> +
>
>
>
>
> Added: incubator/tuscany/java/das/rdb/src/test/resources/extTxWithExtConnection.xml
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/resources/extTxWithExtConnection.xml?rev=572735&view=auto
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/test/resources/extTxWithExtConnection.xml (added)
> +++ incubator/tuscany/java/das/rdb/src/test/resources/extTxWithExtConnection.xml Tue Sep  4 09:50:19 2007
> @@ -0,0 +1,36 @@
> +<?xml version="1.0" encoding="ASCII"?>
> +<!--
> +  Licensed to the Apache Software Foundation (ASF) under one
> +  or more contributor license agreements.  See the NOTICE file
> +  distributed with this work for additional information
> +  regarding copyright ownership.  The ASF licenses this file
> +  to you under the Apache License, Version 2.0 (the
> +  "License"); you may not use this file except in compliance
> +  with the License.  You may obtain a copy of the License at
> +
> +  http://www.apache.org/licenses/LICENSE-2.0
> +
> +  Unless required by applicable law or agreed to in writing,
> +  software distributed under the License is distributed on an
> +  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> +  KIND, either express or implied.  See the License for the
> +  specific language governing permissions and limitations
> +  under the License.
> + -->
> +<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd">
> +       <!--below is needed if user wants to control tx-->
> +       <ConnectionInfo managedtx="false">
> +       </ConnectionInfo>
> +
> +       <Command name="SelectEmployeesFromDepartment1"
> +               SQL="select * from DEPARTMENTS left outer join EMPLOYEES on DEPARTMENTS.ID = EMPLOYEES.DEPARTMENTID where DEPARTMENTS.ID = 1"
> +               kind="Select"/>
> +       <Command name="SelectEmployeesFromDepartment2"
> +               SQL="select * from DEPARTMENTS left outer join EMPLOYEES on DEPARTMENTS.ID = EMPLOYEES.DEPARTMENTID where DEPARTMENTS.ID = 2"
> +               kind="Select"/>
> +
> +       <Relationship name="employed" primaryKeyTable="DEPARTMENTS" foreignKeyTable="EMPLOYEES" many="true" >
> +       <KeyPair primaryKeyColumn="ID" foreignKeyColumn="DEPARTMENTID" />
> +       </Relationship>
> +</Config>
> +
>
> Added: incubator/tuscany/java/das/rdb/src/test/resources/extTxWithIntConnection.xml
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/resources/extTxWithIntConnection.xml?rev=572735&view=auto
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/test/resources/extTxWithIntConnection.xml (added)
> +++ incubator/tuscany/java/das/rdb/src/test/resources/extTxWithIntConnection.xml Tue Sep  4 09:50:19 2007
> @@ -0,0 +1,38 @@
> +<?xml version="1.0" encoding="ASCII"?>
> +<!--
> +  Licensed to the Apache Software Foundation (ASF) under one
> +  or more contributor license agreements.  See the NOTICE file
> +  distributed with this work for additional information
> +  regarding copyright ownership.  The ASF licenses this file
> +  to you under the Apache License, Version 2.0 (the
> +  "License"); you may not use this file except in compliance
> +  with the License.  You may obtain a copy of the License at
> +
> +  http://www.apache.org/licenses/LICENSE-2.0
> +
> +  Unless required by applicable law or agreed to in writing,
> +  software distributed under the License is distributed on an
> +  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> +  KIND, either express or implied.  See the License for the
> +  specific language governing permissions and limitations
> +  under the License.
> + -->
> +<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd">
> +       <ConnectionInfo managedtx="false">
> +               <ConnectionProperties
> +                       driverClass="org.apache.derby.jdbc.EmbeddedDriver"
> +                       databaseURL="jdbc:derby:target/dastest; create = true"
> +                       loginTimeout="600000"/>
> +       </ConnectionInfo>
> +
> +       <Command name="SelectEmployeesFromDepartment1"
> +               SQL="select * from DEPARTMENTS left outer join EMPLOYEES on DEPARTMENTS.ID = EMPLOYEES.DEPARTMENTID where DEPARTMENTS.ID = 1"
> +               kind="Select"/>
> +       <Command name="SelectEmployeesFromDepartment2"
> +               SQL="select * from DEPARTMENTS left outer join EMPLOYEES on DEPARTMENTS.ID = EMPLOYEES.DEPARTMENTID where DEPARTMENTS.ID = 2"
> +               kind="Select"/>
> +
> +       <Relationship name="employed" primaryKeyTable="DEPARTMENTS" foreignKeyTable="EMPLOYEES" many="true" >
> +       <KeyPair primaryKeyColumn="ID" foreignKeyColumn="DEPARTMENTID" />
> +       </Relationship>
> +</Config>
>
> Added: incubator/tuscany/java/das/rdb/src/test/resources/extTxnIntConnectionRollback.xml
> URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/resources/extTxnIntConnectionRollback.xml?rev=572735&view=auto
> ==============================================================================
> --- incubator/tuscany/java/das/rdb/src/test/resources/extTxnIntConnectionRollback.xml (added)
> +++ incubator/tuscany/java/das/rdb/src/test/resources/extTxnIntConnectionRollback.xml Tue Sep  4 09:50:19 2007
> @@ -0,0 +1,34 @@
> +<?xml version="1.0" encoding="ASCII"?>
> +<!--
> +  Licensed to the Apache Software Foundation (ASF) under one
> +  or more contributor license agreements.  See the NOTICE file
> +  distributed with this work for additional information
> +  regarding copyright ownership.  The ASF licenses this file
> +  to you under the Apache License, Version 2.0 (the
> +  "License"); you may not use this file except in compliance
> +  with the License.  You may obtain a copy of the License at
> +
> +  http://www.apache.org/licenses/LICENSE-2.0
> +
> +  Unless required by applicable law or agreed to in writing,
> +  software distributed under the License is distributed on an
> +  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> +  KIND, either express or implied.  See the License for the
> +  specific language governing permissions and limitations
> +  under the License.
> + -->
> +<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd">
> +       <ConnectionInfo managedtx="false">
> +               <ConnectionProperties
> +                       driverClass="org.apache.derby.jdbc.EmbeddedDriver"
> +                       databaseURL="jdbc:derby:target/dastest; create = true"
> +                       loginTimeout="600000"/>
> +       </ConnectionInfo>
> +
> +       <Command name="SelectBalanceFromAccount1"
> +               SQL="select * from BANKACCOUNT where SSN = 564026354 and ID=1"
> +               kind="Select"/>
> +       <Command name="SelectBalanceFromAccount2"
> +               SQL="select * from BANKACCOUNT where SSN = 564026354 and ID=2"
> +               kind="Select"/>
> +</Config>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-commits-help@ws.apache.org
>
>


-- 
Luciano Resende
Apache Tuscany Committer
http://people.apache.org/~lresende
http://lresende.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org