summaryrefslogtreecommitdiffstats
path: root/das-cpp/trunk/runtime/test
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-16 06:46:29 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-16 06:46:29 +0000
commitc5846d0e19e3b5fd9d818d714fea2df3f3ef90eb (patch)
treedac6ae1624ccc49913032c37610440f2a8b2e855 /das-cpp/trunk/runtime/test
parent580265475dca3952d6e243b1edeb5243df998c23 (diff)
Cleaning up SVN structure, moving das trunk to das-cpp/trunk.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@880626 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'das-cpp/trunk/runtime/test')
-rw-r--r--das-cpp/trunk/runtime/test/build.xml73
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testCompositeRelationship.xml35
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testCreateOperation.xml41
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testDeleteOperation.xml41
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testIncompleteCompositeRelationship1.xml35
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testIncompleteCompositeRelationship2.xml34
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testKeyPairColumnTypeNotEqual.xml37
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testManyRelationship1.xml29
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testManyRelationship2.xml29
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testModifyOperation.xml41
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testOCC1.xml43
-rw-r--r--das-cpp/trunk/runtime/test/rsc/testOCC2.xml43
-rw-r--r--das-cpp/trunk/runtime/test/src/main.cpp843
13 files changed, 1324 insertions, 0 deletions
diff --git a/das-cpp/trunk/runtime/test/build.xml b/das-cpp/trunk/runtime/test/build.xml
new file mode 100644
index 0000000000..c1512055ee
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/build.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project name="TuscanyDASNative_test" default="all" basedir="../..">
+
+ <import file="${basedir}/antscripts/system.xml"/>
+ <import file="${basedir}/antscripts/compile-targets.xml"/>
+
+ <!--
+ Notice that the basedir for this project is set to the TuscanyDAS root dir
+ This makes path setting in system.xml much simpler, but we'll just have to
+ set a property here to this directory.
+ -->
+ <property name="this.dir" location="${basedir}/runtime/test"/>
+ <property name="das.test.src.dir" location="${this.dir}/src"/>
+ <property name="das.test.build.dir" location="${this.dir}/build"/>
+ <property name="das.test.app" value="das_test"/>
+
+ <!--
+ Public targets
+ -->
+ <target name="all" description="compile, link, and run TuscanyDASNative test suite">
+ <antcall target="build"/>
+ <antcall target="run"/>
+ </target>
+
+ <target name="build" description="compile and link TuscanyDASNative test suite" depends="check.sdo">
+ <cpp-build
+ srcdir="${das.test.src.dir}"
+ infiles="*.cpp"
+ outdir="${das.test.build.dir}"
+ outfile="${das.test.app}"
+ outtype="executable">
+ <custom-build-elements>
+
+ <includepath path="${tuscanyDAS.install.dir}/include"/>
+ <includepath path="${tuscany.sdo.home.dir}/include"/>
+
+ <libset dir="${tuscanyDAS.install.dir}/lib" libs="tuscany_das"/>
+ <libset dir="${tuscany.sdo.home.dir}/lib" libs="tuscany_sdo"/>
+ <libset libs="odbc32"/>
+
+ </custom-build-elements>
+ </cpp-build>
+
+ </target>
+
+ <target name="run" depends="build" description="Run TuscanyDASNative test suite">
+ <exec executable="${das.test.build.dir}/${das.test.app}${exe.ext}" dir="${das.test.build.dir}"/>
+ </target>
+
+ <target name="clean" description="Clean TuscanyDASNative test suite">
+ <delete dir="${das.test.build.dir}" quiet="@{quiet}"/>
+
+ </target>
+
+</project>
diff --git a/das-cpp/trunk/runtime/test/rsc/testCompositeRelationship.xml b/das-cpp/trunk/runtime/test/rsc/testCompositeRelationship.xml
new file mode 100644
index 0000000000..c22799e650
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testCompositeRelationship.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.composite.relationship">
+
+ <Command name="get composite relationship" SQL="SELECT DEPARTMENT.ID, DEPARTMENT.NAME, EMPLOYEE.ID, EMPLOYEE.DEPARTMENT_ID, EMPLOYEE.DEPARTMENT_NAME FROM DEPARTMENT, EMPLOYEE;"/>
+
+ <Table tableName="department">
+ <Column sqlType="integer" columnName="id" primaryKey="true"/>
+ <Column sqlType="varchar" columnName="name" primaryKey="true"/>
+ </Table>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee" many="true">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ <KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+ </Relationship>
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testCreateOperation.xml b/das-cpp/trunk/runtime/test/rsc/testCreateOperation.xml
new file mode 100644
index 0000000000..c9e8d8a444
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testCreateOperation.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.create.operation"> >
+
+ <Command name="get all tables" SQL="SELECT * FROM company, department, employee;"/>
+
+ <Table tableName="Department">
+ <Column columnName="id" sqlType="integer" primaryKey="true"/>
+ <Column columnName="name" sqlType="varchar" primaryKey="true"/>
+ </Table>
+
+ <Relationship primaryKeyTable="company" foreignKeyTable="department">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+ </Relationship>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ <KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+ </Relationship>
+
+
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testDeleteOperation.xml b/das-cpp/trunk/runtime/test/rsc/testDeleteOperation.xml
new file mode 100644
index 0000000000..fa619fda76
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testDeleteOperation.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.delete.operation">
+
+ <Command name="get all tables" SQL="SELECT * FROM company, department, employee;"/>
+
+ <Table tableName="Department">
+ <Column columnName="id" sqlType="integer" primaryKey="true"/>
+ <Column columnName="name" sqlType="varchar" primaryKey="true"/>
+ </Table>
+
+ <Relationship primaryKeyTable="company" foreignKeyTable="department">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+ </Relationship>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ <KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+ </Relationship>
+
+
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testIncompleteCompositeRelationship1.xml b/das-cpp/trunk/runtime/test/rsc/testIncompleteCompositeRelationship1.xml
new file mode 100644
index 0000000000..b43453d21d
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testIncompleteCompositeRelationship1.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.incomplete.composite.relationship.one">
+
+ <Command name="get incomplete relationship" SQL="SELECT department.id, department.name, employee.id, employee.department_id FROM department, employee;"/>
+
+ <Table tableName="department">
+ <Column sqlType="integer" columnName="id" primaryKey="true"/>
+ <Column sqlType="varchar" columnName="name" primaryKey="true"/>
+ </Table>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee" many="true">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ <KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+ </Relationship>
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testIncompleteCompositeRelationship2.xml b/das-cpp/trunk/runtime/test/rsc/testIncompleteCompositeRelationship2.xml
new file mode 100644
index 0000000000..a3032f2be0
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testIncompleteCompositeRelationship2.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.incomplete.composite.relationship.two">
+
+ <Command name="get incomplete relationship" SQL="SELECT department.id, department.name, employee.id, employee.department_id, employee.department_name FROM department, employee;"/>
+
+ <Table tableName="department">
+ <Column sqlType="varchar" columnName="name" primaryKey="true"/>
+ </Table>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee" many="true">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ <KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+ </Relationship>
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testKeyPairColumnTypeNotEqual.xml b/das-cpp/trunk/runtime/test/rsc/testKeyPairColumnTypeNotEqual.xml
new file mode 100644
index 0000000000..3da18378a1
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testKeyPairColumnTypeNotEqual.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.key.pair.column.type.not.equal">
+
+ <Command name="get all employees and departments" SQL="SELECT * FROM department, employee;"/>
+
+ <Table tableName="department">
+ <Column sqlType="integer" columnName="id" primaryKey="true"/>
+ </Table>
+
+ <Table tableName="employee">
+ <Column sqlType="float" columnName="department_id" primaryKey="true"/>
+ </Table>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee" many="true">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ </Relationship>
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testManyRelationship1.xml b/das-cpp/trunk/runtime/test/rsc/testManyRelationship1.xml
new file mode 100644
index 0000000000..30ceadf1c0
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testManyRelationship1.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.many.relationship.one">
+
+ <Command name="get company 1 and its departments" SQL="SELECT * FROM company, department where company.id = 1;"/>
+
+ <Relationship primaryKeyTable="company" foreignKeyTable="department" many="true">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+ </Relationship>
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testManyRelationship2.xml b/das-cpp/trunk/runtime/test/rsc/testManyRelationship2.xml
new file mode 100644
index 0000000000..9fa38c8a79
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testManyRelationship2.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.many.relationship.two">
+
+ <Command name="get company 1 and its departments" SQL="SELECT * FROM company, department where company.id = 1;"/>
+
+ <Relationship primaryKeyTable="company" foreignKeyTable="department" many="false">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+ </Relationship>
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testModifyOperation.xml b/das-cpp/trunk/runtime/test/rsc/testModifyOperation.xml
new file mode 100644
index 0000000000..59ae0b986a
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testModifyOperation.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.modify.operation">
+
+ <Command name="get all tables" SQL="SELECT * FROM company, department, employee;"/>
+
+ <Table tableName="Department">
+ <Column columnName="id" sqlType="integer" primaryKey="true"/>
+ <Column columnName="name" sqlType="varchar" primaryKey="true"/>
+ </Table>
+
+ <Relationship primaryKeyTable="company" foreignKeyTable="department">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+ </Relationship>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ <KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+ </Relationship>
+
+
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testOCC1.xml b/das-cpp/trunk/runtime/test/rsc/testOCC1.xml
new file mode 100644
index 0000000000..605d1aee83
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testOCC1.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.occ">
+
+ <Command name="get all companies" SQL="SELECT * FROM company;"/>
+
+ <Table tableName="Department">
+ <Column columnName="id" sqlType="integer" primaryKey="true"/>
+ <Column columnName="name" sqlType="varchar" primaryKey="true"/>
+ </Table>
+
+ <Table tableName="company">
+ <Column columnName="occ" sqlType="integer" collision="true" managed="true"/>
+ </Table>
+
+ <Relationship primaryKeyTable="company" foreignKeyTable="department">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+ </Relationship>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ <KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+ </Relationship>
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/rsc/testOCC2.xml b/das-cpp/trunk/runtime/test/rsc/testOCC2.xml
new file mode 100644
index 0000000000..65fab5927f
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/rsc/testOCC2.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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" uri="test.occ">
+
+ <Command name="get all companies" SQL="SELECT * FROM company;"/>
+
+ <Table tableName="Department">
+ <Column columnName="id" sqlType="integer" primaryKey="true"/>
+ <Column columnName="name" sqlType="varchar" primaryKey="true"/>
+ </Table>
+
+ <Table tableName="company">
+ <Column columnName="occ" sqlType="integer" collision="true" managed="false"/>
+ </Table>
+
+ <Relationship primaryKeyTable="company" foreignKeyTable="department">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="company_id"/>
+ </Relationship>
+
+ <Relationship primaryKeyTable="department" foreignKeyTable="employee">
+ <KeyPair primaryKeyColumn="id" foreignKeyColumn="department_id"/>
+ <KeyPair primaryKeyColumn="name" foreignKeyColumn="department_name"/>
+ </Relationship>
+
+</Config> \ No newline at end of file
diff --git a/das-cpp/trunk/runtime/test/src/main.cpp b/das-cpp/trunk/runtime/test/src/main.cpp
new file mode 100644
index 0000000000..b8f6239680
--- /dev/null
+++ b/das-cpp/trunk/runtime/test/src/main.cpp
@@ -0,0 +1,843 @@
+/*
+ * 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.
+ */
+
+#include <iostream>
+#include <apache/das/rdb/Connection.h>
+#include <apache/das/DAS.h>
+#include <apache/das/rdb/DASImpl.h>
+#include <apache/das/CommandPtr.h>
+#include <apache/das/rdb/ResultSet.h>
+#include <apache/das/rdb/Statement.h>
+#include <apache/das/DASNullPointerException.h>
+#include <apache/das/rdb/DASOptimisticConcurrencyControlException.h>
+#include <apache/das/rdb/das_constants.h>
+#include <apache/das/rdb/Column.h>
+#include <apache/das/rdb/Table.h>
+#include <apache/das/DataGraphPrinter.h>
+#include <commonj/sdo/DataObject.h>
+#include <commonj/sdo/SDORuntimeException.h>
+#include <commonj/sdo/DataFactory.h>
+
+#define TEST_RESOURCE_PATH "../rsc/"
+
+using namespace std;
+using namespace apache::das;
+using namespace apache::das::rdb;
+
+std::string clearDBStatements[] = { "delete from EMPLOYEE",
+ "delete from DEPARTMENT",
+ "delete from COMPANY",
+ "drop table EMPLOYEE",
+ "drop table DEPARTMENT",
+ "drop table COMPANY"
+ };
+
+std::string resetDBStatements[] = { "create table COMPANY ( ID int not null, NAME varchar(20), OCC int, primary key(ID) )",
+ "create table DEPARTMENT ( ID int not null, NAME varchar(20) not null, COMPANY_ID int, foreign key (COMPANY_ID) references company (ID), primary key(ID, NAME) )",
+ "create table EMPLOYEE ( ID int not null, NAME varchar(20), DEPARTMENT_ID int, DEPARTMENT_NAME varchar(20), primary key(ID) )",
+ "insert into COMPANY values (1, 'apache', 0)",
+ "insert into COMPANY values (2, 'acme', 0)",
+ "insert into COMPANY values (3, 'google', 0)",
+ "insert into COMPANY values (4, 'ibm', 0)",
+ "insert into COMPANY values (5, 'yahoo', 0)",
+ "insert into DEPARTMENT values (1, 'department1', 1)",
+ "insert into DEPARTMENT values (2, 'department1', 1)",
+ "insert into DEPARTMENT values (3, 'department2', 2)",
+ "insert into DEPARTMENT values (5, 'department3', 3)",
+ "insert into DEPARTMENT values (4, 'department5', 2)",
+ "insert into DEPARTMENT values (6, 'department6', 3)",
+ "insert into EMPLOYEE values (1, 'adriano', 1, 'department1')",
+ "insert into EMPLOYEE values (2, 'paul', 1, 'department1')",
+ "insert into EMPLOYEE values (3, 'richard', 1, 'department1')",
+ "insert into EMPLOYEE values (4, 'ema', 2, 'department2')",
+ "insert into EMPLOYEE values (5, 'james', 2, 'department2')"
+ };
+
+Connection* getConnection() {
+ Connection* conn;
+
+ try {
+ std::string dsn = "DAStestcases";
+ std::string user = "postgres";
+ std::string password = "tuscany";
+
+ conn = new Connection(dsn, user, password);
+
+ } catch (SQLException& ex) {
+ cout << "couldn't connect to the data source: " << ex.what() << endl;
+ system("PAUSE");
+ exit(1);
+
+ }
+
+ StatementPtr stmt = conn->createStatement();
+
+ for (unsigned int i = 0 ; i < 6 ; i++) {
+
+ try {
+ stmt->executeQuery(clearDBStatements[i]);
+ } catch (SQLException& ex) {cout << ex.what() << endl;}
+
+ }
+
+ for (unsigned int i = 0 ; i < 19 ; i++) {
+
+ try {
+ stmt->executeQuery(resetDBStatements[i]);
+ } catch (SQLException& ex) {cout << ex.what() << endl;}
+
+ }
+
+ stmt->executeQuery("commit");
+
+ return conn;
+
+}
+
+
+void testPointers() {
+ cout << "-------------testPointers--------------" << endl;
+ Connection* conn = getConnection();
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(*conn);
+ Command* comm = new ReadCommandImpl(*das, "select * from COMPANY");
+ CommandPtr comm1 = *comm;
+ CommandPtr comm2 = comm1;
+ CommandPtr comm3 = das->createCommand("select * from COMPANY;");
+ StatementPtr stmtPtr1 = conn->createStatement();
+ Statement* stmt = stmtPtr1;
+ StatementPtr stmtPtr2 = stmtPtr1;
+ StatementPtr stmtPtr3 = conn->createStatement();
+ StatementPtr* stmtPtr4 = new StatementPtr(stmt);
+
+ cout << "Command pointer working correctly = ";
+ try {
+ comm1->executeQuery();
+ cout << "OK" << endl;
+ } catch (DASNullPointerException& exp) {
+ cout << "DASNullPointerException" << endl;
+ }
+
+ comm1 = 0;
+ comm2 = 0;
+ cout << "Command object deleted when there is no more reference = ";
+ try {
+ comm1->executeQuery();
+ cout << "not deleted" << endl;
+ } catch (DASNullPointerException& exp) {
+ cout << "OK" << endl;
+ }
+
+ delete das;
+ cout << "Command pointer set as null when object is deleted = ";
+ if (comm3 != 0) {
+ cout << "not null" << endl;
+ } else {
+ cout << "OK" << endl;
+ }
+
+ ResultSetPtr resultSetPtr = stmtPtr1->executeQuery("select * from COMPANY;");
+
+ cout << "ResultSet pointer working correctly = ";
+ try {
+ resultSetPtr->getStatement();
+ cout << "OK" << endl;
+ } catch (DASNullPointerException& exp) {
+ cout << "DASNullPointerException" << endl;
+ }
+
+ stmtPtr1->executeQuery("select * from EMPLOYEE;");
+ cout << "ResultSet object deleted when there is another query on its statement = ";
+ try {
+ resultSetPtr->getStatement();
+ cout << "not deleted" << endl;
+ } catch (DASNullPointerException& exp) {
+ cout << "OK" << endl;
+ }
+
+ cout << "Statement pointer working correctly = ";
+ try {
+ stmtPtr1->getODBCStatement();
+ cout << "OK" << endl;
+ } catch (DASNullPointerException& exp) {
+ cout << "DASNullPointerException" << endl;
+ }
+
+ stmtPtr1 = 0;
+ stmtPtr2 = 0;
+ delete stmtPtr4;
+ cout << "Statement object deleted when there is no more reference = ";
+ try {
+ stmtPtr1->getODBCStatement();
+ cout << "not deleted" << endl;
+ } catch (DASNullPointerException& exp) {
+ cout << "OK" << endl;
+ }
+
+ stmtPtr1 = conn->createStatement();
+ resultSetPtr = stmtPtr1 ->executeQuery("select * from COMPANY;");
+ ResultSetPtr resultSetPtr2 = resultSetPtr;
+ delete conn;
+ stmtPtr1 = 0;
+ resultSetPtr = 0;
+ resultSetPtr2 = 0;
+
+ cout << "Statement pointer set as null when object is deleted = ";
+ if (stmtPtr3 != 0) {
+ cout << "not null" << endl;
+ } else {
+ cout << "OK" << endl;
+ }
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testIncompleteCompositeRelationship() {
+ cout << "-------------testIncompleteCompositeRelationship--------------" << endl;
+
+ Connection* conn = getConnection();
+
+ {
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testIncompleteCompositeRelationship1.xml");
+
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+
+ CommandPtr command = das->getCommand("get incomplete relationship");
+
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ cout << "relationship ignored when the ResultSet does not contain all KeyPairs = ";
+ try {
+ root->getDataFactory()->getType(config.getURI(), "DEPARTMENT").getProperty("EMPLOYEE");
+ cout << "not ignored" << endl;
+
+ } catch (commonj::sdo::SDOPropertyNotFoundException& ex) {
+ cout << "OK" << endl;
+ }
+
+ delete das;
+
+ }
+
+ {
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testIncompleteCompositeRelationship2.xml");
+
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+
+ CommandPtr command = das->getCommand("get incomplete relationship");
+
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ cout << "relationship ignored when a defined relationship pk is not a table pk = ";
+ try {
+ root->getDataFactory()->getType(config.getURI(), "DEPARTMENT").getProperty("EMPLOYEE");
+ cout << "not ignored" << endl;
+
+ } catch (commonj::sdo::SDOPropertyNotFoundException& ex) {
+ cout << "OK" << endl;
+ }
+
+ delete das;
+
+ }
+
+ delete conn;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testCompositeRelationship() {
+ cout << "-------------testCompositeRelationship--------------" << endl;
+
+ Connection* conn = getConnection();
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testCompositeRelationship.xml");
+
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+
+ CommandPtr command = das->getCommand("get composite relationship");
+
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ cout << "relationship created = ";
+ try {
+ root->getDataFactory()->getType(config.getURI(), "DEPARTMENT").getProperty("EMPLOYEE");
+ cout << "OK" << endl;
+
+ cout << "references set = ";
+ if (root->getDataObject("DEPARTMENT[1]")->getList("EMPLOYEE").size() != 0) {
+ cout << "OK" << endl;
+ } else {
+ cout << "not set" << endl;
+ }
+
+ } catch (commonj::sdo::SDOPropertyNotFoundException& ex) {
+ cout << "not created" << endl;
+
+ }
+
+ delete conn;
+ delete das;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testCOCRelationship() {
+ cout << "-------------testCOCRelationship--------------" << endl;
+
+ Connection* conn = getConnection();
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(*conn);
+
+ CommandPtr command = das->createCommand("SELECT * FROM DEPARTMENT, COMPANY;");
+
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+
+ cout << "relationship created = ";
+ try {
+ root->getDataFactory()->getType(das->getConfig().getURI(), "COMPANY").getProperty("DEPARTMENT");
+ cout << "OK" << endl;
+
+ } catch (commonj::sdo::SDOPropertyNotFoundException& ex) {
+ cout << "not created" << endl;
+ }
+
+ delete conn;
+ delete das;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testKeyPairColumnTypeNotEqual() {
+ cout << "-------------testKeyPairColumnTypeNotEqual--------------" << endl;
+
+ Connection* conn = getConnection();
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testKeyPairColumnTypeNotEqual.xml");
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+ CommandPtr command = das->getCommand("get all employees and departments");
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ cout << "relationship ignored when keypair types are not equal = ";
+ try {
+ root->getDataFactory()->getType(config.getURI(), "DEPARTMENT").getProperty("EMPLOYEE");
+ cout << "not ignored" << endl;
+
+ } catch (commonj::sdo::SDOPropertyNotFoundException& ex) {
+ cout << "OK" << endl;
+ }
+
+ delete conn;
+ delete das;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testUniqueObjectByID() {
+ cout << "-------------testUniqueObjectByID--------------" << endl;
+
+ Connection* conn = getConnection();
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(*conn);
+ CommandPtr command = das->createCommand("SELECT * FROM COMPANY, DEPARTMENT where COMPANY.ID = 1;");
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ cout << "table duplicated row ignored = ";
+ if (root->getList("COMPANY").size() == 1) {
+ cout << "OK" << endl;
+ } else {
+ cout << "not ignored" << endl;
+ }
+
+ delete conn;
+ delete das;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testDeleteOperation() {
+ cout << "-------------testDeleteOperation--------------" << endl;
+
+ Connection* conn = getConnection();
+
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testDeleteOperation.xml");
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+ CommandPtr command = das->getCommand("get all tables");
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ root->getDataObject("COMPANY[1]")->getDataObject("DEPARTMENT[1]")->detach();
+ commonj::sdo::DataObjectPtr company = root->getDataObject("COMPANY[1]");
+ company->detach();
+ long removedCompanyID = company->getInt("ID");
+
+ cout << "COMPANY with id " << removedCompanyID << " deleted on database: ";
+
+ das->applyChanges(root);
+
+ root = command->executeQuery();
+
+ commonj::sdo::DataObjectList& companies = root->getList("COMPANY");
+ bool failed = true;
+ for (unsigned int i = 0 ; i < companies.size() ; i++) {
+ failed = false;
+
+ if (companies[i]->getInt("ID") == removedCompanyID) {
+ cout << "Failed" << endl;
+ failed = true;
+ break;
+
+ }
+
+ }
+
+ if (!failed) {
+ cout << "OK" << endl;
+ }
+
+ delete conn;
+ delete das;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testCreateOperation() {
+ cout << "-------------testCreateOperation--------------" << endl;
+
+ Connection* conn = getConnection();
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testCreateOperation.xml");
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+ CommandPtr command = das->getCommand("get all tables");
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ commonj::sdo::DataObjectPtr company = root->createDataObject("COMPANY");
+ StringWrapper("hp").defineOnDataObject(company, "NAME");
+ company->setInt("ID", 40);
+
+ commonj::sdo::DataObjectPtr department = root->createDataObject("DEPARTMENT");
+ StringWrapper("DEPARTMENT40").defineOnDataObject(department, "NAME");
+ department->setInt("ID", 39);
+
+ company = root->getDataObject("COMPANY[1]");
+ long departmentCompanyID = company->getInt("ID");
+ company->getList("DEPARTMENT").append(department);
+
+ commonj::sdo::DataObjectPtr employee = root->createDataObject("EMPLOYEE");
+ StringWrapper("juan").defineOnDataObject(employee, "NAME");
+ employee->setInt("ID", 38);
+ department->getList("EMPLOYEE").append(employee);
+
+ das->applyChanges(root);
+
+ root = command->executeQuery();
+
+ commonj::sdo::DataObjectList& departments = root->getList("DEPARTMENT");
+ bool failed = true;
+ for (unsigned int i = 0 ; i < departments.size() ; i++) {
+
+ if (departments[i]->getInt("ID") == 39 && StringWrapper(departments[i], "NAME").getString() == "DEPARTMENT40"
+ && departments[i]->getDataObject("EMPLOYEE[1]")->getInt("ID") == 38
+ && StringWrapper(departments[i]->getDataObject("EMPLOYEE[1]"), "NAME").getString() == "juan") {
+
+ failed = false;
+ break;
+
+ }
+
+ }
+
+ if (!failed) {
+ failed = true;
+ commonj::sdo::DataObjectList& companies = root->getList("COMPANY");
+ for (unsigned int i = 0 ; i < companies.size() ; i++) {
+
+ if (companies[i]->getInt("ID") == departmentCompanyID) {
+ commonj::sdo::DataObjectList& companyDepartments = root->getList("DEPARTMENT");
+
+ for (unsigned int i = 0 ; i < companyDepartments.size() ; i++) {
+
+ if (companyDepartments[i]->getInt("ID") == 39) {
+ failed = false;
+ break;
+
+ }
+
+ }
+
+ break;
+
+ }
+
+ }
+
+ }
+
+ if (failed) {
+ cout << "Failed" << endl;
+ } else {
+ cout << "OK" << endl;
+ }
+
+ delete conn;
+ delete das;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+//
+
+void testMofidyOperation() {
+ cout << "-------------testMofidyOperation--------------" << endl;
+
+ Connection* conn = getConnection();
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testModifyOperation.xml");
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+ CommandPtr command = das->getCommand("get all tables");
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ commonj::sdo::DataObjectPtr company1 = root->getDataObject("COMPANY[1]");
+ commonj::sdo::DataObjectPtr company2 = root->getDataObject("COMPANY[2]");
+
+ StringWrapper("intel").defineOnDataObject(company1, "NAME");
+
+ commonj::sdo::DataObjectPtr department = root->createDataObject("DEPARTMENT");
+ StringWrapper("department40").defineOnDataObject(department, "NAME");
+ department->setInt("ID", 39);
+ company1->getList("DEPARTMENT").append(department);
+
+ department = company1->getList("DEPARTMENT").remove(0);//company->getDataObject("DEPARTMENT[1]");
+ company2->getList("DEPARTMENT").append(department);
+
+ commonj::sdo::DataObjectPtr employee = root->createDataObject("EMPLOYEE");
+ StringWrapper("albert").defineOnDataObject(employee, "NAME");
+ employee->setInt("ID", 37);
+ department->getList("EMPLOYEE").append(employee);
+
+ das->applyChanges(root);
+
+ commonj::sdo::DataObjectPtr dob;
+ bool failed = false;
+ try {
+ dob = root->getDataObject("COMPANY[NAME='intel']");
+ } catch (commonj::sdo::SDOPathNotFoundException& ex) {
+ cout << ex.getMessageText() << endl;
+ failed = true;
+
+ }
+
+ try {
+ dob = root->getDataObject("COMPANY[NAME='intel']/DEPARTMENT[NAME='department40'and ID=39]");
+ } catch (commonj::sdo::SDOPathNotFoundException& ex) {
+ cout << ex.getMessageText() << endl;
+ failed = true;
+
+ }
+
+ try {
+ dob = root->getDataObject("COMPANY[ID=2]/DEPARTMENT[ID=1]");
+ } catch (commonj::sdo::SDOPathNotFoundException& ex) {
+ cout << ex.getMessageText() << endl;
+ failed = true;
+
+ }
+
+ try {
+ dob = root->getDataObject("COMPANY[ID=2]/DEPARTMENT[ID=1]/EMPLOYEE[ID=37 and NAME='albert']");
+ } catch (commonj::sdo::SDOPathNotFoundException& ex) {
+ cout << ex.getMessageText() << endl;
+ failed = true;
+
+ }
+
+ if (failed) {
+ cout << "Failed" << endl;
+ } else {
+ cout << "OK" << endl;
+ }
+
+ delete conn;
+ delete das;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testOCC() {
+ cout << "-------------testOCC--------------" << endl;
+
+ Connection* conn = getConnection();
+ {
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testOCC1.xml");
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+ CommandPtr command = das->getCommand("get all companies");
+ commonj::sdo::DataObjectPtr root1 = command->executeQuery();
+ commonj::sdo::DataObjectPtr root2 = command->executeQuery();
+
+ commonj::sdo::DataObjectPtr company = root1->getDataObject("COMPANY[ID=1]");
+ StringWrapper("microsoft").defineOnDataObject(company, "NAME");
+ long oldOCCValue = company->getInt("OCC");
+
+ das->applyChanges(root1);
+
+ root1 = command->executeQuery();
+
+ cout << "OCC field incremented after changes applied: ";
+ if (root1->getDataObject("COMPANY[ID=1]")->getInt("OCC") > oldOCCValue) {
+ cout << "OK";
+ } else {
+ cout << "Failed";
+ }
+
+ cout << endl;
+
+ company = root2->getDataObject("COMPANY[ID=1]");
+ StringWrapper("dell").defineOnDataObject(company, "NAME");
+
+ cout << "DASOptimisticConcurrencyControlException thrown in attempt to modify a row with different occ field value: ";
+ try {
+ das->applyChanges(root2);
+ cout << "Failed";
+
+ } catch (DASOptimisticConcurrencyControlException&) {
+ cout << "OK";
+ }
+
+ cout << endl;
+ delete das;
+
+
+ }
+
+ {
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testOCC2.xml");
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+ CommandPtr command = das->getCommand("get all companies");
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ commonj::sdo::DataObjectPtr company = root->getDataObject("COMPANY[ID=1]");
+ StringWrapper("dell").defineOnDataObject(company, "NAME");
+ long oldOCCValue = company->getInt("OCC");
+
+ das->applyChanges(root);
+
+ root = command->executeQuery();
+
+ cout << "OCC field not incremented when it's not managed by DAS: ";
+ if (root->getDataObject("COMPANY[ID=1]")->getInt("OCC") == oldOCCValue) {
+ cout << "OK";
+ } else {
+ cout << "Failed";
+ }
+
+ cout << endl;
+ delete das;
+
+ }
+
+ delete conn;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testManyRelationship() {
+ cout << "-------------testManyRelationship--------------" << endl;
+
+ Connection* conn = getConnection();
+ {
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testManyRelationship1.xml");
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+ CommandPtr command = das->getCommand("get company 1 and its departments");
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ cout << "reference created as many on data graph = ";
+ if (root->getDataFactory()->getType(config.getURI(), "COMPANY").getProperty("DEPARTMENT").isMany()) {
+ cout << "OK" << endl;
+
+ cout << "all data objects added on reference list = ";
+ if (root->getDataObject("COMPANY[1]")->getList("DEPARTMENT").size() > 1) {
+ cout << "OK" << endl;
+ } else {
+ cout << "not added all data objects" << endl;
+ }
+
+ } else {
+ cout << "not created as many" << endl;
+ }
+
+ delete das;
+
+ }
+
+ {
+ ConfigImpl config((std::string) TEST_RESOURCE_PATH + "testManyRelationship2.xml");
+ DASImpl* das = (DASImpl*) DASImpl::getFACTORY().createDAS(config, *conn);
+ CommandPtr command = das->getCommand("get company 1 and its departments");
+ commonj::sdo::DataObjectPtr root = command->executeQuery();
+
+ cout << "reference created as not many on data graph = ";
+ if (!root->getDataFactory()->getType(config.getURI(), "COMPANY").getProperty("DEPARTMENT").isMany()) {
+ cout << "OK" << endl;
+
+ cout << "only one data object added on reference = ";
+ if (root->getDataObject("COMPANY[1]")->isNull("DEPARTMENT")) {
+ cout << "reference data object not set" << endl;
+ } else {
+ cout << "OK" << endl;
+ }
+
+ } else {
+ cout << "not created as many" << endl;
+ }
+
+ delete das;
+
+ }
+
+ delete conn;
+
+ cout << "---------------------------------" << endl << endl;
+
+}
+
+void testDataTypes() {
+ Connection* conn;
+
+ try {
+ std::string dsn = "PostgresTestcases2";
+ std::string user = "postgres";
+ std::string password = "tuscany";
+
+ conn = new Connection(dsn, user, password);
+
+ } catch (SQLException& ex) {
+ cout << "couldn't connect to the data source: " << ex.what() << endl;
+ system("PAUSE");
+ exit(1);
+
+ }
+
+ StatementPtr stmt = conn->createStatement();
+ ResultSetPtr rs = stmt->executeQuery("select * from DATA;");
+ const ResultSetMetaData& rsm = rs->getResultSetMetaData();
+ rs->next();
+ for (int i = 0 ; i < rsm.getColumnCount() ; i++) {
+ SQLSMALLINT type = rsm.getSQLType(i);
+ cout << rsm.getColumnName(i) << ": ";
+
+ switch (type) {
+ case SQL_INTEGER : cout << "SQL_INTEGER" << endl; break;
+ case SQL_DECIMAL : cout << "SQL_DECIMAL" << endl; break;
+ case SQL_CHAR : cout << "SQL_CHAR" << endl; break;
+ case SQL_NUMERIC : cout << "SQL_NUMERIC" << endl; break;
+ case SQL_SMALLINT : cout << "SQL_SMALLINT" << endl; break;
+ case SQL_FLOAT : cout << "SQL_FLOAT" << endl; break;
+ case SQL_REAL : cout << "SQL_REAL" << endl; break;
+ case SQL_DOUBLE : cout << "SQL_DOUBLE" << endl; break;
+ case SQL_DATETIME : cout << "SQL_DATETIME" << endl; break;
+ case SQL_VARCHAR : cout << "SQL_VARCHAR" << endl; break;
+ case SQL_TYPE_DATE : cout << "SQL_TYPE_DATE" << endl; break;
+ case SQL_TYPE_TIME : cout << "SQL_TYPE_TIME" << endl; break;
+ case SQL_TYPE_TIMESTAMP : cout << "SQL_TYPE_TIMESTAMP" << endl; break;
+ case SQL_UNKNOWN_TYPE : cout << "SQL_UNKNOWN_TYPE" << endl; break;
+ default : cout << "more than unknown = " << type << endl;
+
+ }
+
+ Table table("DATA");
+ const apache::das::rdb::Column& column = table.addColumn(rsm.getColumnName(i), type);
+
+ cout << "SQL value = " << ColumnData(column, rs).toSQL() << endl;
+
+ }
+
+ delete conn;
+
+}
+
+int main() {
+
+ //testDataTypes();
+
+ //try {
+ testMofidyOperation();
+ /*} catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }*/
+
+ try {
+ testDeleteOperation();
+ } catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }
+
+ try {
+ testCreateOperation();
+ } catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }
+
+ try {
+ testPointers();
+ } catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }
+
+ try {
+ testUniqueObjectByID();
+ } catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }
+
+ try {
+ testIncompleteCompositeRelationship();
+ } catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }
+
+ try {
+ testCompositeRelationship();
+ } catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }
+
+ try {
+ testCOCRelationship();
+ } catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }
+
+ try {
+ testManyRelationship();
+ } catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }
+
+ try {
+ testOCC();
+ } catch (...) {
+ cout << "FAILED (unexpected unknown exception)" << endl;
+ }
+
+ system("PAUSE");
+
+}