From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../sdo/runtime/core/test/.cdtbuild | 59 + .../sdo/runtime/core/test/.cdtproject | 15 + .../sdo/runtime/core/test/.project | 19 + .../org.eclipse.cdt.managedbuilder.core.prefs | 9 + .../sdo/runtime/core/test/47293Catalog.xml | 2 + .../sdo/runtime/core/test/47293Catalog.xsd | 15 + .../sdo/runtime/core/test/47293Customer.xsd | 31 + .../sdo/runtime/core/test/47293Order.xsd | 47 + .../sdo/runtime/core/test/Catalog.xsd | 15 + .../sdo/runtime/core/test/Customer.xsd | 28 + .../sdo/runtime/core/test/Makefile.am | 11 + .../sdo/runtime/core/test/Order.xsd | 39 + .../sdo/runtime/core/test/StockQuoteService.wsdl | 157 + .../sdo/runtime/core/test/axis.xsd | 20 + .../sdo/runtime/core/test/b46617b.xml | 8 + .../sdo/runtime/core/test/b46617b.xsd | 54 + .../sdo/runtime/core/test/b46693.xsd | 157 + .../sdo/runtime/core/test/company.xsd | 30 + .../runtime/core/test/company_with_nillable_SN.xml | 11 + .../runtime/core/test/company_with_nillable_SN.xsd | 29 + .../sdo/runtime/core/test/companyabs.xsd | 44 + .../sdo/runtime/core/test/companyref.xsd | 47 + .../sdo/runtime/core/test/companysubs.xsd | 44 + .../sdo/runtime/core/test/doctest.xml | 8 + .../sdo/runtime/core/test/doctest.xsd | 28 + .../sdo/runtime/core/test/error1.xml | 11 + .../sdo/runtime/core/test/error1.xsd | 29 + .../sdo/runtime/core/test/g3.xsd | 21 + .../sdo/runtime/core/test/graham1.xsd | 21 + .../sdo/runtime/core/test/graham2.xsd | 20 + .../sdo/runtime/core/test/graham3.xsd | 22 + .../sdo/runtime/core/test/include.xsd | 14 + .../sdo/runtime/core/test/include1.xsd | 18 + .../sdo/runtime/core/test/include2.xsd | 17 + .../sdo/runtime/core/test/includeother3.xsd | 14 + .../sdo/runtime/core/test/many.xml | 14 + .../sdo/runtime/core/test/many.xsd | 1 + .../sdo/runtime/core/test/my-core.xsd | 21 + .../core/test/my-implementation-local-java.xsd | 24 + .../sdo/runtime/core/test/my.xsd | 11 + .../sdo/runtime/core/test/openloadNS.xml | 13 + .../sdo/runtime/core/test/openloadNS.xsd | 33 + .../sdo/runtime/core/test/openloadNS2.xml | 13 + .../sdo/runtime/core/test/openloadNS2.xsd | 8 + .../sdo/runtime/core/test/partial.xml | 14 + .../sdo/runtime/core/test/sca-binding-sca.xsd | 22 + .../runtime/core/test/sca-binding-webservice.xsd | 21 + .../sdo/runtime/core/test/sca-binding-ws.xsd | 22 + .../sdo/runtime/core/test/sca-core.xsd | 214 ++ .../runtime/core/test/sca-implementation-dll.xsd | 22 + .../runtime/core/test/sca-implementation-java.xsd | 22 + .../core/test/sca-implementation-local-java.xsd | 24 + .../sdo/runtime/core/test/sca-interface-cpp.xsd | 49 + .../sdo/runtime/core/test/sca-interface-java.xsd | 24 + .../sdo/runtime/core/test/sca-interface-wsdl.xsd | 23 + .../sdo/runtime/core/test/sca-property-java.xsd | 23 + .../sdo/runtime/core/test/sca-property-xsd.xsd | 22 + .../sdo/runtime/core/test/sca.xsd | 22 + .../sdo/runtime/core/test/sdotest.cpp | 4028 ++++++++++++++++++++ .../sdo/runtime/core/test/sdotest.h | 123 + .../sdo/runtime/core/test/sdotest2.cpp | 3937 +++++++++++++++++++ .../sdo/runtime/core/test/t2/include3.xsd | 14 + .../sdo/runtime/core/test/t2/includeother.xsd | 14 + .../sdo/runtime/core/test/t2/includeother1.xsd | 18 + .../sdo/runtime/core/test/t2/includeother2.xsd | 17 + .../sdo/runtime/core/test/testopen3.xml | 1 + 66 files changed, 9928 insertions(+) create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/.cdtbuild create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/.cdtproject create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/.project create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/.settings/org.eclipse.cdt.managedbuilder.core.prefs create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/47293Catalog.xml create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/47293Catalog.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/47293Customer.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/47293Order.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/Catalog.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/Customer.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/Makefile.am create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/Order.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/StockQuoteService.wsdl create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/axis.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/b46617b.xml create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/b46617b.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/b46693.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/company.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/company_with_nillable_SN.xml create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/company_with_nillable_SN.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/companyabs.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/companyref.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/companysubs.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/doctest.xml create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/doctest.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/error1.xml create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/error1.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/g3.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/graham1.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/graham2.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/graham3.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/include.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/include1.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/include2.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/includeother3.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/many.xml create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/many.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/my-core.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/my-implementation-local-java.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/my.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS.xml create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS2.xml create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS2.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/partial.xml create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-sca.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-webservice.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-ws.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-core.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-dll.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-java.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-local-java.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-cpp.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-java.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-wsdl.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-property-java.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca-property-xsd.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sca.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest.cpp create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest.h create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest2.cpp create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/t2/include3.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother1.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother2.xsd create mode 100644 tags/cpp-stable-20060304/sdo/runtime/core/test/testopen3.xml (limited to 'tags/cpp-stable-20060304/sdo/runtime/core/test') diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/.cdtbuild b/tags/cpp-stable-20060304/sdo/runtime/core/test/.cdtbuild new file mode 100644 index 0000000000..17ebd43324 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/.cdtbuild @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/.cdtproject b/tags/cpp-stable-20060304/sdo/runtime/core/test/.cdtproject new file mode 100644 index 0000000000..48a12e6664 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/.cdtproject @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/.project b/tags/cpp-stable-20060304/sdo/runtime/core/test/.project new file mode 100644 index 0000000000..32920ef4cf --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/.project @@ -0,0 +1,19 @@ + + + tuscany_sdo_test + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.ccnature + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/tags/cpp-stable-20060304/sdo/runtime/core/test/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 0000000000..0c77f0af0f --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,9 @@ +#Wed Feb 15 16:37:24 GMT 2006 +eclipse.preferences.version=1 +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1698024418=\n\n\n\n\n +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1720042110=\n\n\n\n\n +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1698024418=\n\n\n\n +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1720042110=\n\n\n\n +environment/project=\n\n +environment/project/cdt.managedbuild.config.gnu.exe.debug.1698024418=\n\n\n\n +environment/project/cdt.managedbuild.config.gnu.exe.release.1720042110=\n\n\n\n diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Catalog.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Catalog.xml new file mode 100644 index 0000000000..66b2d3dbca --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Catalog.xml @@ -0,0 +1,2 @@ + +1A Partridge in a Pear Tree1.99012Turtle Doves2.99013French Hens3.99014Calling Birds4.99015Golden Rings5.99016Geese a-laying6.99017Swans a-swimming7.99018Maids a-milking8.99019Ladies dancing9.990110Lords a-leaping10.990111Pipers piping11.990112Drummers drumming12.9901 diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Catalog.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Catalog.xsd new file mode 100644 index 0000000000..53fb9bdc0c --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Catalog.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Customer.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Customer.xsd new file mode 100644 index 0000000000..9f09b17244 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Customer.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Order.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Order.xsd new file mode 100644 index 0000000000..59d48398a8 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/47293Order.xsd @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/Catalog.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/Catalog.xsd new file mode 100644 index 0000000000..6eebebdd70 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/Catalog.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/Customer.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/Customer.xsd new file mode 100644 index 0000000000..b3cd832bce --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/Customer.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/Makefile.am b/tags/cpp-stable-20060304/sdo/runtime/core/test/Makefile.am new file mode 100644 index 0000000000..42e672a25e --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/Makefile.am @@ -0,0 +1,11 @@ +prgbindir=$(prefix)/bin/test +prgbin_PROGRAMS = tuscany_sdo_test +SUBDIRS = +AM_CPPFLAGS = $(CPPFLAGS) +tuscany_sdo_test_SOURCES = sdotest.cpp sdotest2.cpp + +tuscany_sdo_test_LDADD = -ltuscany_sdo \ + -L$(top_builddir)/runtime/core/src/commonj/sdo -lxml2 -lstdc++ + +INCLUDES = -I$(top_builddir)/runtime/core/test \ + -I$(top_builddir)/runtime/core/src diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/Order.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/Order.xsd new file mode 100644 index 0000000000..1ece31ac0b --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/Order.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/StockQuoteService.wsdl b/tags/cpp-stable-20060304/sdo/runtime/core/test/StockQuoteService.wsdl new file mode 100644 index 0000000000..4917cde583 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/StockQuoteService.wsdl @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/axis.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/axis.xsd new file mode 100644 index 0000000000..eca2f0cf22 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/axis.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/b46617b.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/b46617b.xml new file mode 100644 index 0000000000..823ef80944 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/b46617b.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/b46617b.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/b46617b.xsd new file mode 100644 index 0000000000..7f8e155406 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/b46617b.xsd @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/b46693.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/b46693.xsd new file mode 100644 index 0000000000..11eb2e964a --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/b46693.xsd @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/company.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/company.xsd new file mode 100644 index 0000000000..8c5ea4a7c1 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/company.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/company_with_nillable_SN.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/company_with_nillable_SN.xml new file mode 100644 index 0000000000..cc6e93e4bb --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/company_with_nillable_SN.xml @@ -0,0 +1,11 @@ + + + + + +Jane Doe + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/company_with_nillable_SN.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/company_with_nillable_SN.xsd new file mode 100644 index 0000000000..3738da590f --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/company_with_nillable_SN.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/companyabs.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/companyabs.xsd new file mode 100644 index 0000000000..bc47867904 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/companyabs.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/companyref.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/companyref.xsd new file mode 100644 index 0000000000..0d4b1240c0 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/companyref.xsd @@ -0,0 +1,47 @@ + + + elementFormDefault="qualified"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/companysubs.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/companysubs.xsd new file mode 100644 index 0000000000..2ffb626e90 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/companysubs.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/doctest.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/doctest.xml new file mode 100644 index 0000000000..1397087013 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/doctest.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/doctest.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/doctest.xsd new file mode 100644 index 0000000000..ca3583f6df --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/doctest.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/error1.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/error1.xml new file mode 100644 index 0000000000..cc6e93e4bb --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/error1.xml @@ -0,0 +1,11 @@ + + + + + +Jane Doe + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/error1.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/error1.xsd new file mode 100644 index 0000000000..6cc581de35 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/error1.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/g3.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/g3.xsd new file mode 100644 index 0000000000..77a586f516 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/g3.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/graham1.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/graham1.xsd new file mode 100644 index 0000000000..c68f1d5b68 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/graham1.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/graham2.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/graham2.xsd new file mode 100644 index 0000000000..6b4e0dcbb1 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/graham2.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/graham3.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/graham3.xsd new file mode 100644 index 0000000000..61c72577d0 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/graham3.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/include.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/include.xsd new file mode 100644 index 0000000000..67f3cb5501 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/include.xsd @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/include1.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/include1.xsd new file mode 100644 index 0000000000..98705f6418 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/include1.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/include2.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/include2.xsd new file mode 100644 index 0000000000..66dfca00a8 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/include2.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/includeother3.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/includeother3.xsd new file mode 100644 index 0000000000..a74c94e318 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/includeother3.xsd @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/many.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/many.xml new file mode 100644 index 0000000000..72a073cd11 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/many.xml @@ -0,0 +1,14 @@ + + + +#/departments.0/employees.0 + + + +Three member +Open bytes +List is complete + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/many.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/many.xsd new file mode 100644 index 0000000000..a40b21a0da --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/many.xsd @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/my-core.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/my-core.xsd new file mode 100644 index 0000000000..2d1a84f9fb --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/my-core.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/my-implementation-local-java.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/my-implementation-local-java.xsd new file mode 100644 index 0000000000..7501eafd25 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/my-implementation-local-java.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/my.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/my.xsd new file mode 100644 index 0000000000..da66b397bf --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/my.xsd @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS.xml new file mode 100644 index 0000000000..9af06a8b02 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS.xml @@ -0,0 +1,13 @@ + + + +#/departments.0/employees.0 + + + +45 + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS.xsd new file mode 100644 index 0000000000..98a12eb8c6 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS2.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS2.xml new file mode 100644 index 0000000000..100ff60176 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS2.xml @@ -0,0 +1,13 @@ + + + +#/departments.0/employees.0 + + + +45 + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS2.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS2.xsd new file mode 100644 index 0000000000..f62ea912b7 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/openloadNS2.xsd @@ -0,0 +1,8 @@ + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/partial.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/partial.xml new file mode 100644 index 0000000000..49563ecbeb --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/partial.xml @@ -0,0 +1,14 @@ + + + +#/departments.0/employees.0 + + + +45 + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-sca.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-sca.xsd new file mode 100644 index 0000000000..2097cff917 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-sca.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-webservice.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-webservice.xsd new file mode 100644 index 0000000000..39196c48f8 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-webservice.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-ws.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-ws.xsd new file mode 100644 index 0000000000..fd528710c1 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-binding-ws.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-core.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-core.xsd new file mode 100644 index 0000000000..b3c90210ed --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-core.xsd @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-dll.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-dll.xsd new file mode 100644 index 0000000000..da4392b9e7 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-dll.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-java.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-java.xsd new file mode 100644 index 0000000000..5adb548ad4 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-java.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-local-java.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-local-java.xsd new file mode 100644 index 0000000000..13286d728e --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-implementation-local-java.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-cpp.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-cpp.xsd new file mode 100644 index 0000000000..8ea5b09cd0 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-cpp.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-java.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-java.xsd new file mode 100644 index 0000000000..160d84f74a --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-java.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-wsdl.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-wsdl.xsd new file mode 100644 index 0000000000..5c84b9a674 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-interface-wsdl.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-property-java.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-property-java.xsd new file mode 100644 index 0000000000..21acbeaab6 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-property-java.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-property-xsd.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-property-xsd.xsd new file mode 100644 index 0000000000..24b9d00e07 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca-property-xsd.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sca.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca.xsd new file mode 100644 index 0000000000..a0d61568e2 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sca.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest.cpp b/tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest.cpp new file mode 100644 index 0000000000..d5e0c0d5c3 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest.cpp @@ -0,0 +1,4028 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + */ + +/* $Rev$ $Date: 2005/12/22 16:54:31 $ */ + +#include + +#pragma warning(disable:4786) + +#include +using namespace std; + +// #include "TypeImpl.h" + +#include "sdotest.h" + + + +using namespace commonj::sdo; + +// very basic print of a data graph + +typedef struct { + //zend_object zo; /* The standard zend_object */ + DataObjectPtr dop; /* The Hydra DataObject */ + //zend_object *df; /* The Data Factory */ +} sdo_doimpl_object; + + +void sdotest::rcptest() +{ + DataFactoryPtr mdg; + sdo_doimpl_object* ptr; + + cout << "RCPtest" << endl; + + mdg = DataFactory::getDataFactory(); + mdg = 0; + mdg = DataFactory::getDataFactory(); + mdg = NULL; + mdg = DataFactory::getDataFactory(); + + cout << "RCPtest 2" << endl; + + mdg->addType("myspace","Root"); + + mdg->addType("myspace","Company"); + + mdg->addPropertyToType("myspace","Company","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Company","id", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Root","companies", + "myspace","Company", true, false, true); + + const Type& tcc = mdg->getType("myspace","Root"); + + + ptr = new sdo_doimpl_object; + + + ptr->dop = mdg->create((Type&)tcc); + + + //delete ptr->dop; + + + ptr->dop = 0; // null ; + +} + + + +void printDataStructure(DataFactory* dd) +{ + TypeList tt = dd->getTypes(); + cout << "Printing Types\n"; + for (int i = 0; i < tt.size(); ++i) + { + cout << "Type " << tt[i].getName() << "\n"; + PropertyList pl = tt[i].getProperties(); + for (int j = 0; j < pl.size() ; j++) + { + cout << "Has Property " << pl[j].getName() << + " of type "; + cout << pl[j].getType().getName() << "\n"; + } + } +} + + +void sdotest::changesummarytest() +{ + scenario5(); + scenario1(); + scenario2(); + scenario3(); + scenario4(); + +} + + + + +void sdotest::printOldValues(ChangeSummaryPtr cs, DataObjectPtr dol) +{ + cout << "===== Old Property Values Begin=====================================" << endl; + SettingList& sl = cs->getOldValues(dol); + if (sl.size() == 0) + { + cout << "No Settings found" << endl; + } + else + { + for (int j=0;j< sl.size(); j++) + { + cout << "Property " << sl[j].getProperty().getName(); + // this could be a many-valued property, and could be one which is + // a data object or a data type... + if (sl[j].getProperty().isMany()) + { + cout << "[" << sl[j].getIndex() << "]" ; + } + if (!sl[j].isSet()) + { + cout << "(UNSET)"; + } + if (sl[j].isNull()) + { + cout << "(ISNULL)"; + } + + cout << " of type " ; + switch (sl[j].getProperty().getTypeEnum()) + { + case Type::BooleanType: + cout << "Boolean:" << sl[j].getBooleanValue(); + break; + case Type::ByteType: + cout << "Byte:" << sl[j].getByteValue(); + break; + case Type::CharacterType: + cout << "Character:" << sl[j].getCharacterValue(); + break; + case Type::IntegerType: + cout << "Integer:" << sl[j].getIntegerValue(); + break; + case Type::ShortType: + cout << "Short:" << sl[j].getShortValue(); + break; + case Type::DoubleType: + cout << "Double:" << sl[j].getDoubleValue(); + break; + case Type::FloatType: + cout << "Float:" << sl[j].getFloatValue(); + break; + case Type::LongType: + cout << "Long:" << sl[j].getIntegerValue(); + break; + case Type::DateType: + cout << "Date:" << sl[j].getDateValue().getTime(); + break; + case Type::BigDecimalType: + case Type::BigIntegerType: + case Type::StringType: + case Type::UriType: + cout << "String:" << sl[j].getCStringValue(); + break; + case Type::BytesType: + cout << "Bytes:" << sl[j].getCStringValue(); + break; + case Type::OtherTypes: + case Type::DataObjectType: + case Type::ChangeSummaryType: + { + cout << "DataObject " ; + DataObjectPtr dob = sl[j].getDataObjectValue(); + if (!dob) + { + cout << " - object null or unset" ; + } + else + { + DataObjectPtr mydo = sl[j].getDataObjectValue(); + if (cs->isDeleted(mydo)) + { + cout << " - object deleted " << endl; + printOldValues(cs,mydo); + } + else + { + cout << " object still exists " << endl; + //printDataObject(mydo); + } + } + } + break; + default: + { + cout << "Unknown object type"; + } + break; + } + cout << endl; + } + } + cout << "===== Old Property Values End ======================================" << endl; +} + + +void sdotest::printValue(DataObjectPtr dp, const Property& p) +{ + switch (p.getTypeEnum()) + { + case Type::BooleanType: + cout << "boolean:" << dp->getBoolean(p); + break; + case Type::ByteType: + cout << "Byte:" << dp->getByte(p); + break; + case Type::CharacterType: + cout << "character:" << dp->getCharacter(p); + break; + case Type::IntegerType: + cout << "integer:" << dp->getInteger(p); + break; + case Type::ShortType: + cout << "short:" << dp->getShort(p); + break; + case Type::DoubleType: + cout << "double:" << dp->getDouble(p); + break; + case Type::FloatType: + cout << "float:" << dp->getFloat(p); + break; + case Type::LongType: + cout << "long:" << "cheat" << dp->getInteger(p); + break; + case Type::DateType: + cout << "date:" << dp->getDate(p).getTime(); + break; + case Type::BigDecimalType: + case Type::BigIntegerType: + case Type::StringType: + case Type::UriType: + cout << "string:" << dp->getCString(p); + break; + case Type::BytesType: + cout << "bytes:" << dp->getCString(p); + break; + case Type::DataObjectType: + { + cout << "dataObject" ; + DataObjectPtr dob = dp->getDataObject(p); + if (!dob) + { + cout << " - null or unset" ; + } + else + { + cout << endl; + printDataObject(dob); + } + } + break; + case Type::OtherTypes: + case Type::ChangeSummaryType: + default: + { + cout << "Unknown object type"; + } + break; + } + cout << endl; +} + +void sdotest::printList(DataObjectPtr dp, const Property& p) +{ + DataObjectList& dobl = dp->getList(p); + cout << " list "; + + if (dobl.size() ==0) { + cout << "(empty)" << endl; + return; + } + + for (int i=0;igetInstanceProperties(); + + for (int j=0;j< pl.size(); j++) + { + cout << "Property " << pl[j].getName() << " of type "; + // this could be a many-valued property, and could be one which is + // a data object or a data type... + if (pl[j].isMany()) + { + printList(dol,pl[j]); + } + else { + printValue(dol,pl[j]); + } + } + cout << "End DataObject Current Values ======================================" << endl; +} + + +void sdotest::dumpchangesummary(ChangeSummaryPtr cs) +{ + ChangedDataObjectList& cdol = cs->getChangedDataObjects(); + + // the changed data object list contains only the objects whose properties have + // been changed. + // a changed and subsequently deleted object will not appear, but necessarily its + // container will appear, so we can rebuild it. + + for (int i=0;i< cdol.size();i++) + { + if (cs->isCreated(cdol[i])) + { + cout << "Created object in changed list: " << cdol[i] << endl; + // So its in the created list, it must exist in the tree... + cout << "The object is " << cdol[i]->getType().getURI() + << "#" << cdol[i]->getType().getName() << endl; + } + if (cs->isModified(cdol[i])) + { + cout <<"===== Modified Object Starts " << cdol[i] << " ==============================" <objectToXPath() << endl; + // end hack + + if (cs->isDeleted(cdol[i])) + { + cout << "PROBLEM: DELETED OBJECT IN CHANGED LIST: " << cdol[i] << endl; + // As the item is in the deleted list - its still present.. + cout << "The type is " << cdol[i]->getType().getURI() + << "#" << cdol[i]->getType().getName() << endl; + } + else { + cout << "The modified objects type is " << cdol[i]->getType().getURI() + << "#" << cdol[i]->getType().getName() << endl; + + printOldValues(cs, cdol[i]); + //printDataObject(cdol[i]); + } + cout <<"=====Modified Object Ends " << cdol[i] << " =================================" <isDeleted(cdol[i])) + { + cout <<"=====Deleted Object Starts " << cdol[i] << " =================================" <addType("myspace","RootOfAllEvil"); + mdg->addPropertyToType("myspace","RootOfAllEvil","whatever", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addType("myspace","Company"); + + mdg->addPropertyToType("myspace","Company","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Company","id", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","RootOfAllEvil","companies", + "myspace","Company", true, false, true); + + const Type& tcc = mdg->getType("myspace","RootOfAllEvil"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + ChangeSummaryPtr cs = dor->getChangeSummary(); + cs->beginLogging(); + + DataObjectPtr com = dor->createDataObject("companies"); + com->setCString("name","acme"); + com->setCString("id","123"); + + dumpchangesummary(cs); + + cs->endLogging(); + + //expect cdo: + //root - isChanged + //comp - isCreated + + +} + + +void sdotest::testui() +{ + + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("companyNS","MainType"); + + + /* Now add the properties to the types...*/ + + + const Type& tmain = mdg->getType("companyNS","MainType"); + const Type& tshort = mdg->getType("commonj.sdo","Short"); + const Type& tint = mdg->getType("commonj.sdo","Integer"); + + + mdg->addPropertyToType(tmain,"short",tshort,true); + mdg->addPropertyToType(tmain,"int",tint, true); + + DataObjectPtr main = mdg->create((Type&)tmain); + + DataObjectList& dol1 = main->getList("short"); + DataObjectList& dol2 = main->getList("int"); + DataObjectList& dol3 = main->getList((unsigned int)0); + DataObjectList& dol4 = main->getList(1); + } + + catch (SDORuntimeException e) + { + cout << "Unsigned int failed" << endl << e << endl; + } +} + + + +void sdotest::scenario5() +{ + // scenario 1 + // create root type - root has cs + // create a company type. and containment ref from root, many valued. + // props on comp id, name both strings single v. + // create root object + // begin logging + // create a company obj. name=acme id=123 + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","RootOfAllEvil"); + mdg->addPropertyToType("myspace","RootOfAllEvil","whatever", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addType("myspace","Company"); + mdg->addType("myspace","Employee"); + mdg->addPropertyToType("myspace","Employee","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","Company","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Company","id", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Company","eotm", + "myspace","Employee", false, false, false); + + mdg->addPropertyToType("myspace","Company","employees", + "myspace","Employee", true, false, true); + + mdg->addPropertyToType("myspace","RootOfAllEvil","companies", + "myspace","Company", true, false, true); + + const Type& tcc = mdg->getType("myspace","RootOfAllEvil"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + ChangeSummaryPtr cs = dor->getChangeSummary(); + + DataObjectPtr com = dor->createDataObject("companies"); + com->setCString("name","acme"); + com->setCString("id","123"); + + const Type& te = mdg->getType("myspace","Employee"); + + DataObjectPtr emp = mdg->create(te); + emp->setCString("name", "Mr Expendible"); + + DataObjectList& emps = com->getList("employees"); + + emps.append(emp); + + com->setDataObject("eotm",emp); + + cs->beginLogging(); + + com->unset("eotm"); + + dumpchangesummary(cs); + + cs->endLogging(); + + //expect com to have change record, nothing for eotm: + +} + +void sdotest::scenario2() +{ + // create root type - root has cs + // create a company type. and containment ref from root, many valued. + // 2 props on comp id, name both strings single v. + // create root object + // create a company obj. name=acme id=123 + // begin logging() + // name="megacorp" + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","RootOfAllEvil"); + mdg->addPropertyToType("myspace","RootOfAllEvil","whatever", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addType("myspace","Company"); + + mdg->addPropertyToType("myspace","Company","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Company","id", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","RootOfAllEvil","companies", + "myspace","Company", true, false, true); + + const Type& tcc = mdg->getType("myspace","RootOfAllEvil"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + DataObjectPtr com = dor->createDataObject("companies"); + com->setCString("name","acme"); + com->setCString("id","123"); + + ChangeSummaryPtr cs = dor->getChangeSummary(); + cs->beginLogging(); + + com->setCString("name","megacorp"); + + dumpchangesummary(cs); + + cs->endLogging(); + + //expect cdo: + //root- nothing + // company- isChanged + //setting prop=name, value="acme" + +} + +void sdotest::scenario3() +{ + + //create root type - root has cs + //create a company type. and containment ref from root, many valued. + //2 props on comp id, name both strings single v. + //create root object + //create a company obj. name=acme id=123 + //begin logging() + //delete company + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","RootOfAllEvil"); + mdg->addPropertyToType("myspace","RootOfAllEvil","whatever", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addType("myspace","Company"); + + mdg->addPropertyToType("myspace","Company","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Company","id", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","RootOfAllEvil","companies", + "myspace","Company", true, false, true); + + const Type& tcc = mdg->getType("myspace","RootOfAllEvil"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + DataObjectPtr com = dor->createDataObject("companies"); + com->setCString("name","acme"); + com->setCString("id","123"); + + ChangeSummaryPtr cs = dor->getChangeSummary(); + cs->beginLogging(); + + com->detach(); + + dumpchangesummary(cs); + + cs->endLogging(); + + // expect cdo + // root - changed + // company - deleted + +} + +void sdotest::scenario4() +{ + //create root type - root has cs + //create a company type. and containment ref from root, many valued. + //create a dept type. and containment ref from comp, many valued. + //create a emp type. and containment ref from dept, many valued. + // give name and id properties to comp,dept, emp + + //create root object + //create a company obj. name=acme id=123 + //create a company obj. name=megacorp id=124 + // give each company 2 depts + // give each dept 2 employees + + // begin logging() + // add new employee to first dept of acme + // delete employee from second dept of acme + + // change name of first employee of first dept megacorp. + // delete first dept of megacorp. + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","RootOfAllEvil"); + mdg->addPropertyToType("myspace","RootOfAllEvil","whatever", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addType("myspace","Company"); + mdg->addPropertyToType("myspace","Company","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Company","id", + "commonj.sdo","String", false, false, false); + + mdg->addType("myspace","Department"); + mdg->addPropertyToType("myspace","Department","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Department","id", + "commonj.sdo","String", false, false, false); + + mdg->addType("myspace","Employee"); + mdg->addPropertyToType("myspace","Employee","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Employee","id", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","RootOfAllEvil","companies", + "myspace","Company", true, false, true); + + mdg->addPropertyToType("myspace","Company","departments", + "myspace","Department", true, false, true); + + mdg->addPropertyToType("myspace","Department","employees", + "myspace","Employee", true, false, true); + + const Type& tcc = mdg->getType("myspace","RootOfAllEvil"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + DataObjectPtr com = dor->createDataObject("companies"); + com->setCString("name","acme"); + com->setCString("id","123"); + + DataObjectPtr dep = com->createDataObject("departments"); + dep->setCString("name","widgets"); + dep->setCString("id","1"); + + DataObjectPtr emp = dep->createDataObject("employees"); + emp->setCString("name","John O'Watt"); + emp->setCString("id","1"); + + emp = dep->createDataObject("employees"); + emp->setCString("name","Ida Know"); + emp->setCString("id","2"); + + + dep = com->createDataObject("departments"); + dep->setCString("name","gadgets"); + dep->setCString("id","2"); + + emp = dep->createDataObject("employees"); + emp->setCString("name","Ed Memoire"); + emp->setCString("id","1"); + + emp = dep->createDataObject("employees"); + emp->setCString("name","Phyllis Tyne"); + emp->setCString("id","2"); + + + DataObjectPtr com2 = dor->createDataObject("companies"); + com2->setCString("name","megacorp"); + com2->setCString("id","124"); + + dep = com2->createDataObject("departments"); + dep->setCString("name","windows"); + dep->setCString("id","1"); + + emp = dep->createDataObject("employees"); + emp->setCString("name","Ivor Payne"); + emp->setCString("id","1"); + + emp = dep->createDataObject("employees"); + emp->setCString("name","Colin Poisson"); + emp->setCString("id","2"); + + dep = com2->createDataObject("departments"); + dep->setCString("name","portholes"); + dep->setCString("id","2"); + + emp = dep->createDataObject("employees"); + emp->setCString("name","Graham Angreeneggs"); + emp->setCString("id","1"); + + emp = dep->createDataObject("employees"); + emp->setCString("name","Helen Highwater"); + emp->setCString("id","2"); + + cout << "-----------------------------------" << endl; + cout << com->getCString("name") << endl; + DataObjectList& deps = com->getList("departments"); + cout << "Depts[0]:" << deps[0]->getCString("name") << endl; + DataObjectList& emps = deps[0]->getList("employees"); + cout << "Emps[0]:" << emps[0]->getCString("name") << endl; + cout << "Emps[1]:" << emps[1]->getCString("name") << endl; + cout << "Depts[1]:" << deps[1]->getCString("name") << endl; + DataObjectList& emps2 = deps[1]->getList("employees"); + cout << "Emps[0]:" << emps2[0]->getCString("name") << endl; + cout << "Emps[1]:" << emps2[1]->getCString("name") << endl; + cout << "-----------------------------------" << endl; + cout << com2->getCString("name") << endl; + DataObjectList& deps2 = com2->getList("departments"); + cout << "Depts[0]:" << deps2[0]->getCString("name") << endl; + DataObjectList& emps3 = deps2[0]->getList("employees"); + cout << "Emps[0]:" << emps3[0]->getCString("name") << endl; + cout << "Emps[1]:" << emps3[1]->getCString("name") << endl; + cout << "Depts[1]:" << deps2[1]->getCString("name") << endl; + DataObjectList& emps4 = deps2[1]->getList("employees"); + cout << "Emps[0]:" << emps4[0]->getCString("name") << endl; + cout << "Emps[1]:" << emps4[1]->getCString("name") << endl; + cout << "-----------------------------------" << endl; + + // should be able to get the change summary property, but it + // should be zero. + // should be able to find out if the type is a change summary type + + if (dor->getType().isChangeSummaryType()) + { + cout << "The root object has a change summary" << endl; + } + else { + cout << "The root object DOESNT HAVE a change summary !!!" << endl; + } + + try { + DataObjectPtr csptr = dor->getDataObject("whatever"); + + if (!csptr) { + cout << "CS property was zero - should be invisible!!!!" << endl; + } + else { + cout << "CS property was NOT zero !!" << endl; + } + } + catch (SDOPropertyNotFoundException e) + { + cout << "No property shows - this is correct" << endl; + } + + + if (com->getType().isChangeSummaryType()) + { + cout << "The company object has a change summary !!!!" << endl; + } + else { + cout << "The company object is OK" << endl; + } + + + + + ChangeSummaryPtr cs = dor->getChangeSummary(); + cs->beginLogging(); + + DataObjectList& depsout = com->getList("departments"); + + emp = depsout[0]->createDataObject("employees"); + emp->setCString("name","Irma Newby"); + emp->setCString("id","3"); + + DataObjectList& empsout = depsout[1]->getList("employees"); + empsout.remove(0); + + DataObjectList& depsout2 = com2->getList("departments"); + DataObjectList& empsout2 = depsout2[0]->getList("employees"); + empsout2[0]->setCString("name","Ive had my name changed"); + + depsout2[0]->detach(); + + dumpchangesummary(cs); + + cs->endLogging(); + + // expect: + // company acme, department widgets changed. + // employee 3 of dept widgets of acme (Irma Newby) created. + // employee 1 of dept gadgets or acme deleted + // no change record for employee 1 of company megacorp, dept windows + // deletion for dept windows of megacorp + // deletion for emp 1 of windows - showing original value for name (Ivor Payne) + // deletion for emp 2 of windows. + + +} + +void sdotest::seqtest() +{ + DataFactoryPtr mdg = DataFactory::getDataFactory(); + // company is sequenced. + mdg->addType("myspace","Company",true,false); + + mdg->addType("myspace","Department",true,false); + // string is many + + mdg->addPropertyToType("myspace","Company","string","commonj.sdo","String", + true); + + mdg->addPropertyToType("myspace","Company","departments","myspace","Department", + true); + + mdg->addPropertyToType("myspace","Department","name","commonj.sdo","String"); + + + const Type& tcc = mdg->getType("myspace","Company"); + + DataObjectPtr dor = mdg->create(tcc); + const Property& sprop = dor->getType().getProperty("string"); + SequencePtr sptr = dor->getSequence(); + + printseq(sptr); + + sptr->addCString(sprop,"I am Item 1 of string"); + + printseq(sptr); + + sptr->addText("I am the first free text"); + + printseq(sptr); + + sptr->addCString(sprop,"I am Item 2 of string"); + + printseq(sptr); + + sptr->setCStringValue(1,"I am free text which has been modified"); + + DataObjectPtr dep1 = dor->createDataObject("departments"); + + printseq(sptr); + + dep1->setCString("name","department1"); + + printseq(sptr); + + DataObjectList& dol = dor->getList("departments"); + + const Type& tcd = mdg->getType("myspace","Department"); + DataObjectPtr dep2 = mdg->create(tcd); + + printseq(sptr); + + dep2->setCString("name","department2"); + + printseq(sptr); + + dol.append(dep2); + + printseq(sptr); + +} + +void sdotest::printseq(SequencePtr sptr) +{ + cout << "======================================" <size();i++) + { + try { + if (!sptr->isText(i)) + { + const Property& prp = sptr->getProperty(i); + if (!strcmp(prp.getType().getName(),"Department")) + { + DataObjectPtr pdep = sptr->getDataObjectValue(i); + if (pdep != 0) + { + const char * cs = pdep->getCString("name"); + if (cs != 0) + { + cout << cs << endl; + } + else + { + cout << " is empty " << endl; + } + } + } + else + { + const char* stx = sptr->getCStringValue(i); + if (stx != 0) + { + cout << stx << endl; + } + else + { + cout << " is empty " << endl; + } + } + } + else + { + const char* st = sptr->getCStringValue(i); + if (st != 0) + { + cout << st << endl; + } + else + { + cout << " is empty " << endl; + } + } + } + catch (SDOPropertyNotSetException) + { + cout << "WRONG - got a property not set exception!!!" << endl; + continue; + } + } + cout << "======================================" << endl; +} + +void sdotest::boolbug() +{ + DataFactoryPtr mdg = DataFactory::getDataFactory(); + mdg->addType("myspace","Company"); + mdg->addPropertyToType("myspace","Company","bool","commonj.sdo","Boolean"); + const Type& tcc = mdg->getType("myspace","Company"); + DataObjectPtr dor = mdg->create((Type&)tcc); + try { + bool b = dor->getBoolean("bool"); + cout << "bool:" << b << endl; + } + catch (SDOPropertyNotSetException) + { + cout << "WRONG not set exception" << endl; + } +} + +void sdotest::scope1() +{ + cout << "SCOPE1 - Data Factory" << endl; + + DataFactoryPtr mdg = DataFactory::getDataFactory(); +} + +void sdotest::scope2() +{ + cout << "SCOPE2 - Create Data Object" << endl; + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + mdg->addType("myspace","Company"); + mdg->addPropertyToType("myspace","Company","csumm","commonj.sdo","ChangeSummary"); + const Type& tcc = mdg->getType("myspace","Company"); + DataObjectPtr dor = mdg->create((Type&)tcc); +} + +void sdotest::scope3() +{ + cout << "SCOPE3 - Lists" << endl; + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + mdg->addType("myspace","Main"); + mdg->addType("myspace","Subs"); + mdg->addPropertyToType("myspace","Main","name","commonj.sdo","String"); + mdg->addPropertyToType("myspace","Main","subs","myspace","Subs", true); + mdg->addPropertyToType("myspace","Subs","name","commonj.sdo","String"); + + const Type& tcc = mdg->getType("myspace","Main"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + DataObjectPtr sub = dor->createDataObject("subs"); + sub->setCString("name", "sub1"); + + sub = dor->createDataObject("subs"); + sub->setCString("name", "sub2"); + + +} + +void sdotest::testGetters(DataObjectPtr dor) +{ + testGetter(dor,"boolean"); + testGetter(dor,"byte"); + testGetter(dor,"character"); + testGetter(dor,"short"); + testGetter(dor,"integer"); + testGetter(dor,"long"); + testGetter(dor,"double"); + testGetter(dor,"float"); + testGetter(dor,"date"); + testGetter(dor,"string"); + testGetter(dor,"bytes"); + testGetter(dor,"dataobject"); +} + +void sdotest::testGetter(DataObjectPtr dor, char* str) +{ + + try { + cout << "Boolean from " << str; + bool b = dor->getBoolean(str); + cout << " was " << b << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + try { + cout << "Byte from " << str; + char by = dor->getByte(str); + cout << " was " << by <getCharacter(str); + cout << " was " << cy << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + try { + cout << "Short from " << str; + short s = dor->getShort(str); + cout << " was " << s << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + try { + cout << "Int from " << str; + int i = dor->getInteger(str); + cout << " was " << i << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + try { + cout << "Long from " << str; + long l = dor->getLong(str); + cout << " was " << l << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + try { + cout << "LongLong from " << str; + int64_t ll = dor->getLong(str); + cout << " was got OK" << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + try { + cout << "Float from " << str; + float f = dor->getFloat(str); + cout << " was " << f << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + try { + cout << "Double from " << str; + long double d = dor->getDouble(str); + cout << " was " << d << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + unsigned int len; + + try { + cout << "Length of " << str; + len = dor->getLength(str); + cout << " was " << len << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + if (len > 0) { + try { + cout << "String from " << str; + wchar_t * buf = new wchar_t[len]; + unsigned int gotlen = dor->getString(str,buf,len); + cout << " size "; + cout << gotlen << endl; + for (int jj=0;jjgetBytes(str,cbuf,len); + cout << " size " << gotlen << endl; + for (int jj=0;jjgetDate(str); + cout << " was " << t.getTime() << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << " WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + try { + cout << "CString from " << str; + const char * string = dor->getCString(str); + if ( string != 0) cout << " was " << string << endl; + else cout << " was empty " << endl; + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG - unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + + try { + cout << "DataObject from " << str; + DataObjectPtr dob = dor->getDataObject(str); + if (dob != 0) + { + cout << " was " << dob << endl; + } + else + { + cout << " was empty" << endl; + } + } + catch (SDOPropertyNotSetException pe) + { + cout << "WRONG unset and undefaulted" << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << endl; + } + +} + +void sdotest::conversiontest() +{ + cout << "Conversion tests" << endl; + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + mdg->addType("myspace","Container"); + mdg->addType("myspace","Contained"); + mdg->addPropertyToType("myspace","Container","boolean","commonj.sdo","Boolean"); + mdg->addPropertyToType("myspace","Container","byte","commonj.sdo","Byte"); + mdg->addPropertyToType("myspace","Container","character","commonj.sdo","Character"); + mdg->addPropertyToType("myspace","Container","short","commonj.sdo","Short"); + mdg->addPropertyToType("myspace","Container","integer","commonj.sdo","Integer"); + mdg->addPropertyToType("myspace","Container","long","commonj.sdo","Long"); + mdg->addPropertyToType("myspace","Container","float","commonj.sdo","Float"); + mdg->addPropertyToType("myspace","Container","double","commonj.sdo","Double"); + mdg->addPropertyToType("myspace","Container","string","commonj.sdo","String"); + mdg->addPropertyToType("myspace","Container","bytes","commonj.sdo","Bytes"); + mdg->addPropertyToType("myspace","Container","dataobject","myspace","Contained"); + mdg->addPropertyToType("myspace","Container","date","commonj.sdo","Date"); + mdg->addPropertyToType("myspace","Container","bigint","commonj.sdo","BigInteger"); + mdg->addPropertyToType("myspace","Container","bigdec","commonj.sdo","BigDecimal"); + + + const Type& tcc = mdg->getType("myspace","Container"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + // phase 1 - all unset....... + + cout << "+++++++++++++++PROPERTY VALUES UNSET ++++++++++++++++++" << endl; + + testGetters(dor); + + cout << "+++++++++++++++PROPERTY VALUES SET ++++++++++++++++++++" << endl; + + DataObjectPtr sub = dor->createDataObject("dataobject"); + dor->setBoolean("boolean", true); + dor->setByte("byte",20); + dor->setCharacter("character", 1000); + dor->setShort("short", (short)12345678); + dor->setInteger("integer", 87654321); + dor->setLong("long", 0xFFFFFFFFFFFF); + dor->setFloat("float", (float)12345.678); + dor->setDouble("double", 1234567.891); + dor->setDate("date", 37575); + wchar_t* chars = new wchar_t[50]; + for (int i=0;i<50;i++) {chars[i] = 0x7F20 + i ;} + dor->setString("string",chars, 50); + + char* tchars = new char[50]; + for (int ii=0;ii<50;ii++) {tchars[ii] = ii + 32;} + dor->setBytes("bytes",tchars, 50); + + + testGetters(dor); + + cout << "+++++++++++++++END OF TEST ++++++++++++++++++++++++++++" << endl; + + // phase 2 all set..... + +} + + +void sdotest::usertest() +{ + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Root"); + mdg->addType("myspace","UserTest"); + mdg->addType("myspace","AnObject"); + + const Type& tr = mdg->getType("myspace", "Root"); + const Type& tm = mdg->getType("myspace", "UserTest"); + const Type& to = mdg->getType("myspace", "AnObject"); + + mdg->addPropertyToType(tm,"boolean", "commonj.sdo","Boolean"); + mdg->addPropertyToType(tm,"unsetboolean", "commonj.sdo","Boolean"); + mdg->addPropertyToType(tm,"object", "myspace","AnObject"); + mdg->addPropertyToType(tm,"unsetobject","myspace","AnObject"); + + // many valued... + mdg->addPropertyToType(tm,"longs", "commonj.sdo","Integer", true); + mdg->addPropertyToType(tm,"objects", "myspace","AnObject", true); + + mdg->addPropertyToType(tr,"usertest", "myspace","UserTest"); + + DataObjectPtr root = mdg->create((Type&)tr); + DataObjectPtr test = root->createDataObject("usertest"); + DataObjectPtr do1 = test->createDataObject("object"); + DataObjectPtr do2 = test->createDataObject("objects"); + DataObjectPtr do3 = test->createDataObject("objects"); + + test->setBoolean("boolean", true); + + void* value = (void*)0xFACC0FF; + + test->setUserData(value); + + cout << "I wanted 0xFACC0FF " << test->getUserData() << endl; + + root->setUserData("usertest",value); + + cout << "I wanted 0xFACC0FF and got " << root->getUserData("usertest") << endl; + + root->setUserData((unsigned int)0,(void*)0x20); + + cout << "I wanted 0x20 and got " << root->getUserData((unsigned int)0) << endl; + + const Property& prop = root->getType().getProperty("usertest"); + root->setUserData(prop,(void*)0x40020); + + cout << "I wanted 0x40020 and got " << root->getUserData(prop) << endl; + + test->setUserData("boolean", (void*)0x120); + + cout << "I wanted (graceful)0 and got " << test->getUserData("boolean") << endl; + + test->setUserData("unsetboolean", (void*)0x340); + + cout << "I wanted (graceful)0 and got " << test->getUserData("boolean") << endl; + + test->setUserData("object", (void*)0x120); + + cout << "I wanted 120 and got " << test->getUserData("object") << endl; + + test->setUserData("unsetobject", (void*)0x540); + + cout << "I wanted (graceful)0 and got " << test->getUserData("unsetobject") << endl; + + test->setUserData("objects", (void*)0x640); + + // TODO might be dodgy - this allows setting of user data on a base of a list + cout << "I wanted 640 and got " << test->getUserData("objects") << endl; + + test->setUserData("objects[1]", (void*)0x740); + + cout << "I wanted 0x740 and got " << test->getUserData("objects[1]") << endl; + } + catch (SDORuntimeException e) + { + cout << "Exception in user test - unexpected" << endl; + } + +} + +void sdotest::versiontest() +{ + cout << "The SDO version is :" << SdoRuntime::getVersion() << endl; + cout << "The Major version is: " << SdoRuntime::getMajor() << endl; + cout << "The Minor version is: " << SdoRuntime::getMinor() << endl; + cout << "The Fix level is: " << SdoRuntime::getFix() << endl; +} + +void sdotest::noncontest() +{ + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Company"); + mdg->addType("myspace","Department"); + mdg->addType("myspace","Employee"); + + const Type& tr = mdg->getType("myspace", "Company"); + const Type& tm = mdg->getType("myspace", "Department"); + const Type& to = mdg->getType("myspace", "Employee"); + + // many... + mdg->addPropertyToType(tr,"departments","myspace", "Department", + true); + + //mdg->addPropertyToType(to,"name","commonj.sdo", "String"); + + mdg->addPropertyToType(tm,"employees","myspace", "Employee", true); + + // single, non containment + mdg->addPropertyToType(tr,"eom", "myspace","Employee", false + , false, false); + + DataObjectPtr comp = mdg->create((Type&)tr); + + { + DataObjectPtr dept = comp->createDataObject("departments"); + DataObjectPtr emp1 = dept->createDataObject("employees"); + //emp1->setCString("name", "Will"); + DataObjectPtr emp2 = dept->createDataObject("employees"); + //emp1->setCString("name", "Bill"); + DataObjectPtr emp3 = dept->createDataObject("employees"); + //emp1->setCString("name", "Gill"); + comp->setDataObject("eom", emp3); + } + + + +} + + + + +void sdotest::defaulttest() +{ + try{ + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","DefaultTest"); + mdg->addType("myspace","AnObject"); + + const Type& tm = mdg->getType("myspace", "DefaultTest"); + const Type& to = mdg->getType("myspace", "AnObject"); + + mdg->addPropertyToType(tm,"boolean", "commonj.sdo","Boolean"); + + mdg->setDefault("myspace","DefaultTest","boolean", true); + + mdg->addPropertyToType(tm,"byte", "commonj.sdo","Byte"); + + mdg->setDefault("myspace","DefaultTest","byte", (char)'d'); + + mdg->addPropertyToType(tm,"character", "commonj.sdo","Character"); + + mdg->setDefault("myspace","DefaultTest","character", (wchar_t)'e'); + + mdg->addPropertyToType(tm,"short", "commonj.sdo","Short"); + + mdg->setDefault("myspace","DefaultTest","short", (short)300); + + mdg->addPropertyToType(tm,"long", "commonj.sdo","Integer"); + + mdg->setDefault("myspace","DefaultTest","long", (long)400); + + mdg->addPropertyToType(tm,"longs", "commonj.sdo","Integer", true); + + mdg->setDefault("myspace","DefaultTest","longs", (long)800); + + mdg->addPropertyToType(tm,"longlong", "commonj.sdo","Long"); + + mdg->setDefault("myspace","DefaultTest","longlong", (int64_t)500); + + mdg->addPropertyToType(tm,"float", "commonj.sdo","Float"); + + mdg->setDefault("myspace","DefaultTest","float", (float)600.0); + + mdg->addPropertyToType(tm,"longdouble", "commonj.sdo","Double"); + + mdg->setDefault("myspace","DefaultTest","longdouble", (long double)700.0); + + mdg->addPropertyToType(tm,"date", "commonj.sdo","Date"); + + mdg->setDefault("myspace","DefaultTest","date", (long)900); + + mdg->addPropertyToType(tm,"string", "commonj.sdo","String"); + + wchar_t* help = new wchar_t[4]; + help[0] = 'H'; + help[1] = 'E'; + help[2] = 'L'; + help[3] = 'P'; + + mdg->setDefault("myspace","DefaultTest","string", help, 4); + + delete help; + + char* help2 = new char[4]; + help2[0] = 'H'; + help2[1] = 'E'; + help2[2] = 'L'; + help2[3] = 'P'; + + mdg->addPropertyToType(tm,"bytes", "commonj.sdo","Bytes"); + + mdg->setDefault("myspace","DefaultTest","bytes", help2, 4); + + delete help2; + + mdg->addPropertyToType(tm,"object", "myspace","AnObject"); + + DataObjectPtr test = mdg->create((Type&)tm); + + cout << "Boolean default is true: " << test->getBoolean("boolean") << endl; + + cout << "Byte default is d: " << test->getByte("byte") << endl; + + cout << "Character default is e: " << test->getCharacter("character") << endl; + + cout << "Short default is 300: " << test->getShort("short") << endl; + + cout << "Long default is 400: " << test->getInteger("long") << endl; + + try { + cout << "Longs default is 800: " << test->getInteger("longs[1]") << endl; + } + catch (SDOIndexOutOfRangeException ex) + { + cout << "Expected index out of range OK" << endl; + } + + cout << "Float default is 600: " << test->getFloat("float") << endl; + + cout << "LongDouble default is 700: " << test->getDouble("longdouble") << endl; + + cout << "String default is HELP: "; + unsigned int lenw = test->getLength("string"); + if (lenw > 0) { + char* tw = new char[lenw]; + test->getBytes("string",tw,lenw); + for (int i=0;igetLength("bytes"); + if (len > 0) { + char* tc = new char[len]; + test->getBytes("bytes",tc,len); + for (int i=0;i 0) + { + wchar_t * buf = new wchar_t[l+1]; + l = pstring.getStringDefault(buf,l); + cout << "String default length is" << l << endl; + for (int i=0;i 0) + { + char * buf = new char[l+1]; + l = pbytes.getBytesDefault(buf,l); + cout << "Bytes default length is" << l << endl; + for (int i=0;iaddType("myspace","DefaultTest"); + mdg->addType("myspace","AnObject"); + + const Type& tm = mdg->getType("myspace", "DefaultTest"); + const Type& to = mdg->getType("myspace", "AnObject"); + + mdg->addPropertyToType(tm,"boolean", "commonj.sdo","Boolean"); + mdg->addPropertyToType(tm,"byte", "commonj.sdo","Byte"); + mdg->addPropertyToType(tm,"character", "commonj.sdo","Character"); + mdg->addPropertyToType(tm,"short", "commonj.sdo","Short"); + mdg->addPropertyToType(tm,"long", "commonj.sdo","Integer"); + mdg->addPropertyToType(tm,"longs", "commonj.sdo","Integer", true); + mdg->addPropertyToType(tm,"longlong", "commonj.sdo","Long"); + mdg->addPropertyToType(tm,"float", "commonj.sdo","Float"); + mdg->addPropertyToType(tm,"longdouble", "commonj.sdo","Double"); + mdg->addPropertyToType(tm,"date", "commonj.sdo","Date"); + mdg->addPropertyToType(tm,"string", "commonj.sdo","String"); + mdg->addPropertyToType(tm,"bytes", "commonj.sdo","Bytes"); + mdg->addPropertyToType(tm,"object" , "myspace","AnObject"); + + cout << "Testing unset defaults....." << endl; + + showdefault(tm); + + + //now set all the defaults.... + + mdg->setDefault("myspace","DefaultTest","boolean", true); + mdg->setDefault("myspace","DefaultTest","byte", (char)'d'); + mdg->setDefault("myspace","DefaultTest","character", (wchar_t)'e'); + mdg->setDefault("myspace","DefaultTest","short", (short)300); + mdg->setDefault("myspace","DefaultTest","long", (long)400); + mdg->setDefault("myspace","DefaultTest","longs", (long)800); + mdg->setDefault("myspace","DefaultTest","longlong", (int64_t)500); + mdg->setDefault("myspace","DefaultTest","float", (float)600.0); + mdg->setDefault("myspace","DefaultTest","longdouble", (long double)700.0); + mdg->setDefault("myspace","DefaultTest","date", (long)900); + + + wchar_t* help = new wchar_t[4]; + help[0] = 'H'; + help[1] = 'E'; + help[2] = 'L'; + help[3] = 'P'; + + mdg->setDefault("myspace","DefaultTest","string", help, 4); + + delete help; + + char* help2 = new char[4]; + help2[0] = 'H'; + help2[1] = 'E'; + help2[2] = 'L'; + help2[3] = 'P'; + + + mdg->setDefault("myspace","DefaultTest","bytes", help2, 4); + + delete help2; + + // and have another go at getting them.... + + cout << "Testing set defaults....." << endl; + + showdefault(tm); + + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << " in "; + cout << e.getFileName() << " at line "; + cout << e.getLineNumber() << endl; + cout << e.getFunctionName() << " "; + cout << e.getMessageText() << endl; + } + +} + +void sdotest::nulltest() +{ + int i; + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","NullTest",true, false); // sequenced + mdg->addType("myspace","AnObject"); + + const Type& tm = mdg->getType("myspace", "NullTest"); + const Type& to = mdg->getType("myspace", "AnObject"); + + mdg->addPropertyToType(tm,"boolean", "commonj.sdo","Boolean"); + mdg->addPropertyToType(tm,"byte", "commonj.sdo","Byte"); + mdg->addPropertyToType(tm,"character", "commonj.sdo","Character"); + mdg->addPropertyToType(tm,"short", "commonj.sdo","Short"); + mdg->addPropertyToType(tm,"long", "commonj.sdo","Integer"); + mdg->addPropertyToType(tm,"longlong", "commonj.sdo","Long"); + mdg->addPropertyToType(tm,"float", "commonj.sdo","Float"); + mdg->addPropertyToType(tm,"longdouble", "commonj.sdo","Double"); + mdg->addPropertyToType(tm,"date", "commonj.sdo","Date"); + mdg->addPropertyToType(tm,"string", "commonj.sdo","String"); + mdg->addPropertyToType(tm,"bytes", "commonj.sdo","Bytes"); + mdg->addPropertyToType(tm,"object", "myspace","AnObject"); + + + mdg->addPropertyToType(tm,"cs", "commonj.sdo","ChangeSummary"); + + DataObjectPtr test = mdg->create((Type&)tm); + DataObjectPtr ob = mdg->create((Type&)to); + DataObjectPtr ob2 = mdg->create((Type&)to); + DataObjectPtr ob3 = mdg->create((Type&)to); + + // first check all props are unset + + ChangeSummaryPtr cs = test->getChangeSummary(); + + cs->beginLogging(); + + PropertyList pl = test->getInstanceProperties(); + + cout << "Initially - all properties unset, and default values..." << endl; + for (i=0;iisSet(pl[i]) << " value:"; + const char *xx = test->getCString(pl[i]); + if (xx != 0) + { + cout << xx << endl; + } + else + { + cout << " is empty " << endl; + } + } + else { + cout << pl[i].getName() << " set:" << test->isSet(pl[i]) << " value:"; + DataObjectPtr xy = test->getDataObject(pl[i]); + if (xy != 0) + { + cout << xy << endl; + } + else + { + cout << " is empty " << endl; + } + } + } + catch (SDOPropertyNotSetException) + { + cout << " WRONG - got not set exception!!!"; + continue; + } + } + test->setBoolean("boolean", false); + test->setByte("byte",0); + test->setCharacter("character",0); + test->setShort("short",0); + test->setInteger("long",0); + test->setLong("longlong",0 ); + test->setFloat("float",0); + test->setDouble("longdouble",0 ); + test->setDate("date",0 ); + test->setString("string",0,0); + test->setBytes("bytes","",0) ; + test->setDataObject("object",0) ; + + + + cout << "Should now have all properties set, and zero values..." << endl; + for (i=0;iisSet(pl[i]) << " value:" << test->getCString(pl[i]) << endl; + } + else { + cout << pl[i].getName() <<" set:" << test->isSet(pl[i]) << " value:" << test->getDataObject(pl[i]) << endl; + } + + } + + for (i=0;iunset(pl[i]); + } + cout << "Should be back to having properties unset, and default values..." << endl; + for (i=0;iisSet(pl[i]) << " value:"; + const char *xx = test->getCString(pl[i]); + if (xx != 0) + { + cout << xx << endl; + } + else + { + cout << " is empty " << endl; + } + } + else { + cout << pl[i].getName() << " set:" << test->isSet(pl[i]) << " value:"; + DataObjectPtr dp = test->getDataObject(pl[i]); + if (dp != 0) + { + cout << dp << endl; + } + else + { + cout << " is empty " << endl; + } + } + } + catch (SDOPropertyNotSetException) + { + cout << "WRONG - not set exception" << endl; + continue; + } + } + + SequencePtr s = test->getSequence(); + + s->addBoolean(test->getType().getProperty("boolean")/*"boolean"*/, false); + s->addByte(1/*"byte"*/,0); + s->addCharacter(2/*"character"*/,0); + s->addShort(3/*"short"*/,0); + s->addInteger(4/*"long"*/,0); + s->addLong(5/*"longlong"*/,0 ); + s->addFloat(6/*"float"*/,0); + s->addDouble(7/*"longdouble"*/,0 ); + // bug ...s->setDate(8/*"date"*/,0 ); + s->addString(9/*"string"*/,0,0); + s->addBytes(10/*"bytes"*/,"",0) ; + s->addDataObject(11/*"object"*/,0) ; + + for (i=0;iisSet(pl[i]) << " value:"; + const char* xx = test->getCString(pl[i]); + if ( xx != 0) + { + cout << xx << endl; + } + else + { + cout << " is empty " << endl; + } + } + else { + cout << pl[i].getName() << " set:" << test->isSet(pl[i]) << " value:"; + DataObjectPtr db = test->getDataObject(pl[i]); + if (db != 0) + { + cout << db << endl; + } + else + { + cout << " is empty " << endl; + } + } + } + catch (SDOPropertyNotSetException) + { + cout << "WRONG - not set exception " << endl; + continue; + } + } + ChangedDataObjectList& cl = cs->getChangedDataObjects(); + for ( i =0; i< cl.size() ; i++) + { + if (cs->isCreated(cl[i])) { + cout << "Created:" << cl[i] << endl; + } + if (cs->isDeleted(cl[i])) { + cout << "Deleted:" << cl[i] << endl; + } + if (cs->isModified(cl[i])) { + cout << "Modified:" << cl[i] << endl; + } + } + + // now unset all the properties... + for (i=0;iunset(pl[i]); + } + + for (i=0;isetNull(i); + } + } + + cout << "Should all be null, and default values..." << endl; + for (i=0;iisNull(i) <<" set:" << test->isSet(pl[i]) << " value:"; + if (test->getCString(pl[i]) == 0) cout << endl; + else cout << test->getCString(pl[i]) << endl; + } + else { + cout << pl[i].getName() << "isNull:" << test->isNull(i) <<" set:" << test->isSet(pl[i]) << " value:"; + if (test->getDataObject(pl[i]) == 0) cout << endl; + else cout << test->getDataObject(pl[i]) << endl; + } + } + + s->addBoolean(test->getType().getProperty("boolean")/*"boolean"*/, true); + s->addByte(1/*"byte"*/,1); + s->addCharacter(2/*"character"*/,1); + s->addShort(3/*"short"*/,1); + s->addInteger(4/*"long"*/,1); + s->addLong(5/*"longlong"*/,1 ); + s->addFloat(6/*"float"*/,1.0); + s->addDouble(7/*"longdouble"*/,1.0 ); + // bug ...s->setDate(8/*"date"*/,0 ); + wchar_t* chs = new wchar_t[5]; + chs[0] = 'h'; + chs[1] = 'e'; + chs[2] = 'l'; + chs[3] = 'l'; + chs[4] = 'o'; + s->addString(9/*"string"*/,chs,5); + delete chs; + s->addBytes(10/*"bytes"*/,"hello",5) ; + s->addDataObject(11/*"object"*/,ob) ; + + cout << "Should all have values, and not be null.." << endl; + for (i=0;iisNull(i) <<" set:" << test->isSet(pl[i]) << " value:"; + if (test->getCString(pl[i]) == 0) cout << endl; + else cout << test->getCString(pl[i]) << endl; + + } + else { + cout << pl[i].getName() << "isNull:" << test->isNull(i) <<" set:" << test->isSet(pl[i]) << " value:"; + if (test->getDataObject(pl[i]) == 0) cout << endl; + else cout << test->getDataObject(pl[i]) << endl; + } + } + + for (i=0;isetNull(pl[i]); + } + } + + cout << "Should all be null, and default values..." << endl; + for (i=0;iisNull(i) <<" set:" << test->isSet(pl[i]) << " value:"; + if (test->getCString(pl[i]) == 0) cout << endl; + else cout << test->getCString(pl[i]) << endl; + + } + else { + cout << pl[i].getName() << "isNull:" << test->isNull(i) <<" set:" << test->isSet(pl[i]) << " value:"; + if (test->getDataObject(pl[i]) == 0) cout << endl; + else cout << test->getDataObject(pl[i]) << endl; + } + } + catch (SDOPropertyNotSetException) + { + cout << " WRONG - not set exception" << endl; + continue; + } + } + + cs->endLogging(); +} + +int sdotest::main(int argc, char** argv) +{ + + int i; + + printf("Test Program starting to create types ...\n"); + + /* First create a DataFactory , then add some types and props...*/ + + /* This is dms creation of metadata */ + + try { + + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Company"); + mdg->addType("myspace","Department"); + // manager is a sequenced type... + mdg->addType("myspace","Manager", true, false); + + mdg->addType("myspace","Employee"); + + // tests of base types + + // note - base type of a seq type must be seq... + mdg->addType("myspace","Person", true, false); + + mdg->addType("myspace","DerivedString"); + mdg->addType("myspace","SubDepartment"); + + /* Now add the properties to the types...*/ + + const Type& tc = mdg->getType("myspace","Company"); + const Type& ts = mdg->getType("commonj.sdo","String"); + const Type& ti = mdg->getType("commonj.sdo","Integer"); + const Type& tf = mdg->getType("commonj.sdo","Float"); + const Type& tm = mdg->getType("myspace","Manager"); + + cout << "Manager is sequenced?" << tm.isSequencedType() << endl; + + const Type& td = mdg->getType("myspace","Department"); + const Type& te = mdg->getType("myspace","Employee"); + const Type& tp = mdg->getType("myspace","Person"); + const Type& tds= mdg->getType("myspace","DerivedString"); + const Type& tsd= mdg->getType("myspace","SubDepartment"); + + cout << "Manager is sequenced?" << tm.isSequencedType() << endl; + + + + + + /* By type, with a type */ + mdg->addPropertyToType(tc,"name",ts); + + /* by name/uri with a type */ + mdg->addPropertyToType("myspace","Company","address",ts); + + /* by type with name/uri */ + mdg->addPropertyToType(tc,"departments", "myspace","Department", + true); + + + // add a reference to employee of the month + mdg->addPropertyToType(tc,"employee of the month", "myspace","Employee", + false, false, false); + + + + /* A list of floats */ + + mdg->addPropertyToType(tc,"floatlist", tf,true); + + mdg->addPropertyToType(tc,"pdg", tm); + + cout << "Manager is sequenced?" << tm.isSequencedType() << endl; + + mdg->addPropertyToType(td,"name", ts); + + mdg->addPropertyToType(td,"id", ti); + + mdg->addPropertyToType(td,"manager", tm); + + mdg->addPropertyToType(tm,"name", ts); + + + mdg->addPropertyToType(te,"name",ts); + mdg->addPropertyToType(td,"employees",te,true,false,true); + + + + // emps and managers are both people (in theory). + mdg->setBaseType(te,tp); + cout << "Manager is sequenced?" << tm.isSequencedType() << endl; + mdg->setBaseType(tm,tp); + cout << "Manager is sequenced?" << tm.isSequencedType() << endl; + mdg->addPropertyToType(tp,"haircolour", ts); + mdg->addPropertyToType(tp,"name", ts); + mdg->addPropertyToType(tm,"officeid", ts); + mdg->addPropertyToType(te,"cubelocation", ts); + + mdg->addPropertyToType(tc,"shareholder", tp); + + //derived string - derived from string - cannot have properties!!! + mdg->setBaseType(tds,ts); + + // subdept derived from dept + mdg->setBaseType(tsd,td); + mdg->addPropertyToType(tsd,"subname",ts); + + mdg->addPropertyToType(tc, "substring",tds); + + /* by type with name/uri */ + mdg->addPropertyToType(tc,"subdepartments", "myspace","SubDepartment", + true); + + /* This is the data structure */ + + + + /* company + ----shareholder (Person) + ----substring (DerivedString) + * ----name (String) + * ----pdg (Manager) + (inherits haircolour from person, + has name as duplicate property - should use person.name + has officeid) + * ----name(String) + ----haircolour(String) + ----officeid(String) + * + * ----depts[] (Department) + * ----name (String) + * ----id (Integer) + * ----manager (Manager). + * ----name(String) + ----haircolour(String) from Person + * ----employees[] (Employee) + * ----name(String) + ----haircolour(String) - from Person + ----cubelocation(String) + --subdepartments[] (SubDepartment) + ----name (String) from Department + ----id (String) from Department + ----manager (Manager) from Department + ----employees (from department) + */ + + /* Now add a primitive type test to the manager */ + mdg->addPropertyToType(tm,"string",ts); + + cout << "Manager is sequenced?" << tm.isSequencedType() << endl; + + mdg->addPropertyToType(tm,"boolean", "commonj.sdo","Boolean"); + mdg->addPropertyToType(tm,"byte", "commonj.sdo","Byte"); + mdg->addPropertyToType(tm,"character", "commonj.sdo","Character"); + mdg->addPropertyToType(tm,"short", "commonj.sdo","Short"); + mdg->addPropertyToType(tm,"long", "commonj.sdo","Integer"); + mdg->addPropertyToType(tm,"longlong", "commonj.sdo","Long"); + mdg->addPropertyToType(tm,"float", "commonj.sdo","Float"); + mdg->addPropertyToType(tm,"longdouble", "commonj.sdo","Double"); + mdg->addPropertyToType(tm,"date", "commonj.sdo","Date"); + // dead mdg->addPropertyToType(tm,"charptr", "commonj.sdo","Bytes"); + mdg->addPropertyToType(tm,"string", "commonj.sdo","String"); + mdg->addPropertyToType(tm,"bytes", "commonj.sdo","Bytes"); + + + cout << "Manager is sequenced?" << tm.isSequencedType() << endl; + + // create a few aliases + + mdg->setAlias("myspace","Company","TheFirm"); + mdg->setAlias("myspace","Company","departments","TheDepartments"); + mdg->setAlias("myspace","Company","TheBigFirm"); + mdg->setAlias("myspace","Company","TheLittleFirm"); + + const Type& tlf = mdg->getType("myspace","TheBigFirm"); + + cout << "I hope this says Company :" << tlf.getName() << endl; + + cout << "I hope this says 3 : " << tlf.getAliasCount() << endl; + + for (int ai = 0; ai < tlf.getAliasCount(); ai++) + { + cout << "AKA : " << tlf.getAlias(ai) << endl; + } + + // just for a laugh - how about finding the TheDepartments? + + + + + /* + * create an empty datagraph with a type system starting from + * company + */ + + /* + * + * start of dms getting datagraph + */ + + // Change summary test begins + mdg->addPropertyToType(tc,"csumm","commonj.sdo","ChangeSummary"); + // should log an error - but not fail + mdg->addPropertyToType(td,"csumm","commonj.sdo","ChangeSummary"); + + cout << "Manager is sequenced?" << tm.isSequencedType() << endl; + + cout << "BEFORE RESOLUTION" << endl; + printDataStructure(mdg); + + /* Now create some objects in the dg */ + +// DataObjectPtr dor; + + const Type& tcc = mdg->getType("myspace","Company"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + cout << "AFTER RESOLUTION" << endl; + printDataStructure(mdg); + + cout << "Manager is sequenced?" << tm.isSequencedType() << endl; + + dor->setCString("substring","This is the sub string - its primitive, but not a string"); + + const char* subby = dor->getCString("substring"); + + cout << subby << endl; + + dor->setCString("name","acmecorp"); + const char* chnam = dor->getCString("name"); + cout << chnam << endl; + + dor->unset("name"); + + dor->setCString("name","acmecorp"); + + // Set up the two departments before logging starts + + DataObjectPtr dep1 = dor->createDataObject("departments"); + dep1->setCString("name","Developement"); + + DataObjectPtr dep2= dor->createDataObject("departments"); + dep2->setCString("name","Marketing"); + + // add a couple of floats to the floatlist + DataObjectList& dolist = dor->getList("floatlist"); + dolist.append((float)1.4); + dolist.append((float)1.5); + + //TODO - change summaries should live on the DataObject + // interface - can this be done? + + ChangeSummaryPtr cs = dor->getChangeSummary(); + cs->beginLogging(); + + const char* sname = dor->getCString("name"); + + cout << sname << endl; + + // This should put a created entry in the cs. + + // This should be equivalent to the alternative below......... + const Type& tcd = mdg->getType("myspace","Manager"); + DataObjectPtr pdg = mdg->create((Type&)tcd); + + // This set should put the entry into the change summary. + // both in the creations and in the changes. + dor->setDataObject("pdg",pdg); + + + // try getting the boolean as a string - should be defalted to false: + const char *bol; + try{ + bol = pdg->getCString("boolean"); + if (bol != 0) + { + cout << "Expected default boolean (false) : " << bol << endl; + } + else + { + cout << " is empty " << endl; + } + } + catch (SDOPropertyNotSetException) + { + cout << "WRONG handled notset exception " << endl; + } + + pdg->setBoolean("boolean", true); + bol = pdg->getCString("boolean"); + cout << "Expected boolean (true) : " << bol << endl; + + // and the widechars? + const char* wdc; + try { + wdc = pdg->getCString("string"); + if (wdc != 0) + { + cout << "Expected default string (0) : " << bol << endl; + } + else + { + cout << " is empty " << endl; + } + } + catch (SDOPropertyNotSetException) + { + cout << "WRONG handled notset exception" << endl; + } + + + // this should get a valid sequence.. + + SequencePtr sq = pdg->getSequence(); + + + // The alternative............................................. + // Here the create should put the entry into the change summary + //DataObject* pdg = dor->createDataObject("pdg"); + + // This should do nothing to the cs, as its in a created object + pdg->setCString("name","Jacques LePlace"); + + // This should modify the property, and add an item to the sequence. + sq->addCString("name", "Jacques LeWrongPlace"); + + + // The creation entry should be removed from the change summary + // The entry should no longer exist and the pointer is invalid + pdg->detach(); + + pdg = dor->getDataObject("pdg"); + + + cout << " A deleted data object should be zero: " << pdg << endl; + + pdg = mdg->create((Type&)tcd); + + // A new creation in the change summary + dor->setDataObject("pdg",pdg); + + // No modification as the object is created + pdg->setCString("name", "Mr Horace the snail"); + + sq = pdg->getSequence(); + + try { + // element 0 is the first setting - which we just deleted! + sq->setCStringValue(0,"Eric the half a bee"); + } + catch (SDOIndexOutOfRangeException) + { + // thats OK + sq->addCString("name","Eric the quarter bee"); + } + + + sq->addText(" - only a quarter was expected \r\n"); + + for (int ii=0;iisize();ii++) + { + cout << sq->getCStringValue(ii); + } + + try { + const char* n = pdg->getCString("name"); + cout << " Name from deleted item: " << n << endl; + } + catch (SDOPropertyNotFoundException e) + { + // thats ok + cout << "caught prop not found" << endl; + } + + + // This should put a change in the cs. + dor->setCString("name","mega-new-acmecorp"); + + + // At this point, we should know that pdg was empty and is now + // a created object. And that the old string for company name + // was "acmecorp" + + // cs->DebugPrint(); + + + /* Now set up the primitive type test on PDG */ + + pdg->setCString("string","Hello I am a string"); + pdg->setBoolean("boolean",true); + pdg->setByte("byte",23); + pdg->setCharacter("character",45); + pdg->setShort("short",34); + pdg->setLong("long", 56); + pdg->setDouble("longdouble",89.0); + pdg->setFloat("float",90.0); + pdg->setDate("date",(time_t)200); + + + pdg->setLong("longlong",0xFFFFFFFFFFFFFFFF); + + // try reading the longlong as a string + const char *lls = pdg->getCString("longlong"); + cout << "0xffffffffffffffff = : " << lls << endl; + + pdg->setLong("longlong",0x7FFFFFFFFFFFFFFF); + + lls = pdg->getCString("longlong"); + cout << "0x7fffffffffffffff = " << lls << endl; + + pdg->setLong("longlong",0x7FFFFFFF); + lls = pdg->getCString("longlong"); + cout << "0x7fffffff = " << lls << endl; + + pdg->setLong("longlong",0x80000000); + lls = pdg->getCString("longlong"); + cout << "0x80000000 = " << lls << endl; + + pdg->setLong("longlong",78); + + // pdg->setCharPtr("charptr","Hello I am a char star"); + + wchar_t* wide = new wchar_t[4]; + wide[0] = 'W'; + wide[1] = 'i'; + wide[2] = 'd'; + wide[3] = 'e'; + + pdg->setString("string",wide,4); + + // and as a string? + wdc = pdg->getCString("string"); + cout << " Expected Wide (fat chance) - got : " << wdc << endl; + + delete wide; + + char* thin = new char[4]; + thin[0] = 'T'; + thin[1] = 'h'; + thin[2] = 'i'; + thin[3] = 'n'; + + pdg->setBytes("bytes",thin,4); + + delete thin; + + + const char* ps = pdg->getCString("string"); + cout << "Expecting string, got " << ps << endl; + + bool pb = pdg->getBoolean("boolean"); + cout << "Expected bool true, got " << pb << endl; + + char pc = pdg->getByte("byte"); + cout << "Expected char 23, got " << pc << endl; + + wchar_t pw = pdg->getCharacter("character"); + cout << "expected wchar 45, got " << pw << endl; + + short pss = pdg->getShort("short"); + cout << "Expected short 34, got " << pss << endl; + + long pl = pdg->getLong("long"); + cout << "Expected long 56 , got " <getLong("longlong"); + cout << "Expected long long 78, got " << (long)pi << endl; + + long double ld = pdg->getDouble("longdouble"); + cout << "Expected long double 89, got " << ld << endl; + + float pf = pdg->getFloat("float"); + cout << "Expected float 90, got " << pf << endl; + + SDODate pt = pdg->getDate("date"); + cout << "Expected time_t 200, got " << pt.getTime() << endl; + + //const char * pcs = pdg->getCharPtr("charptr"); + //cout <<"Expected charptr, got " << pcs << endl; + + wchar_t* result; + // get the length to allocate: + unsigned int widelen = pdg->getString("string",0,0); + if (widelen > 0) { + result = new wchar_t[widelen]; + widelen = pdg->getString("string",result,widelen); + for ( i=0;i 0) { + thinresult = new char[thinlen]; + thinlen = pdg->getBytes("bytes",thinresult,thinlen); + for ( i=0;icreateDataObject("departments"); + dep3->setCString("name","Architecture"); + + // The second should do no logging in the change summary + + DataObjectPtr dep4= dor->createDataObject("departments"); + dep4->setCString("name","Pyrotechnics"); + + + // create another one using tha alias + DataObjectPtr dep5= dor->createDataObject("TheDepartments"); + dep5->setCString("name","WibbleSmodging"); + + DataObjectPtr emp1 = dep1->createDataObject("employees"); + emp1->setCString("name","Eric"); + + + DataObjectPtr emp2 = dep1->createDataObject("employees"); + emp2->setCString("name","Bill"); + + // now lets make eric employee of the month + dor->setDataObject("employee of the month",emp1); + + // no - actually it was bill + dor->setDataObject("employee of the month",emp2); + + + + // Now add to the list of floats, hopefully the two old + // values will get change summarised. + + dolist = dor->getList("floatlist"); + //float f = dolist[0]->getFloat(""); + float f = dolist.getFloat(0); + + cout << f; + + dolist.setFloat(0,(float)567.7); + + f = dolist.getFloat(0); + + cout << f; + + dolist.insert(0,(float)34.56); + + + + + // cs->DebugPrint(); + +// const char* ch = dor->getString("departments[1]/employees[2]/name"); + + DataObjectPtr ddd = dor->getDataObject("departments[1]/employees[2]"); + + const char* ch = ddd->getCString("name"); + + cout << "Are you Bill?:" << ch << endl; + + // just for a laugh - how about finding the TheDepartments? + + DataObjectPtr ddd2 = dor->getDataObject("TheDepartments[1]/employees[2]"); + + const char* ch2 = ddd2->getCString("name"); + + cout << "Are you still Bill?:" << ch2 << endl; + + + + DataObjectPtr dempofm = dor->getDataObject("employee of the month"); + + const char* chh = dempofm->getCString("name"); + + cout << "The employee of the month is " << chh << endl; + + // Suppose we delete bill - I wonder what happens? + + // doesnt work - why not??dor->unSet("departments[1]/employees[2]"); + DataObjectList& dlo = dor->getList("departments[1]/employees"); + DataObjectPtr fred = dlo.remove(1); + //delete fred; + + dempofm = dor->getDataObject("employee of the month"); + + cout << "Hopefully emp of month is now zero : " << dempofm << endl; + + /* "The client would create a data mediator and get graph which + would return the root data object " says colin*/ + + const char* boss = dor->getCString("pdg/name"); + + cout << boss << endl; + + DataObjectPtr mypdg = dor->getDataObject("pdg"); + + Type::Types t = mypdg->getTypeEnum(); + + if (t != Type::OtherTypes) { + cout << "MY pdg is not something!" << endl; + } + + const char* boss2 = mypdg->getCString("name"); + + cout << boss2 << endl; + + /* TODO1 ref or pointer to dol. + Manip done by methods of the + list, reflected directly in the dg + need methods to create /insert dataobjects in lists*/ + + + /* getPrimitiveArrayListVectorThingy() */ + + DataObjectList& deps = dor->getList("departments"); + + cout << "size of list " << deps.size() << endl; + + DataObjectPtr dout = deps[0]; + + dout->setCString("name","Research And Development"); + + const char* snew = dout->getCString("name"); + + cout << snew << endl; + + string snew2 = dor->getCString("departments[1 ] /name"); + + cout << snew2 << endl; + + for (int lx = 0; lx < deps.size(); lx++) + { + cout << "Department: " << deps[lx]->getCString("name") << endl; + } + + cs->endLogging(); + + + try { + // should fail - if localtype not setstd:: + dor->setCString("departments","department label"); + const char* slabel = dor->getCString("departments"); + cout << "String in list type:" << slabel << endl; + } + catch (SDORuntimeException e) + { + cout << "Normal expected exception in test case" << endl; + } + + try + { + // The exception for path is caught by the SDO library - perhaps we should + // pass it up? + const char* snew3 = dor->getCString(" ]awep50wi4,0qw9q]45]# q2345 -t -v3lt6o -56o 56=-o7nl ewv/;sdl f[vxddglh]px dfju/ g#k./jh#.k./"); + cout << snew3 << endl; + } + catch (SDOPropertyNotFoundException e) + { + cout << "Normal Invalid path exception" << endl; + } + + try + { + + // catch a and a property not found + const Property& pp = dor->getType().getProperty("notaproperty"); + } + catch (SDOPropertyNotFoundException e) + { + cout << "Normal SDOPropertyNotFound exception" << endl; + } + + } + + catch (SDORuntimeException e) + { + cout << e.getEClassName() << " in "; + cout << e.getFileName() << " at line "; + cout << e.getLineNumber() << endl; + cout << e.getFunctionName() << " "; + cout << e.getSeverity() << " "; + cout << e.getMessageText() << endl; + } + + + return 0; +} + +void sdotest::getproptest() +{ + // should be able to get a property by xpath... + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Company"); + mdg->addType("myspace","Department"); + // manager is a sequenced type... + mdg->addType("myspace","Manager", true, false); + mdg->addType("myspace","Employee"); + + + /* Now add the properties to the types...*/ + + const Type& tc = mdg->getType("myspace","Company"); + const Type& ts = mdg->getType("commonj.sdo","String"); + const Type& ti = mdg->getType("commonj.sdo","Integer"); + const Type& tf = mdg->getType("commonj.sdo","Float"); + const Type& tm = mdg->getType("myspace","Manager"); + const Type& td = mdg->getType("myspace","Department"); + const Type& te = mdg->getType("myspace","Employee"); + + mdg->addPropertyToType(tc,"name",ts); + + mdg->addPropertyToType(tc,"address",ts); + + mdg->addPropertyToType(tc,"departments", td,true); + + // add a reference to employee of the month + mdg->addPropertyToType(tc,"employee of the month", te, false, false, false); + + /* A list of floats */ + mdg->addPropertyToType(tc,"floatlist", tf,true); + mdg->addPropertyToType(tc,"director", tm); + + mdg->addPropertyToType(td,"name", ts); + mdg->addPropertyToType(td,"id", ti); + + mdg->addPropertyToType(td,"manager", tm); + mdg->addPropertyToType(tm,"name", ts); + + mdg->addPropertyToType(te,"name",ts); + mdg->addPropertyToType(td,"employees",te,true,false,true); + + //company/departments/employees. + // company - name, address, floatlist + // department name, id, manager + // employee name + + const Type& tcc = mdg->getType("myspace","Company"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + try + { + + const Property& p = dor->getType().getProperty("name"); + cout << "Companys name property is:" << p.getName() << endl; + + const Property& p1 = dor->getType().getProperty("departments"); + cout << "Companys dept property is:" << p1.getName() << endl; + + // now try some xpaths... + + const Property& p2 = dor->getType().getProperty("departments/employees"); + cout << "Departments empl property is:" << p2.getName() << endl; + + const Property& p3 = dor->getType().getProperty("departments[456]/employees[123]"); + cout << "Departments empl property is:" << p3.getName() << endl; + + const Property& p4 = dor->getType().getProperty("departments.34/employees.123/name"); + cout << "Employees name property is:" << p4.getName() << endl; + + } + catch (SDORuntimeException e) + { + cout <<"Exceptions - xpath didnt work" << endl; + } + try { + cout << "before p5" << endl; + const Property& p5 = dor->getType().getProperty("departments.34/[]/name"); + cout << "after p5" << endl; + cout << "Employees name property is:" << p5.getName() << endl; + cout << "Expected error - didnt get one" << endl; + } + catch (SDORuntimeException e) + { + } + + try { + const Property& p6 = dor->getType().getProperty("deptartments"); + cout << "Deptartments property is:" << p6.getName() << endl; + cout << "Expected error - didnt get one" << endl; + } + catch (SDORuntimeException e) + { + } + + try { + const Property& p7 = dor->getType().getProperty("../company"); + cout << "Company property is:" << p7.getName() << endl; + cout << "Expected error - didnt get one" << endl; + } + catch (SDORuntimeException e) + { + } +} + +void sdotest::querytest() +{ + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Company"); + mdg->addType("myspace","Department"); + // manager is a sequenced type... + mdg->addType("myspace","Manager", true, false); + mdg->addType("myspace","Employee"); + + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool= mdg->getType("commonj.sdo","Boolean"); + const Type& tbyte= mdg->getType("commonj.sdo","Byte"); + const Type& tchar= mdg->getType("commonj.sdo","Character"); + const Type& tint= mdg->getType("commonj.sdo","Integer"); + const Type& tlong= mdg->getType("commonj.sdo","Long"); + const Type& tfloat= mdg->getType("commonj.sdo","Float"); + const Type& tbytes = mdg->getType("commonj.sdo","Bytes"); + const Type& tdouble= mdg->getType("commonj.sdo","Double"); + + const Type& tc = mdg->getType("myspace","Company"); + const Type& tm = mdg->getType("myspace","Manager"); + const Type& td = mdg->getType("myspace","Department"); + const Type& te = mdg->getType("myspace","Employee"); + + mdg->addPropertyToType(tc,"name",tstring); + + mdg->addPropertyToType(tc,"departments", td,true); + + // add a reference to employee of the month + mdg->addPropertyToType(tc,"employee of the month", te, false, false, false); + + mdg->addPropertyToType(tc,"director", tm); + + mdg->addPropertyToType(td,"name", tstring); + + mdg->addPropertyToType(td,"manager", tm); + + mdg->addPropertyToType(tm,"name", tstring); + + + mdg->addPropertyToType(td,"employees",te,true,false,true); + + mdg->addPropertyToType(te,"bool",tbool); + mdg->addPropertyToType(te,"byte",tbyte); + mdg->addPropertyToType(te,"char",tchar); + mdg->addPropertyToType(te,"int",tint); + mdg->addPropertyToType(te,"float",tfloat); + mdg->addPropertyToType(te,"long",tlong); + mdg->addPropertyToType(te,"double",tdouble); + mdg->addPropertyToType(te,"bytes",tbytes); + mdg->addPropertyToType(te,"string",tstring); + mdg->addPropertyToType(te,"name",tstring); + + //company/departments/employees. + // company - name, address, floatlist + // department name, id, manager + // employee name + + const Type& tcc = mdg->getType("myspace","Company"); + DataObjectPtr dor = mdg->create((Type&)tcc); + + DataObjectPtr dept = dor->createDataObject("departments"); + + DataObjectPtr emp1 = dept->createDataObject("employees"); + DataObjectPtr emp2 = dept->createDataObject("employees"); + DataObjectPtr emp3 = dept->createDataObject("employees"); + + emp1->setCString("name","Employee1"); + emp2->setCString("name","Employee2"); + emp3->setCString("name","Employee3"); + + + emp1->setBoolean("bool",true); + emp1->setByte("byte",'1'); + emp1->setCharacter("char",'1'); + emp1->setInteger("int",1); + emp1->setFloat("float",1.0); + emp1->setLong("long",1); + emp1->setDouble("double",1.0); + + char* bytes = new char[6]; + bytes[0] = 'h'; + bytes[1] = 'e'; + bytes[2] = 'l'; + bytes[3] = 'l'; + bytes[4] = 'o'; + + emp1->setBytes("bytes",bytes,5); + + wchar_t* mbytes = new wchar_t[6]; + mbytes[0] = 'h'; + mbytes[1] = 'e'; + mbytes[2] = 'l'; + mbytes[3] = 'l'; + mbytes[4] = 'o'; + + emp1->setString("string",mbytes,5); + + + emp2->setBoolean("bool",true); + emp2->setByte("byte",'2'); + emp2->setCharacter("char",'2'); + emp2->setInteger("int",200); + emp2->setFloat("float",200.0); + emp2->setLong("long",200); + emp2->setDouble("double",200.0); + + char* bytes2 = new char[6]; + bytes2[0] = 'h'; + bytes2[1] = 'e'; + bytes2[2] = 'l'; + bytes2[3] = 'p'; + bytes2[4] = '!'; + + emp2->setBytes("bytes",bytes2,5); + + wchar_t* mbytes2 = new wchar_t[6]; + mbytes2[0] = 'h'; + mbytes2[1] = 'e'; + mbytes2[2] = 'l'; + mbytes2[3] = 'p'; + mbytes2[4] = '!'; + + emp2->setString("string",mbytes2,5); + + emp3->setBoolean("bool",false); + emp3->setByte("byte",'4'); + emp3->setCharacter("char",'4'); + emp3->setInteger("int",400); + emp3->setFloat("float",400.0); + emp3->setLong("long",400); + emp3->setDouble("double",400.0); + + char* bytes3 = new char[6]; + bytes3[0] = 'w'; + bytes3[1] = 'o'; + bytes3[2] = 'm'; + bytes3[3] = 'p'; + bytes3[4] = '!'; + + emp3->setBytes("bytes",bytes3,5); + + wchar_t* mbytes3 = new wchar_t[6]; + mbytes3[0] = 'w'; + mbytes3[1] = 'o'; + mbytes3[2] = 'm'; + mbytes3[3] = 'p'; + mbytes3[4] = '!'; + + emp3->setString("string",mbytes3,5); + + try { + DataObjectPtr dob1 = dor->getDataObject("departments[1]/employees[bool=false]"); + cout << "Expected employee3: got " << dob1->getCString("name") << endl; + + DataObjectPtr dob2 = dor->getDataObject("departments[1]/employees[bool=true]"); + cout << "Expected employee1: got " << dob2->getCString("name") << endl; + + DataObjectPtr dob3 = dor->getDataObject("departments[1]/employees[byte=2]"); + cout << "Expected employee2: got " << dob3->getCString("name") << endl; + + DataObjectPtr dob4 = dor->getDataObject("departments[1]/employees[byte=1]"); + cout << "Expected employee1: got " << dob4->getCString("name") << endl; + + DataObjectPtr dob5 = dor->getDataObject("departments[1]/employees[bytes=hello]"); + cout << "Expected employee1: got " << dob5->getCString("name") << endl; + + DataObjectPtr dob5a = dor->getDataObject("departments[1]/employees[bytes=\"hello\"]"); + cout << "Expected employee1: got " << dob5a->getCString("name") << endl; + + DataObjectPtr dob5b = dor->getDataObject("departments[1]/employees[bytes='hello']"); + cout << "Expected employee1: got " << dob5b->getCString("name") << endl; + + DataObjectPtr dob6 = dor->getDataObject("departments[1]/employees[bytes=womp!]"); + cout << "Expected employee3: got " << dob6->getCString("name") << endl; + + DataObjectPtr dob7 = dor->getDataObject("departments[1]/employees[double=200.0]"); + cout << "Expected employee2: got " << dob7->getCString("name") << endl; + + DataObjectPtr dob8 = dor->getDataObject("departments[1]/employees[string=help!]"); + cout << "Expected employee2: got " << dob8->getCString("name") << endl; + + DataObjectPtr dob8a = dor->getDataObject("departments[1]/employees[string=\"help!\"]"); + cout << "Expected employee2: got " << dob8a->getCString("name") << endl; + + DataObjectPtr dob8b = dor->getDataObject("departments[1]/employees[string= 'help!']"); + cout << "Expected employee2: got " << dob8b->getCString("name") << endl; + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << " in "; + cout << e.getFileName() << " at line "; + cout << e.getLineNumber() << endl; + cout << e.getFunctionName() << " "; + cout << e.getMessageText() << endl; + } + try { + DataObjectPtr dob1 = dor->getDataObject("departments[1]/employees[bool=doughnut]"); + cout << "Expected to fail!" << endl; + } + catch (SDORuntimeException e) + { + } + + try { + DataObjectPtr dob1 = dor->getDataObject("departments[4]/employees[bool=true]"); + cout << "Expected to fail!" << endl; + } + catch (SDORuntimeException e) + { + } + + try { + DataObjectPtr dob1 = dor->getDataObject("departments[1]/employees[bytes=whoomp!]"); + cout << "Expected to fail!" << endl; + } + catch (SDORuntimeException e) + { + } + + try { + DataObjectPtr dob1 = dor->getDataObject("departments[1]/blmployees[bool=true]"); + cout << "Expected to fail!" << endl; + } + catch (SDORuntimeException e) + { + } + + try { + DataObjectPtr dob1 = dor->getDataObject("departments[teapot]/employees[bool=true]"); + cout << "Expected to fail!" << endl; + } + + catch (SDORuntimeException e) + { + } + + delete bytes; + delete bytes2; + delete bytes3; + delete mbytes; + delete mbytes2; + delete mbytes3; +} + +void sdotest::setmany() +{ + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","School"); + mdg->addType("myspace","Class"); + mdg->addType("myspace","Teacher"); + mdg->addType("myspace","Child"); + mdg->addType("myspace","Address"); + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tint = mdg->getType("commonj.sdo","Integer"); + const Type& ts = mdg->getType("myspace","School"); + const Type& tc = mdg->getType("myspace","Class"); + const Type& tch = mdg->getType("myspace","Child"); + const Type& tt = mdg->getType("myspace","Teacher"); + const Type& ta = mdg->getType("myspace","Address"); + + mdg->addPropertyToType(tc,"name",tstring); + mdg->addPropertyToType(ts,"name",tstring); + mdg->addPropertyToType(tch,"name",tstring); + mdg->addPropertyToType(tt,"name",tstring); + + mdg->addPropertyToType(tc,"number",tint); + mdg->addPropertyToType(ts,"number",tint); + mdg->addPropertyToType(tch,"number",tint); + mdg->addPropertyToType(tt,"number",tint); + + mdg->addPropertyToType(ts,"classes", tc,true); + mdg->addPropertyToType(tc,"children", tch,true); + mdg->addPropertyToType(tc,"teacher", tt); + + mdg->addPropertyToType(tch,"address", ta); + mdg->addPropertyToType(ts,"address", ta); + mdg->addPropertyToType(tt,"address", ta); + + mdg->addPropertyToType(ta,"lines", tstring, true); + + DataObjectPtr school = mdg->create((Type&)ts); + + DataObjectPtr class1 = school->createDataObject("classes"); + DataObjectPtr class2 = school->createDataObject("classes"); + + DataObjectPtr teach1 = class1->createDataObject("teacher"); + + DataObjectPtr kid1 = class1->createDataObject("children"); + DataObjectPtr kid2 = class1->createDataObject("children"); + DataObjectPtr kid3 = class1->createDataObject("children"); + + DataObjectPtr teach2 = class2->createDataObject("teacher"); + + DataObjectPtr kid4 = class2->createDataObject("children"); + DataObjectPtr kid5 = class2->createDataObject("children"); + DataObjectPtr kid6 = class2->createDataObject("children"); + + school->setCString("name","King Norberts"); + school->createDataObject("address"); + school->setCString("address/lines.0","The Place"); + school->setCString("address/lines.1","1 The Avenue"); + school->setCString("address/lines.2","Murchester"); + school->setCString("address/lines.3","England"); + + class1->setCString("name","Primary"); + class2->setCString("name","Secondary"); + + class1->setCString("teacher/name","Mr Philbert Chloroform"); + class2->setCString("teacher/name","Mr Brian Onastick"); + + kid1->setCString("name", "Witherspoon Jnr"); + kid2->setCString("name", "Snape"); + kid3->setCString("name", "Thannet"); + kid4->setCString("name", "Grimbling"); + kid5->setCString("name", "Snagget Minor"); + kid6->setCString("name", "Van Den Bograt"); + + kid1->setInteger("number", 1); + kid2->setInteger("number", 2); + kid3->setInteger("number", 3); + kid4->setInteger("number", 4); + kid5->setInteger("number", 5); + kid6->setInteger("number", 6); + + cout <<" School :" << school->getCString("name") << endl; + + cout <<" Address1:" << school->getCString("address/lines.0") << endl; + cout <<" Address2:" << school->getCString("address/lines.1") << endl; + cout <<" Address3:" << school->getCString("address/lines.2") << endl; + cout <<" Address4:" << school->getCString("address/lines.3") << endl; + + cout <<" Class :" << class1->getCString("name") << endl; + cout <<" Teacher :" << class1->getCString("teacher/name") << endl; + cout <<" Pupil1 :" << class1->getCString("children.0/name") << endl; + cout <<" Pupil2 :" << class1->getCString("children[number=2]/name") << endl; + cout <<" Pupil3 :" << class1->getCString("children[3]/name") << endl; + + cout <<" Class :" << class2->getCString("name") << endl; + cout <<" Teacher :" << class2->getCString("teacher/name") << endl; + cout <<" Pupil1 :" << class2->getCString("children[1]/name") << endl; + cout <<" Pupil2 :" << class2->getCString("children.1/name") << endl; + cout <<" Pupil3 :" << class2->getCString("children[number=6]/name") << endl; + + try { + cout <<" Pupil3 :" << class2->getCString("children[4]/name") << endl; + cout << "That should have failed with a path not found" << endl; + } + catch (SDOPathNotFoundException e) + { + + } + if (XpathHelper::isIndexed("abc[2]")) { + cout << "Indexed as expected" << endl; + } + else { + cout << "Bad - not indexed" << endl; + } + + if (XpathHelper::isIndexed("wibble/[2]")) { + cout << "Indexed as expected" << endl; + } + else { + cout << "Bad - not indexed" << endl; + } + + if (XpathHelper::isIndexed("wibble/wobble[2]")) { + cout << "Indexed as expected" << endl; + } + else { + cout << "Bad - not indexed" << endl; + } + + if (XpathHelper::isIndexed("wibble/wobble.2")) { + cout << "Indexed as expected" << endl; + } + else { + cout << "Bad - not indexed" << endl; + } + + if (XpathHelper::isIndexed("wibble/wobble.2")) { + cout << "Indexed as expected" << endl; + } + else { + cout << "Bad - not indexed" << endl; + } + + try { + cout <<" Address5 :" << school->getCString("address/lines[5]") << endl; + cout << "Address5 should have failed with an index out of range" << endl; + } + catch (SDOIndexOutOfRangeException e) + { + + } + + try { + school->setCString("address/lines[6]","PostCode"); + cout << "Debatable behaviour - appended" << endl; + cout <<" Address4 :" << school->getCString("address/lines[5]") << endl; + } + catch (SDORuntimeException e) + { + cout <<"Unexpected exception"<< endl; + } + + +} + +void sdotest::carotest2() +{ + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","root"); + + mdg->addPropertyToType("myspace","root","cs", + "commonj.sdo","ChangeSummary", false, false, false); + + const Type& troot = mdg->getType("myspace","root"); + + DataObjectPtr root = mdg->create((Type&)troot); + +} + +void sdotest::adddeletetest() +{ + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","root"); + mdg->addType("myspace","bill"); + + mdg->addPropertyToType("myspace","root","cs", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addPropertyToType("myspace","root","bill", + "myspace","bill"); + + const Type& troot = mdg->getType("myspace","root"); + + DataObjectPtr root = mdg->create((Type&)troot); + + ChangeSummaryPtr cs = root->getChangeSummary(); + cs->beginLogging(); + DataObjectPtr dob = root->createDataObject("bill"); + root->unset("bill"); + +} + +void sdotest::carotest() +{ + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","root"); + mdg->addType("myspace","company"); + mdg->addType("myspace","department"); + mdg->addType("myspace","employee"); + + mdg->addPropertyToType("myspace","root","cs", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addPropertyToType("myspace","company","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","department","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","employee","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","root","companies", + "myspace","company", true, false, true); + + mdg->addPropertyToType("myspace","company","departments", + "myspace","department", true, false, true); + + mdg->addPropertyToType("myspace","company","eotm", + "myspace","employee", false, false, false); + + mdg->addPropertyToType("myspace","department","employees", + "myspace","employee", true, false, true); + + const Type& troot = mdg->getType("myspace","root"); + + + DataObjectPtr root = mdg->create((Type&)troot); + ChangeSummaryPtr cs = root->getChangeSummary(); + + cs->beginLogging(); + + DataObjectPtr comp = root->createDataObject("companies"); + + comp->setCString("name","Acme"); + + cout << "name of the company is " << comp->getCString("name") << endl; + try { + root->unset("companies[0]"); + } + catch (SDOUnsupportedOperationException e) + { + cout << "Normal unsupported operation for unset of many valued item" << endl; + } +} + + +void sdotest::bug2() +{ + + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","root"); + mdg->addType("myspace","company"); + + mdg->addPropertyToType("myspace","root","cs", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addPropertyToType("myspace","company","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","root","companies", + "myspace","company", true, false, true); + + + const Type& troot = mdg->getType("myspace","root"); + + + DataObjectPtr root = mdg->create((Type&)troot); + + ChangeSummaryPtr cs = root->getChangeSummary(); + + cs->beginLogging(); + + DataObjectPtr comp = root->createDataObject("companies"); + + comp->setCString("name","Acme"); + + dumpproperties(root); + + DataObjectList& dl = root->getList("companies"); + dl.remove(0); + + dumpproperties(root); + + + cout << "Change summary should have no entries..." << endl; + + dumpchangesummary(cs); + + dumpproperties(root); + + cout << "Change summary should have no entries..." << endl; + + dumpchangesummary(cs); + + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << " in "; + cout << e.getFileName() << " at line "; + cout << e.getLineNumber() << endl; + cout << e.getFunctionName() << " "; + cout << e.getMessageText() << endl; + } +} + + +void sdotest::dumpproperties(DataObjectPtr root) +{ + PropertyList pl = root->getInstanceProperties(); + for (int i=0;igetList(pl[i]); + if (pl[i].getType().isDataType()) + { + char buf[10]; + for (int j=0;jgetCString(pl[i]) << endl; + } + else + { + cout << "Object Property:" << pl[i].getName() << endl; + DataObjectPtr d = root->getDataObject(pl[i]); + if (d != 0) + { + dumpproperties(d); + } + else + { + cout << " Value was not set or null" << endl; + } + cout << "End of Object Property " << pl[i].getName() << endl; + } + } + } +} + + +void sdotest::datetest() +{ + + try { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","root"); + mdg->addType("myspace","company"); + + mdg->addPropertyToType("myspace","root","cs", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addPropertyToType("myspace","company","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","company","startupdate", + "commonj.sdo","Date", false, false, false); + + mdg->addPropertyToType("myspace","company","reviewdates", + "commonj.sdo","Date", true, false, false); + + + mdg->addPropertyToType("myspace","root","company", + "myspace","company", false, false, true); + + + + const Type& troot = mdg->getType("myspace","root"); + + + DataObjectPtr root = mdg->create((Type&)troot); + ChangeSummaryPtr cs = root->getChangeSummary(); + + cs->beginLogging(); + + DataObjectPtr comp = root->createDataObject("company"); + + + comp->setCString("name","DateTest"); + + cout << "name of the company is " << comp->getCString("name") << endl; + + // cannot get undefaulted properties + //cout << "unset start of the company is " << comp->getDate("startupdate").getTime() << endl; + + comp->setDate("startupdate",SDODate( 1000 )); + + cout << "set start of the company is " << comp->getDate("startupdate").getTime() << endl; + + DataObjectList& dol = comp->getList("reviewdates"); + + + dol.append(SDODate(2000)); + dol.append(SDODate(4000)); + + for (int i=0;i < dol.size(); i++) + { + cout << "Review number:" << i << " was:" << dol.getDate(i).getTime() << endl; + cout << "Formatted:" << i << " was:" << dol.getDate(i).ascTime() << endl; + } + + cs->endLogging(); + } + + catch (SDORuntimeException e) + { + cout << e.getEClassName() << " in "; + cout << e.getFileName() << " at line "; + cout << e.getLineNumber() << endl; + cout << e.getFunctionName() << " "; + cout << e.getMessageText() << endl; + } + +} + +void sdotest::matttest1() +{ + + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","root"); + mdg->addType("myspace","company"); + mdg->addType("myspace","department"); + mdg->addType("myspace","employee"); + + mdg->addPropertyToType("myspace","root","cs", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addPropertyToType("myspace","company","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","department","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","employee","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","root","companies", + "myspace","company", true, false, true); + + mdg->addPropertyToType("myspace","company","departments", + "myspace","department", true, false, true); + + mdg->addPropertyToType("myspace","company","eotm", + "myspace","employee", false, false, false); + + mdg->addPropertyToType("myspace","department","employees", + "myspace","employee", true, false, true); + + const Type& troot = mdg->getType("myspace","root"); + + + DataObjectPtr root = mdg->create((Type&)troot); + + DataObjectPtr comp = root->createDataObject("companies"); + + comp->setCString("name","Acme"); + + DataObjectPtr dept1 = comp->createDataObject("departments"); + + dept1->setCString("name","Shoe"); + + DataObjectPtr dept2 = comp->createDataObject("departments"); + + dept2->setCString("name","IT"); + + DataObjectPtr sue = dept1->createDataObject("employees"); + + sue->setCString("name","Sue"); + + DataObjectPtr billy = dept2->createDataObject("employees"); + + billy->setCString("name","Billy"); + + // Want to swap Sue and Billy so, while holding them in variables, should be + //able to unset from department then reinsert + + // method 1 - clear the lists... + dept1->unset("employees"); + dept2->unset("employees"); + + DataObjectPtr cont = billy->getContainer(); + + if (cont != 0) + { + cout << "Container of Billy should be zero, but is :" << cont->getCString("name") << endl; + } + else { + cout << "OK, - Billy is not contained." << endl; + } + + DataObjectList& li1 = dept1->getList("employees"); + DataObjectList& li2 = dept2->getList("employees"); + li1.append(billy); + li2.append(sue); + + DataObjectPtr cont2 = billy->getContainer(); + + if (cont2 != 0) + { + cout << "Container of Billy should be dept1, and is :" << cont2->getCString("name") << endl; + } + else { + cout << "Problem - Billy is not contained." << endl; + } + + li1.remove(0); + li2.remove(0); + + DataObjectPtr cont3 = billy->getContainer(); + + if (cont3 != 0) + { + cout << "Container of Billy should be zero, but is :" << cont3->getCString("name") << endl; + } + else { + cout << "OK, - Billy is not contained." << endl; + } + + + li1.append(sue); + li2.append(billy); + + DataObjectPtr cont4 = billy->getContainer(); + + if (cont4 != 0) + { + cout << "Container of Billy should be dept2, and is :" << cont4->getCString("name") << endl; + } + else { + cout << "Problem - Billy is not contained." << endl; + } + + } + catch (SDORuntimeException e) + { + cout << e.getEClassName() << " in "; + cout << e.getFileName() << " at line "; + cout << e.getLineNumber() << endl; + cout << e.getFunctionName() << " "; + cout << e.getMessageText() << endl; + } +} + +void sdotest::carotest3() +{ + // sequence new APIs + // data object list, new getLength(unsigned int) + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + // company is sequenced. + mdg->addType("myspace","Company",true,false); + + mdg->addType("myspace","Department",true,false); + // string is many + + mdg->addPropertyToType("myspace","Company","string","commonj.sdo","String", + true); + + mdg->addPropertyToType("myspace","Company","departments","myspace","Department", + true); + + mdg->addPropertyToType("myspace","Company","strings","commonj.sdo","String", + true); + + mdg->addPropertyToType("myspace","Company","integers","commonj.sdo","Integer", + true); + + + mdg->addPropertyToType("myspace","Department","name","commonj.sdo","String"); + + + const Type& tcc = mdg->getType("myspace","Company"); + + DataObjectPtr dor = mdg->create(tcc); + const Property& sprop = dor->getType().getProperty("string"); + + SequencePtr sptr = dor->getSequence(); + + printseq(sptr); + + sptr->addCString(sprop,"I am Item 1 of string"); + + printseq(sptr); + + sptr->addText("I am the first free text"); + + printseq(sptr); + + sptr->addCString(sprop,"I am Item 2 of string"); + + printseq(sptr); + + sptr->setText(1,"I am free text which has been modified"); + + printseq(sptr); + + DataObjectPtr dep1 = dor->createDataObject("departments"); + + printseq(sptr); + + dep1->setCString("name","department1"); + + printseq(sptr); + + DataObjectList& dol = dor->getList("departments"); + + unsigned int ii = dol.getLength(0); + + cout << "Length of a data object should be zero:" << ii << endl; + + DataObjectList& strl = dor->getList("strings"); + + wchar_t * buf = new wchar_t[5]; + buf[0] = 'a'; + buf[1] = 'b'; + buf[2] = 'c'; + buf[3] = 'd'; + buf[4] = 'e'; + + strl.append(buf,1); + strl.append(buf,2); + strl.append(buf,3); + strl.append(buf,4); + strl.append(buf,5); + + cout << "Element zero, length 1: " << strl.getLength(0) << endl; + cout << "Element one, length 2: " << strl.getLength(1) << endl; + cout << "Element two, length 3: " << strl.getLength(2) << endl; + cout << "Element three,length 4: " << strl.getLength(3) << endl; + cout << "Element four, length 5: " << strl.getLength(4) << endl; + + try { + cout << "Element five doesnt exist: " << strl.getLength(5); + } + catch (SDOIndexOutOfRangeException e) + { + cout << "Normal out of range exception in test" << endl; + } + + DataObjectList& numl = dor->getList("integers"); + + try { + cout << "On an empty list? " << numl.getLength(0); + } + catch (SDOIndexOutOfRangeException e) + { + cout << "Normal out of range exception in test" << endl; + } +} + + +int main (int argc, char** argv) +{ + Logger::setLogging(20); + + sdotest::b47293(); + + + sdotest::propdefaulttest(); + sdotest::graham5(); + sdotest::graham4(); + + sdotest::detachtest(); + sdotest::includetest(); + sdotest::testLoad(); + sdotest::leak(); + sdotest::twolists(); + sdotest::b46633(); + + sdotest::testUtil(); + + sdotest::clonetest(); + + sdotest::b46693(); + Logger::setLogging(0); +// sdotest::b46734(); + sdotest::notfound(); + sdotest::testErrors(); + + sdotest::b46634(); + sdotest::loadManyOpen(); + + sdotest::doctest(); + sdotest::b46617b(); + sdotest::b46617(); + sdotest::b46613(); + + sdotest::graham3(); + sdotest::graham1(); + sdotest::graham2(); + + + sdotest::merle1(); + sdotest::loadOpenNS(); + + sdotest::saveOpen(); + sdotest::loadOpen(); + sdotest::testui(); + sdotest::testOpen(); + sdotest::testSCA(); + sdotest::testabstract(); + + sdotest::testsubsload(); + sdotest::testsubs(); + sdotest::bug45933(); + sdotest::setnull(); + sdotest::bug2(); + sdotest::cssave2(); + sdotest::csload2(); + sdotest::cssave(); + sdotest::csload(); + sdotest::eqhelpertest(); + sdotest::cohelpertest(); + sdotest::datetest(); + sdotest::carotest3(); + sdotest::matttest1(); + sdotest::adddeletetest(); + sdotest::carotest2(); + sdotest::carotest(); + sdotest::setmany(); + sdotest::noncontest(); + sdotest::versiontest(); + sdotest::defaulttest(); + sdotest::nulltest(); + sdotest::usertest(); + sdotest::querytest(); + sdotest::getproptest(); + sdotest::rcptest(); + sdotest::seqtest(); + sdotest::changesummarytest(); + sdotest::conversiontest(); + sdotest::boolbug(); + sdotest::scope1(); + sdotest::scope2(); + sdotest::scope3(); + return sdotest::main(argc, argv); + /* All objects freed ? */ +return 0; +} + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest.h b/tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest.h new file mode 100644 index 0000000000..6f1b63de1b --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest.h @@ -0,0 +1,123 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + */ + +/* $Rev$ $Date: 2005/12/22 16:54:31 $ */ + +#include "commonj/sdo/SDO.h" +using namespace commonj::sdo; + +class sdotest { + public: + + + static void changeSummaryHeader(ChangeSummaryPtr cs); + static void changeSummaryFooter(); + static void changeSummaryChange(int level, ChangeSummaryPtr cs, DataObjectPtr dob); + static void changeSummaryDeletedObject(int indent, const char* name, ChangeSummaryPtr cs, DataObjectPtr dob); + static void changeSummaryElements(int indent, ChangeSummaryPtr cs, DataObjectPtr dob); + static void changeSummarySetting(Setting& s); + static bool changeSummaryAttributes(ChangeSummaryPtr cs, DataObjectPtr dol); + + static void b47293(); + static void propdefaulttest(); + static void showdefault(const Type& tm); + static void graham5(); + static void graham4(); + static void leak(); + static void twolists(); + static void printset(ChangeSummaryPtr cs); + static void detachtest(); + static void includetest(); + static void testLoad(); + static void b46633(); + static void clonetest(); + static void testUtil(); + static void testErrors(); + static void b46734(); + static void b46693(); + static void b46634(); + static void b46613(); + static void b46617(); + static void b46617b(); + static void doctest(); + static void notfound(); + + + static void serializeChangeSummary(ChangeSummaryPtr cs); + static void cssave(); + static void csload(); + static void cssave2(); + static void csload2(); + static void bug2(); + static void setnull(); + static void bug45933(); + static void testsubsload(); + static void testabstract(); + static void testsubs(); + static void testSCA(); + static void testOpen(); + static void saveOpen(); + static void loadOpen(); + static void testui(); + static void merle1(); + static void graham1(); + static void graham2(); + static void graham3(); + static void loadManyOpen(); + static void loadOpenNS(); + + + static void eqhelpertest(); + static void cohelpertest(); + static void datetest(); + static void matttest1(); + static void adddeletetest(); + static void carotest3(); + static void carotest2(); + static void carotest(); + static void setmany(); + static void noncontest(); + static void versiontest(); + static void defaulttest(); + static void querytest(); + static void getproptest(); + static void nulltest(); + static void usertest(); + static void rcptest(); + static void boolbug(); + static void scope1(); + static void scope2(); + static void scope3(); + static void conversiontest(); + static void changesummarytest(); + static void scenario1(); + static void scenario2(); + static void scenario3(); + static void scenario4(); + static void scenario5(); + static void printseq(SequencePtr sptr); + static void seqtest(); + static void printDataObject(DataObjectPtr dol); + static void printValue(DataObjectPtr dob, const Property& prop); + static void printList(DataObjectPtr dob, const Property& prop); + static void printOldValues(ChangeSummaryPtr cs, DataObjectPtr dob); + static void dumpchangesummary(ChangeSummaryPtr cs); + static void dumpproperties(DataObjectPtr root); + static void testGetters(DataObjectPtr dor); + static void testGetter(DataObjectPtr dor, char* str); + static int main(int argc, char** argv); +}; \ No newline at end of file diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest2.cpp b/tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest2.cpp new file mode 100644 index 0000000000..9f547af4eb --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/sdotest2.cpp @@ -0,0 +1,3937 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + */ + +/* $Rev$ $Date: 2005/12/22 16:54:31 $ */ + +#include + +#pragma warning(disable:4786) + +#include +using namespace std; + +// #include "TypeImpl.h" + +#include "sdotest.h" + + + +using namespace commonj::sdo; + +void sdotest::eqhelpertest() +{ + + // copy and equality helpers + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Assembly"); + mdg->addType("myspace","SubAssembly"); + mdg->addType("myspace","Part"); + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tint = mdg->getType("commonj.sdo","Integer"); + const Type& tassy = mdg->getType("myspace","Assembly"); + const Type& tsubassy = mdg->getType("myspace","SubAssembly"); + const Type& tpart = mdg->getType("myspace","Part"); + + + mdg->addPropertyToType(tassy,"name",tstring); + mdg->addPropertyToType(tsubassy,"name",tstring); + mdg->addPropertyToType(tpart,"name",tstring); + + mdg->addPropertyToType(tassy,"number",tint); + mdg->addPropertyToType(tsubassy,"number",tint); + mdg->addPropertyToType(tpart,"number",tint); + + mdg->addPropertyToType(tassy,"subassemblies", tsubassy,true); + mdg->addPropertyToType(tsubassy,"parts", tpart,true); + + + // assy 1 + + DataObjectPtr assy1 = mdg->create((Type&)tassy); + + DataObjectPtr subassy1 = assy1->createDataObject("subassemblies"); + DataObjectPtr subassy2 = assy1->createDataObject("subassemblies"); + + DataObjectPtr part1 = subassy1->createDataObject("parts"); + DataObjectPtr part2 = subassy1->createDataObject("parts"); + DataObjectPtr part3 = subassy1->createDataObject("parts"); + + DataObjectPtr part4 = subassy2->createDataObject("parts"); + DataObjectPtr part5 = subassy2->createDataObject("parts"); + DataObjectPtr part6 = subassy2->createDataObject("parts"); + + + assy1->setCString("name","MicroFrame"); + assy1->setInteger("number",32768); + + subassy1->setCString("name","Legs"); + subassy2->setCString("name","Body"); + subassy1->setInteger("number",1); + subassy2->setInteger("number",2); + + part1->setCString("name","Leg1"); + part2->setCString("name","Leg2"); + part3->setCString("name","Leg3"); + part1->setInteger("number",10001); + part2->setInteger("number",10002); + part3->setInteger("number",10003); + + + part4->setCString("name","MainStrut"); + part5->setCString("name","Brace1"); + part6->setCString("name","Brace2"); + part4->setInteger("number",20001); + part5->setInteger("number",20002); + part6->setInteger("number",20003); + + // assy2 - shallow equal to assy, but not deep equal + + DataObjectPtr assy2 = mdg->create((Type&)tassy); + + DataObjectPtr subassy3 = assy2->createDataObject("subassemblies"); + DataObjectPtr subassy4 = assy2->createDataObject("subassemblies"); + + DataObjectPtr part7 = subassy3->createDataObject("parts"); + DataObjectPtr part8 = subassy3->createDataObject("parts"); + DataObjectPtr part9 = subassy3->createDataObject("parts"); + + DataObjectPtr part10 = subassy4->createDataObject("parts"); + DataObjectPtr part11 = subassy4->createDataObject("parts"); + DataObjectPtr part12 = subassy4->createDataObject("parts"); + + + assy2->setCString("name","MicroFrame"); + assy2->setInteger("number",32768); + + subassy3->setCString("name","Legs"); + subassy4->setCString("name","Body"); + subassy3->setInteger("number",1); + subassy4->setInteger("number",2); + + part7->setCString("name","Leg1"); + part8->setCString("name","Leg2"); + part9->setCString("name","Leg3"); + part7->setInteger("number",10001); + part8->setInteger("number",10002); + part9->setInteger("number",10003); + + + part10->setCString("name","MainStrut"); + part11->setCString("name","Brace1"); + part12->setCString("name","OddBrace2"); + part10->setInteger("number",20001); + part11->setInteger("number",20002); + part12->setInteger("number",20003); + + if (!EqualityHelper::equalShallow(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at first test" << endl; + } + else + { + cout << "Equality Helper test 1 passed" << endl; + } + if (EqualityHelper::equal(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at second test" << endl; + } + else + { + cout << "Equality Helper test 2 passed" << endl; + } + + // Now alter assy2 to be deep equal... + + + part12->setCString("name","Brace2"); + + if (!EqualityHelper::equalShallow(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at third test" << endl; + } + else + { + cout << "Equality Helper test 3 passed" << endl; + } + if (!EqualityHelper::equal(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at fourth test" << endl; + } + else + { + cout << "Equality Helper test 4 passed" << endl; + } + + // now add a part, so its not deep equal again + DataObjectPtr part13 = subassy4->createDataObject("parts"); + + if (!EqualityHelper::equalShallow(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at fifth test" << endl; + } + else + { + cout << "Equality Helper test 5 passed" << endl; + } + if (EqualityHelper::equal(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at sixth test" << endl; + } + else + { + cout << "Equality Helper test 6 passed" << endl; + } + + // now remove that part again... + DataObjectList& dl = subassy4->getList("parts"); + dl.remove(3); + + // should be deep equal again... + + if (!EqualityHelper::equalShallow(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at seventh test" << endl; + } + else + { + cout << "Equality Helper test 7 passed" << endl; + } + if (!EqualityHelper::equal(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at eighth test" << endl; + } + else + { + cout << "Equality Helper test 8 passed" << endl; + } + // now make them not shallow equal + assy2->setInteger("number",32767); + + if (EqualityHelper::equalShallow(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at nineth test" << endl; + } + else + { + cout << "Equality Helper test 9 passed" << endl; + } + if (EqualityHelper::equal(assy1, assy2)) + { + cout << "EQUALITY HELPER TEST - failure at tenth test" << endl; + } + else + { + cout << "Equality Helper test 10 passed" << endl; + } + +} + +void sdotest::cohelpertest() +{ + + // copy and equality helpers + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Assembly"); + mdg->addType("myspace","SubAssembly"); + mdg->addType("myspace","Part"); + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tint = mdg->getType("commonj.sdo","Integer"); + const Type& tassy = mdg->getType("myspace","Assembly"); + const Type& tsubassy = mdg->getType("myspace","SubAssembly"); + const Type& tpart = mdg->getType("myspace","Part"); + + + mdg->addPropertyToType(tassy,"name",tstring); + mdg->addPropertyToType(tsubassy,"name",tstring); + mdg->addPropertyToType(tpart,"name",tstring); + + mdg->addPropertyToType(tassy,"number",tint); + mdg->addPropertyToType(tsubassy,"number",tint); + mdg->addPropertyToType(tpart,"number",tint); + + mdg->addPropertyToType(tassy,"subassemblies", tsubassy,true); + mdg->addPropertyToType(tsubassy,"parts", tpart,true); + + + // assy 1 + + DataObjectPtr assy1 = mdg->create((Type&)tassy); + + DataObjectPtr subassy1 = assy1->createDataObject("subassemblies"); + DataObjectPtr subassy2 = assy1->createDataObject("subassemblies"); + + DataObjectPtr part1 = subassy1->createDataObject("parts"); + DataObjectPtr part2 = subassy1->createDataObject("parts"); + DataObjectPtr part3 = subassy1->createDataObject("parts"); + + DataObjectPtr part4 = subassy2->createDataObject("parts"); + DataObjectPtr part5 = subassy2->createDataObject("parts"); + DataObjectPtr part6 = subassy2->createDataObject("parts"); + + + assy1->setCString("name","MicroFrame"); + assy1->setInteger("number",32768); + + subassy1->setCString("name","Legs"); + subassy2->setCString("name","Body"); + subassy1->setInteger("number",1); + subassy2->setInteger("number",2); + + part1->setCString("name","Leg1"); + part2->setCString("name","Leg2"); + part3->setCString("name","Leg3"); + part1->setInteger("number",10001); + part2->setInteger("number",10002); + part3->setInteger("number",10003); + + + part4->setCString("name","MainStrut"); + part5->setCString("name","Brace1"); + part6->setCString("name","Brace2"); + part4->setInteger("number",20001); + part5->setInteger("number",20002); + part6->setInteger("number",20003); + + // first lets shallow copy assy1: + + DataObjectPtr assy2 = CopyHelper::copyShallow(assy1); + + if (strcmp(assy2->getCString("name"),"MicroFrame")) + { + cout << "COPYHELPER shallow copy failed(1)" << endl; + } + else if (assy2->getInteger("number") != 32768) + { + cout << "COPYHELPER shallow copy 1 failed(2)" << endl; + } + else if (assy2->getList("subassemblies").size() != 0) + { + cout << "COPYHELPER shallow copy 1 failed(3)" << endl; + } + else if (assy2->getContainer() != 0) + { + cout << "COPYHELPER shallow copy failed(4)" << endl; + } + else + { + cout << "CopyHelper test1 passed" << endl; + } + + // now deep copy it + + DataObjectPtr assy3 = CopyHelper::copy(assy1); + + if (!EqualityHelper::equal(assy1, assy3)) + { + cout << "COPYHELPER deep copy failed(1)" << endl; + } + else if (assy3->getContainer() != 0) + { + cout << "COPYHELPER deep copy failed(2)" << endl; + } + else + { + cout << "CopyHelper test 2 passed" << endl; + } + +} + + +///////////////////////////////////////////////////////////////////////////// +///test code for serialization........... +///////////////////////////////////////////////////////////////////////////// +// +//bool sdotest::serializeOldSingleValues(int indent, ChangeSummaryPtr cs, DataObjectPtr dol) +//{ +// bool onlySingle = true; +// SettingList& sl = cs->getOldValues(dol); +// if (sl.size() == 0) +// { +// return onlySingle; +// } +// +// for (int k=0;kisDeleted(dob)) +// { +// cout << "\"" << cs->getOldXpath(dob) << "\""; +// } +// else +// { +// cout << "\"" << dob->objectToXPath() << "\""; +// } +// } +// } +// break; +// default: +// { +// } +// break; +// } +// } +// return onlySingle; +//} +// +// +// +// +//void sdotest::serializeOldManyValues(int indent, ChangeSummaryPtr cs, DataObjectPtr dol) +//{ +// SettingList& sl = cs->getOldValues(dol); +// if (sl.size() == 0) +// { +// return; +// } +// for (int j=0;j< sl.size(); j++) +// { +// if (!sl[j].getProperty().isMany()) continue; +// +// for (int k=0;kisDeleted(dob)) +// { +// // TODO +// cout << " sdo:ref=\"" << "deleted" << "\""; +// } +// else +// { +// cout << " sdo:ref=\"" << dob->objectToXPath() << "\""; +// } +// } +// } +// break; +// default: +// { +// } +// break; +// } // switch +// cout << "/>" << endl; +// } // for +//} +// +// +// +//void sdotest::serializechangesummary(ChangeSummaryPtr cs) +//{ +// changeSummaryHeader(cs); +// +// ChangedDataObjectList& cdol = cs->getChangedDataObjects(); +// +// for (i=0;i< cdol.size();i++) +// { +// if (cs->isModified(cdol[i])) +// { +// changeSummaryChange(cs,cdol[i]); +// } +// } +// +// changeSummaryFooter(); +// +//} +// +/////////////////////////////////////////////////////////////////////////////// +/////end code for serialization........... +/////////////////////////////////////////////////////////////////////////////// +// +// + + +bool sdotest::changeSummaryAttributes(ChangeSummaryPtr cs, DataObjectPtr dol) +{ + bool onlySingle = true; + SettingList& sl = cs->getOldValues(dol); + if (sl.size() == 0) + { + return onlySingle; + } + + for (int j=0;j< sl.size(); j++) + { + if (sl[j].getProperty().isMany()) + { + onlySingle = false; + continue; + } + + cout << " " << sl[j].getProperty().getName() << "=\""; + + if (sl[j].getProperty().getType().isDataType()) + { + changeSummarySetting(sl[j]); + } + else + { + DataObjectPtr dob = sl[j].getDataObjectValue(); + if (dob) + { + if (cs->isDeleted(dob)) + { + cout << cs->getOldXpath(dob); + } + else + { + cout << dob->objectToXPath(); + } + } + } + cout << "\" "; + } + return onlySingle; +} + + +void sdotest::changeSummarySetting(Setting& s) +{ + + switch (s.getProperty().getTypeEnum()) + { + case Type::BooleanType: + cout << s.getCStringValue(); + break; + case Type::ByteType: + cout << s.getByteValue(); + break; + case Type::CharacterType: + cout << s.getCharacterValue(); + break; + case Type::IntegerType: + cout << s.getIntegerValue(); + break; + case Type::ShortType: + cout << s.getShortValue(); + break; + case Type::DoubleType: + cout << s.getDoubleValue(); + break; + case Type::FloatType: + cout << s.getFloatValue(); + break; + case Type::LongType: + cout << s.getIntegerValue(); + break; + case Type::DateType: + cout << s.getDateValue().getTime(); + break; + case Type::BigDecimalType: + case Type::BigIntegerType: + case Type::StringType: + case Type::UriType: + cout << s.getCStringValue(); + break; + case Type::BytesType: + cout << s.getCStringValue(); + break; + default: + break; + } // switch +} + + +void sdotest::changeSummaryElements(int indent, ChangeSummaryPtr cs, DataObjectPtr dob) +{ + SettingList& sl = cs->getOldValues(dob); + + if (sl.size() == 0) + { + // there are no setting for this element. + return; + } + + for (int j=0;j< sl.size(); j++) + { + // single values will have been covered by the attributes. + if (!sl[j].getProperty().isMany()) continue; + + if (sl[j].getProperty().getType().isDataType()) + { + + // indent the line + for (int k=0;k\""; + + changeSummarySetting(sl[j]); + + cout << "\"" << endl; + } // if datatype + else + { + DataObjectPtr dob2 = sl[j].getDataObjectValue(); + if (!dob2) + { + return; + } + if (cs->isDeleted(dob2)) + { + changeSummaryDeletedObject(indent,sl[j].getProperty().getName(), cs,dob2); + } + else + { + // indent the line + for (int k=0;kobjectToXPath() << "\"/>" << endl; + } + } + } // for +} + + + +void sdotest::changeSummaryDeletedObject(int indent, const char* name, ChangeSummaryPtr cs, DataObjectPtr dob) +{ + + bool elements = false; // are there any elements to process? + int ind; + + // indent the line + for (ind=0;indgetOldValues(dob); + + if (sl.size() == 0) + { + // there are no setting for this element. + cout << "/>"; + return; + } + + cout << " "; + + // print single valued datatypes as attributes + + for (int j=0;j< sl.size(); j++) + { + // single values will have been covered by the attributes. + if ( sl[j].getProperty().isMany()) + { + elements = true; + continue; + } + if (!sl[j].getProperty().getType().isDataType()) + { + elements = true; + continue; + } + + cout << sl[j].getProperty().getName() << "=\""; + + changeSummarySetting(sl[j]); + + cout << "\" "; + } // for attributes + + if (!elements) + { + cout << "/>" << endl; + return; + } + + // now we are onto the many-values, and dataobject single values. + for (int k=0;k< sl.size(); k++) + { + if ( !sl[k].getProperty().getType().isDataType()) + { + // its a dataobject type + DataObjectPtr dob2 = sl[k].getDataObjectValue(); + if (!dob2) continue; + if (!cs->isDeleted(dob2)) continue; + changeSummaryDeletedObject(indent+1,sl[k].getProperty().getName(),cs,dob2); + } + else + { + // could only be many valued data type + + for (ind=0;ind\""; + + changeSummarySetting(sl[k]); + + cout << "" << endl; + } + } // for attributes + + // indent the line + for (ind=0;ind" << endl; +} + + + +void sdotest::changeSummaryHeader(ChangeSummaryPtr cs) +{ + int i; + + ChangedDataObjectList& cdol = cs->getChangedDataObjects(); + + cout << "isLogging()) + { + cout << " logging=\"true\" "; + } + + cout << ">" << endl; + + + for (i=0;i< cdol.size();i++) + { + if (cs->isCreated(cdol[i]) && cdol.getType(i) == ChangedDataObjectList::Change) + { + cout << " "; + // TODO is there an IDREF for this created/deleted object? + DataObject* temp = cdol[i]; + cout << ((DataObject*)temp)->objectToXPath(); + cout << "" << endl; + } + if (cs->isDeleted(cdol[i]) && cdol.getType(i) == ChangedDataObjectList::Delete) + { + cout << " "; + // TODO is there an IDREF for this created/deleted object? + const char* path = cs->getOldXpath(cdol[i]); + if (path != 0) + { + cout << path; + } + cout << "" << endl; + } + } +} + +void sdotest::changeSummaryFooter() +{ + cout << "" << endl; +} + + +void sdotest::changeSummaryChange(int level, ChangeSummaryPtr cs, DataObjectPtr dob) +{ + DataObject* temp = dob; + + // indent by level. + for (int l=0;lgetContainmentProperty().getName(); + } + catch (SDORuntimeException e) + { + // the object which was changed has no name, + // so its the root object of a data object tree. + cout << "root"; + } + + cout << " "; + + try + { + cout << "sdo:ref=\"" << temp->objectToXPath() << "\" "; + } + catch (SDORuntimeException e) + { + // TODO there was no xpath - thats not good + } + + // returns true if there were only single values - attributes only. + if (changeSummaryAttributes(cs, temp)) + { + cout << "/>" << endl; + return; + } + + // there are some elements + cout << ">" << endl; + + + changeSummaryElements(level+1, cs, temp); + + + // indent by level. + + for (int m=0;mgetContainmentProperty().getName(); + } + catch (SDORuntimeException e) + { + // the object which was changed has no name, + // so its the root object of a data object tree. + cout << "root"; + } + + cout << ">" << endl; + +} + + + +void sdotest::serializeChangeSummary(ChangeSummaryPtr cs) +{ + changeSummaryHeader(cs); + + ChangedDataObjectList& cdol = cs->getChangedDataObjects(); + + for (int i=0;i< cdol.size();i++) + { + if (cs->isModified(cdol[i])) + { + changeSummaryChange(1, cs,cdol[i]); + } + } + + changeSummaryFooter(); +} + + +void sdotest::cssave() +{ + + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("company.xsd"); + + //mdg->addType("companyNS","CompanyType"); + //mdg->addType("companyNS","EmployeeType"); + //mdg->addType("companyNS","DepartmentType"); + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& tdept = mdg->getType("companyNS","DepartmentType"); + const Type& temp = mdg->getType("companyNS","EmployeeType"); + + + //mdg->addPropertyToType(tcomp,"name",tstring); + // not containment... + //mdg->addPropertyToType(tcomp,"employeeOfTheMonth",temp, false,false,false); + //mdg->addPropertyToType(tcomp,"departments",tdept, true); + //mdg->addPropertyToType(tcomp,"cs",tcs); + + //mdg->addPropertyToType(tdept,"name",tstring); + //mdg->addPropertyToType(tdept,"location",tstring); + //mdg->addPropertyToType(tdept,"number",tstring); + //mdg->addPropertyToType(tdept,"employees",temp,true); + + //mdg->addPropertyToType(temp, "name",tstring); + //mdg->addPropertyToType(temp, "SN", tstring); + //mdg->addPropertyToType(temp, "manager", tbool); + + + // create a graph, then save it + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","ACME"); + + DataObjectPtr dept = mdg->create((Type&)tdept); + DataObjectList& dol = comp->getList("departments"); + dol.append(dept); + + dept->setCString("name","Advanced Technologies"); + dept->setCString("location","NY"); + dept->setCString("number","123"); + + DataObjectPtr emp1 = mdg->create(temp); + DataObjectPtr emp2 = mdg->create(temp); + DataObjectPtr emp3 = mdg->create(temp); + + emp1->setCString("name","John Jones"); + emp1->setCString("SN","E0001"); + + emp2->setCString("name","Mary Smith"); + emp2->setCString("SN","E0002"); + emp2->setBoolean("manager",true); + + emp3->setCString("name","Jane Doe"); + emp3->setCString("SN","E0003"); + + DataObjectList& dol2 = dept->getList("employees"); + dol2.append(emp1); + dol2.append(emp2); + dol2.append(emp3); + + comp->setDataObject("employeeOfTheMonth",emp2); + + ChangeSummaryPtr cs = comp->getChangeSummary(); + + cs->beginLogging(); + + DataObjectPtr emp4 = mdg->create(temp); + emp4->setCString("name","Al Smith"); + emp4->setCString("SN","E0004"); + emp4->setBoolean("manager",true); + + // first change - create employee 4 + dol2.append(emp4); + + dol2.remove(1); // element 1 is Mary + + DataObjectPtr emp5 = mdg->create(temp); + emp5->setCString("name","Bill Withers"); + emp5->setCString("SN","E0005"); + + dol2.append(emp5); + + + comp->setCString("name","MegaCorp"); + comp->setDataObject("employeeOfTheMonth",emp4); + + // silly test - add mary back again + dol2.append(emp2); + + // and why not delete her again? + //dol2.remove(4); + + + + cs->endLogging(); + + //serializeChangeSummary(cs); + + XMLHelperPtr xmh = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr doc = xmh->createDocument(comp,"companyNS","company"); + xmh->save(doc,"cssave-output.xml"); + } + catch (SDORuntimeException e) + { + cout << "CSSAVE FAILED" << e << endl; + } +} + +void sdotest::cssave2() +{ + + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("company.xsd"); + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& tdept = mdg->getType("companyNS","DepartmentType"); + const Type& temp = mdg->getType("companyNS","EmployeeType"); + + + // create a graph, then save it + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","Eastleigh Borough Council"); + + DataObjectPtr dept = mdg->create((Type&)tdept); + DataObjectList& dol = comp->getList("departments"); + dol.append(dept); + + dept->setCString("name","Waste Disposal"); + dept->setCString("location","Botley"); + dept->setCString("number","123"); + + DataObjectPtr emp1 = mdg->create(temp); + DataObjectPtr emp2 = mdg->create(temp); + DataObjectPtr emp3 = mdg->create(temp); + DataObjectPtr emp4 = mdg->create(temp); + DataObjectPtr emp5 = mdg->create(temp); + + emp1->setCString("name","Alphonse Dodet"); + emp1->setCString("SN","E0001"); + + emp2->setCString("name","Bridget Jones"); + emp2->setCString("SN","E0002"); + emp2->setBoolean("manager",true); + + emp3->setCString("name","Colin Thorne"); + emp3->setCString("SN","E0003"); + + emp4->setCString("name","Donald Trump"); + emp4->setCString("SN","E0004"); + + emp5->setCString("name","Eddy the eagle"); + emp5->setCString("SN","E0005"); + + DataObjectList& dol2 = dept->getList("employees"); + dol2.append(emp1); + dol2.append(emp2); + dol2.append(emp3); + dol2.append(emp4); + dol2.append(emp5); + + //comp->setDataObject("employeeOfTheMonth",emp2); + + DataObjectPtr dept2 = mdg->create((Type&)tdept); + dol.append(dept2); + + dept2->setCString("name","Tax Collection"); + dept2->setCString("location","Winchester"); + dept2->setCString("number","666"); + + DataObjectPtr empb1 = mdg->create(temp); + DataObjectPtr empb2 = mdg->create(temp); + DataObjectPtr empb3 = mdg->create(temp); + DataObjectPtr empb4 = mdg->create(temp); + DataObjectPtr empb5 = mdg->create(temp); + + empb1->setCString("name","Arch Meanie"); + empb1->setCString("SN","D0001"); + + empb2->setCString("name","Boris the Spider"); + empb2->setCString("SN","D0002"); + empb2->setBoolean("manager",true); + + empb3->setCString("name","Cash Hoarder"); + empb3->setCString("SN","D0003"); + + empb4->setCString("name","Dean Giyatoss"); + empb4->setCString("SN","D0004"); + + empb5->setCString("name","Ebenezer Scrooge"); + empb5->setCString("SN","D0005"); + + DataObjectList& dol3 = dept2->getList("employees"); + dol3.append(empb1); + dol3.append(empb2); + dol3.append(empb3); + dol3.append(empb4); + dol3.append(empb5); + + ChangeSummaryPtr cs = comp->getChangeSummary(); + + cs->beginLogging(); + + // start by deleting a few employees from dept 1 + + dol2.remove(1); // B + dol2.remove(1); // C + dol2.remove(1); // D + + // Now delete the tax collectors as a whole + + dol.remove(1); + + // now perhaps add back one of the employees + + dol2.append(emp3); // C + + comp->setCString("name","MegaCorp"); + + try { + comp->setDataObject("employeeOfTheMonth",emp4); + cout << "THIS ISNT RIGHT - emp4 was nolt in the tree" << endl; + } + catch (SDORuntimeException e) + { + } + + comp->setDataObject("employeeOfTheMonth",emp5); + + cs->endLogging(); + + + XMLHelperPtr xmh = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr doc = xmh->createDocument(comp,"companyNS","company"); + xmh->save(doc,"cssave2-output.xml"); + } + catch (SDORuntimeException e) + { + cout << "CSSAVE FAILED" << e << endl; + } +} + +void sdotest::bug45933() +{ + + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + + mdg->addType("companyNS","CompanyType"); + mdg->addType("companyNS","WombatType"); + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& twom = mdg->getType("companyNS","WombatType"); + + + mdg->addPropertyToType(tcomp,"name",tstring); + mdg->addPropertyToType(tcomp,"bools",tbool, true); + mdg->addPropertyToType(tcomp,"woms",twom, true); + mdg->addPropertyToType(tcomp,"cs",tcs); + + + // create a graph, then save it + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","Bug45933"); + + ChangeSummaryPtr cs = comp->getChangeSummary(); + + cs->beginLogging(); + + DataObjectList& dol = comp->getList("bools"); + dol.append(false); + dol.remove(0); + DataObjectPtr awom = mdg->create((Type&)twom); + DataObjectList& dol2 = comp->getList("woms"); + dol2.append(awom); + dol2.remove(0); + + cs->endLogging(); + + dumpchangesummary(cs); + + XMLHelperPtr xmh = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr doc = xmh->createDocument(comp,"companyNS","company"); + xmh->save(doc,"bug45933-output.xml"); + } + catch (SDORuntimeException e) + { + cout << "BUG45933 FAILED" << endl << e << endl; + } +} + +void sdotest::b46617() +{ + + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + //XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + //xsh->defineFile("b46617.xsd"); + mdg->addType("companyNS","CompanyType"); + mdg->addType("companyNS","DepartmentType"); + mdg->addType("companyNS","EmployeeType"); + + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& tdept = mdg->getType("companyNS","DepartmentType"); + const Type& temp = mdg->getType("companyNS","EmployeeType"); + + mdg->addPropertyToType(tcomp,"name",tstring); + mdg->addPropertyToType(tcomp,"departments",tdept,true,false,true); + mdg->addPropertyToType(tcomp,"employeeOfTheMonth",temp,false,false,false); + mdg->addPropertyToType(tcomp,"CEO",temp,false,false,true); + + mdg->addPropertyToType(tdept,"employees",temp,true,false,true); + mdg->addPropertyToType(tdept,"name",tstring,false,false,true); + mdg->addPropertyToType(tdept,"location",tstring,false,false,true); + mdg->addPropertyToType(tdept,"number",tstring,false,false,true); + + mdg->addPropertyToType(temp,"name",tstring,false,false,true); + mdg->addPropertyToType(temp,"SN",tstring,false,false,true); + mdg->addPropertyToType(temp,"manager",tbool,false,false,true); + + // create a graph, then save it + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","Eastleigh Borough Council"); + + DataObjectPtr dept = mdg->create((Type&)tdept); + DataObjectList& dol = comp->getList("departments"); + dol.append(dept); + + dept->setCString("name","Waste Disposal"); + dept->setCString("location","Botley"); + dept->setCString("number","123"); + + DataObjectPtr emp1 = mdg->create(temp); + DataObjectPtr emp2 = mdg->create(temp); + DataObjectPtr emp3 = mdg->create(temp); + + emp1->setCString("name","Alphonse Dodet"); + emp1->setCString("SN","E0001"); + + emp2->setCString("name","Bridget Jones"); + emp2->setCString("SN","E0002"); + emp2->setBoolean("manager",true); + + emp3->setCString("name","Carl Marx"); + emp3->setCString("SN","E0003"); + + comp->setDataObject("CEO",emp2); + + DataObjectList& dol2 = dept->getList("employees"); + dol2.append(emp1); + //dol2.append(emp2); + dol2.append(emp3); + + comp->setDataObject("employeeOfTheMonth",emp2); + + XSDHelperPtr xmd = HelperProvider::getXSDHelper(mdg); + xmd->generateFile(mdg->getTypes(), + "b46617.xsd","companyNS"); + + + XMLHelperPtr xmh = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr doc = xmh->createDocument(comp,"companyNS","company"); + xmh->save(doc,"b46617.xml"); + + // now try loading the xml, using the same schema, and see if we get the + // same answer + + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("b46617.xml", "companyNS"); + DataObjectPtr newdob = myXMLDocument->getRootDataObject(); + + cout << "EOMS name is " + << newdob->getDataObject("employeeOfTheMonth")->getCString("name") + << endl; + + + } + catch (SDORuntimeException e) + { + cout << "b46617 failed" << e << endl; + } +} + +void sdotest::b46617b() +{ + + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("b46617b.xsd"); + + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("b46617b.xml", "companyNS"); + DataObjectPtr newdob = myXMLDocument->getRootDataObject(); + + cout << "EOMS name is " + << newdob->getDataObject("employeeOfTheMonth")->getCString("name") + << endl; + + + } + catch (SDORuntimeException e) + { + cout << "b46617b failed" << e << endl; + } +} + +void sdotest::notfound() +{ + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + try { + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("not_present.xsd"); + } + catch (SDOFileNotFoundException e) + { + cout << "NotFound threw correct exception " << endl; + } + + catch (SDORuntimeException e) + { + cout << "NOTFOUND THREW THE WRONG EXCEPTION" << e << endl; + } + + try { + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("not-present.xml", "companyNS"); + + } + catch (SDOFileNotFoundException ee) + { + cout << "NotFound threw the correct exception" << endl; + } + + catch (SDORuntimeException e) + { + cout << "NOTFOUND THREW THE WRONG EXCEPTION" << e << endl; + } +} + +void sdotest::csload() +{ + try + { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("company.xsd"); + + cout << "TYPES LOADED FROM COMPANY XSD" << endl; + + TypeList tl = mdg->getTypes(); + for (int i=0;i< tl.size(); i++) + { + cout << tl[i].getURI() << ":" << tl[i].getName() << endl; + } + + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("cssave-output.xml", "companyNS"); + //myXMLDocument->setRootElementName("company"); + //myXMLHelper->save(myXMLDocument,"csload-output.xml"); + myXMLHelper->save(myXMLDocument->getRootDataObject(), + 0, "company", "csload-output.xml"); + } + catch (SDORuntimeException e) + { + cout << "CSLOAD FAILED" << e << endl; + } + +} + +void sdotest::testsubsload() +{ + cout << "TEST: TestSubsLoad ==========================================" << endl; + try + { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("companysubs.xsd"); + + //cout << "TYPES LOADED FROM COMPANYSUBS XSD" << endl; + + //TypeList tl = mdg->getTypes(); + //for (int i=0;i< tl.size(); i++) + //{ + // cout << tl[i].getURI() << ":" << tl[i].getName() << endl; + //} + + // so now we should be able to put book or a magazine into + // the publication under company... + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& book = mdg->getType("companyNS","BookType"); + const Type& mag = mdg->getType("companyNS","MagazineType"); + const Type& pub = mdg->getType("companyNS","PublicationType"); + + + // create a graph, then save it + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","Puflet Publishing"); + + + DataObjectPtr book1 = mdg->create(book); + book1->setCString("author","Mr P B Writer"); + // inherted from publication + book1->setCString("title","Nowhere Man"); + + DataObjectPtr mag1 = mdg->create(mag); + mag1->setCString("editor","Mr B Picky"); + // inherited from publication + mag1->setCString("title","Bionicle Weekly"); + + DataObjectPtr pub1 = mdg->create(pub); + pub1->setCString("title","Noddy In Toyland"); + + + // publication should accept any of them... + + comp->setDataObject("Publication",pub1); + const Type& tpub1 = comp->getDataObject("Publication")->getType(); + cout << "Publication is of type " << tpub1.getName() << endl; + + comp->setDataObject("Publication",book1); + const Type& tpub2 = comp->getDataObject("Publication")->getType(); + cout << "Publication is of type " << tpub2.getName() << endl; + + comp->setDataObject("Publication",mag1); + const Type& tpub3 = comp->getDataObject("Publication")->getType(); + cout << "Publication is of type " << tpub3.getName() << endl; + + // should be able to address publication as book or magazine + + comp->setDataObject("Book",book1); + const Type& tpub4 = comp->getDataObject("Book")->getType(); + cout << "Book is of type " << tpub4.getName() << endl; + + comp->setDataObject("Magazine",mag1); + const Type& tpub5 = comp->getDataObject("Magazine")->getType(); + cout << "Magazine is of type " << tpub5.getName() << endl; + + } + catch (SDORuntimeException e) + { + cout << "ERROR in TeseSubsLoad" << e << endl; + } + cout << "END TEST: TestSubsLoad ======================================" << endl; +} + +void sdotest::testSCA() +{ + cout << "TEST: TestSCA ==========================================" << endl; + try + { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("sca.xsd"); + + } + catch (SDORuntimeException e) + { + cout << "ERROR in TeseSCA" << e << endl; + } + cout << "END TEST: TestSCA ======================================" << endl; +} + +void sdotest::testabstract() +{ + cout << "TEST: TestAbstract ==========================================" << endl; + try + { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("companyabs.xsd"); + + //cout << "TYPES LOADED FROM COMPANYABS XSD" << endl; + + //TypeList tl = mdg->getTypes(); + //for (int i=0;i< tl.size(); i++) + //{ + // cout << tl[i].getURI() << ":" << tl[i].getName() << endl; + //} + + // so now we should be able to put book or a magazine into + // the publication under company... + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& book = mdg->getType("companyNS","BookType"); + const Type& mag = mdg->getType("companyNS","MagazineType"); + const Type& pub = mdg->getType("companyNS","PublicationType"); + + + // create a graph, then save it + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","Puflet Publishing"); + + // should be allowed... + DataObjectPtr book1 = mdg->create(book); + book1->setCString("author","Mr P B Writer"); + // inherted from publication + book1->setCString("title","Nowhere Man"); + + DataObjectPtr mag1 = mdg->create(mag); + mag1->setCString("editor","Mr B Picky"); + // inherited from publication + mag1->setCString("title","Bionicle Weekly"); + + try { + DataObjectPtr pub1 = mdg->create(pub); + pub1->setCString("title","Noddy In Toyland"); + } + catch (SDOUnsupportedOperationException e) + { + cout << "Normal unsupportedoperation for creation of abstract type" << endl; + } + + + // publication should accept books and magazines... + + comp->setDataObject("Publication",book1); + const Type& tpub2 = comp->getDataObject("Publication")->getType(); + cout << "Publication is of type " << tpub2.getName() << endl; + + comp->setDataObject("Publication",mag1); + const Type& tpub3 = comp->getDataObject("Publication")->getType(); + cout << "Publication is of type " << tpub3.getName() << endl; + + // should be able to address publication as book or magazine + + comp->setDataObject("Book",book1); + const Type& tpub4 = comp->getDataObject("Book")->getType(); + cout << "Book is of type " << tpub4.getName() << endl; + + comp->setDataObject("Magazine",mag1); + const Type& tpub5 = comp->getDataObject("Magazine")->getType(); + cout << "Magazine is of type " << tpub5.getName() << endl; + + } + catch (SDORuntimeException e) + { + cout << "ERROR in TestAbstract" << e << endl; + } + cout << "END TEST: TestAbstract ======================================" << endl; +} + +void sdotest::testOpen() +{ + cout << "TEST: TestOpen ==========================================" << endl; + //try + //{ + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + + mdg->addType("companyNS","CompanyType"); + // employee will be an open type... + mdg->addType("companyNS","EmployeeType", /*seq*/false, + /*open*/true, + /*abs */ false, + /*data*/ false); + + mdg->addType("companyNS","DepartmentType"); + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& tdept = mdg->getType("companyNS","DepartmentType"); + const Type& temp = mdg->getType("companyNS","EmployeeType"); + + + mdg->addPropertyToType(tcomp,"name",tstring); + // not containment... + mdg->addPropertyToType(tcomp,"employeeOfTheMonth",temp, false,false,false); + mdg->addPropertyToType(tcomp,"departments",tdept, true); + mdg->addPropertyToType(tcomp,"cs",tcs); + + mdg->addPropertyToType(tdept,"name",tstring); + mdg->addPropertyToType(tdept,"location",tstring); + mdg->addPropertyToType(tdept,"number",tstring); + mdg->addPropertyToType(tdept,"employees",temp,true); + + mdg->addPropertyToType(temp, "name",tstring); + mdg->addPropertyToType(temp, "SN", tstring); + mdg->addPropertyToType(temp, "manager", tbool); + + + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","ACME"); + + DataObjectPtr dept = mdg->create((Type&)tdept); + DataObjectList& dol = comp->getList("departments"); + dol.append(dept); + + dept->setCString("name","Advanced Technologies"); + dept->setCString("location","NY"); + dept->setCString("number","123"); + + DataObjectPtr emp1 = mdg->create(temp); + DataObjectPtr emp2 = mdg->create(temp); + DataObjectPtr emp3 = mdg->create(temp); + + emp1->setCString("name","Albert"); + emp1->setCString("SN","E0001"); + + emp2->setCString("name","Boris"); + emp2->setCString("SN","E0002"); + emp2->setBoolean("manager",true); + + emp3->setCString("name","Carl"); + emp3->setCString("SN","E0003"); + + // now we should be able to add extra properties to employees, + // and get them back again... + + + emp1->setCString("openstring","Value Of Open String"); + emp1->setBoolean("openboolean",true); + + const char* c = emp1->getCString("openstring"); + + cout << "Open Type string value: " << c << endl; + + bool b = emp1->getBoolean("openboolean"); + + cout << "Open Type boolean value: " << b << endl; + + // unknown list type at present.. + DataObjectList& dl = emp1->getList("opentypelist"); + + int i = 45; + dl.append((short)i); // now the list must be primitive + + // we should now have instance properties + PropertyList pl = emp1->getType().getProperties(); + + for (i=0;igetInstanceProperties(); + + for (i=0;iunset("openstring"); + + PropertyList plk = emp1->getInstanceProperties(); + + for (i=0;iunset("openboolean"); + + dl.remove(0); // so is this list gone, or empty - I vote for still there. + + PropertyList pll = emp1->getInstanceProperties(); + for (i=0;iunset("opentypelist"); + + // now I vote for gone... + + PropertyList plm = emp1->getInstanceProperties(); + for (i=0;iaddType("companyNS","CompanyType"); + // employee will be an open type... + mdg->addType("companyNS","EmployeeType", /*seq*/false, + /*open*/true, + /*abs */ false, + /*data*/ false); + + mdg->addType("companyNS","DepartmentType"); + + mdg->addType("companyNS","OpenType"); + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& tdept = mdg->getType("companyNS","DepartmentType"); + const Type& temp = mdg->getType("companyNS","EmployeeType"); + const Type& topen = mdg->getType("companyNS","OpenType"); + + + mdg->addPropertyToType(tcomp,"name",tstring); + // not containment... + mdg->addPropertyToType(tcomp,"employeeOfTheMonth",temp, false,false,false); + mdg->addPropertyToType(tcomp,"departments",tdept, true); + mdg->addPropertyToType(tcomp,"cs",tcs); + + mdg->addPropertyToType(tdept,"name",tstring); + mdg->addPropertyToType(tdept,"location",tstring); + mdg->addPropertyToType(tdept,"number",tstring); + mdg->addPropertyToType(tdept,"employees",temp,true); + + mdg->addPropertyToType(temp, "name",tstring); + mdg->addPropertyToType(temp, "SN", tstring); + mdg->addPropertyToType(temp, "manager", tbool); + + mdg->setAlias("companyNS","CompanyType","TheFirm"); + mdg->setAlias("companyNS","CompanyType","departments","TheDepartments"); + mdg->setAlias("companyNS","CompanyType","departments","MYDepartments"); + mdg->setAlias("companyNS","CompanyType","TheBigFirm"); + + mdg->addPropertyToType(topen,"name",tstring); + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","ACME"); + + DataObjectPtr dept = mdg->create((Type&)tdept); + DataObjectList& dol = comp->getList("departments"); + dol.append(dept); + + ChangeSummaryPtr cs = comp->getChangeSummary(); + + cs->beginLogging(); + + dept->setCString("name","Advanced Technologies"); + dept->setCString("location","NY"); + dept->setCString("number","123"); + + DataObjectList& emps = dept->getList("employees"); + + DataObjectPtr emp1 = mdg->create(temp); + DataObjectPtr emp2 = mdg->create(temp); + DataObjectPtr emp3 = mdg->create(temp); + + emps.append(emp1); + emps.append(emp2); + emps.append(emp3); + + emp1->setCString("name","Albert"); + emp1->setCString("SN","E0001"); + + emp2->setCString("name","Boris"); + emp2->setCString("SN","E0002"); + emp2->setBoolean("manager",true); + + emp3->setCString("name","Carl"); + emp3->setCString("SN","E0003"); + + // now we should be able to add extra properties to employees, + // and get them back again... + + + emp1->setCString("openstring","Value Of Open String"); + emp1->setBoolean("openboolean",true); + + const char* c = emp1->getCString("openstring"); + + cout << "Open Type string value: " << c << endl; + + bool b = emp1->getBoolean("openboolean"); + + cout << "Open Type boolean value: " << b << endl; + + // unknown list type at present.. + DataObjectList& dl = emp1->getList("openintlist"); + + int i = 45; + dl.append((short)i); // now the list must be primitive and short!! + + // unknown list type at present.. + DataObjectList& dl2 = emp1->getList("opendataobjectlist"); + + DataObjectPtr myopen = mdg->create("companyNS","OpenType"); + myopen->setCString("name","MyOpenName"); + dl2.append(myopen); // now the list must be of data objects + + + // now a single valued data object - should have an xsi:type + emp1->setDataObject("opendataobject", myopen); + + + cs->endLogging(); + + dumpchangesummary(cs); + + XSDHelperPtr xdh = HelperProvider::getXSDHelper(mdg); + + xdh->generateFile(mdg->getTypes(), + "saveopen-output.xsd","companyNS"); + + XMLHelperPtr xmh = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr doc = xmh->createDocument(comp,"companyNS","company"); + xmh->save(doc,"saveopen-output.xml"); + + } + catch (SDORuntimeException e) + { + cout << "ERROR in SaveOpen" << e << endl; + } + cout << "END TEST: SaveOpen ======================================" << endl; +} + +void sdotest::loadOpen() +{ + cout << "TEST: LoadOpen ==========================================" << endl; + try + { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("saveopen-output.xsd"); + + + //cout << "TYPES LOADED FROM COMPANY XSD" << endl; + //int i; + //TypeList tl = mdg->getTypes(); + //for (i=0;i< tl.size(); i++) + //{ + // cout << tl[i].getURI() << ":" << tl[i].getName() << endl; + //} + + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + + + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("partial.xml", "companyNS"); + + + + // so, we now expect that the openboolean and openstring props will + // be of type boolean and Bytes, and the openlist will be a list of integers. + // The dataobjectlist an dataobject will be of the correct OpenType + + // we need a test for data objects, and that we are writing out xsi:type + // correctly. + DataObjectPtr comp = myXMLDocument->getRootDataObject(); + DataObjectList& dl = comp->getList("departments"); + DataObjectPtr dept = dl[0]; + DataObjectList& dl2 = dept->getList("employees"); + DataObjectPtr emp = dl2[0]; + + if (strcmp(emp->getProperty("openboolean").getType().getName(), + "Boolean")) + { + cout << "OpenLoad failure - bool property not boolean" << endl; + + } + if (emp->getBoolean("openboolean") != true) + { + cout << "OpenLoad failure - bool property not true" << endl; + } + + if (strcmp(emp->getProperty("openstring").getType().getName(), + "Bytes")) + { + cout << "OpenLoad failure - bytes property not bytes" << endl; + + } + if (strcmp(emp->getCString("openstring"),"Value Of Open String")) + { + cout << "OpenLoad failure - string value is" << + emp->getCString("openstring") << endl; + } + + + DataObjectList& dl3 = emp->getList("openintlist"); + + if (strcmp(emp->getProperty("openintlist").getType().getName(), + "Short")) + { + cout << "OpenLoad failure - IntegerList not Short " << + emp->getProperty("openintlist").getType().getName() << endl; + } + + if (dl3.getInteger(0) != 45) + { + cout << "OpenLoad failure - Integer value is" << + dl.getInteger(0) << endl; + } + + if (strcmp(emp->getProperty("opendataobjectlist").getType().getName(), + "OpenType")) + { + cout << "OpenLoad failure - OpenTypeList not OpenType" << endl; + } + + DataObjectList& dl4 = emp->getList("opendataobjectlist"); + + if (strcmp(dl4[0]->getCString("name"),"MyOpenName")) + { + cout << "OpenLoad failure - list element name is " << + dl4[0]->getCString("name") << endl; + } + + if (strcmp(emp->getProperty("opendataobject").getType().getName(), + "OpenType")) + { + cout << "OpenLoad failure - OpenType not OpenType" << endl; + } + + DataObjectPtr dob2 = emp->getDataObject("opendataobject"); + + if (strcmp(dob2->getCString("name"),"MyOpenName")) + { + cout << "OpenLoad failure - open value name is " << + dob2->getCString("name") << endl; + } + + + myXMLHelper->save(myXMLDocument->getRootDataObject(), + 0, "company", "loadload-output.xml"); + + + } + catch (SDORuntimeException e) + { + cout << "LoadOpen FAILED" << e << endl; + } + +} + +void sdotest::loadOpenNS() +{ + cout << "TEST: LoadOpenNS ==========================================" << endl; + try + { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("openloadNS.xsd"); + xsh->defineFile("openloadNS2.xsd"); + + + //cout << "TYPES LOADED FROM COMPANY XSD" << endl; + //int i; + //TypeList tl = mdg->getTypes(); + //for (i=0;i< tl.size(); i++) + //{ + // cout << tl[i].getURI() << ":" << tl[i].getName() << endl; + //} + + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + + + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("openloadNS.xml", "companyNS"); + + + + // so, we now expect that the openboolean and openstring props will + // be of type boolean and Bytes, and the openlist will be a list of integers. + // The dataobjectlist an dataobject will be of the correct OpenType + + // we need a test for data objects, and that we are writing out xsi:type + // correctly. + DataObjectPtr comp = myXMLDocument->getRootDataObject(); + DataObjectList& dl = comp->getList("departments"); + DataObjectPtr dept = dl[0]; + DataObjectList& dl2 = dept->getList("employees"); + DataObjectPtr emp = dl2[0]; + + if (strcmp(emp->getProperty("openboolean").getType().getName(), + "Boolean")) + { + cout << "OpenLoadNS failure - bool property not boolean" << endl; + + } + if (emp->getBoolean("openboolean") != true) + { + cout << "OpenLoadNS failure - bool property not true" << endl; + } + + if (strcmp(emp->getProperty("openstring").getType().getName(), + "Bytes")) + { + cout << "OpenLoadNS failure - bytes property not bytes" << endl; + + } + if (strcmp(emp->getCString("openstring"),"Value Of Open String")) + { + cout << "OpenLoadNS failure - string value is" << + emp->getCString("openstring") << endl; + } + + + DataObjectList& dl3 = emp->getList("openintlist"); + + if (strcmp(emp->getProperty("openintlist").getType().getName(), + "Short")) + { + cout << "OpenLoadNS failure - IntegerList not Short " << + emp->getProperty("openintlist").getType().getName() << endl; + } + + if (dl3.getInteger(0) != 45) + { + cout << "OpenLoadNS failure - Integer value is" << + dl.getInteger(0) << endl; + } + + + + myXMLHelper->save(myXMLDocument->getRootDataObject(), + 0, "company", "openloadNSout.xml"); + + + // now try exactly the same, but with NS which doesnt exist + XMLDocumentPtr myXMLDocument2 = myXMLHelper->loadFile("openloadNS2.xml", "companyNS"); + + + + // so, we now expect that the openboolean and openstring props will + // be of type boolean and Bytes, and the openlist will be a list of integers. + // The dataobjectlist an dataobject will be of the correct OpenType + + // we need a test for data objects, and that we are writing out xsi:type + // correctly. + DataObjectPtr comp2 = myXMLDocument2->getRootDataObject(); + DataObjectList& dld = comp2->getList("departments"); + DataObjectPtr dept2 = dld[0]; + DataObjectList& dl22 = dept2->getList("employees"); + DataObjectPtr emp2 = dl22[0]; + + if (strcmp(emp2->getProperty("openboolean").getType().getName(), + "Bytes")) + { + cout << "OpenLoadNS2 failure - bool property not bytes" << endl; + + } + if (emp2->getBoolean("openboolean") != true) + { + cout << "OpenLoadNS2 failure - bool property not true" << endl; + } + + if (strcmp(emp2->getProperty("openstring").getType().getName(), + "Bytes")) + { + cout << "OpenLoadNS2 failure - bytes property not bytes" << endl; + + } + if (strcmp(emp2->getCString("openstring"),"Value Of Open String")) + { + cout << "OpenLoadNS failure - string value is" << + emp2->getCString("openstring") << endl; + } + + + DataObjectList& dl32 = emp2->getList("openintlist"); + + if (strcmp(emp2->getProperty("openintlist").getType().getName(), + "Bytes")) + { + cout << "OpenLoadNS2 failure - IntegerList not Bytes " << + emp2->getProperty("openintlist").getType().getName() << endl; + } + + if (dl32.getInteger(0) != 45) + { + cout << "OpenLoadNS2 failure - Integer value is" << + dl32.getInteger(0) << endl; + } + + + } + catch (SDORuntimeException e) + { + cout << "LoadOpenNS FAILED" << e << endl; + } + +} + +void sdotest::loadManyOpen() +{ + cout << "TEST: LoadManyOpen ==========================================" << endl; + try + { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("many.xsd"); + + + //cout << "TYPES LOADED FROM COMPANY XSD" << endl; + //int i; + //TypeList tl = mdg->getTypes(); + //for (i=0;i< tl.size(); i++) + //{ + // cout << tl[i].getURI() << ":" << tl[i].getName() << endl; + //} + + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + + + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("many.xml", "companyNS"); + + + + // so, we now expect that the openboolean and openstring props will + // be of type boolean and Bytes, and the openlist will be a list of integers. + // The dataobjectlist an dataobject will be of the correct OpenType + + // we need a test for data objects, and that we are writing out xsi:type + // correctly. + DataObjectPtr comp = myXMLDocument->getRootDataObject(); + DataObjectList& dl = comp->getList("departments"); + DataObjectPtr dept = dl[0]; + DataObjectList& dl2 = dept->getList("employees"); + DataObjectPtr emp = dl2[0]; + + + DataObjectList& dl3 = emp->getList("openlist"); + + if (strcmp(emp->getProperty("openlist").getType().getName(), + "Bytes")) + { + cout << "OpenManyLoad failure - BytesList not Bytes " << + emp->getProperty("openlist").getType().getName() << endl; + } + + if (dl3.size() != 3) + { + cout << "OpenManyLoad failure - size is " << + dl3.size() << endl; + } + + for (int i=0;i< dl3.size();i++) + { + cout << "Value:" << + dl3.getCString(i) << endl; + } + + } + catch (SDORuntimeException e) + { + cout << "LoadOpen FAILED" << e << endl; + } + +} + +void sdotest::csload2() +{ + cout << "TEST: CSLoad2 ===============================================" << endl; + try + { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("company.xsd"); + + //cout << "TYPES LOADED FROM COMPANY XSD" << endl; + + //TypeList tl = mdg->getTypes(); + //for (int i=0;i< tl.size(); i++) + //{ + // cout << tl[i].getURI() << ":" << tl[i].getName() << endl; + //} + + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("cssave2-output.xml", "companyNS"); + myXMLHelper->save(myXMLDocument->getRootDataObject(), + 0, "company", "csload2-output.xml"); + XMLDocumentPtr myXMLDocument2 = myXMLHelper->loadFile("csload2-output.xml", "companyNS"); + myXMLHelper->save(myXMLDocument2->getRootDataObject(), + 0, "company", "csload3-output.xml"); + } + catch (SDORuntimeException e) + { + cout << "ERROR in CsLoad2" << e << endl; + } + cout << "END TEST: CSLoad2 ===========================================" << endl; + +} + + + +void sdotest::setnull() +{ + +// try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("NullNS","NullMainType"); + mdg->addType("NullNS","NullSubType"); + + /* Now add the properties to the types...*/ + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tint = mdg->getType("commonj.sdo","Integer"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tmain = mdg->getType("NullNS","NullMainType"); + const Type& tsub = mdg->getType("NullNS","NullSubType"); + + + mdg->addPropertyToType(tmain,"name",tstring); + mdg->addPropertyToType(tmain,"subs",tsub, true); // many + mdg->addPropertyToType(tmain,"asub",tsub, false); // single + mdg->addPropertyToType(tmain,"bsub",tsub, false); // single + + mdg->addPropertyToType(tmain,"cs",tcs); // change summary + + mdg->addPropertyToType(tsub,"name",tstring); + mdg->addPropertyToType(tsub,"number",tint); + mdg->addPropertyToType(tsub,"bool",tbool); + + + // create a graph, then save it + + DataObjectPtr main1 = mdg->create((Type&)tmain); + main1->setCString("name","MainObject"); + + // asub is initially set + DataObjectPtr sub0 = main1->createDataObject("asub"); + // bsub is not set. + + DataObjectPtr sub1 = mdg->create((Type&)tsub); + DataObjectPtr sub2 = mdg->create((Type&)tsub); + DataObjectPtr sub3 = mdg->create((Type&)tsub); + + DataObjectList& dol = main1->getList("subs"); + + dol.append(sub1); + dol.append(sub2); + dol.append(sub3); + + // sub1 has all values set initially + + sub1->setCString("name","All Initially set"); + sub1->setInteger("number",100); + sub1->setBoolean("bool",false); + + // sub2 has no values set at all + + + // sub3 has all values set to null + sub3->setNull("name"); + sub3->setNull("number"); + sub3->setNull("bool"); + + + // report + + cout << "is ASUB null? (0 expected) " << + main1->isNull("asub") << endl; + + cout << "is ASUB set? (1 expected) " << + main1->isSet("asub") << endl; + + cout << "is BSUB null? (0 expected) " << + main1->isNull("bsub") << endl; + + cout << "is BSUB set? (0 expected) " << + main1->isSet("bsub") << endl; + +// dol0 is set, not null + + cout << "dol[0] name is null? (0 expected) " << + dol[0]->isNull("name") << endl; + + cout << "dol[0] number is null? (0 expected) " << + dol[0]->isNull("number") << endl; + + cout << "dol[0] bool is null? (0 expected) " << + dol[0]->isNull("bool") << endl; + + cout << "dol[0] name is set? (1 expected) " << + dol[0]->isSet("name") << endl; + + cout << "dol[0] number is set? (1 expected) " << + dol[0]->isSet("number") << endl; + + cout << "dol[0] bool is set? (1 expected) " << + dol[0]->isSet("bool") << endl; + +// dol1 is all unset , so no nulls + + cout << "dol[1] name is null? (0 expected) " << + dol[1]->isNull("name") << endl; + + cout << "dol[1] number is null? (0 expected) " << + dol[1]->isNull("number") << endl; + + cout << "dol[1] bool is null? (0 expected) " << + dol[1]->isNull("bool") << endl; + + cout << "dol[1] name is set? (0 expected) " << + dol[1]->isSet("name") << endl; + + cout << "dol[1] number is set? (0 expected) " << + dol[1]->isSet("number") << endl; + + cout << "dol[1] bool is set? (0 expected) " << + dol[1]->isSet("bool") << endl; + +// dol2 is all nulls, so all set + + cout << "dol[2] name is null? (1 expected) " << + dol[2]->isNull("name") << endl; + + cout << "dol[2] number is null? (1 expected) " << + dol[2]->isNull("number") << endl; + + cout << "dol[2] bool is null? (1 expected) " << + dol[2]->isNull("bool") << endl; + + cout << "dol[2] name is set? (1 expected) " << + dol[2]->isSet("name") << endl; + + cout << "dol[2] number is set? (1 expected) " << + dol[2]->isSet("number") << endl; + + cout << "dol[2] bool is set? (1 expected) " << + dol[2]->isSet("bool") << endl; + + ChangeSummaryPtr cs = main1->getChangeSummary(); + + cs->beginLogging(); + + main1->setNull("asub"); + main1->setNull("bsub"); + + dol[0]->setNull("name"); + dol[0]->setNull("number"); + dol[0]->setNull("bool"); + + dol[1]->setNull("bool"); + + dol[2]->setCString("name","NewName"); + dol[2]->setInteger("number",100); + dol[2]->setBoolean("bool",true); + + + cs->endLogging(); + + // what would we expect from the change summary? + + cout << "==============Expected in Change Summary=================" << endl; + cout << "change to main1 - object asub set to null, oldvalue asub (set)" << endl; + cout << "change to main1 - object bsub set to null, oldvalue null (unset)" << endl; + cout << "change to sub1 - name asub set to null, oldvalue \"All Initially Set\" (set)" << endl; + cout << "change to sub1 - number asub set to null, oldvalue 100 (set)" << endl; + cout << "change to sub1 - bool asub set to null, oldvalue false (set)" << endl; + cout << "change to sub2 - bool asub set to null, oldvalue false (unset)" << endl; + cout << "change to sub3 - name asub set to \"NewName\", oldvalue null, set" << endl; + cout << "change to sub3 - number asub set to 100, oldvalue null, set" << endl; + cout << "change to sub3 - bool asub set to true, oldvalue null, set" << endl; + cout << "==============End Expected in Change Summary=============" << endl; + + + dumpchangesummary(cs); + + // report + + cout << "is ASUB null? (1 expected) " << + main1->isNull("asub") << endl; + + cout << "is ASUB set? (1 expected) " << + main1->isSet("asub") << endl; + + cout << "is BSUB null? (1 expected) " << + main1->isNull("bsub") << endl; + + cout << "is BSUB set? (1 expected) " << + main1->isSet("bsub") << endl; + +// dol0 is set to null + + cout << "dol[0] name is null? (1 expected) " << + dol[0]->isNull("name") << endl; + + cout << "dol[0] number is null? (1 expected) " << + dol[0]->isNull("number") << endl; + + cout << "dol[0] bool is null? (1 expected) " << + dol[0]->isNull("bool") << endl; + + cout << "dol[0] name is set? (1 expected) " << + dol[0]->isSet("name") << endl; + + cout << "dol[0] number is set? (1 expected) " << + dol[0]->isSet("number") << endl; + + cout << "dol[0] bool is set? (1 expected) " << + dol[0]->isSet("bool") << endl; + +// dol1 is all unset except bool which is null + + cout << "dol[1] name is null? (0 expected) " << + dol[1]->isNull("name") << endl; + + cout << "dol[1] number is null? (0 expected) " << + dol[1]->isNull("number") << endl; + + cout << "dol[1] bool is null? (1 expected) " << + dol[1]->isNull("bool") << endl; + + cout << "dol[1] name is set? (0 expected) " << + dol[1]->isSet("name") << endl; + + cout << "dol[1] number is set? (0 expected) " << + dol[1]->isSet("number") << endl; + + cout << "dol[1] bool is set? (1 expected) " << + dol[1]->isSet("bool") << endl; + +// dol2 is all set non-null, so all set + + cout << "dol[2] name is null? (0 expected) " << + dol[2]->isNull("name") << endl; + + cout << "dol[2] number is null? (0 expected) " << + dol[2]->isNull("number") << endl; + + cout << "dol[2] bool is null? (0 expected) " << + dol[2]->isNull("bool") << endl; + + cout << "dol[2] name is set? (1 expected) " << + dol[2]->isSet("name") << endl; + + cout << "dol[2] number is set? (1 expected) " << + dol[2]->isSet("number") << endl; + + cout << "dol[2] bool is set? (1 expected) " << + dol[2]->isSet("bool") << endl; + + + // what would we expect from the change summary? +// } +// catch (SDORuntimeException e) +// { +// cout << "Exception in setnull" << endl; +// cout << e; +// } + +} + +void sdotest::testsubs() +{ + + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("companyNS","MainType"); + + mdg->addType("companyNS","SubType"); + mdg->addType("companyNS","SuperType"); + mdg->addType("companyNS","SubstituteType"); + mdg->addType("companyNS","UnrelatedType"); + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tmain = mdg->getType("companyNS","MainType"); + const Type& sub = mdg->getType("companyNS","SubType"); + const Type& super = mdg->getType("companyNS","SuperType"); + const Type& subst = mdg->getType("companyNS","SubstituteType"); + const Type& unrel = mdg->getType("companyNS","UnrelatedType"); + + + mdg->addPropertyToType(tmain,"name",tstring); + mdg->addPropertyToType(tmain,"sub",super, false); + mdg->addPropertyToType(tmain,"subs",super, true); + + + mdg->setPropertySubstitute(tmain, "sub","wilbur", subst); + mdg->setPropertySubstitute(tmain, "subs","wilburs", subst); + + mdg->setBaseType(sub,super); + + //now sub and subs should accept all the three types + + DataObjectPtr main = mdg->create((Type&)tmain); + main->setCString("name","SubstituteTest"); + + DataObjectList& dol = main->getList("subs"); + + DataObjectPtr sub1 = mdg->create(sub); + DataObjectPtr super1 = mdg->create(super); + DataObjectPtr subst1 = mdg->create(subst); + DataObjectPtr unrel1 = mdg->create(unrel); + + dol.append(sub1); + dol.append(super1); + dol.append(subst1); + try + { + dol.append(unrel1); + } + catch (SDOInvalidConversionException e) + { + cout << "Normal failure to append wrong type" << endl; + } + + dol.remove(0); + dol.remove(0); + dol.remove(0); + + DataObjectList& dol2 = main->getList("wilburs"); + + dol2.append(sub1); + dol2.append(super1); + dol2.append(subst1); + try + { + dol2.append(unrel1); + } + catch (SDOInvalidConversionException e) + { + cout << "Normal failure to append wrong type" << endl; + } + + main->setDataObject("sub",sub1); + main->setDataObject("sub",super1); + main->setDataObject("sub",subst1); + + main->setDataObject("wilbur",sub1); + main->setDataObject("wilbur",super1); + main->setDataObject("wilbur",subst1); + + try + { + main->setDataObject("sub", unrel1); + } + catch (SDOInvalidConversionException e) + { + cout << "Normal failure to set wrong type" << endl; + } + } + + catch (SDORuntimeException e) + { + cout << "Substitute test failed" << endl << e << endl; + } +} + + +void sdotest::merle1() +{ + + try { + + // Dynamic setup of the metadata + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("axis.xsd"); + + // or dynamically create, but that would get attributes for the strings, not elements + //mdg->addType("axis","ItemSearch",true); // sequenced + //mdg->addType("axis","ItemSearchRequest",true); // sequenced + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tsearch = mdg->getType("axis","ItemSearch"); + const Type& treq = mdg->getType("axis","ItemSearchRequest"); + + //mdg->addPropertyToType(tsearch,"SubscriptionId",tstring); + //mdg->addPropertyToType(tsearch,"AssociateTag",tstring); + //mdg->addPropertyToType(tsearch,"XMLEscaping",tstring); + //mdg->addPropertyToType(tsearch,"Validate",tstring); + //mdg->addPropertyToType(tsearch,"Shared",treq, false, false, true); + //mdg->addPropertyToType(tsearch,"Request",treq, true, false, true); + + //mdg->addPropertyToType(treq,"Keywords",tstring); + //mdg->addPropertyToType(treq,"SearchIndex",tstring); + + // dynamic creation of the data + + DataObjectPtr search = mdg->create((Type&)tsearch); + + search->setCString("SubscriptionId","I am the subscription ID string"); + search->setCString("AssociateTag","I am the associate Tag string"); + search->setCString("XMLEscaping","I am the XML escaping string"); + search->setCString("Validate","I am the Validate string"); + + DataObjectPtr shared = search->createDataObject("Shared"); + shared->setCString("Keywords","SharedKeywordsString"); + shared->setCString("SearchIndex","SearchIndexString"); + + DataObjectList& requests = search->getList("Request"); + DataObjectPtr request1 = mdg->create(treq); + requests.append(request1); + request1->setCString("Keywords","RequestKeywords"); + request1->setCString("SearchIndex","RequestSearchIndex"); + + // Read the data and put it into XML: + + PropertyList properties = search->getInstanceProperties(); + + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + + for (int i=0;i" << + search->getCString(prop) << "" << endl; + break; + + case Type::DataObjectType: + if (prop.isMany()) + { + // many valued property, such as Requests , so get the list + DataObjectList& rq = search->getList(prop); + for (int j=0;jcreateDocument(dob, + "axis", prop.getName()); + doc->setXMLDeclaration(false); + char* dobXML = myXMLHelper->save(doc); + cout << "DataObject \"" << prop.getName() << + "\" as XML:" << endl; + cout << dobXML << endl; + } // if dob + } // for + } // if many + else + { + DataObjectPtr dob = search->getDataObject(prop); + if (dob != 0) + { + XMLDocumentPtr doc = myXMLHelper->createDocument(dob, + "axis", prop.getName()); + doc->setXMLDeclaration(false); + char* dobXML = myXMLHelper->save(doc); + cout << "DataObject \"" << prop.getName() << + "\" as XML:" << endl; + cout << dobXML << endl; + } // if + } // else + break; + + default: + break; + + } // switch + } // for + } // try + catch (SDORuntimeException e) + { + cout << "Merle 1 failed" << endl << e << endl; + } +} + + +void sdotest::graham3() +{ + //try { + + // Dynamic setup of the metadata + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("graham3.xsd"); + //} + //catch (SDORuntimeException e) + //{ +// cout << "Graham1 failed " << e << endl; +// } +} + +void sdotest::graham1() +{ + try { + + // Dynamic setup of the metadata + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("graham1.xsd"); + } + catch (SDORuntimeException e) + { + cout << "Graham1 failed " << e << endl; + } +} +void sdotest::graham2() +{ + try { + + // Dynamic setup of the metadata + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("graham2.xsd"); + } + catch (SDORuntimeException e) + { + cout << "Graham2 failed " << e << endl; + } +} + + +void sdotest::b46613() +{ + try { + + // Dynamic setup of the metadata + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->create("rubbish","MyObject"); + + } + catch (SDOTypeNotFoundException e) + { + cout << "b46613 gave the correct exception" << endl; + } +} + +void sdotest::doctest() +{ + try { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("doctest.xsd"); + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("doctest.xml", + "companyNS"); + cout << "RootURI=" << myXMLDocument->getRootElementURI(); + cout << "RootName=" << myXMLDocument->getRootElementName(); + } + catch (SDOTypeNotFoundException e) + { + cout << "doctest failed" << endl; + } + +} + + +void sdotest::b46634() +{ + try { + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("company_with_nillable_SN.xsd"); + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("company_with_nillable_SN.xml", + "companyNS"); + + DataObjectPtr dob = myXMLDocument->getRootDataObject(); + DataObjectList& dol = dob->getList("departments"); + DataObjectPtr dept = dol[0]; + DataObjectList& dol2 = dept->getList("employees"); + DataObjectPtr emp = dol2[0]; + + if (!emp->isSet("SN")) + { + cout << "B46634 WRONG - isSet should be true" << endl; + } + if (!emp->isNull("SN")) + { + cout << "B46634 WRONG - isNull should be true" << endl; + } + + // now write out the nill value and check its still nil + myXMLHelper->save(myXMLDocument->getRootDataObject(), + 0, "company", "b46634_out.xml"); + + } + catch (SDORuntimeException e) + { + cout << "b46634 failed" << endl; + } + +} + +void sdotest::testErrors() +{ + try { + + int i,j; + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->defineFile("error1.xsd"); + if ((i = xsh->getErrorCount()) > 0) + { + cout << "XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("error1.xml", + "companyNS"); + + if ((i = myXMLHelper->getErrorCount()) > 0) + { + cout << "XML reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + + } + catch (SDORuntimeException e) + { + cout << "testErrors failed" << endl << e << endl; + } + +} + +void sdotest::b46734() +{ + try { + + int i,j; + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + + xsh->defineFile("wsdl.xsd"); + if ((i = xsh->getErrorCount()) > 0) + { + cout << "WSDL XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + xsh->defineFile("wsdl-soap.xsd"); + if ((i = xsh->getErrorCount()) > 0) + { + cout << "WSDL SOAP XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + xsh->defineFile("wsdl-http.xsd"); + if ((i = xsh->getErrorCount()) > 0) + { + cout << "WSDL HTTP XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + // xsh->defineFile("StockQuoteService.wsdl"); + // if ((i = xsh->getErrorCount()) > 0) + // { + // cout << "SQ WSDL reported some errors:" << endl; + // for (j=0;jgetErrorMessage(j); + // if (m != 0) cout << m; + // cout << endl; + // } + // } + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("StockQuoteService.wsdl" + ); + //, "http://swanandmokashi.com"); + + if ((i = myXMLHelper->getErrorCount()) > 0) + { + cout << "XML reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0)cout << m; + cout << endl; + } + } + + } + catch (SDORuntimeException e) + { + cout << "b46734 failed" << endl << e << endl; + } + +} + +void sdotest::b46693() +{ + try { + + int i,j; + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + + xsh->defineFile("b46693.xsd"); + if ((i = xsh->getErrorCount()) > 0) + { + cout << "b46693 XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0)cout << m; + cout << endl; + } + } + + // XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + // XMLDocumentPtr myXMLDocument = myXMLHelper->loadFile("b46693.xsd" + // ); + + // if ((i = myXMLHelper->getErrorCount()) > 0) + // { + // cout << "b46693 reported some errors:" << endl; + // for (j=0;jgetErrorMessage(j); + // if (m != 0)cout << m; + // cout << endl; + // } + // } + + } + catch (SDORuntimeException e) + { + cout << "b46693 failed" << endl << e << endl; + } + +} + +void sdotest::clonetest() +{ + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("companyNS","CompanyType"); + mdg->addType("companyNS","DepartmentType"); + mdg->addType("companyNS","EmployeeType"); + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& tdept = mdg->getType("companyNS","DepartmentType"); + const Type& temp = mdg->getType("companyNS","EmployeeType"); + + mdg->addPropertyToType(tcomp,"name",tstring); + mdg->addPropertyToType(tcomp,"departments",tdept,true,false,true); + mdg->addPropertyToType(tcomp,"employeeOfTheMonth",temp,false,false,false); + mdg->addPropertyToType(tcomp,"CEO",temp,false,false,true); + + mdg->addPropertyToType(tdept,"employees",temp,true,false,true); + mdg->addPropertyToType(tdept,"name",tstring,false,false,true); + mdg->addPropertyToType(tdept,"location",tstring,false,false,true); + mdg->addPropertyToType(tdept,"number",tstring,false,false,true); + + mdg->addPropertyToType(temp,"name",tstring,false,false,true); + mdg->addPropertyToType(temp,"SN",tstring,false,false,true); + mdg->addPropertyToType(temp,"manager",tbool,false,false,true); + + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","The Company"); + + DataObjectPtr dept = mdg->create((Type&)tdept); + + DataObjectList& dol = comp->getList("departments"); + dol.append(dept); + + dept->setCString("name","The Department"); + dept->setCString("location","Botley"); + dept->setCString("number","123"); + + + // now clone the data factory, and add more types + + DataFactoryPtr df2 = mdg->clone(); + + df2->addType("otherNS","DataSet"); + + df2->addPropertyToType("companyNS","DepartmentType","dataset", + "otherNS","DataSet", false, false, true); + + const Type& tstring2 = df2->getType("commonj.sdo","String"); + const Type& tbool2 = df2->getType("commonj.sdo","Boolean"); + const Type& tcs2 = df2->getType("commonj.sdo","ChangeSummary"); + const Type& tcomp2 = df2->getType("companyNS","CompanyType"); + const Type& tdept2 = df2->getType("companyNS","DepartmentType"); + const Type& temp2 = df2->getType("companyNS","EmployeeType"); + + DataObjectPtr comp2 = df2->create((Type&)tcomp2); + comp->setCString("name","The Company"); + + DataObjectPtr dept2 = df2->create((Type&)tdept2); + + DataObjectList& dol2 = comp2->getList("departments"); + dol2.append(dept2); + + dept2->setCString("name","The Other Department"); + dept2->setCString("location","Not Botley"); + dept2->setCString("number","321"); + } + catch (SDORuntimeException e) + { + cout << "clone failed " << e << endl; + } + + +} + +void sdotest::testUtil() +{ + try { + + cout << "START TEST: UTILS ======================================" << endl; + + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + + mdg->addType("companyNS","CompanyType"); + // employee will be an open type... + mdg->addType("companyNS","EmployeeType", /*seq*/false, + /*open*/true, + /*abs */ false, + /*data*/ false); + + mdg->addType("companyNS","DepartmentType"); + + mdg->addType("companyNS","OpenType"); + + /* Now add the properties to the types...*/ + + + const Type& tstring = mdg->getType("commonj.sdo","String"); + const Type& tbool = mdg->getType("commonj.sdo","Boolean"); + const Type& tcs = mdg->getType("commonj.sdo","ChangeSummary"); + const Type& tcomp = mdg->getType("companyNS","CompanyType"); + const Type& tdept = mdg->getType("companyNS","DepartmentType"); + const Type& temp = mdg->getType("companyNS","EmployeeType"); + const Type& topen = mdg->getType("companyNS","OpenType"); + + + mdg->addPropertyToType(tcomp,"name",tstring); + // not containment... + mdg->addPropertyToType(tcomp,"employeeOfTheMonth",temp, false,false,false); + mdg->addPropertyToType(tcomp,"departments",tdept, true); + mdg->addPropertyToType(tcomp,"cs",tcs); + + mdg->addPropertyToType(tdept,"name",tstring); + mdg->addPropertyToType(tdept,"location",tstring); + mdg->addPropertyToType(tdept,"number",tstring); + mdg->addPropertyToType(tdept,"employees",temp,true); + + mdg->addPropertyToType(temp, "name",tstring); + mdg->addPropertyToType(temp, "SN", tstring); + mdg->addPropertyToType(temp, "manager", tbool); + + mdg->addPropertyToType(topen,"name",tstring); + + DataObjectPtr comp = mdg->create((Type&)tcomp); + comp->setCString("name","ACME"); + + DataObjectPtr dept = mdg->create((Type&)tdept); + DataObjectList& dol = comp->getList("departments"); + dol.append(dept); + + dept->setCString("name","Advanced Technologies"); + dept->setCString("location","NY"); + dept->setCString("number","123"); + + DataObjectList& emps = dept->getList("employees"); + + DataObjectPtr emp1 = mdg->create(temp); + DataObjectPtr emp2 = mdg->create(temp); + DataObjectPtr emp3 = mdg->create(temp); + + emps.append(emp1); + emps.append(emp2); + emps.append(emp3); + + emp1->setCString("name","Albert"); + emp1->setCString("SN","E0001"); + + emp2->setCString("name","Boris"); + emp2->setCString("SN","E0002"); + emp2->setBoolean("manager",true); + + emp3->setCString("name","Carl"); + emp3->setCString("SN","E0003"); + + emp1->setCString("openstring","Value Of Open String"); + emp1->setBoolean("openboolean",true); + + const char* c = emp1->getCString("openstring"); + + bool b = emp1->getBoolean("openboolean"); + + // unknown list type at present.. + DataObjectList& dl = emp1->getList("openintlist"); + + int i = 45; + dl.append((short)i); // now the list must be primitive and short!! + + // unknown list type at present.. + DataObjectList& dl2 = emp1->getList("opendataobjectlist"); + + DataObjectPtr myopen = mdg->create("companyNS","OpenType"); + myopen->setCString("name","MyOpenName"); + dl2.append(myopen); // now the list must be of data objects + + emp1->setDataObject("opendataobject", myopen); + + SDOUtils::printDataObject(comp); + + } + catch (SDORuntimeException e) + { + cout << "ERROR in UTILS test" << e << endl; + } + cout << "END TEST: UTILS ======================================" << endl; + +} + +void sdotest::printset(ChangeSummaryPtr cs) +{ + ChangedDataObjectList& cdl = cs->getChangedDataObjects(); + + // here there should be a creation of Ed, and a change to dept, which has a + // bool previously unset, and a int list previuously unset and an employees list + // previously unset + + for (int i=0;i< cdl.size();i++) + { + if (cs->isModified(cdl[i])) + { + + cout << "A modified of type " << cdl[i]->getType().getURI() + << "#" << cdl[i]->getType().getName() << endl; + + SettingList& sl = cs->getOldValues(cdl[i]); + if (sl.size() == 0) + { + cout << "No Settings found" << endl; + } + else + { + for (int j=0;j< sl.size(); j++) + { + cout << "Property " << sl[j].getProperty().getName(); + // this could be a many-valued property, and could be one which is + // a data object or a data type... + if (sl[j].getProperty().isMany()) + { + cout << "[" << sl[j].getIndex() << "]" ; + } + if (!sl[j].isSet()) + { + cout << " was unset before the change" << endl; + } + else + { + cout << " was set before the change !!" << endl; + } + } + } + } + } +} + + +void sdotest::b46633() +{ + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Root"); + mdg->addPropertyToType("myspace","Root","cs", + "commonj.sdo","ChangeSummary", false, false, false); + + mdg->addType("myspace","Company"); + mdg->addType("myspace","Department"); + mdg->addType("myspace","Manager"); + mdg->addType("myspace","Employee"); + + + mdg->addPropertyToType("myspace","Company","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","Root","company", + "myspace","Company", false, false, true); + + mdg->addPropertyToType("myspace","Company","departments", + "myspace","Department", true, false, true); + + + mdg->addPropertyToType("myspace","Department","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Department","ints", + "commonj.sdo","Integer", true, false, false); + + + mdg->addPropertyToType("myspace","Department","bool", + "commonj.sdo","Boolean", false, false, false); + + mdg->addPropertyToType("myspace","Department","manager", + "myspace","Manager", false, false, true); + + mdg->addPropertyToType("myspace","Department","employees", + "myspace","Employee", true, false, true); + + mdg->addPropertyToType("myspace","Manager","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Employee","name", + "commonj.sdo","String", false, false, false); + + const Type& tcc = mdg->getType("myspace","Root"); + + DataObjectPtr dor = mdg->create((Type&)tcc); + + ChangeSummaryPtr cs = dor->getChangeSummary(); + + DataObjectPtr com = dor->createDataObject("company"); + com->setCString("name","IBM"); + + DataObjectPtr dept = com->createDataObject("departments"); + dept->setCString("name","JTC"); + + // employees initally unset + + cs->beginLogging(); + + DataObjectPtr emp = dept->createDataObject("employees"); + emp->setCString("name","Ed"); + + + + DataObjectList& dl = dept->getList("ints"); + dl.append((long)400); + + dept->setBoolean("bool", true); + + printset(cs); + + cs->endLogging(); + + // unset them all , restart logging, and get the same results + + dept->unset("bool"); + dept->unset("ints"); + dept->unset("employees"); + + cs->beginLogging(); + + DataObjectPtr emp2 = dept->createDataObject("employees"); + emp2->setCString("name","Ed2"); + + dl.append((long)600); + + dept->setBoolean("bool", true); + + printset(cs); + + cs->endLogging(); + + } + catch (SDORuntimeException e) + { + cout << "b46633 failed " << e << endl; + } + +} + + + +void sdotest::testLoad() +{ + try + { + int i,j; + DataFactoryPtr mdg = DataFactory::getDataFactory(); + FILE* f = fopen("company_with_nillable_SN.xsd","r+"); + char* buffer = new char[4000]; + j = 0; + while ((i = fgetc(f)) != EOF) + { + buffer[j++] = (char)i; + } + buffer[j] = 0; + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + xsh->define(buffer); + + if ((i = xsh->getErrorCount()) > 0) + { + cout << "XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + + FILE* f2 = fopen("company_with_nillable_SN.xml","r+"); + j = 0; + while ((i = fgetc(f2)) != EOF) + { + buffer[j++] = (char)i; + } + buffer[j] = 0; + + XMLHelperPtr myXMLHelper = HelperProvider::getXMLHelper(mdg); + XMLDocumentPtr myXMLDocument = myXMLHelper->load(buffer); + + } + catch (SDORuntimeException e) + { + cout << "Exception in testDAS " << e << endl; + } +} + +void sdotest::includetest() +{ + try + { + int i,j; + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + + xsh->defineFile("include.xsd"); + if ((i = xsh->getErrorCount()) > 0) + { + cout << "INCLUDE XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + + xsh->defineFile("../t2/includeother.xsd"); + if ((i = xsh->getErrorCount()) > 0) + { + cout << "INCLUDE XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + } + catch (SDORuntimeException e) + { + cout << "Exception in include test" << e << endl; + } +} + +void sdotest::detachtest() +{ + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Root"); + + mdg->addType("myspace","Company"); + mdg->addType("myspace","Department"); + mdg->addType("myspace","Manager"); + mdg->addType("myspace","Employee"); + + + mdg->addPropertyToType("myspace","Company","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","Root","company", + "myspace","Company", false, false, true); + + mdg->addPropertyToType("myspace","Company","departments", + "myspace","Department", true, false, true); + + + mdg->addPropertyToType("myspace","Department","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","Department","manager", + "myspace","Manager", false, false, true); + + mdg->addPropertyToType("myspace","Department","employees", + "myspace","Employee", true, false, true); + + mdg->addPropertyToType("myspace","Manager","name", + "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Employee","name", + "commonj.sdo","String", false, false, false); + + const Type& tcc = mdg->getType("myspace","Root"); + + DataObjectPtr dor = mdg->create((Type&)tcc); + + DataObjectPtr com = dor->createDataObject("company"); + com->setCString("name","IBM"); + + DataObjectPtr dept = com->createDataObject("departments"); + + dept->setCString("name","JTC"); + + + DataObjectPtr emp = dept->createDataObject("employees"); + emp->setCString("name","Ed"); + + DataObjectPtr emp2 = dept->createDataObject("employees"); + emp2->setCString("name","Tom"); + + DataObjectList& dol = dept->getList("employees"); + + DataObjectPtr e = dol[0]; + e->detach(); + + DataObjectPtr cont = emp->getContainer(); + + if (cont != 0) + { + cout << "EMP STILL ATTACHED - problem" << endl; + } + + DataObjectPtr cont2 = dol[0]->getContainer(); + + if (cont2 == 0) + { + cout << "SECOND DETACHED - problem" << endl; + } + + } + catch (SDORuntimeException e) + { + cout << "detach failed " << e << endl; + } + +} + + +void sdotest::leak() +{ + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Root"); + + + mdg->addPropertyToType("myspace","Root","ints", + "commonj.sdo","Integer", true, false, false); + + + const Type& tcc = mdg->getType("myspace","Root"); + + DataObjectPtr dor = mdg->create((Type&)tcc); + + + cout << "List set should be false and is " << dor->isSet("ints") << endl; + + DataObjectList& dl = dor->getList("ints"); + + cout << "List set should be false and is " << dor->isSet("ints") << endl; + + dl.append((long)400); + + cout << "List set should be true and is " << dor->isSet("ints") << endl; + + dl.remove(0); + + cout << "List set should be false and is " << dor->isSet("ints") << endl; + + dl.append((long)400); + + cout << "List set should be true and is " << dor->isSet("ints") << endl; + + dor->unset("ints"); + + cout << "List set should be false and is " << dor->isSet("ints") << endl; + + dl.append((long)600); + + cout << "List set should be true and is " << dor->isSet("ints") << endl; + + + } + catch (SDORuntimeException e) + { + cout << "leak failed " << e << endl; + } + +} + +void sdotest::twolists() +{ + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Root"); + + //mdg->addType("myspace","Company"); + //mdg->addType("myspace","Department"); + //mdg->addType("myspace","Manager"); + //mdg->addType("myspace","Employee"); + + + //mdg->addPropertyToType("myspace","Company","name", + // "commonj.sdo","String", false, false, false); + + + //mdg->addPropertyToType("myspace","Root","company", + // "myspace","Company", false, false, true); + + //mdg->addPropertyToType("myspace","Company","departments", + // "myspace","Department", true, false, true); + + + //mdg->addPropertyToType("myspace","Department","name", + // "commonj.sdo","String", false, false, false); + + mdg->addPropertyToType("myspace","Root","ints", + "commonj.sdo","Integer", true, false, false); + + mdg->addPropertyToType("myspace","Root","ints2", + "commonj.sdo","Integer", true, false, false); + + //mdg->addPropertyToType("myspace","Department","bool", + // "commonj.sdo","Boolean", false, false, false); + + //mdg->addPropertyToType("myspace","Department","manager", + // "myspace","Manager", false, false, true); + + //mdg->addPropertyToType("myspace","Department","employees", + // "myspace","Employee", true, false, true); + + //mdg->addPropertyToType("myspace","Manager","name", + // "commonj.sdo","String", false, false, false); + + //mdg->addPropertyToType("myspace","Employee","name", + // "commonj.sdo","String", false, false, false); + + const Type& tcc = mdg->getType("myspace","Root"); + + DataObjectPtr dor = mdg->create((Type&)tcc); + + //ChangeSummaryPtr cs = dor->getChangeSummary(); + + //DataObjectPtr com = dor->createDataObject("company"); + //com->setCString("name","IBM"); + + //DataObjectPtr dept = com->createDataObject("departments"); + //dept->setCString("name","JTC"); + + // employees initally unset + + //cs->beginLogging(); + + //DataObjectPtr emp = dept->createDataObject("employees"); + //emp->setCString("name","Ed"); + + DataObjectList& dl2 = dor->getList("ints2"); + dl2.append((long)400); + + + DataObjectList& dl = dor->getList("ints"); + dl.append((long)400); + + //dept->setBoolean("bool", true); + + //printset(cs); + + //cs->endLogging(); + + // unset them all , restart logging, and get the same results + + //dept->unset("bool"); + //dept->unset("ints"); + //dept->unset("employees"); + + //cs->beginLogging(); + + //DataObjectPtr emp2 = dept->createDataObject("employees"); + //emp2->setCString("name","Ed2"); + + //dl.append((long)600); + + //dept->setBoolean("bool", true); + + // printset(cs); + + //cs->endLogging(); + + } + catch (SDORuntimeException e) + { + cout << "twolists failed " << e << endl; + } + +} + + +void sdotest::graham4() +{ + try { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + mdg->addType("myspace","Root"); + mdg->addType("myspace","ListItem"); + + + mdg->addPropertyToType("myspace","ListItem","name", + "commonj.sdo","String", false, false, false); + + + mdg->addPropertyToType("myspace","Root","ints", + "commonj.sdo","Integer", true, false, false); + + mdg->addPropertyToType("myspace","Root","items", + "myspace","ListItem", true, false, true); + + + const Type& tcc = mdg->getType("myspace","Root"); + + DataObjectPtr dor = mdg->create((Type&)tcc); + + + // first try with no elements in lists + + try { + DataObjectPtr pitem = dor->getDataObject("items[name=\"hello\"]"); + } + catch (SDOIndexOutOfRangeException e) + { + cout << "Normal exception in Graham4" << endl; + } + + try { + int inty = dor->getInteger("ints[1]"); + } + catch (SDOIndexOutOfRangeException e) + { + cout << "Normal exception in Graham4" << endl; + } + + // now populate them + + DataObjectPtr myitem = dor->createDataObject("items"); + myitem->setCString("name","not hello"); + + try { + DataObjectPtr pitem2 = dor->getDataObject("items[name=\"hello\"]"); + } + catch (SDOIndexOutOfRangeException e) + { + cout << "Normal exception in Graham4" << endl; + } + + DataObjectList& dl = dor->getList("ints"); + dl.append((long)100); + + try { + int inty2 = dor->getInteger("ints[2]"); + } + catch (SDOIndexOutOfRangeException e) + { + cout << "Normal exception in Graham4" << endl; + } + + try + { + DataObjectPtr pitem2 = dor->getDataObject("items[name=\"not hello\"]"); + cout << "item name is " << pitem2->getCString("name") << endl; + } + catch (SDORuntimeException e) + { + cout << "ABNORMAL exception in Graham4" << endl; + } + + try { + int inty2 = dor->getInteger("ints[1]"); + cout << "Integer is " << inty2 << endl; + } + catch (SDOIndexOutOfRangeException e) + { + cout << "Normal exception in Graham4" << endl; + } + + } + catch (SDORuntimeException e) + { + cout << "twolists failed " << e << endl; + } + +} + + +void sdotest::graham5() +{ + try + { + int i,j; + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + + xsh->defineFile("Order.xsd"); + if ((i = xsh->getErrorCount()) > 0) + { + cout << "INCLUDE XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + } + catch (SDORuntimeException r) + { + cout << "Graham5 failed " << r << endl; + } +} + + + +void sdotest::b47293() +{ + int i,j,k; + try + { + DataFactoryPtr mdg = DataFactory::getDataFactory(); + + XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg); + + xsh->defineFile("47293Catalog.xsd"); + + if ((i = xsh->getErrorCount()) > 0) + { + cout << "47293 XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + + TypeList tl = mdg->getTypes(); + for ( k=0;kgenerateFile(tl,"47293Catalog-out.xsd","catalogNS"); + + DataFactoryPtr mdg2 = DataFactory::getDataFactory(); + + XSDHelperPtr xsh2 = HelperProvider::getXSDHelper(mdg2); + + xsh2->defineFile("47293Catalog-out.xsd"); + + if ((i = xsh2->getErrorCount()) > 0) + { + cout << "47293-out XSD reported some errors:" << endl; + for (j=0;jgetErrorMessage(j); + if (m != 0) cout << m; + cout << endl; + } + } + + TypeList tl2 = mdg2->getTypes(); + for (k=0;kloadFile("47293Catalog.xml", "catalog"); + + //DataObjectPtr dob = doc->getRootDataObject(); + + //xmh->save(dob,"","catalog","47293Catalog-out.xml"); + + + } + catch (SDORuntimeException e) + { + cout << "B47137 failed " << e << endl; + } +} + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/include3.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/include3.xsd new file mode 100644 index 0000000000..a74c94e318 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/include3.xsd @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother.xsd new file mode 100644 index 0000000000..7e42346471 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother.xsd @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother1.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother1.xsd new file mode 100644 index 0000000000..98705f6418 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother1.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother2.xsd b/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother2.xsd new file mode 100644 index 0000000000..66dfca00a8 --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/t2/includeother2.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/tags/cpp-stable-20060304/sdo/runtime/core/test/testopen3.xml b/tags/cpp-stable-20060304/sdo/runtime/core/test/testopen3.xml new file mode 100644 index 0000000000..4af489c53a --- /dev/null +++ b/tags/cpp-stable-20060304/sdo/runtime/core/test/testopen3.xml @@ -0,0 +1 @@ + \ No newline at end of file -- cgit v1.2.3